summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c4
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp24
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-myanmar.c4
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp51
-rw-r--r--src/3rdparty/harfbuzz/tests/shaping/main.cpp29
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp13
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h3
-rw-r--r--src/3rdparty/md5/md5.cpp1
-rw-r--r--src/3rdparty/phonon/gstreamer/devicemanager.cpp4
-rw-r--r--src/3rdparty/phonon/gstreamer/videowidget.cpp4
-rw-r--r--src/3rdparty/phonon/gstreamer/x11renderer.h4
-rw-r--r--src/3rdparty/phonon/phonon/mediacontroller.cpp4
-rw-r--r--src/3rdparty/phonon/phonon/objectdescriptionmodel.h3
-rw-r--r--src/3rdparty/phonon/phonon/qsettingsgroup_p.h4
-rw-r--r--src/3rdparty/phonon/qt7/videowidget.mm12
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro11
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h2
-rw-r--r--src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp28
-rw-r--r--src/3rdparty/zlib/zlib.h2
-rw-r--r--src/activeqt/container/qaxbase.cpp12
-rw-r--r--src/activeqt/container/qaxwidget.cpp4
-rw-r--r--src/activeqt/control/qaxserver.cpp2
-rw-r--r--src/activeqt/control/qaxserverbase.cpp16
-rw-r--r--src/activeqt/shared/qaxtypes.cpp28
-rw-r--r--src/corelib/animation/qabstractanimation.cpp159
-rw-r--r--src/corelib/animation/qabstractanimation.h31
-rw-r--r--src/corelib/animation/qabstractanimation_p.h52
-rw-r--r--src/corelib/arch/arch.pri4
-rw-r--r--src/corelib/arch/armv6/arch.pri3
-rw-r--r--src/corelib/arch/integrity/arch.pri3
-rw-r--r--src/corelib/arch/qatomic_arch.h6
-rw-r--r--src/corelib/arch/qatomic_arm.h403
-rw-r--r--src/corelib/arch/qatomic_armv5.h431
-rw-r--r--src/corelib/arch/qatomic_armv6.h161
-rw-r--r--src/corelib/arch/qatomic_armv7.h61
-rw-r--r--src/corelib/arch/qatomic_integrity.h289
-rw-r--r--src/corelib/arch/symbian/arch.pri2
-rw-r--r--src/corelib/arch/symbian/qatomic_generic_armv6.cpp (renamed from src/corelib/arch/armv6/qatomic_generic_armv6.cpp)0
-rw-r--r--src/corelib/arch/symbian/qt_hybridheap_symbian_p.h3
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp38
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/concurrent/qfuture.h2
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp9
-rw-r--r--src/corelib/concurrent/qtconcurrentcompilertest.h6
-rw-r--r--src/corelib/concurrent/qtconcurrentiteratekernel.h5
-rw-r--r--src/corelib/concurrent/qtconcurrentrunbase.h25
-rw-r--r--src/corelib/concurrent/qthreadpool.cpp35
-rw-r--r--src/corelib/concurrent/qthreadpool.h1
-rw-r--r--src/corelib/concurrent/qthreadpool_p.h2
-rw-r--r--src/corelib/corelib.pro10
-rw-r--r--src/corelib/global/global.pri2
-rw-r--r--src/corelib/global/qconfig-nacl.h371
-rw-r--r--src/corelib/global/qendian.h4
-rw-r--r--src/corelib/global/qfeatures.h13
-rw-r--r--src/corelib/global/qfeatures.txt8
-rw-r--r--src/corelib/global/qglobal.cpp49
-rw-r--r--src/corelib/global/qglobal.h372
-rw-r--r--src/corelib/global/qlibraryinfo.cpp3
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/global/qnamespace.qdoc36
-rw-r--r--src/corelib/io/io.pri41
-rw-r--r--src/corelib/io/qabstractfileengine.cpp85
-rw-r--r--src/corelib/io/qabstractfileengine_p.h2
-rw-r--r--src/corelib/io/qdatastream.cpp59
-rw-r--r--src/corelib/io/qdatastream.h10
-rw-r--r--src/corelib/io/qdebug.h7
-rw-r--r--src/corelib/io/qdir.cpp398
-rw-r--r--src/corelib/io/qdir.h4
-rw-r--r--src/corelib/io/qdir_p.h98
-rw-r--r--src/corelib/io/qdiriterator.cpp154
-rw-r--r--src/corelib/io/qfile.cpp209
-rw-r--r--src/corelib/io/qfile.h14
-rw-r--r--src/corelib/io/qfile_p.h7
-rw-r--r--src/corelib/io/qfileinfo.cpp234
-rw-r--r--src/corelib/io/qfileinfo.h8
-rw-r--r--src/corelib/io/qfileinfo_p.h31
-rw-r--r--src/corelib/io/qfilesystemengine.cpp391
-rw-r--r--src/corelib/io/qfilesystemengine_mac.cpp48
-rw-r--r--src/corelib/io/qfilesystemengine_p.h133
-rw-r--r--src/corelib/io/qfilesystemengine_symbian.cpp408
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp660
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp1218
-rw-r--r--src/corelib/io/qfilesystementry.cpp383
-rw-r--r--src/corelib/io/qfilesystementry_p.h126
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h120
-rw-r--r--src/corelib/io/qfilesystemiterator_symbian.cpp129
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp117
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp148
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h400
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp7
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h4
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp18
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue_p.h2
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp2
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp3
-rw-r--r--src/corelib/io/qfsfileengine.cpp187
-rw-r--r--src/corelib/io/qfsfileengine.h8
-rw-r--r--src/corelib/io/qfsfileengine_iterator.cpp33
-rw-r--r--src/corelib/io/qfsfileengine_iterator_p.h13
-rw-r--r--src/corelib/io/qfsfileengine_iterator_unix.cpp140
-rw-r--r--src/corelib/io/qfsfileengine_iterator_win.cpp161
-rw-r--r--src/corelib/io/qfsfileengine_p.h60
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp1188
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp1286
-rw-r--r--src/corelib/io/qiodevice.cpp12
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp14
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h10
-rw-r--r--src/corelib/io/qprocess.cpp19
-rw-r--r--src/corelib/io/qprocess_unix.cpp25
-rw-r--r--src/corelib/io/qresource.cpp27
-rw-r--r--src/corelib/io/qsettings.cpp8
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp22
-rw-r--r--src/corelib/io/qtextstream.cpp49
-rw-r--r--src/corelib/io/qtextstream.h3
-rw-r--r--src/corelib/io/qurl.cpp368
-rw-r--r--src/corelib/io/qurl.h7
-rw-r--r--src/corelib/kernel/kernel.pri145
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp2
-rw-r--r--src/corelib/kernel/qcore_mac_p.h8
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp6
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h16
-rw-r--r--src/corelib/kernel/qcore_unix.cpp3
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp47
-rw-r--r--src/corelib/kernel/qcoreapplication.h18
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h6
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h4
-rw-r--r--src/corelib/kernel/qcrashhandler.cpp3
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp8
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h3
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp18
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp4
-rw-r--r--src/corelib/kernel/qeventloop.cpp5
-rw-r--r--src/corelib/kernel/qfunctions_nacl.cpp156
-rw-r--r--src/corelib/kernel/qfunctions_nacl.h97
-rw-r--r--src/corelib/kernel/qfunctions_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp73
-rw-r--r--src/corelib/kernel/qmetaobject.h2
-rw-r--r--src/corelib/kernel/qmetaobject_p.h2
-rw-r--r--src/corelib/kernel/qmetatype.cpp1
-rw-r--r--src/corelib/kernel/qmetatype.h1
-rw-r--r--src/corelib/kernel/qobject.cpp641
-rw-r--r--src/corelib/kernel/qobject.h111
-rw-r--r--src/corelib/kernel/qobject_p.h8
-rw-r--r--src/corelib/kernel/qobjectdefs.h13
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp131
-rw-r--r--src/corelib/kernel/qsharedmemory.h2
-rw-r--r--src/corelib/kernel/qsharedmemory_p.h1
-rw-r--r--src/corelib/kernel/qsharedmemory_symbian.cpp11
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp15
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp13
-rw-r--r--src/corelib/kernel/qsystemerror.cpp220
-rw-r--r--src/corelib/kernel/qsystemerror_p.h107
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp9
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qvariant.cpp80
-rw-r--r--src/corelib/kernel/qvariant.h36
-rw-r--r--src/corelib/plugin/plugin.pri10
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp240
-rw-r--r--src/corelib/plugin/qelfparser_p.h108
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp4
-rw-r--r--src/corelib/plugin/qlibrary.cpp223
-rw-r--r--src/corelib/plugin/qlibrary_p.h2
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp30
-rw-r--r--src/corelib/plugin/qplugin.h13
-rw-r--r--src/corelib/plugin/qpluginloader.cpp8
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp23
-rw-r--r--src/corelib/thread/qmutex.cpp198
-rw-r--r--src/corelib/thread/qmutex.h78
-rw-r--r--src/corelib/thread/qmutex_p.h25
-rw-r--r--src/corelib/thread/qmutex_unix.cpp91
-rw-r--r--src/corelib/thread/qmutex_win.cpp10
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h14
-rw-r--r--src/corelib/thread/qsemaphore.cpp5
-rw-r--r--src/corelib/thread/qthread.cpp8
-rw-r--r--src/corelib/thread/qthread_p.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp75
-rw-r--r--src/corelib/thread/qthread_win.cpp42
-rw-r--r--src/corelib/thread/qthreadstorage.cpp59
-rw-r--r--src/corelib/thread/qthreadstorage.h13
-rw-r--r--src/corelib/thread/thread.pri4
-rw-r--r--src/corelib/tools/qbitarray.cpp7
-rw-r--r--src/corelib/tools/qbitarray.h6
-rw-r--r--src/corelib/tools/qbytearray.cpp64
-rw-r--r--src/corelib/tools/qbytearray.h6
-rw-r--r--src/corelib/tools/qcache.h2
-rw-r--r--src/corelib/tools/qchar.cpp39
-rw-r--r--src/corelib/tools/qchar.h8
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp7
-rw-r--r--src/corelib/tools/qcontiguouscache.h5
-rw-r--r--src/corelib/tools/qdatetime.cpp41
-rw-r--r--src/corelib/tools/qdatetime_p.h6
-rw-r--r--src/corelib/tools/qelapsedtimer.cpp23
-rw-r--r--src/corelib/tools/qelapsedtimer.h4
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp16
-rw-r--r--src/corelib/tools/qelapsedtimer_mac.cpp6
-rw-r--r--src/corelib/tools/qelapsedtimer_symbian.cpp22
-rw-r--r--src/corelib/tools/qelapsedtimer_unix.cpp11
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp58
-rw-r--r--src/corelib/tools/qhash.cpp18
-rw-r--r--src/corelib/tools/qhash.h11
-rw-r--r--src/corelib/tools/qlinkedlist.cpp7
-rw-r--r--src/corelib/tools/qlinkedlist.h5
-rw-r--r--src/corelib/tools/qlist.cpp7
-rw-r--r--src/corelib/tools/qlist.h18
-rw-r--r--src/corelib/tools/qmap.cpp14
-rw-r--r--src/corelib/tools/qmap.h12
-rw-r--r--src/corelib/tools/qpoint.cpp63
-rw-r--r--src/corelib/tools/qpoint.h38
-rw-r--r--src/corelib/tools/qqueue.cpp8
-rw-r--r--src/corelib/tools/qqueue.h1
-rw-r--r--src/corelib/tools/qregexp.cpp11
-rw-r--r--src/corelib/tools/qregexp.h5
-rw-r--r--src/corelib/tools/qscopedpointer.h36
-rw-r--r--src/corelib/tools/qscopedvaluerollback.cpp84
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h81
-rw-r--r--src/corelib/tools/qset.h5
-rw-r--r--src/corelib/tools/qset.qdoc7
-rw-r--r--src/corelib/tools/qshareddata.h26
-rw-r--r--src/corelib/tools/qsharedpointer.cpp4
-rw-r--r--src/corelib/tools/qsharedpointer.h3
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h34
-rw-r--r--src/corelib/tools/qsimd.cpp7
-rw-r--r--src/corelib/tools/qstack.cpp8
-rw-r--r--src/corelib/tools/qstack.h1
-rw-r--r--src/corelib/tools/qstring.cpp1094
-rw-r--r--src/corelib/tools/qstring.h67
-rw-r--r--src/corelib/tools/qstringbuilder.cpp4
-rw-r--r--src/corelib/tools/qstringbuilder.h5
-rw-r--r--src/corelib/tools/qvarlengtharray.h124
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc208
-rw-r--r--src/corelib/tools/qvector.cpp7
-rw-r--r--src/corelib/tools/qvector.h35
-rw-r--r--src/corelib/tools/tools.pri10
-rw-r--r--src/corelib/xml/qxmlstream.cpp76
-rw-r--r--src/corelib/xml/qxmlstream.h3
-rw-r--r--src/dbus/dbus.pro2
-rw-r--r--src/dbus/qdbusabstractinterface.cpp2
-rw-r--r--src/dbus/qdbusargument.cpp8
-rw-r--r--src/dbus/qdbusargument.h15
-rw-r--r--src/dbus/qdbusargument_p.h10
-rw-r--r--src/dbus/qdbusconnection.cpp50
-rw-r--r--src/dbus/qdbusconnection.h9
-rw-r--r--src/dbus/qdbusconnection_p.h1
-rw-r--r--src/dbus/qdbusdemarshaller.cpp26
-rw-r--r--src/dbus/qdbusintegrator.cpp20
-rw-r--r--src/dbus/qdbusinternalfilters.cpp6
-rw-r--r--src/dbus/qdbusmarshaller.cpp11
-rw-r--r--src/dbus/qdbusmessage.cpp17
-rw-r--r--src/dbus/qdbusmessage_p.h6
-rw-r--r--src/dbus/qdbusmetatype.cpp1
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp2
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp2
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver_p.h2
-rw-r--r--src/declarative/debugger/qdeclarativedebugserverconnection_p.h2
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p_p.h2
-rw-r--r--src/declarative/declarative.pro9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp69
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepincharea_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp23
-rw-r--r--src/declarative/qml/parser/qdeclarativejsengine_p.h6
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp34
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp32
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp4
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp30
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase.cpp14
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp2
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp2
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp23
-rw-r--r--src/declarative/qml/qperformancetimer.cpp2
-rw-r--r--src/declarative/qml/qperformancetimer_p.h2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp4
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h3
-rw-r--r--src/declarative/util/qdeclarativeapplication.cpp2
-rw-r--r--src/declarative/util/qdeclarativeapplication_p.h2
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp6
-rw-r--r--src/declarative/util/qdeclarativeview.cpp17
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp2
-rw-r--r--src/gui/accessible/accessible.pri2
-rw-r--r--src/gui/accessible/qaccessible.cpp17
-rw-r--r--src/gui/accessible/qaccessible_mac.mm2
-rw-r--r--src/gui/accessible/qaccessibleobject.cpp2
-rw-r--r--src/gui/accessible/qaccessiblewidget.cpp2
-rw-r--r--src/gui/dialogs/dialogs.pri4
-rw-r--r--src/gui/dialogs/qcolordialog_mac.mm4
-rw-r--r--src/gui/dialogs/qdialog.cpp6
-rw-r--r--src/gui/dialogs/qfiledialog.cpp8
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm9
-rw-r--r--src/gui/dialogs/qfiledialog_win.cpp3
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp6
-rw-r--r--src/gui/dialogs/qfileinfogatherer_p.h3
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp13
-rw-r--r--src/gui/dialogs/qfilesystemmodel.h4
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm7
-rw-r--r--src/gui/dialogs/qinputdialog.cpp32
-rw-r--r--src/gui/dialogs/qinputdialog.h25
-rw-r--r--src/gui/dialogs/qmessagebox.cpp8
-rw-r--r--src/gui/dialogs/qnspanelproxy_mac.mm87
-rw-r--r--src/gui/dialogs/qpagesetupdialog_mac.mm4
-rw-r--r--src/gui/egl/egl.pri28
-rw-r--r--src/gui/egl/qegl.cpp2
-rw-r--r--src/gui/egl/qegl_qpa.cpp111
-rw-r--r--src/gui/embedded/embedded.pri16
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h8
-rw-r--r--src/gui/embedded/qkbd_qws.cpp22
-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.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/qgraphicsgridlayout.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsgridlayout.h3
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp48
-rw-r--r--src/gui/graphicsview/qgraphicsitemanimation.cpp22
-rw-r--r--src/gui/graphicsview/qgraphicslayout.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicslayout_p.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicslayout_p.h8
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.h2
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp41
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h34
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp38
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp11
-rw-r--r--src/gui/graphicsview/qgridlayoutengine_p.h1
-rw-r--r--src/gui/gui.pro15
-rw-r--r--src/gui/image/image.pri5
-rw-r--r--src/gui/image/qbitmap.cpp8
-rw-r--r--src/gui/image/qbitmap.h1
-rw-r--r--src/gui/image/qicon.cpp8
-rw-r--r--src/gui/image/qicon.h6
-rw-r--r--src/gui/image/qimage.cpp152
-rw-r--r--src/gui/image/qimage.h10
-rw-r--r--src/gui/image/qimage_p.h37
-rw-r--r--src/gui/image/qimagereader.cpp2
-rw-r--r--src/gui/image/qmnghandler.cpp2
-rw-r--r--src/gui/image/qmovie.cpp6
-rw-r--r--src/gui/image/qnativeimage.cpp30
-rw-r--r--src/gui/image/qpicture.cpp8
-rw-r--r--src/gui/image/qpicture.h5
-rw-r--r--src/gui/image/qpixmap.cpp59
-rw-r--r--src/gui/image/qpixmap.h6
-rw-r--r--src/gui/image/qpixmap_blitter.cpp311
-rw-r--r--src/gui/image/qpixmap_blitter_p.h166
-rw-r--r--src/gui/image/qpixmap_mac.cpp6
-rw-r--r--src/gui/image/qpixmap_qpa.cpp49
-rw-r--r--src/gui/image/qpixmap_raster.cpp8
-rw-r--r--src/gui/image/qpixmap_x11.cpp12
-rw-r--r--src/gui/image/qpixmapdata_p.h3
-rw-r--r--src/gui/image/qpixmapdatafactory.cpp7
-rw-r--r--src/gui/image/qpnghandler.cpp132
-rw-r--r--src/gui/image/qtiffhandler.cpp7
-rw-r--r--src/gui/image/qvolatileimagedata.cpp1
-rw-r--r--src/gui/image/qxpmhandler.cpp32
-rw-r--r--src/gui/inputmethod/inputmethod.pri2
-rw-r--r--src/gui/itemviews/qabstractitemdelegate.cpp4
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp193
-rw-r--r--src/gui/itemviews/qabstractitemview.h3
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h42
-rw-r--r--src/gui/itemviews/qabstractproxymodel.cpp120
-rw-r--r--src/gui/itemviews/qabstractproxymodel.h15
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp2
-rw-r--r--src/gui/itemviews/qheaderview.cpp22
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp10
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp21
-rw-r--r--src/gui/itemviews/qitemselectionmodel.h24
-rw-r--r--src/gui/itemviews/qlistview.cpp126
-rw-r--r--src/gui/itemviews/qlistview_p.h9
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp2
-rw-r--r--src/gui/itemviews/qstringlistmodel.cpp3
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp9
-rw-r--r--src/gui/itemviews/qtableview.cpp13
-rw-r--r--src/gui/itemviews/qtreeview.cpp37
-rw-r--r--src/gui/kernel/kernel.pri76
-rw-r--r--src/gui/kernel/mac.pri2
-rw-r--r--src/gui/kernel/qapplication.cpp114
-rw-r--r--src/gui/kernel/qapplication.h12
-rw-r--r--src/gui/kernel/qapplication_mac.mm157
-rw-r--r--src/gui/kernel/qapplication_p.h62
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp952
-rw-r--r--src/gui/kernel/qapplication_qws.cpp5
-rw-r--r--src/gui/kernel/qapplication_s60.cpp20
-rw-r--r--src/gui/kernel/qapplication_win.cpp78
-rw-r--r--src/gui/kernel/qapplication_x11.cpp69
-rw-r--r--src/gui/kernel/qclipboard.cpp2
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp105
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm87
-rw-r--r--src/gui/kernel/qcocoaapplication_mac_p.h8
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm29
-rw-r--r--src/gui/kernel/qcocoaintrospection_mac.mm125
-rw-r--r--src/gui/kernel/qcocoaintrospection_p.h84
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm12
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm7
-rw-r--r--src/gui/kernel/qcocoapanel_mac_p.h16
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h438
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm998
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h30
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm4
-rw-r--r--src/gui/kernel/qcocoawindow_mac_p.h17
-rw-r--r--src/gui/kernel/qcocoawindowdelegate_mac.mm23
-rw-r--r--src/gui/kernel/qcursor.h11
-rw-r--r--src/gui/kernel/qcursor_mac.mm128
-rw-r--r--src/gui/kernel/qcursor_p.h2
-rw-r--r--src/gui/kernel/qcursor_qpa.cpp127
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa.cpp180
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa_p.h82
-rw-r--r--src/gui/kernel/qdesktopwidget_win.cpp14
-rw-r--r--src/gui/kernel/qdnd_mac.mm4
-rw-r--r--src/gui/kernel/qdnd_p.h6
-rw-r--r--src/gui/kernel/qevent.cpp298
-rw-r--r--src/gui/kernel/qevent.h55
-rw-r--r--src/gui/kernel/qevent_p.h36
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa.cpp147
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa_p.h (renamed from src/network/access/qnetworkaccessdatabackend_p.h)42
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm65
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa.cpp334
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa_p.h86
-rw-r--r--src/gui/kernel/qgenericplugin_qpa.cpp112
-rw-r--r--src/gui/kernel/qgenericplugin_qpa.h84
-rw-r--r--src/gui/kernel/qgenericpluginfactory_qpa.cpp115
-rw-r--r--src/gui/kernel/qgenericpluginfactory_qpa.h67
-rw-r--r--src/gui/kernel/qgesturemanager.cpp41
-rw-r--r--src/gui/kernel/qguifunctions_wince.cpp5
-rw-r--r--src/gui/kernel/qguiplatformplugin.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/qkeysequence.cpp15
-rw-r--r--src/gui/kernel/qkeysequence.h5
-rw-r--r--src/gui/kernel/qlayoutitem.cpp4
-rw-r--r--src/gui/kernel/qmacdefines_mac.h12
-rw-r--r--src/gui/kernel/qpalette.h8
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp105
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.h73
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.cpp660
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.h103
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.cpp86
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.h82
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp227
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h94
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp234
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h109
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa.cpp109
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa_p.h78
-rw-r--r--src/gui/kernel/qplatformintegrationplugin_qpa.cpp55
-rw-r--r--src/gui/kernel/qplatformintegrationplugin_qpa.h92
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.cpp53
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.h65
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp129
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h86
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp229
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h95
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.cpp1019
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.h243
-rw-r--r--src/gui/kernel/qsizepolicy.h21
-rw-r--r--src/gui/kernel/qsizepolicy.qdoc24
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm714
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h130
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/kernel/qtooltip.cpp2
-rw-r--r--src/gui/kernel/qwidget.cpp176
-rw-r--r--src/gui/kernel/qwidget.h27
-rw-r--r--src/gui/kernel/qwidget_mac.mm875
-rw-r--r--src/gui/kernel/qwidget_p.h33
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp875
-rw-r--r--src/gui/kernel/qwidget_s60.cpp8
-rw-r--r--src/gui/kernel/qwidget_win.cpp28
-rw-r--r--src/gui/kernel/qwidget_x11.cpp23
-rw-r--r--src/gui/kernel/qwindowdefs.h6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp291
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h107
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h208
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp12
-rw-r--r--src/gui/math3d/qgenericmatrix.h6
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp14
-rw-r--r--src/gui/math3d/qmatrix4x4.h22
-rw-r--r--src/gui/painting/painting.pri38
-rw-r--r--src/gui/painting/qbackingstore.cpp51
-rw-r--r--src/gui/painting/qbackingstore_p.h6
-rw-r--r--src/gui/painting/qblendfunctions.cpp4
-rw-r--r--src/gui/painting/qblittable.cpp105
-rw-r--r--src/gui/painting/qblittable_p.h91
-rw-r--r--src/gui/painting/qbrush.cpp9
-rw-r--r--src/gui/painting/qbrush.h6
-rw-r--r--src/gui/painting/qcolor.cpp2
-rw-r--r--src/gui/painting/qcolor_p.cpp36
-rw-r--r--src/gui/painting/qcolormap_qpa.cpp231
-rw-r--r--src/gui/painting/qdrawingprimitive_sse2_p.h4
-rw-r--r--src/gui/painting/qgraphicssystem.cpp7
-rw-r--r--src/gui/painting/qgraphicssystem_p.h6
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp10
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h3
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp4
-rw-r--r--src/gui/painting/qgrayraster.c35
-rw-r--r--src/gui/painting/qgrayraster_p.h2
-rw-r--r--src/gui/painting/qoutlinemapper.cpp9
-rw-r--r--src/gui/painting/qoutlinemapper_p.h8
-rw-r--r--src/gui/painting/qpaintbuffer.cpp44
-rw-r--r--src/gui/painting/qpaintdevice.cpp2
-rw-r--r--src/gui/painting/qpaintdevice_qpa.cpp68
-rw-r--r--src/gui/painting/qpaintengine.h4
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp663
-rw-r--r--src/gui/painting/qpaintengine_blitter_p.h113
-rw-r--r--src/gui/painting/qpaintengine_mac.cpp5
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp429
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h5
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp2
-rw-r--r--src/gui/painting/qpainter.cpp202
-rw-r--r--src/gui/painting/qpainter.h5
-rw-r--r--src/gui/painting/qpainter_p.h3
-rw-r--r--src/gui/painting/qpainterpath.cpp79
-rw-r--r--src/gui/painting/qpainterpath.h5
-rw-r--r--src/gui/painting/qpdf.cpp3
-rw-r--r--src/gui/painting/qpen.cpp8
-rw-r--r--src/gui/painting/qpen.h5
-rw-r--r--src/gui/painting/qpolygon.cpp16
-rw-r--r--src/gui/painting/qpolygon.h3
-rw-r--r--src/gui/painting/qprintengine_pdf.cpp2
-rw-r--r--src/gui/painting/qprinterinfo.cpp (renamed from src/gui/painting/qprinterinfo.qdoc)82
-rw-r--r--src/gui/painting/qprinterinfo.h15
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp185
-rw-r--r--src/gui/painting/qprinterinfo_p.h107
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp411
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp193
-rw-r--r--src/gui/painting/qrasterizer.cpp4
-rw-r--r--src/gui/painting/qregion.cpp12
-rw-r--r--src/gui/painting/qregion.h12
-rw-r--r--src/gui/painting/qstroker.cpp40
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp198
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h49
-rw-r--r--src/gui/painting/qtransform.cpp3
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp264
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h107
-rw-r--r--src/gui/painting/qwindowsurface.cpp65
-rw-r--r--src/gui/painting/qwindowsurface_mac.cpp2
-rw-r--r--src/gui/painting/qwindowsurface_p.h15
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp110
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h17
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp10
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp14
-rw-r--r--src/gui/painting/qwindowsurface_x11_p.h1
-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/styles/qcleanlooksstyle.cpp1
-rw-r--r--src/gui/styles/qcommonstyle.cpp2
-rw-r--r--src/gui/styles/qgtkstyle.cpp48
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp8
-rw-r--r--src/gui/styles/qgtkstyle_p.h8
-rw-r--r--src/gui/styles/qmacstyle_mac.mm77
-rw-r--r--src/gui/styles/qplastiquestyle.cpp7
-rw-r--r--src/gui/styles/qs60style.cpp2
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp166
-rw-r--r--src/gui/styles/qstylesheetstyle_default.cpp2
-rw-r--r--src/gui/styles/qstylesheetstyle_p.h20
-rw-r--r--src/gui/styles/qwindowscestyle.cpp1
-rw-r--r--src/gui/styles/qwindowsstyle.cpp6
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp16
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp2
-rw-r--r--src/gui/styles/styles.pri2
-rw-r--r--src/gui/symbian/qsymbianevent.cpp33
-rw-r--r--src/gui/symbian/qsymbianevent.h4
-rw-r--r--src/gui/text/qcssparser.cpp91
-rw-r--r--src/gui/text/qcssparser_p.h6
-rw-r--r--src/gui/text/qfont.cpp131
-rw-r--r--src/gui/text/qfont.h49
-rw-r--r--src/gui/text/qfont_mac.cpp1
-rw-r--r--src/gui/text/qfont_p.h12
-rw-r--r--src/gui/text/qfont_qpa.cpp114
-rw-r--r--src/gui/text/qfont_s60.cpp18
-rw-r--r--src/gui/text/qfontdatabase.cpp99
-rw-r--r--src/gui/text/qfontdatabase.h4
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp120
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp394
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp10
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp2
-rw-r--r--src/gui/text/qfontdatabase_win.cpp220
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp64
-rw-r--r--src/gui/text/qfontengine.cpp57
-rw-r--r--src/gui/text/qfontengine_coretext.mm747
-rw-r--r--src/gui/text/qfontengine_coretext_p.h136
-rw-r--r--src/gui/text/qfontengine_ft.cpp212
-rw-r--r--src/gui/text/qfontengine_ft_p.h82
-rw-r--r--src/gui/text/qfontengine_mac.mm711
-rw-r--r--src/gui/text/qfontengine_mac_p.h167
-rw-r--r--src/gui/text/qfontengine_p.h239
-rw-r--r--src/gui/text/qfontengine_qpa.cpp691
-rw-r--r--src/gui/text/qfontengine_qpa_p.h262
-rw-r--r--src/gui/text/qfontengine_qpf.cpp2
-rw-r--r--src/gui/text/qfontengine_qws.cpp51
-rw-r--r--src/gui/text/qfontengine_s60.cpp7
-rw-r--r--src/gui/text/qfontengine_win.cpp4
-rw-r--r--src/gui/text/qfontengine_win_p.h4
-rw-r--r--src/gui/text/qfontengine_x11.cpp25
-rw-r--r--src/gui/text/qfontenginedirectwrite.cpp641
-rw-r--r--src/gui/text/qfontenginedirectwrite_p.h133
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h2
-rw-r--r--src/gui/text/qfontmetrics.cpp32
-rw-r--r--src/gui/text/qfontmetrics.h11
-rw-r--r--src/gui/text/qglyphs.cpp240
-rw-r--r--src/gui/text/qglyphs.h96
-rw-r--r--src/gui/text/qglyphs_p.h84
-rw-r--r--src/gui/text/qpfutil.cpp2
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp291
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.h108
-rw-r--r--src/gui/text/qtextcontrol.cpp5
-rw-r--r--src/gui/text/qtextcursor.h1
-rw-r--r--src/gui/text/qtextdocument.cpp36
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp4
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp54
-rw-r--r--src/gui/text/qtextdocumentlayout_p.h7
-rw-r--r--src/gui/text/qtextengine.cpp102
-rw-r--r--src/gui/text/qtextengine_mac.cpp3
-rw-r--r--src/gui/text/qtextengine_p.h23
-rw-r--r--src/gui/text/qtextformat.cpp133
-rw-r--r--src/gui/text/qtextformat.h62
-rw-r--r--src/gui/text/qtexthtmlparser.cpp20
-rw-r--r--src/gui/text/qtexthtmlparser_p.h2
-rw-r--r--src/gui/text/qtextlayout.cpp464
-rw-r--r--src/gui/text/qtextlayout.h6
-rw-r--r--src/gui/text/qtextlist.cpp14
-rw-r--r--src/gui/text/qtextobject.cpp29
-rw-r--r--src/gui/text/qtextobject.h3
-rw-r--r--src/gui/text/qtextodfwriter.cpp10
-rw-r--r--src/gui/text/text.pri44
-rw-r--r--src/gui/util/qcompleter.cpp2
-rw-r--r--src/gui/util/qdesktopservices.cpp2
-rw-r--r--src/gui/util/qdesktopservices_mac.cpp2
-rw-r--r--src/gui/util/qflickgesture.cpp715
-rw-r--r--src/gui/util/qflickgesture_p.h113
-rw-r--r--src/gui/util/qscroller.cpp2057
-rw-r--r--src/gui/util/qscroller.h155
-rw-r--r--src/gui/util/qscroller_mac.mm71
-rw-r--r--src/gui/util/qscroller_p.h213
-rw-r--r--src/gui/util/qscrollerproperties.cpp393
-rw-r--r--src/gui/util/qscrollerproperties.h140
-rw-r--r--src/gui/util/qscrollerproperties_p.h94
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp1
-rw-r--r--src/gui/util/util.pri18
-rw-r--r--src/gui/widgets/qabstractbutton.cpp2
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp107
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qabstractslider_p.h2
-rw-r--r--src/gui/widgets/qcheckbox.cpp9
-rw-r--r--src/gui/widgets/qcheckbox.h1
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm30
-rw-r--r--src/gui/widgets/qcombobox.cpp24
-rw-r--r--src/gui/widgets/qcombobox.h2
-rw-r--r--src/gui/widgets/qcombobox_p.h2
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp15
-rw-r--r--src/gui/widgets/qdial.cpp15
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp10
-rw-r--r--src/gui/widgets/qeffects.cpp29
-rw-r--r--src/gui/widgets/qfocusframe.cpp3
-rw-r--r--src/gui/widgets/qlabel.cpp2
-rw-r--r--src/gui/widgets/qlinecontrol.cpp4
-rw-r--r--src/gui/widgets/qlineedit.h1
-rw-r--r--src/gui/widgets/qlineedit_p.cpp23
-rw-r--r--src/gui/widgets/qlineedit_p.h3
-rw-r--r--src/gui/widgets/qmainwindow.cpp27
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp4
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm56
-rw-r--r--src/gui/widgets/qmainwindowlayout_p.h18
-rw-r--r--src/gui/widgets/qmdiarea.cpp79
-rw-r--r--src/gui/widgets/qmdiarea.h12
-rw-r--r--src/gui/widgets/qmdiarea_p.h4
-rw-r--r--src/gui/widgets/qmdisubwindow.cpp4
-rw-r--r--src/gui/widgets/qmenu.cpp2
-rw-r--r--src/gui/widgets/qmenu.h4
-rw-r--r--src/gui/widgets/qmenu_mac.mm17
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp3
-rw-r--r--src/gui/widgets/qmenu_wince.cpp2
-rw-r--r--src/gui/widgets/qmenubar.cpp5
-rw-r--r--src/gui/widgets/qradiobutton.cpp8
-rw-r--r--src/gui/widgets/qradiobutton.h1
-rw-r--r--src/gui/widgets/qsizegrip.cpp19
-rw-r--r--src/gui/widgets/qspinbox.cpp3
-rw-r--r--src/gui/widgets/qsplashscreen.cpp58
-rw-r--r--src/gui/widgets/qstackedwidget.cpp46
-rw-r--r--src/gui/widgets/qtabbar.cpp13
-rw-r--r--src/gui/widgets/qtabwidget.cpp62
-rw-r--r--src/gui/widgets/qtabwidget.h1
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp8
-rw-r--r--src/gui/widgets/qtoolbutton.cpp3
-rw-r--r--src/gui/widgets/qvalidator.h6
-rw-r--r--src/gui/widgets/qworkspace.cpp2
-rw-r--r--src/gui/widgets/widgets.pri2
-rw-r--r--src/imports/folderlistmodel/folderlistmodel.pro4
-rw-r--r--src/imports/gestures/gestures.pro4
-rw-r--r--src/imports/particles/particles.pro4
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp6
-rw-r--r--src/multimedia/multimedia.pro2
-rw-r--r--src/multimedia/video/qvideosurfaceformat.cpp26
-rw-r--r--src/network/access/access.pri16
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp58
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h2
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp286
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h16
-rw-r--r--src/network/access/qhttpnetworkreply.cpp119
-rw-r--r--src/network/access/qhttpnetworkreply_p.h16
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp11
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h4
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp518
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h285
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager.cpp297
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h107
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp35
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h19
-rw-r--r--src/network/access/qnetworkaccessdatabackend.cpp135
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp13
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp2
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp794
-rw-r--r--src/network/access/qnetworkaccesshttpbackend_p.h42
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp312
-rw-r--r--src/network/access/qnetworkaccessmanager.h2
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h10
-rw-r--r--src/network/access/qnetworkdiskcache.cpp2
-rw-r--r--src/network/access/qnetworkreply.cpp18
-rw-r--r--src/network/access/qnetworkreply.h1
-rw-r--r--src/network/access/qnetworkreply_p.h3
-rw-r--r--src/network/access/qnetworkreplydataimpl.cpp148
-rw-r--r--src/network/access/qnetworkreplydataimpl_p.h98
-rw-r--r--src/network/access/qnetworkreplyfileimpl.cpp (renamed from src/network/access/qfilenetworkreply.cpp)93
-rw-r--r--src/network/access/qnetworkreplyfileimpl_p.h (renamed from src/network/access/qfilenetworkreply_p.h)30
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp167
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h18
-rw-r--r--src/network/access/qnetworkrequest.cpp6
-rw-r--r--src/network/access/qnetworkrequest.h4
-rw-r--r--src/network/bearer/bearer.pri1
-rw-r--r--src/network/bearer/qbearerengine.cpp14
-rw-r--r--src/network/bearer/qbearerengine_p.h5
-rw-r--r--src/network/bearer/qbearerplugin.cpp4
-rw-r--r--src/network/bearer/qbearerplugin_p.h6
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp19
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h22
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp102
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h48
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp30
-rw-r--r--src/network/bearer/qnetworkconfiguration.h11
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h17
-rw-r--r--src/network/bearer/qnetworksession.cpp102
-rw-r--r--src/network/bearer/qnetworksession.h17
-rw-r--r--src/network/bearer/qnetworksession_p.h20
-rw-r--r--src/network/bearer/qsharednetworksession_p.h4
-rw-r--r--src/network/kernel/kernel.pri1
-rw-r--r--src/network/kernel/qhostinfo.cpp26
-rw-r--r--src/network/kernel/qhostinfo_p.h7
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp2
-rw-r--r--src/network/kernel/qhostinfo_win.cpp7
-rw-r--r--src/network/network.pro2
-rw-r--r--src/network/socket/qabstractsocket.cpp192
-rw-r--r--src/network/socket/qabstractsocket.h5
-rw-r--r--src/network/socket/qabstractsocket_p.h3
-rw-r--r--src/network/socket/qabstractsocketengine_p.h18
-rw-r--r--src/network/socket/qhttpsocketengine.cpp36
-rw-r--r--src/network/socket/qhttpsocketengine_p.h9
-rw-r--r--src/network/socket/qlocalsocket.cpp2
-rw-r--r--src/network/socket/qnativesocketengine.cpp49
-rw-r--r--src/network/socket/qnativesocketengine_p.h20
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp219
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp269
-rw-r--r--src/network/socket/qsocks5socketengine.cpp32
-rw-r--r--src/network/socket/qsocks5socketengine_p.h9
-rw-r--r--src/network/socket/qudpsocket.cpp126
-rw-r--r--src/network/socket/qudpsocket.h13
-rw-r--r--src/network/socket/socket.pri10
-rw-r--r--src/network/ssl/qssl.cpp7
-rw-r--r--src/network/ssl/qssl.h4
-rw-r--r--src/network/ssl/qsslconfiguration.cpp4
-rw-r--r--src/network/ssl/qsslconfiguration_p.h2
-rw-r--r--src/network/ssl/qsslsocket.cpp74
-rw-r--r--src/network/ssl/qsslsocket.h3
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp66
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h4
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp15
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h5
-rw-r--r--src/network/ssl/qsslsocket_p.h5
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp336
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h11
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h28
-rw-r--r--src/opengl/gl2paintengineex/qglgradientcache.cpp35
-rw-r--r--src/opengl/gl2paintengineex/qglgradientcache_p.h9
-rw-r--r--src/opengl/gl2paintengineex/qglshadercache_meego_p.h457
-rw-r--r--src/opengl/gl2paintengineex/qglshadercache_p.h98
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp132
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp250
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h115
-rw-r--r--src/opengl/opengl.pro24
-rw-r--r--src/opengl/opengl.pro.user.2.1pre183
-rw-r--r--src/opengl/qgl.cpp274
-rw-r--r--src/opengl/qgl.h21
-rw-r--r--src/opengl/qgl_p.h187
-rw-r--r--src/opengl/qgl_qpa.cpp393
-rw-r--r--src/opengl/qgl_win.cpp5
-rw-r--r--src/opengl/qgl_x11egl.cpp2
-rw-r--r--src/opengl/qglextensions_p.h4
-rw-r--r--src/opengl/qglframebufferobject.cpp59
-rw-r--r--src/opengl/qglframebufferobject.h3
-rw-r--r--src/opengl/qglframebufferobject_p.h13
-rw-r--r--src/opengl/qglfunctions.cpp3705
-rw-r--r--src/opengl/qglfunctions.h2295
-rw-r--r--src/opengl/qglpaintdevice.cpp6
-rw-r--r--src/opengl/qglpaintdevice_p.h1
-rw-r--r--src/opengl/qglpixelbuffer.cpp20
-rw-r--r--src/opengl/qglpixelbuffer_p.h4
-rw-r--r--src/opengl/qglpixelbuffer_stub.cpp84
-rw-r--r--src/opengl/qglpixmapfilter.cpp21
-rw-r--r--src/opengl/qglshaderprogram.cpp21
-rw-r--r--src/opengl/qpixmapdata_gl.cpp30
-rw-r--r--src/opengl/qwindowsurface_gl.cpp86
-rw-r--r--src/opengl/qwindowsurface_gl_p.h12
-rw-r--r--src/opengl/util/meego/main.cpp89
-rw-r--r--src/opengl/util/meego/shader-cache-introspector.pro7
-rw-r--r--src/openvg/openvg.pro9
-rw-r--r--src/openvg/qwindowsurface_vg.cpp6
-rw-r--r--src/openvg/qwindowsurface_vg_p.h2
-rw-r--r--src/phonon/phonon.pro2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp2
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.cpp4
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.cpp2
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp1
-rw-r--r--src/plugins/bearer/connman/qofonoservice_linux.cpp5
-rw-r--r--src/plugins/bearer/connman/qofonoservice_linux_p.h6
-rw-r--r--src/plugins/bearer/corewlan/corewlan.pro3
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm4
-rw-r--r--src/plugins/bearer/platformdefs_win.h5
-rw-r--r--src/plugins/bearer/qbearerengine_impl.h7
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp67
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h23
-rw-r--r--src/plugins/codecs/kr/qeuckrcodec.cpp16
-rw-r--r--src/plugins/generic/linuxinput/linuxinput.pro18
-rw-r--r--src/plugins/generic/linuxinput/main.cpp80
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.cpp557
-rw-r--r--src/plugins/generic/linuxinput/qlinuxinput.h111
-rw-r--r--src/plugins/generic/tslib/main.cpp78
-rw-r--r--src/plugins/generic/tslib/qtslib.cpp144
-rw-r--r--src/plugins/generic/tslib/qtslib.h77
-rw-r--r--src/plugins/generic/tslib/tslib.pro13
-rw-r--r--src/plugins/gfxdrivers/eglnullws/README48
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullws.pro18
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp181
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h69
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp66
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h47
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp84
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h63
-rw-r--r--src/plugins/gfxdrivers/gfxdrivers.pro1
-rw-r--r--src/plugins/graphicssystems/graphicssystems.pro4
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp4
-rw-r--r--src/plugins/phonon/gstreamer/gstreamer.pro2
-rw-r--r--src/plugins/phonon/mmf/mmf.pro6
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro29
-rw-r--r--src/plugins/platforms/cocoa/main.mm74
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.h57
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm52
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.h65
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm112
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h99
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm132
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h75
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm110
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.h73
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.mm103
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h79
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm211
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h61
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm73
-rw-r--r--src/plugins/platforms/directfb/directfb.pro35
-rw-r--r--src/plugins/platforms/directfb/main.cpp72
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.cpp155
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.h76
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.cpp376
-rw-r--r--src/plugins/platforms/directfb/qdirectfbconvenience.h84
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.cpp80
-rw-r--r--src/plugins/platforms/directfb/qdirectfbcursor.h63
-rw-r--r--src/plugins/platforms/directfb/qdirectfbglcontext.cpp99
-rw-r--r--src/plugins/platforms/directfb/qdirectfbglcontext.h69
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.cpp208
-rw-r--r--src/plugins/platforms/directfb/qdirectfbinput.h86
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.cpp144
-rw-r--r--src/plugins/platforms/directfb/qdirectfbintegration.h104
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.cpp191
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindow.h79
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp141
-rw-r--r--src/plugins/platforms/directfb/qdirectfbwindowsurface.h77
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp324
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h64
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp162
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.h73
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp186
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.h53
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro31
-rw-r--r--src/plugins/platforms/eglfs/main.cpp72
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp109
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h77
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp245
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h79
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp87
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h71
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindowsurface.cpp101
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindowsurface.h67
-rw-r--r--src/plugins/platforms/externalplugin.pri29
-rw-r--r--src/plugins/platforms/fb_base/fb_base.cpp507
-rw-r--r--src/plugins/platforms/fb_base/fb_base.h210
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pri2
-rw-r--r--src/plugins/platforms/fb_base/fb_base.pro23
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/basicunix.pri86
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp328
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h67
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri12
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp601
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h56
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/genericunix.pri10
-rw-r--r--src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h53
-rw-r--r--src/plugins/platforms/linuxfb/linuxfb.pro13
-rw-r--r--src/plugins/platforms/linuxfb/main.cpp72
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp875
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.h135
-rw-r--r--src/plugins/platforms/minimal/main.cpp73
-rw-r--r--src/plugins/platforms/minimal/minimal.pro13
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp82
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h86
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.cpp86
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.h67
-rw-r--r--src/plugins/platforms/openkode/main.cpp72
-rw-r--r--src/plugins/platforms/openkode/openkode.pro42
-rw-r--r--src/plugins/platforms/openkode/openkodekeytranslator.h244
-rw-r--r--src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp128
-rw-r--r--src/plugins/platforms/openkode/qopenkodeeventloopintegration.h71
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.cpp249
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.h118
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.cpp315
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.h89
-rw-r--r--src/plugins/platforms/openkode/resources.qrc6
-rw-r--r--src/plugins/platforms/openkode/shaders/frag.glslf49
-rw-r--r--src/plugins/platforms/openkode/shaders/vert.glslv55
-rw-r--r--src/plugins/platforms/openvglite/main.cpp71
-rw-r--r--src/plugins/platforms/openvglite/openvglite.pro12
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp193
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.h93
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp131
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.h91
-rw-r--r--src/plugins/platforms/platforms.pro8
-rw-r--r--src/plugins/platforms/qvfb/main.cpp73
-rw-r--r--src/plugins/platforms/qvfb/qvfb.pro13
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.cpp448
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.h100
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.cpp108
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.h80
-rw-r--r--src/plugins/platforms/uikit/README45
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/main.mm74
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qml/main.qml112
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp110
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp196
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h80
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist28
-rwxr-xr-xsrc/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj463
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch8
-rw-r--r--src/plugins/platforms/uikit/main.mm74
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.h68
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.mm160
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.h72
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.mm104
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.h75
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.mm81
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.h70
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.mm89
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.h83
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.mm242
-rw-r--r--src/plugins/platforms/uikit/uikit.pro23
-rw-r--r--src/plugins/platforms/vnc/main.cpp73
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.cpp156
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.h76
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp251
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h110
-rw-r--r--src/plugins/platforms/vnc/qvncserver.cpp1935
-rw-r--r--src/plugins/platforms/vnc/qvncserver.h533
-rw-r--r--src/plugins/platforms/vnc/vnc.pro22
-rw-r--r--src/plugins/platforms/wayland/main.cpp75
-rw-r--r--src/plugins/platforms/wayland/qwaylandbuffer.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp191
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp247
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h125
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.cpp183
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.h70
-rw-r--r--src/plugins/platforms/wayland/qwaylandeglwindow.cpp113
-rw-r--r--src/plugins/platforms/wayland/qwaylandeglwindow.h68
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.cpp155
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.h81
-rw-r--r--src/plugins/platforms/wayland/qwaylandinclude.h63
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp329
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h100
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp115
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h74
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp106
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h77
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.cpp158
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.h86
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp89
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h63
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp104
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h83
-rw-r--r--src/plugins/platforms/wayland/wayland.pro58
-rw-r--r--src/plugins/platforms/xcb/README2
-rw-r--r--src/plugins/platforms/xcb/main.cpp72
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp271
-rw-r--r--src/plugins/platforms/xcb/qdri2context.h77
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp360
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h87
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp557
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h294
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp142
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h82
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp967
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h82
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp185
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h75
-rw-r--r--src/plugins/platforms/xcb/qxcbobject.h62
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp99
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h74
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp588
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h98
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp220
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h70
-rw-r--r--src/plugins/platforms/xcb/xcb.pro69
-rw-r--r--src/plugins/platforms/xlib/main.cpp79
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.cpp377
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.h94
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.cpp677
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.h94
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.cpp200
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.h68
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.cpp78
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.h63
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp157
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.h85
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.cpp1001
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.h76
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.cpp322
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.h67
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp485
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.h104
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.cpp512
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.h413
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.cpp736
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.h145
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.cpp224
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.h86
-rw-r--r--src/plugins/platforms/xlib/xlib.pro59
-rw-r--r--src/plugins/plugins.pro5
-rw-r--r--src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp2
-rw-r--r--src/plugins/qmltooling/tcpserver/qtcpserverconnection.h2
-rw-r--r--src/plugins/qpluginbase.pri2
-rw-r--r--src/qbase.pri13
-rw-r--r--src/qt3support/qt3support.pro2
-rw-r--r--src/qt3support/text/q3richtext.cpp4
-rw-r--r--src/qt3support/text/q3textstream.h6
-rw-r--r--src/qt3support/tools/q3cstring.h50
-rw-r--r--src/qt3support/tools/q3valuevector.h4
-rw-r--r--src/qt_install.pri2
-rw-r--r--src/s60installs/bwins/QtCoreu.def134
-rw-r--r--src/s60installs/bwins/QtGuiu.def490
-rw-r--r--src/s60installs/bwins/QtNetworku.def32
-rw-r--r--src/s60installs/bwins/QtOpenGLu.def185
-rw-r--r--src/s60installs/bwins/QtTestu.def89
-rw-r--r--src/s60installs/eabi/QtCoreu.def108
-rw-r--r--src/s60installs/eabi/QtGuiu.def339
-rw-r--r--src/s60installs/eabi/QtNetworku.def29
-rw-r--r--src/s60installs/eabi/QtOpenGLu.def113
-rw-r--r--src/s60installs/eabi/QtOpenVGu.def18
-rw-r--r--src/s60installs/eabi/QtTestu.def94
-rw-r--r--src/s60installs/s60installs.pro56
-rw-r--r--src/s60main/newallocator_hook.cpp97
-rw-r--r--src/s60main/qts60main.cpp3
-rw-r--r--src/s60main/qts60main_mcrt0.cpp8
-rw-r--r--src/s60main/s60main.pro3
-rw-r--r--src/script/api/qscriptcontextinfo.cpp10
-rw-r--r--src/script/api/qscriptengine.cpp98
-rw-r--r--src/script/api/qscriptengine.h72
-rw-r--r--src/script/api/qscriptprogram.cpp1
-rw-r--r--src/script/api/qscriptvalue.cpp39
-rw-r--r--src/script/api/qscriptvalueiterator.cpp4
-rw-r--r--src/script/bridge/qscriptclassobject.cpp11
-rw-r--r--src/script/bridge/qscriptqobject.cpp10
-rw-r--r--src/script/script.pro18
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommand.cpp6
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp8
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsole.cpp14
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp8
-rw-r--r--src/scripttools/debugging/qscriptdebuggerevent.cpp2
-rw-r--r--src/scripttools/debugging/qscriptdebuggerresponse.cpp16
-rw-r--r--src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp2
-rw-r--r--src/scripttools/debugging/qscriptdebugoutputwidget.cpp8
-rw-r--r--src/scripttools/debugging/qscripterrorlogwidget.cpp8
-rw-r--r--src/scripttools/scripttools.pro2
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp6
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp14
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp41
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp4
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp4
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.cpp4
-rw-r--r--src/sql/kernel/qsqldatabase.cpp8
-rw-r--r--src/sql/sql.pro2
-rw-r--r--src/src.pro2
-rw-r--r--src/svg/svg.pro2
-rw-r--r--src/testlib/qabstracttestlogger_p.h2
-rw-r--r--src/testlib/qplaintestlogger.cpp22
-rw-r--r--src/testlib/qplaintestlogger_p.h4
-rw-r--r--src/testlib/qtest.h2
-rw-r--r--src/testlib/qtest_global.h2
-rw-r--r--src/testlib/qtestcase.cpp170
-rw-r--r--src/testlib/qtestlightxmlstreamer.cpp8
-rw-r--r--src/testlib/qtestlog.cpp55
-rw-r--r--src/testlib/qtestlog_p.h2
-rw-r--r--src/testlib/qtestlogger.cpp27
-rw-r--r--src/testlib/qtestlogger_p.h5
-rw-r--r--src/testlib/qtestmouse.h4
-rw-r--r--src/testlib/qtestresult.cpp5
-rw-r--r--src/testlib/qtestxmlstreamer.cpp10
-rw-r--r--src/testlib/qxmltestlogger.cpp27
-rw-r--r--src/testlib/qxmltestlogger_p.h4
-rw-r--r--src/testlib/testlib.pro10
-rw-r--r--src/tools/bootstrap/bootstrap.pri4
-rw-r--r--src/tools/bootstrap/bootstrap.pro20
-rw-r--r--src/tools/moc/main.cpp10
-rw-r--r--src/tools/moc/moc.cpp5
-rw-r--r--src/tools/moc/parser.cpp6
-rw-r--r--src/tools/moc/parser.h4
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp94
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h1
-rw-r--r--src/tools/uic/ui4.cpp22
-rw-r--r--src/tools/uic/ui4.h16
-rw-r--r--src/tools/uic3/converter.cpp2
-rw-r--r--src/tools/uic3/domtool.cpp14
-rw-r--r--src/tools/uic3/domtool.h2
-rw-r--r--src/xml/xml.pro2
-rw-r--r--src/xmlpatterns/api/quriloader.cpp2
-rw-r--r--src/xmlpatterns/api/qvariableloader.cpp14
-rw-r--r--src/xmlpatterns/api/qxmlquery.cpp6
-rw-r--r--src/xmlpatterns/data/qatomicvalue.cpp2
-rw-r--r--src/xmlpatterns/utils/qautoptr_p.h2
-rw-r--r--src/xmlpatterns/xmlpatterns.pro2
1166 files changed, 88623 insertions, 13427 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c b/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
index 67029be..b5431a5 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-hebrew.c
@@ -84,7 +84,7 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
logClusters[0] = 0;
for (i = 1; i < shaper_item->item.length; ++i) {
- hb_uint16 base = shapedChars[slen-1];
+ hb_uint16 base = shapedChars[cluster_start];
hb_uint16 shaped = 0;
HB_Bool invalid = FALSE;
if (uc[i] == Dagesh) {
@@ -143,7 +143,7 @@ HB_Bool HB_HebrewShape(HB_ShaperItem *shaper_item)
}
if (shaped) {
if (shaper_item->font->klass->canRender(shaper_item->font, (HB_UChar16 *)&shaped, 1)) {
- shapedChars[slen-1] = shaped;
+ shapedChars[cluster_start] = shaped;
} else
shaped = 0;
}
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp
index 237c9ae..bbf479e 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp
@@ -37,7 +37,7 @@ static HB_Bool isLetter(HB_UChar16 ucs)
FLAG(HB_Letter_Titlecase) |
FLAG(HB_Letter_Modifier) |
FLAG(HB_Letter_Other);
- return FLAG(HB_GetUnicodeCharCategory(ucs)) & test;
+ return (FLAG(HB_GetUnicodeCharCategory(ucs)) & test) != 0;
}
static HB_Bool isMark(HB_UChar16 ucs)
@@ -660,18 +660,18 @@ static const unsigned char indicPosition[0xe00-0x900] = {
None, None, None, None,
None, None, None, None,
- None, None, None, None,
- None, None, None, None,
- None, None, None, None,
+ None, Below, Below, Below,
+ Below, Below, Below, Below,
+ Below, Below, None, Below,
- None, None, None, None,
- Below, None, None, None,
- Below, None, None, None,
+ Below, Below, Below, Below,
+ Below, Below, Below, Below,
+ Below, None, Below, Below,
Below, Below, Below, Post,
Below, None, Below, Below,
- None, None, None, None,
- None, None, None, None,
+ None, Below, Below, Below,
+ Below, Below, None, None,
None, None, Post, Above,
Post, Below, Below, Below,
@@ -1683,6 +1683,7 @@ static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv
}
item->glyphs[j] = item->glyphs[i];
item->attributes[j] = item->attributes[i];
+ item->advances[j] = item->advances[i];
++i;
++j;
}
@@ -1741,6 +1742,11 @@ static int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int
if (state == Halant && uc[pos] == 0x200d /* ZWJ */)
break;
// the control character should be the last char in the item
+ if (state == Consonant && script == HB_Script_Bengali && uc[pos-1] == 0x09B0 && uc[pos] == 0x200d /* ZWJ */)
+ break;
+ if (state == Consonant && script == HB_Script_Kannada && uc[pos-1] == 0x0CB0 && uc[pos] == 0x200d /* ZWJ */)
+ break;
+ // Bengali and Kannada has a special exception for rendering yaphala with ra (to avoid reph) see http://www.unicode.org/faq/indic.html#15
++pos;
goto finish;
case Consonant:
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-myanmar.c b/src/3rdparty/harfbuzz/src/harfbuzz-myanmar.c
index 7cd82bb..4b68e64 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-myanmar.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-myanmar.c
@@ -424,12 +424,8 @@ static HB_Bool myanmar_shape_syllable(HB_Bool openType, HB_ShaperItem *item, HB_
#ifndef NO_OPENTYPE
if (openType) {
- unsigned short logClusters[32];
hb_uint32 where[32];
- for (i = 0; i < len; ++i)
- logClusters[i] = i;
-
for (i = 0; i < len; ++i) {
where[i] = ~(PreSubstProperty
| BelowSubstProperty
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index ce4d4ac..c202e1f 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -538,8 +538,20 @@ void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item)
#ifndef NO_OPENTYPE
static const HB_OpenTypeFeature basic_features[] = {
{ HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
- { HB_MAKE_TAG('l', 'i', 'g', 'a'), CcmpProperty },
- { HB_MAKE_TAG('c', 'l', 'i', 'g'), CcmpProperty },
+ { HB_MAKE_TAG('l', 'i', 'g', 'a'), LigaProperty },
+ { HB_MAKE_TAG('c', 'l', 'i', 'g'), CligProperty },
+ {0, 0}
+};
+
+static const HB_OpenTypeFeature disabled_features[] = {
+ { HB_MAKE_TAG('c', 'p', 'c', 't'), PositioningProperties },
+ { HB_MAKE_TAG('h', 'a', 'l', 't'), PositioningProperties },
+ // TODO: we need to add certain HB_ShaperFlag for vertical
+ // writing mode to enable these vertical writing features:
+ { HB_MAKE_TAG('v', 'a', 'l', 't'), PositioningProperties },
+ { HB_MAKE_TAG('v', 'h', 'a', 'l'), PositioningProperties },
+ { HB_MAKE_TAG('v', 'k', 'r', 'n'), PositioningProperties },
+ { HB_MAKE_TAG('v', 'p', 'a', 'l'), PositioningProperties },
{0, 0}
};
#endif
@@ -1040,16 +1052,16 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe
{
HB_Script script = shaper_item->item.script;
- if (!shaper_item->face->supported_scripts[script])
- return false;
-
HB_Face face = shaper_item->face;
if (face->current_script == script && face->current_flags == shaper_item->shaperFlags)
- return true;
+ return shaper_item->face->supported_scripts[script] ? true : false;
face->current_script = script;
face->current_flags = shaper_item->shaperFlags;
+ if (!shaper_item->face->supported_scripts[script])
+ return false;
+
assert(script < HB_ScriptCount);
// find script in our list of supported scripts.
unsigned int tag = ot_scripts[script].tag;
@@ -1110,12 +1122,29 @@ HB_Bool HB_SelectScript(HB_ShaperItem *shaper_item, const HB_OpenTypeFeature *fe
HB_UInt *feature_tag_list = feature_tag_list_buffer;
while (*feature_tag_list) {
HB_UShort feature_index;
+ bool skip = false;
if (*feature_tag_list == HB_MAKE_TAG('k', 'e', 'r', 'n')) {
- if (face->current_flags & HB_ShaperFlag_NoKerning) {
- ++feature_tag_list;
- continue;
+ if (face->current_flags & HB_ShaperFlag_NoKerning)
+ skip = true;
+ else
+ face->has_opentype_kerning = true;
+ }
+ features = disabled_features;
+ while (features->tag) {
+ if (*feature_tag_list == features->tag) {
+ skip = true;
+ break;
}
- face->has_opentype_kerning = true;
+ ++features;
+ }
+ // 'palt' should be turned off by default unless 'kern' is on
+ if (!face->has_opentype_kerning &&
+ *feature_tag_list == HB_MAKE_TAG('p', 'a', 'l', 't'))
+ skip = true;
+
+ if (skip) {
+ ++feature_tag_list;
+ continue;
}
error = HB_GPOS_Select_Feature(face->gpos, *feature_tag_list, script_index, 0xffff, &feature_index);
if (!error)
@@ -1203,7 +1232,7 @@ HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool do
}
if (!face->glyphs_substituted && !glyphs_positioned) {
- HB_GetGlyphAdvances(item);
+ HB_HeuristicPosition(item);
return true; // nothing to do for us
}
diff --git a/src/3rdparty/harfbuzz/tests/shaping/main.cpp b/src/3rdparty/harfbuzz/tests/shaping/main.cpp
index 28f8e07..73760a8 100644
--- a/src/3rdparty/harfbuzz/tests/shaping/main.cpp
+++ b/src/3rdparty/harfbuzz/tests/shaping/main.cpp
@@ -642,6 +642,10 @@ void tst_QScriptEngine::bengali()
{ { 0x9f1, 0x9cd, 0x9ad, 0x0 },
{ 0x191, 0x17d, 0x168, 0x0 } },
+ // Ra ZWJ Halant Ya
+ { { 0x09b0, 0x200d, 0x09cd, 0x09af, 0x0 },
+ { 0x016b, 0x01cf, 0x0 } },
+
{ {0}, {0} }
};
@@ -749,6 +753,13 @@ void tst_QScriptEngine::bengali()
{ { 0x09b0, 0x09cd, 0x09ac, 0x09cd, 0x09ac, 0x0 },
{ 0x013b, 0x00e1, 0x0 } },
+ // Init feature for vowel sign E should only be
+ // applied when it's initial character (QTBUG-13620)
+ { { 0x09a8, 0x09c7, 0x0 },
+ { 0x0232, 0x0086, 0x0 } },
+ { { 0x09a8, 0x09a8, 0x09c7, 0x0 },
+ { 0x0086, 0x009b, 0x0086, 0x0 } },
+
{ {0}, {0} }
};
@@ -847,6 +858,19 @@ void tst_QScriptEngine::oriya()
{ 0x177, 0x0 } },
{ { 0xb28, 0xb4d, 0xb24, 0xb4d, 0xb30, 0xb4d, 0xb2f, 0x0 },
{ 0x176, 0x124, 0x0 } },
+
+ // QTBUG-13542
+ { { 0x0b2c, 0x0b4d, 0x0b21, 0x0 },
+ { 0x0089, 0x00fc, 0x0 } },
+ { { 0x0b36, 0x0b4d, 0x0b2b, 0x0 },
+ { 0x0092, 0x0105, 0x0 } },
+ { { 0x0b36, 0x0b4d, 0x0b1f, 0x0 },
+ { 0x0092, 0x00fa, 0x0 } },
+ { { 0x0b39, 0x0b4d, 0x0b1f, 0x0 },
+ { 0x0095, 0x00fa, 0x0 } },
+ { { 0x0b15, 0x0b4d, 0x0b16, 0x0 },
+ { 0x0073, 0x00f1, 0x0 } },
+
{ {0}, {0} }
};
@@ -1005,6 +1029,11 @@ void tst_QScriptEngine::kannada()
{ 0x0036, 0x00c1, 0x0 } },
{ { 0x0cb0, 0x0ccd, 0x200d, 0x0c95, 0x0 },
{ 0x0050, 0x00a7, 0x0 } },
+
+ // Kaphala
+ { { 0x0cb0, 0x200d, 0x0ccd, 0x0c95, 0x0 },
+ { 0x0050, 0x00a7, 0x0 } },
+
{ {0}, {0} }
};
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
index b3c229e..d8027ff 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
@@ -1168,8 +1168,17 @@ DEFINE_STUB_FUNCTION(int, timeout_check)
globalData->exception = createInterruptedExecutionException(globalData);
VM_THROW_EXCEPTION_AT_END();
}
-
- CHECK_FOR_EXCEPTION_AT_END();
+#ifdef QT_BUILD_SCRIPT_LIB
+ else {
+ // It's possible that the call to QtScript's implementation of
+ // TimeoutChecker::didTimeOut() caused an error to be thrown.
+ // In that case, didTimeOut() should still return false, since
+ // we don't want the interrupted-exception to override the
+ // user-thrown error. But we need to check for exception here,
+ // otherwise JSC would continue normal execution.
+ CHECK_FOR_EXCEPTION_AT_END();
+ }
+#endif
return timeoutChecker->ticksUntilNextCheck();
}
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
index 5abe9a1..cb4a963 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
@@ -635,6 +635,9 @@
#define ENABLE_REPAINT_THROTTLING 1
#define HAVE_READLINE 1
#define WTF_PLATFORM_CF 1
+#endif
+
+#if OS(IPHONE_OS) && !PLATFORM(QT)
#define WTF_USE_PTHREADS 1
#define HAVE_PTHREAD_RWLOCK 1
#endif
diff --git a/src/3rdparty/md5/md5.cpp b/src/3rdparty/md5/md5.cpp
index f32903c..ac296b5 100644
--- a/src/3rdparty/md5/md5.cpp
+++ b/src/3rdparty/md5/md5.cpp
@@ -24,6 +24,7 @@
#ifndef _WIN32_WCE
#include <sys/types.h> /* for stupid systems */
#else
+#include <windef.h>
#include <types.h>
#endif
diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp
index c3826eb..518aa85 100644
--- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp
+++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp
@@ -22,7 +22,9 @@
#include "videowidget.h"
#include "glrenderer.h"
#include "widgetrenderer.h"
+#ifdef Q_WS_X11
#include "x11renderer.h"
+#endif
#include "artssink.h"
#include "pulsesupport.h"
@@ -264,7 +266,7 @@ AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent)
if (m_videoSinkWidget == "software") {
return new WidgetRenderer(parent);
}
-#ifndef Q_WS_QWS
+#ifdef Q_WS_X11
else if (m_videoSinkWidget == "xwindow") {
return new X11Renderer(parent);
} else {
diff --git a/src/3rdparty/phonon/gstreamer/videowidget.cpp b/src/3rdparty/phonon/gstreamer/videowidget.cpp
index e1f0ec9..a4c6f79 100644
--- a/src/3rdparty/phonon/gstreamer/videowidget.cpp
+++ b/src/3rdparty/phonon/gstreamer/videowidget.cpp
@@ -31,7 +31,9 @@
#include "glrenderer.h"
#include "widgetrenderer.h"
+#ifdef Q_WS_X11
#include "x11renderer.h"
+#endif
#ifndef QT_NO_PHONON_VIDEO
QT_BEGIN_NAMESPACE
@@ -116,10 +118,12 @@ void VideoWidget::setupVideoBin()
GstPad *videopad = gst_element_get_pad (queue, "sink");
gst_element_add_pad (m_videoBin, gst_ghost_pad_new ("sink", videopad));
gst_object_unref (videopad);
+#ifndef Q_WS_QPA
QWidget *parentWidget = qobject_cast<QWidget*>(parent());
if (parentWidget)
parentWidget->winId(); // Due to some existing issues with alien in 4.4,
// we must currently force the creation of a parent widget.
+#endif
m_isValid = true; //initialization ok, accept input
}
}
diff --git a/src/3rdparty/phonon/gstreamer/x11renderer.h b/src/3rdparty/phonon/gstreamer/x11renderer.h
index f7140da..8e2ea19 100644
--- a/src/3rdparty/phonon/gstreamer/x11renderer.h
+++ b/src/3rdparty/phonon/gstreamer/x11renderer.h
@@ -27,8 +27,6 @@
QT_BEGIN_NAMESPACE
-#ifndef Q_WS_QWS
-
class QString;
namespace Phonon
@@ -61,8 +59,6 @@ private:
}
} //namespace Phonon::Gstreamer
-#endif // Q_WS_QWS
-
QT_END_NAMESPACE
#endif // Phonon_GSTREAMER_X11RENDERER_H
diff --git a/src/3rdparty/phonon/phonon/mediacontroller.cpp b/src/3rdparty/phonon/phonon/mediacontroller.cpp
index 37af3f7..3dc22b7 100644
--- a/src/3rdparty/phonon/phonon/mediacontroller.cpp
+++ b/src/3rdparty/phonon/phonon/mediacontroller.cpp
@@ -216,14 +216,14 @@ void MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescripti
{
IFACE;
iface->interfaceCall(AddonInterface::AudioChannelInterface,
- AddonInterface::setCurrentAudioChannel, QList<QVariant>() << qVariantFromValue(stream));
+ AddonInterface::setCurrentAudioChannel, QList<QVariant>() << QVariant::fromValue(stream));
}
void MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &stream)
{
IFACE;
iface->interfaceCall(AddonInterface::SubtitleInterface,
- AddonInterface::setCurrentSubtitle, QList<QVariant>() << qVariantFromValue(stream));
+ AddonInterface::setCurrentSubtitle, QList<QVariant>() << QVariant::fromValue(stream));
}
#undef IFACE
diff --git a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
index 8fd622f..d994600 100644
--- a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
+++ b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
@@ -141,10 +141,11 @@ namespace Phonon
/* Required to ensure template class vtables are exported on both symbian
and existing builds. */
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)
+#if (defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)) || defined(Q_CC_CLANG)
// RVCT compiler (2.2.686) requires the export declaration to be on the class to export vtables
// MWC compiler works both ways
// GCCE compiler is unknown (it can't compile QtCore yet)
+// Clang also requires the export declaration to be on the class to export vtables
#define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT
#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
#else
diff --git a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h
index f28ecaa..f25b15e 100644
--- a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h
+++ b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h
@@ -54,7 +54,7 @@ class QSettingsGroup
template<typename T>
inline T value(const QString &key, const T &def) const
{
- return qvariant_cast<T>(value(key, qVariantFromValue(def)));
+ return qvariant_cast<T>(value(key, QVariant::fromValue(def)));
}
inline QVariant value(const QString &key, const QVariant &def) const
@@ -66,7 +66,7 @@ class QSettingsGroup
inline void setValue(const QString &key, const T &value)
{
Q_ASSERT(m_mutableSettings);
- m_mutableSettings->setValue(m_group + key, qVariantFromValue(value));
+ m_mutableSettings->setValue(m_group + key, QVariant::fromValue(value));
}
inline void removeEntry(const QString &key)
diff --git a/src/3rdparty/phonon/qt7/videowidget.mm b/src/3rdparty/phonon/qt7/videowidget.mm
index 736dcdf..0600268 100644
--- a/src/3rdparty/phonon/qt7/videowidget.mm
+++ b/src/3rdparty/phonon/qt7/videowidget.mm
@@ -278,7 +278,7 @@ public:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, GLsizei(w), GLsizei(h));
- gluOrtho2D(0, GLsizei(w), 0, GLsizei(h));
+ glOrtho(0, GLsizei(w), 0, GLsizei(h), -1, 1);
updateGL();
}
@@ -446,10 +446,12 @@ public:
void setDrawFrameRect(const QRect &rect)
{
- m_movieLayer.frame.origin.x = rect.x();
- m_movieLayer.frame.origin.y = rect.y();
- m_movieLayer.frame.size.width = rect.width();
- m_movieLayer.frame.size.height = rect.height();
+ CGRect frame = m_movieLayer.frame;
+ frame.origin.x = rect.x();
+ frame.origin.y = rect.y();
+ frame.size.width = rect.width();
+ frame.size.height = rect.height();
+ m_movieLayer.frame = frame;
}
#else // QT_MAC_USE_COCOA == false
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index 37d216d..2de6961 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -56,6 +56,7 @@ TEMPLATE = lib
TARGET = QtWebKit
contains(QT_CONFIG, embedded):CONFIG += embedded
+contains(QT_CONFIG, qpa):CONFIG += embedded
CONFIG(standalone_package) {
isEmpty(WC_GENERATED_SOURCES_DIR):WC_GENERATED_SOURCES_DIR = $$PWD/generated
@@ -85,9 +86,7 @@ moduleFile=$$PWD/../WebKit/qt/qt_webkit_version.pri
isEmpty(QT_BUILD_TREE):include($$moduleFile)
VERSION = $${QT_WEBKIT_MAJOR_VERSION}.$${QT_WEBKIT_MINOR_VERSION}.$${QT_WEBKIT_PATCH_VERSION}
-unix {
- QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
-}
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
unix:!mac:*-g++*:QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
unix:!mac:*-g++*:QMAKE_LFLAGS += -Wl,--gc-sections
@@ -2180,11 +2179,11 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
mac {
SOURCES += \
- plugins/mac/PluginPackageMac.cpp \
- plugins/mac/PluginViewMac.mm
+ plugins/mac/PluginPackageMac.cpp
OBJECTIVE_SOURCES += \
platform/text/mac/StringImplMac.mm \
- platform/mac/WebCoreNSStringExtras.mm
+ platform/mac/WebCoreNSStringExtras.mm \
+ plugins/mac/PluginViewMac.mm
INCLUDEPATH += platform/mac
# Note: XP_MACOSX is defined in npapi.h
} else {
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
index 40f7e40..0df23a2 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
@@ -225,7 +225,7 @@ namespace WebCore {
{
if (!node)
return JSC::jsNull();
- if (JSNode* wrapper = getCachedDOMNodeWrapper(exec, node->document(), node))
+ if (JSC::JSCell* wrapper = getCachedDOMNodeWrapper(exec, node->document(), node))
return wrapper;
return createDOMNodeWrapper<WrapperClass>(exec, globalObject, node);
}
diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp
index 2212f58..7f5d37d 100644
--- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp
+++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp
@@ -567,7 +567,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
if (qstring.mid(lastSlash + 1).contains(QLatin1Char('i')))
realRe.setCaseSensitivity(Qt::CaseInsensitive);
- ret = qVariantFromValue(realRe);
+ ret = QVariant::fromValue(realRe);
dist = 0;
} else {
qConvDebug() << "couldn't parse a JS regexp";
@@ -578,7 +578,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
QRegExp re(qstring);
if (re.isValid()) {
- ret = qVariantFromValue(re);
+ ret = QVariant::fromValue(re);
dist = 10;
}
}
@@ -590,7 +590,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
if (qtinst) {
if (qtinst->getObject()) {
qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
- ret = qVariantFromValue(qtinst->getObject());
+ ret = QVariant::fromValue(qtinst->getObject());
qConvDebug() << ret;
dist = 0;
} else {
@@ -601,7 +601,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
}
} else if (type == Null) {
QObject* nullobj = 0;
- ret = qVariantFromValue(nullobj);
+ ret = QVariant::fromValue(nullobj);
dist = 0;
} else {
qConvDebug() << "previous type was not an object:" << type;
@@ -614,7 +614,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
if (qtinst) {
if (qtinst->getObject()) {
qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
- ret = qVariantFromValue((void *)qtinst->getObject());
+ ret = QVariant::fromValue((void *)qtinst->getObject());
qConvDebug() << ret;
dist = 0;
} else {
@@ -624,7 +624,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
qConvDebug() << "wasn't a qtinstance";
}
} else if (type == Null) {
- ret = qVariantFromValue((void*)0);
+ ret = QVariant::fromValue((void*)0);
dist = 0;
} else if (type == Number) {
// I don't think that converting a double to a pointer is a wise
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
index 88c7a1c..9de5c08 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
@@ -101,7 +101,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
// Make sure we get updates for each frame
m_videoWidget->installEventFilter(this);
- foreach (QWidget* widget, qFindChildren<QWidget*>(m_videoWidget))
+ foreach (QWidget* widget, m_videoWidget->findChildren<QWidget*>())
widget->installEventFilter(this);
connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
index 7708191..965c0ef 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
@@ -185,7 +185,7 @@ void MediaPlayerPrivate::load(const String& url)
// Don't set the header if there are no cookies.
// This prevents a warning from being emitted.
if (!cookies.isEmpty())
- request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
+ request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
// Set the refferer, but not when requesting insecure content from a secure page
QUrl documentUrl = QUrl(QString(document->documentURI()));
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index e584f97..dcae35f 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -306,7 +306,7 @@ public:
}
Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList &lst) {
m_qtFunctionInvoked = 14;
- m_actuals << qVariantFromValue(lst);
+ m_actuals << QVariant::fromValue(lst);
return lst;
}
Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant &v) {
@@ -321,38 +321,38 @@ public:
}
Q_INVOKABLE QList<int> myInvokableWithListOfIntArg(const QList<int> &lst) {
m_qtFunctionInvoked = 17;
- m_actuals << qVariantFromValue(lst);
+ m_actuals << QVariant::fromValue(lst);
return lst;
}
Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject* obj) {
m_qtFunctionInvoked = 18;
- m_actuals << qVariantFromValue(obj);
+ m_actuals << QVariant::fromValue(obj);
return obj;
}
Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush &brush) {
m_qtFunctionInvoked = 19;
- m_actuals << qVariantFromValue(brush);
+ m_actuals << QVariant::fromValue(brush);
return brush;
}
Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style) {
m_qtFunctionInvoked = 43;
- m_actuals << qVariantFromValue(style);
+ m_actuals << QVariant::fromValue(style);
}
Q_INVOKABLE void myInvokableWithVoidStarArg(void* arg) {
m_qtFunctionInvoked = 44;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg) {
m_qtFunctionInvoked = 45;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg) {
m_qtFunctionInvoked = 46;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString &arg2 = "") {
m_qtFunctionInvoked = 47;
- m_actuals << qVariantFromValue(arg1) << qVariantFromValue(arg2);
+ m_actuals << QVariant::fromValue(arg1) << qVariantFromValue(arg2);
}
Q_INVOKABLE QObject& myInvokableReturningRef() {
m_qtFunctionInvoked = 48;
@@ -364,11 +364,11 @@ public:
}
Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg) {
const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 50;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg) {
const_cast<MyQObject*>(this)->m_qtFunctionInvoked = 51;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
Q_INVOKABLE void myInvokableWithBoolArg(bool arg) {
m_qtFunctionInvoked = 52;
@@ -416,7 +416,7 @@ public Q_SLOTS:
}
void myOverloadedSlot(QObject* arg) {
m_qtFunctionInvoked = 41;
- m_actuals << qVariantFromValue(arg);
+ m_actuals << QVariant::fromValue(arg);
}
void myOverloadedSlot(bool arg) {
m_qtFunctionInvoked = 25;
@@ -818,7 +818,7 @@ void tst_QWebFrame::getSetStaticProperty()
QCOMPARE(evalJS("myObject.variantProperty === 'bar'"), sTrue);
m_myObject->setVariantProperty(42);
QCOMPARE(evalJS("myObject.variantProperty === 42"), sTrue);
- m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+ m_myObject->setVariantProperty(QVariant::fromValue(QBrush()));
//XFAIL
// QCOMPARE(evalJS("typeof myObject.variantProperty"), sVariant);
@@ -1240,7 +1240,7 @@ void tst_QWebFrame::callQtInvokable()
/* XFAIL - variant support
m_myObject->resetQtFunctionInvoked();
{
- m_myObject->setVariantProperty(qVariantFromValue(QBrush()));
+ m_myObject->setVariantProperty(QVariant::fromValue(QBrush()));
QVariant ret = evalJS("myObject.myInvokableWithVariantArg(myObject.variantProperty)");
QVERIFY(ret.isVariant());
QCOMPARE(m_myObject->qtFunctionInvoked(), 15);
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/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp
index a798cd3..aa51925 100644
--- a/src/activeqt/container/qaxbase.cpp
+++ b/src/activeqt/container/qaxbase.cpp
@@ -3539,7 +3539,7 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v)
proptype = 0;
} else if (t == QVariant::UserType) {
qvar = QVariant(qRegisterMetaType<void*>(prop.typeName()), (void**)v[0]);
-// qVariantSetValue(qvar, *(void**)v[0], prop.typeName());
+// qvar.setValue(*(void**)v[0], prop.typeName());
} else {
proptype = d->metaObject()->propertyType(propname);
qvar = QVariant(t, v[0]);
@@ -3627,9 +3627,9 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v)
if (!qvar.isValid()) {
if (type == "IDispatch*")
- qVariantSetValue(qvar, *(IDispatch**)v[p+1]);
+ qvar.setValue(*(IDispatch**)v[p+1]);
else if (type == "IUnknown*")
- qVariantSetValue(qvar, *(IUnknown**)v[p+1]);
+ qvar.setValue(*(IUnknown**)v[p+1]);
else if (type == "QVariant")
qvar = *(QVariant*)v[p + 1];
else if (mo->indexOfEnumerator(type) != -1)
@@ -4394,15 +4394,15 @@ QVariant QAxBase::asVariant() const
QByteArray cn(className());
if (cn == "QAxObject" || cn == "QAxWidget" || cn == "QAxBase") {
if (d->dispatch())
- qVariantSetValue(qvar, d->dispatch());
+ qvar.setValue(d->dispatch());
else if (d->ptr)
- qVariantSetValue(qvar, d->ptr);
+ qvar.setValue(d->ptr);
} else {
cn = cn.mid(cn.lastIndexOf(':') + 1);
QObject *object = qObject();
if (QMetaType::type(cn))
qvar = QVariant(qRegisterMetaType<QObject*>(cn + '*'), &object);
-// qVariantSetValue(qvar, qObject(), cn + '*');
+// qvar.setValue(qObject(), cn + '*');
}
return qvar;
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 8583d52..f69ef95 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -1163,7 +1163,7 @@ HRESULT WINAPI QAxClientSite::InsertMenus(HMENU /*hmenuShared*/, LPOLEMENUGROUPW
AX_DEBUG(QAxClientSite::InsertMenus);
QMenuBar *mb = menuBar;
if (!mb)
- mb = qFindChild<QMenuBar*>(widget->window());
+ mb = widget->window()->findChild<QMenuBar*>();
if (!mb)
return E_NOTIMPL;
menuBar = mb;
@@ -1309,7 +1309,7 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND
m_menuOwner = hwndActiveObject;
QMenuBar *mb = menuBar;
if (!mb)
- mb = qFindChild<QMenuBar*>(widget->window());
+ mb = widget->window()->findChild<QMenuBar*>();
if (!mb)
return E_NOTIMPL;
menuBar = mb;
diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp
index 88b6ce5..1726f92 100644
--- a/src/activeqt/control/qaxserver.cpp
+++ b/src/activeqt/control/qaxserver.cpp
@@ -285,7 +285,7 @@ HRESULT UpdateRegistry(BOOL bRegister)
|OLEMISC_RECOMPOSEONRESIZE;
if (!control)
olemisc |= OLEMISC_INVISIBLEATRUNTIME;
- else if (qFindChild<QMenuBar*>(object) && !qax_disable_inplaceframe)
+ else if (object->findChild<QMenuBar*>() && !qax_disable_inplaceframe)
olemisc |= OLEMISC_WANTSTOMENUMERGE;
settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/."), className + QLatin1String(" Class"));
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index b7a1a18..a2f9579 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -1313,7 +1313,7 @@ bool QAxServerBase::internalCreate()
// install an event filter for stock events
if (isWidget) {
qt.object->installEventFilter(this);
- const QList<QWidget*> children = qFindChildren<QWidget*>(qt.object);
+ const QList<QWidget*> children = qt.object->findChildren<QWidget*>();
QList<QWidget*>::ConstIterator it = children.constBegin();
while (it != children.constEnd()) {
(*it)->installEventFilter(this);
@@ -2047,10 +2047,10 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
if (vt == QVariant::UserType) {
if (ptype.endsWith('*')) {
variant = QVariant(QMetaType::type(ptype), (void**)argv[p+1]);
- // qVariantSetValue(variant, *(void**)(argv[p + 1]), ptype);
+ // variant.setValue(*(void**)(argv[p + 1]), ptype);
} else {
variant = QVariant(QMetaType::type(ptype), argv[p+1]);
- // qVariantSetValue(variant, argv[p + 1], ptype);
+ // variant.setValue(argv[p + 1], ptype);
}
} else {
variant = QVariant(vt, argv[p + 1]);
@@ -2537,7 +2537,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
if (!type.isEmpty() && pvarResult) {
if (!varp[0].isValid() && type != "QVariant")
varp[0] = QVariant(QMetaType::type(type), argv_pointer);
-// qVariantSetValue(varp[0], argv_pointer[0], type);
+// varp[0].setValue(argv_pointer[0], type);
ok = QVariantToVARIANT(varp[0], *pvarResult, type);
}
}
@@ -3325,7 +3325,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID)
break;
{
QVariant qvar = VARIANTToQVariant(var, "QFont", QVariant::Font);
- QFont qfont = qVariantValue<QFont>(qvar);
+ QFont qfont = qvariant_cast<QFont>(qvar);
qt.widget->setFont(qfont);
}
break;
@@ -3818,7 +3818,7 @@ HRESULT QAxServerBase::internalActivate()
// Gone active by now, take care of UIACTIVATE
canTakeFocus = qt.widget->focusPolicy() != Qt::NoFocus && !inDesignMode;
if (!canTakeFocus && !inDesignMode) {
- QList<QWidget*> widgets = qFindChildren<QWidget*>(qt.widget);
+ QList<QWidget*> widgets = qt.widget->findChildren<QWidget*>();
for (int w = 0; w < widgets.count(); ++w) {
QWidget *widget = widgets[w];
canTakeFocus = widget->focusPolicy() != Qt::NoFocus;
@@ -3844,13 +3844,13 @@ HRESULT QAxServerBase::internalActivate()
if (m_spInPlaceFrame) {
hr = m_spInPlaceFrame->SetActiveObject(this, QStringToBSTR(class_name));
if (!FAILED(hr)) {
- menuBar = (qt.widget && !qax_disable_inplaceframe) ? qFindChild<QMenuBar*>(qt.widget) : 0;
+ menuBar = (qt.widget && !qax_disable_inplaceframe) ? qt.widget->findChild<QMenuBar*>() : 0;
if (menuBar && !menuBar->isVisible()) {
createMenu(menuBar);
menuBar->hide();
menuBar->installEventFilter(this);
}
- statusBar = qt.widget ? qFindChild<QStatusBar*>(qt.widget) : 0;
+ statusBar = qt.widget ? qt.widget->findChild<QStatusBar*>() : 0;
if (statusBar && !statusBar->isVisible()) {
const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)");
QMetaObject::connect(statusBar, index, this, -1);
diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp
index f0a8ad8..c48b55b 100644
--- a/src/activeqt/shared/qaxtypes.cpp
+++ b/src/activeqt/shared/qaxtypes.cpp
@@ -954,20 +954,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint
break;
case VT_I4:
if (type == QVariant::Color || (!type && typeName == "QColor"))
- var = qVariantFromValue(OLEColorToQColor(arg.lVal));
+ var = QVariant::fromValue(OLEColorToQColor(arg.lVal));
#ifndef QT_NO_CURSOR
else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*")))
- var = qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(arg.lVal)));
+ var = QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(arg.lVal)));
#endif
else
var = (int)arg.lVal;
break;
case VT_I4|VT_BYREF:
if (type == QVariant::Color || (!type && typeName == "QColor"))
- var = qVariantFromValue(OLEColorToQColor((int)*arg.plVal));
+ var = QVariant::fromValue(OLEColorToQColor((int)*arg.plVal));
#ifndef QT_NO_CURSOR
else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*")))
- var = qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(*arg.plVal)));
+ var = QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(*arg.plVal)));
#endif
else
var = (int)*arg.plVal;
@@ -992,20 +992,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint
break;
case VT_UI4:
if (type == QVariant::Color || (!type && typeName == "QColor"))
- var = qVariantFromValue(OLEColorToQColor(arg.ulVal));
+ var = QVariant::fromValue(OLEColorToQColor(arg.ulVal));
#ifndef QT_NO_CURSOR
else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*")))
- var = qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(arg.ulVal)));
+ var = QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(arg.ulVal)));
#endif
else
var = (int)arg.ulVal;
break;
case VT_UI4|VT_BYREF:
if (type == QVariant::Color || (!type && typeName == "QColor"))
- var = qVariantFromValue(OLEColorToQColor((uint)*arg.pulVal));
+ var = QVariant::fromValue(OLEColorToQColor((uint)*arg.pulVal));
#ifndef QT_NO_CURSOR
else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*")))
- var = qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(*arg.pulVal)));
+ var = QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(*arg.pulVal)));
#endif
else
var = (int)*arg.pulVal;
@@ -1084,20 +1084,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint
if (disp)
disp->QueryInterface(IID_IFont, (void**)&ifont);
if (ifont) {
- var = qVariantFromValue(IFontToQFont(ifont));
+ var = QVariant::fromValue(IFontToQFont(ifont));
ifont->Release();
} else {
- var = qVariantFromValue(QFont());
+ var = QVariant::fromValue(QFont());
}
} else if (type == QVariant::Pixmap || (!type && (typeName == "QPixmap" || typeName == "QPixmap*"))) {
IPicture *ipic = 0;
if (disp)
disp->QueryInterface(IID_IPicture, (void**)&ipic);
if (ipic) {
- var = qVariantFromValue(IPictureToQPixmap(ipic));
+ var = QVariant::fromValue(IPictureToQPixmap(ipic));
ipic->Release();
} else {
- var = qVariantFromValue(QPixmap());
+ var = QVariant::fromValue(QPixmap());
}
} else {
#ifdef QAX_SERVER
@@ -1118,7 +1118,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint
#ifndef QAX_SERVER
if (typeName == "QVariant") {
QAxObject *object = new QAxObject(disp);
- var = qVariantFromValue<QAxObject*>(object);
+ var = QVariant::fromValue<QAxObject*>(object);
} else if (typeName != "IDispatch*" && QMetaType::type(typeName)) {
QByteArray typeNameStr = QByteArray(typeName);
int pIndex = typeName.lastIndexOf('*');
@@ -1145,7 +1145,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint
unkn = *arg.ppunkVal;
else
unkn = arg.punkVal;
- qVariantSetValue(var, unkn);
+ var.setValue(unkn);
}
break;
case VT_ARRAY|VT_VARIANT:
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index a9bb129..f20bbf4 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -166,11 +166,12 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
#endif
QUnifiedTimer::QUnifiedTimer() :
- QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
- insideTick(false), currentAnimationIdx(0), consistentTiming(false), slowMode(false),
+ QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
+ currentAnimationIdx(0), consistentTiming(false), slowMode(false),
slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
{
time.invalidate();
+ driver = &defaultDriver;
}
@@ -253,14 +254,27 @@ void QUnifiedTimer::restartAnimationTimer()
qDebug() << runningPauseAnimations;
qDebug() << closestPauseAnimationTimeToFinish();
}
+ driver->stop();
animationTimer.start(closestTimeToFinish, this);
isPauseTimerActive = true;
- } else if (!animationTimer.isActive() || isPauseTimerActive) {
- animationTimer.start(timingInterval, this);
+ } else if (!driver->isRunning() || isPauseTimerActive) {
+ driver->start();
isPauseTimerActive = false;
}
}
+void QUnifiedTimer::setTimingInterval(int interval)
+{
+ timingInterval = interval;
+
+ if (driver->isRunning() && !isPauseTimerActive) {
+ //we changed the timing interval
+ driver->stop();
+ driver->start();
+ }
+}
+
+
void QUnifiedTimer::timerEvent(QTimerEvent *event)
{
//in the case of consistent timing we make sure the orders in which events come is always the same
@@ -375,6 +389,140 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish()
return closestTimeToFinish;
}
+void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
+{
+ if (driver->isRunning()) {
+ qWarning("QUnifiedTimer: Cannot change animation driver while animations are running");
+ return;
+ }
+
+ if (driver && driver != &defaultDriver)
+ delete driver;
+
+ driver = d;
+}
+
+/*!
+ \class QAnimationDriver
+
+ \brief The QAnimationDriver class is used to exchange the mechanism that drives animations.
+
+ 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)
+ : QObject(*(new QAnimationDriverPrivate), parent)
+{
+}
+
+QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
+ : QObject(dd, 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()
+{
+ QUnifiedTimer *instance = QUnifiedTimer::instance();
+
+ // update current time on all top level animations
+ instance->updateAnimationsTime();
+ instance->restartAnimationTimer();
+}
+
+
+/*!
+ Installs this animation driver. The animation driver is thread local and
+ will only apply for the thread its installed in.
+
+ \internal
+ */
+void QAnimationDriver::install()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance(true);
+ timer->installAnimationDriver(this);
+}
+
+bool QAnimationDriver::isRunning() const
+{
+ return d_func()->running;
+}
+
+
+void QAnimationDriver::start()
+{
+ Q_D(QAnimationDriver);
+ if (!d->running) {
+ started();
+ d->running = true;
+ }
+}
+
+
+void QAnimationDriver::stop()
+{
+ Q_D(QAnimationDriver);
+ if (d->running) {
+ stopped();
+ d->running = false;
+ }
+}
+
+/*!
+ \fn QAnimationDriver::started()
+
+ This function is called by the animation framework to notify the driver
+ that it should start running.
+
+ \internal
+ */
+
+/*!
+ \fn QAnimationDriver::stopped()
+
+ This function is called by the animation framework to notify the driver
+ that it should stop running.
+
+ \internal
+ */
+
+/*!
+ The default animation driver just spins the timer...
+ */
+QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer)
+ : QAnimationDriver(0), m_unified_timer(timer)
+{
+}
+
+void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
+{
+ Q_ASSERT(e->timerId() == m_timer.timerId());
+ Q_UNUSED(e); // if the assertions are disabled
+ advance();
+}
+
+void QDefaultAnimationDriver::started()
+{
+ m_timer.start(m_unified_timer->timingInterval, this);
+}
+
+void QDefaultAnimationDriver::stopped()
+{
+ m_timer.stop();
+}
+
+
+
void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
{
Q_Q(QAbstractAnimation);
@@ -800,6 +948,9 @@ void QAbstractAnimation::stop()
{
Q_D(QAbstractAnimation);
+ if (d->state == Stopped)
+ return;
+
d->setState(Stopped);
}
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index 447b89d..0900870 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -54,6 +54,7 @@ QT_MODULE(Core)
class QAnimationGroup;
class QSequentialAnimationGroup;
+class QAnimationDriver;
class QAbstractAnimationPrivate;
class Q_CORE_EXPORT QAbstractAnimation : public QObject
@@ -132,6 +133,36 @@ private:
Q_DECLARE_PRIVATE(QAbstractAnimation)
};
+class QAnimationDriverPrivate;
+class Q_CORE_EXPORT QAnimationDriver : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QAnimationDriver)
+
+public:
+ QAnimationDriver(QObject *parent = 0);
+
+ void advance();
+ void install();
+
+ bool isRunning() const;
+
+protected:
+ virtual void started() {};
+ virtual void stopped() {};
+
+ QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
+
+private:
+ friend class QUnifiedTimer;
+
+ void start();
+ void stop();
+};
+
+
+
+
#endif //QT_NO_ANIMATION
QT_END_NAMESPACE
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index aeee1f2..ba92960 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -58,6 +58,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qelapsedtimer.h>
#include <private/qobject_p.h>
+#include <qabstractanimation.h>
#ifdef Q_OS_WIN
#include <qt_windows.h>
@@ -114,30 +115,47 @@ private:
Q_DECLARE_PUBLIC(QAbstractAnimation)
};
+
+class QUnifiedTimer;
+class QDefaultAnimationDriver : public QAnimationDriver
+{
+ Q_OBJECT
+public:
+ QDefaultAnimationDriver(QUnifiedTimer *timer);
+ void timerEvent(QTimerEvent *e);
+
+ void started();
+ void stopped();
+
+private:
+ QBasicTimer m_timer;
+ QUnifiedTimer *m_unified_timer;
+};
+
+class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate
+{
+public:
+ QAnimationDriverPrivate() : running(false) {}
+ bool running;
+};
+
typedef QElapsedTimer ElapsedTimer;
-class QUnifiedTimer : public QObject
+class Q_CORE_EXPORT QUnifiedTimer : public QObject
{
private:
QUnifiedTimer();
public:
//XXX this is needed by dui
- static Q_CORE_EXPORT QUnifiedTimer *instance();
+ static QUnifiedTimer *instance();
static QUnifiedTimer *instance(bool create);
static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
static void unregisterAnimation(QAbstractAnimation *animation);
//defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
- void setTimingInterval(int interval)
- {
- timingInterval = interval;
- if (animationTimer.isActive() && !isPauseTimerActive) {
- //we changed the timing interval
- animationTimer.start(timingInterval, this);
- }
- }
+ void setTimingInterval(int interval);
/*
this allows to have a consistent timer interval at each tick from the timer
@@ -161,11 +179,20 @@ public:
*/
static void updateAnimationTimer();
+ void installAnimationDriver(QAnimationDriver *driver);
+
+ void restartAnimationTimer();
+ void updateAnimationsTime();
+
protected:
void timerEvent(QTimerEvent *);
private:
- // timer used for all active (running) animations
+ friend class QDefaultAnimationDriver;
+
+ QAnimationDriver *driver;
+ QDefaultAnimationDriver defaultDriver;
+
QBasicTimer animationTimer;
// timer used to delay the check if we should start/stop the animation timer
QBasicTimer startStopAnimationTimer;
@@ -196,9 +223,6 @@ private:
void registerRunningAnimation(QAbstractAnimation *animation);
void unregisterRunningAnimation(QAbstractAnimation *animation);
- void restartAnimationTimer();
-
- void updateAnimationsTime();
int closestPauseAnimationTimeToFinish();
};
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index 57bc80a..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 \
@@ -21,7 +23,9 @@ vxworks:HEADERS += arch/qatomic_vxworks.h
arch/qatomic_generic.h \
arch/qatomic_powerpc.h \
arch/qatomic_arm.h \
+ arch/qatomic_armv5.h \
arch/qatomic_armv6.h \
+ arch/qatomic_armv7.h \
arch/qatomic_i386.h \
arch/qatomic_mips.h \
arch/qatomic_s390.h \
diff --git a/src/corelib/arch/armv6/arch.pri b/src/corelib/arch/armv6/arch.pri
deleted file mode 100644
index fd0cce1..0000000
--- a/src/corelib/arch/armv6/arch.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-#
-# ARMv6
-#
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 baf899f..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"
@@ -88,6 +90,8 @@ QT_BEGIN_HEADER
# include "QtCore/qatomic_sh.h"
#elif defined(QT_ARCH_SH4A)
# include "QtCore/qatomic_sh4a.h"
+#elif defined(QT_ARCH_NACL)
+# include "QtCore/qatomic_generic.h"
#else
# error "Qt has not been ported to this architecture"
#endif
diff --git a/src/corelib/arch/qatomic_arm.h b/src/corelib/arch/qatomic_arm.h
index 7b15e0a..07d2143 100644
--- a/src/corelib/arch/qatomic_arm.h
+++ b/src/corelib/arch/qatomic_arm.h
@@ -44,387 +44,32 @@
QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-#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 false; }
-inline bool QBasicAtomicInt::isTestAndSetWaitFree()
-{ return false; }
-
-#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
-
-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 false; }
-inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
-{ return false; }
-
-#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
-
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
-{ return false; }
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
-{ return false; }
-
-#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
-#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
-
-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 false; }
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
-{ return false; }
-
-#ifndef QT_NO_ARM_EABI
-
-// 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, 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))
-
-#else
-
-extern Q_CORE_EXPORT char q_atomic_lock;
-Q_CORE_EXPORT void qt_atomic_yield(int *);
-
-#ifdef Q_CC_RVCT
-
-Q_CORE_EXPORT __asm char q_atomic_swp(volatile char *ptr, char newval);
-
-#else
-
-inline char q_atomic_swp(volatile char *ptr, char newval)
-{
- register char ret;
- asm volatile("swpb %0,%2,[%3]"
- : "=&r"(ret), "=m" (*ptr)
- : "r"(newval), "r"(ptr)
- : "cc", "memory");
- return ret;
-}
-
-#endif // Q_CC_RVCT
-
-#endif // QT_NO_ARM_EABI
-
-// Reference counting
-
-inline bool QBasicAtomicInt::ref()
-{
-#ifndef QT_NO_ARM_EABI
- register int originalValue;
- register int newValue;
- do {
- originalValue = _q_value;
- newValue = originalValue + 1;
- } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
- return newValue != 0;
-#else
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- int originalValue = _q_value++;
- q_atomic_swp(&q_atomic_lock, 0);
- return originalValue != -1;
-#endif
-}
-
-inline bool QBasicAtomicInt::deref()
-{
-#ifndef QT_NO_ARM_EABI
- register int originalValue;
- register int newValue;
- do {
- originalValue = _q_value;
- newValue = originalValue - 1;
- } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
- return newValue != 0;
-#else
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- int originalValue = _q_value--;
- q_atomic_swp(&q_atomic_lock, 0);
- return originalValue != 1;
-#endif
-}
-
-// Test and set for integers
-
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
-{
-#ifndef QT_NO_ARM_EABI
- register int originalValue;
- do {
- originalValue = _q_value;
- if (originalValue != expectedValue)
- return false;
- } while (qt_atomic_eabi_cmpxchg_int(expectedValue, newValue, &_q_value) != 0);
- return true;
-#else
- bool returnValue = false;
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- if (_q_value == expectedValue) {
- _q_value = newValue;
- returnValue = true;
- }
- q_atomic_swp(&q_atomic_lock, 0);
- return returnValue;
-#endif
-}
-
-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
-
-#ifndef Q_CC_RVCT
-
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
-{
- int originalValue;
- asm volatile("swp %0,%2,[%3]"
- : "=&r"(originalValue), "=m" (_q_value)
- : "r"(newValue), "r"(&_q_value)
- : "cc", "memory");
- return originalValue;
-}
-
-#endif
-
-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)
-{
-#ifndef QT_NO_ARM_EABI
- register int originalValue;
- register int newValue;
- do {
- originalValue = _q_value;
- newValue = originalValue + valueToAdd;
- } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
- return originalValue;
-#else
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- int originalValue = _q_value;
- _q_value += valueToAdd;
- q_atomic_swp(&q_atomic_lock, 0);
- return originalValue;
-#endif
-}
-
-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)
-{
-#ifndef QT_NO_ARM_EABI
- register T *originalValue;
- do {
- originalValue = _q_value;
- if (originalValue != expectedValue)
- return false;
- } while (qt_atomic_eabi_cmpxchg_ptr(expectedValue, newValue, &_q_value) != 0);
- return true;
+#if defined(__ARM_ARCH_7__) \
+ || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) \
+ || defined(__ARM_ARCH_7M__)
+# define QT_ARCH_ARMV7
+QT_BEGIN_INCLUDE_HEADER
+# include "QtCore/qatomic_armv7.h"
+QT_END_INCLUDE_HEADER
+#elif defined(__ARM_ARCH_6__) \
+ || defined(__ARM_ARCH_6J__) \
+ || defined(__ARM_ARCH_6T2__) \
+ || defined(__ARM_ARCH_6Z__) \
+ || defined(__ARM_ARCH_6K__) \
+ || defined(__ARM_ARCH_6ZK__) \
+ || defined(__ARM_ARCH_6M__) \
+ || (defined(__TARGET_ARCH_ARM) && (__TARGET_ARCH_ARM-0 >= 6))
+# define QT_ARCH_ARMV6
+QT_BEGIN_INCLUDE_HEADER
+# include "QtCore/qatomic_armv6.h"
+QT_END_INCLUDE_HEADER
#else
- bool returnValue = false;
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- if (_q_value == expectedValue) {
- _q_value = newValue;
- returnValue = true;
- }
- q_atomic_swp(&q_atomic_lock, 0);
- return returnValue;
+# define QT_ARCH_ARMV5
+QT_BEGIN_INCLUDE_HEADER
+# include "QtCore/qatomic_armv5.h"
+QT_END_INCLUDE_HEADER
#endif
-}
-
-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
-
-#ifdef Q_CC_RVCT
-
-template <typename T>
-__asm T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
-{
- add r2, pc, #0
- bx r2
- arm
- swp r2,r1,[r0]
- mov r0, r2
- bx lr
- thumb
-}
-
-#else
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
-{
- T *originalValue;
- asm volatile("swp %0,%2,[%3]"
- : "=&r"(originalValue), "=m" (_q_value)
- : "r"(newValue), "r"(&_q_value)
- : "cc", "memory");
- return originalValue;
-}
-
-#endif // Q_CC_RVCT
-
-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)
-{
-#ifndef QT_NO_ARM_EABI
- register T *originalValue;
- register T *newValue;
- do {
- originalValue = _q_value;
- newValue = originalValue + valueToAdd;
- } while (qt_atomic_eabi_cmpxchg_ptr(originalValue, newValue, &_q_value) != 0);
- return originalValue;
-#else
- int count = 0;
- while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
- qt_atomic_yield(&count);
- T *originalValue = (_q_value);
- _q_value += valueToAdd;
- q_atomic_swp(&q_atomic_lock, 0);
- return originalValue;
-#endif
-}
-
-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
diff --git a/src/corelib/arch/qatomic_armv5.h b/src/corelib/arch/qatomic_armv5.h
new file mode 100644
index 0000000..ac8fe96
--- /dev/null
+++ b/src/corelib/arch/qatomic_armv5.h
@@ -0,0 +1,431 @@
+/****************************************************************************
+**
+** 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 QATOMIC_ARMV5_H
+#define QATOMIC_ARMV5_H
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+#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 false; }
+inline bool QBasicAtomicInt::isTestAndSetWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
+
+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 false; }
+inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
+{ return false; }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
+#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
+
+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 false; }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
+{ return false; }
+
+#ifndef QT_NO_ARM_EABI
+
+// 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, 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))
+
+#else
+
+extern Q_CORE_EXPORT char q_atomic_lock;
+Q_CORE_EXPORT void qt_atomic_yield(int *);
+
+#ifdef Q_CC_RVCT
+
+Q_CORE_EXPORT __asm char q_atomic_swp(volatile char *ptr, char newval);
+
+#else
+
+inline char q_atomic_swp(volatile char *ptr, char newval)
+{
+ register char ret;
+ asm volatile("swpb %0,%2,[%3]"
+ : "=&r"(ret), "=m" (*ptr)
+ : "r"(newval), "r"(ptr)
+ : "cc", "memory");
+ return ret;
+}
+
+#endif // Q_CC_RVCT
+
+#endif // QT_NO_ARM_EABI
+
+// Reference counting
+
+inline bool QBasicAtomicInt::ref()
+{
+#ifndef QT_NO_ARM_EABI
+ register int originalValue;
+ register int newValue;
+ do {
+ originalValue = _q_value;
+ newValue = originalValue + 1;
+ } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
+ return newValue != 0;
+#else
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ int originalValue = _q_value++;
+ q_atomic_swp(&q_atomic_lock, 0);
+ return originalValue != -1;
+#endif
+}
+
+inline bool QBasicAtomicInt::deref()
+{
+#ifndef QT_NO_ARM_EABI
+ register int originalValue;
+ register int newValue;
+ do {
+ originalValue = _q_value;
+ newValue = originalValue - 1;
+ } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
+ return newValue != 0;
+#else
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ int originalValue = _q_value--;
+ q_atomic_swp(&q_atomic_lock, 0);
+ return originalValue != 1;
+#endif
+}
+
+// Test and set for integers
+
+inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+{
+#ifndef QT_NO_ARM_EABI
+ register int originalValue;
+ do {
+ originalValue = _q_value;
+ if (originalValue != expectedValue)
+ return false;
+ } while (qt_atomic_eabi_cmpxchg_int(expectedValue, newValue, &_q_value) != 0);
+ return true;
+#else
+ bool returnValue = false;
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ if (_q_value == expectedValue) {
+ _q_value = newValue;
+ returnValue = true;
+ }
+ q_atomic_swp(&q_atomic_lock, 0);
+ return returnValue;
+#endif
+}
+
+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
+
+#ifndef Q_CC_RVCT
+
+inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+{
+ int originalValue;
+ asm volatile("swp %0,%2,[%3]"
+ : "=&r"(originalValue), "=m" (_q_value)
+ : "r"(newValue), "r"(&_q_value)
+ : "cc", "memory");
+ return originalValue;
+}
+
+#endif
+
+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)
+{
+#ifndef QT_NO_ARM_EABI
+ register int originalValue;
+ register int newValue;
+ do {
+ originalValue = _q_value;
+ newValue = originalValue + valueToAdd;
+ } while (qt_atomic_eabi_cmpxchg_int(originalValue, newValue, &_q_value) != 0);
+ return originalValue;
+#else
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ int originalValue = _q_value;
+ _q_value += valueToAdd;
+ q_atomic_swp(&q_atomic_lock, 0);
+ return originalValue;
+#endif
+}
+
+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)
+{
+#ifndef QT_NO_ARM_EABI
+ register T *originalValue;
+ do {
+ originalValue = _q_value;
+ if (originalValue != expectedValue)
+ return false;
+ } while (qt_atomic_eabi_cmpxchg_ptr(expectedValue, newValue, &_q_value) != 0);
+ return true;
+#else
+ bool returnValue = false;
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ if (_q_value == expectedValue) {
+ _q_value = newValue;
+ returnValue = true;
+ }
+ q_atomic_swp(&q_atomic_lock, 0);
+ return returnValue;
+#endif
+}
+
+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
+
+#ifdef Q_CC_RVCT
+
+template <typename T>
+__asm T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+{
+ add r2, pc, #0
+ bx r2
+ arm
+ swp r2,r1,[r0]
+ mov r0, r2
+ bx lr
+ thumb
+}
+
+#else
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+{
+ T *originalValue;
+ asm volatile("swp %0,%2,[%3]"
+ : "=&r"(originalValue), "=m" (_q_value)
+ : "r"(newValue), "r"(&_q_value)
+ : "cc", "memory");
+ return originalValue;
+}
+
+#endif // Q_CC_RVCT
+
+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)
+{
+#ifndef QT_NO_ARM_EABI
+ register T *originalValue;
+ register T *newValue;
+ do {
+ originalValue = _q_value;
+ newValue = originalValue + valueToAdd;
+ } while (qt_atomic_eabi_cmpxchg_ptr(originalValue, newValue, &_q_value) != 0);
+ return originalValue;
+#else
+ int count = 0;
+ while (q_atomic_swp(&q_atomic_lock, ~0) != 0)
+ qt_atomic_yield(&count);
+ T *originalValue = (_q_value);
+ _q_value += valueToAdd;
+ q_atomic_swp(&q_atomic_lock, 0);
+ return originalValue;
+#endif
+}
+
+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_ARMV5_H
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index 4fb9963..3bd6058 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -45,6 +45,7 @@
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
inline bool QBasicAtomicInt::isReferenceCountingNative()
@@ -102,6 +103,13 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
#ifndef Q_CC_RVCT
+#ifndef Q_DATA_MEMORY_BARRIER
+# define Q_DATA_MEMORY_BARRIER asm volatile("":::"memory")
+#endif
+#ifndef Q_COMPILER_MEMORY_BARRIER
+# define Q_COMPILER_MEMORY_BARRIER asm volatile("":::"memory")
+#endif
+
inline bool QBasicAtomicInt::ref()
{
register int newValue;
@@ -138,7 +146,7 @@ inline bool QBasicAtomicInt::deref()
return newValue != 0;
}
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
register int result;
asm volatile("0:\n"
@@ -152,11 +160,11 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
: [expectedValue] "r" (expectedValue),
[newValue] "r" (newValue),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return result == 0;
}
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
register int originalValue;
register int result;
@@ -170,11 +178,11 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
"+m" (_q_value)
: [newValue] "r" (newValue),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return originalValue;
}
-inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
+inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
register int originalValue;
register int newValue;
@@ -191,12 +199,12 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
"+m" (_q_value)
: [valueToAdd] "r" (valueToAdd),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return originalValue;
}
template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
register T *result;
asm volatile("0:\n"
@@ -210,12 +218,12 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValu
: [expectedValue] "r" (expectedValue),
[newValue] "r" (newValue),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return result == 0;
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
register T *originalValue;
register int result;
@@ -229,12 +237,12 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
"+m" (_q_value)
: [newValue] "r" (newValue),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return originalValue;
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
register T *originalValue;
register T *newValue;
@@ -251,7 +259,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
"+m" (_q_value)
: [valueToAdd] "r" (valueToAdd * sizeof(T)),
[_q_value] "r" (&_q_value)
- : "cc", "memory");
+ : "cc");
return originalValue;
}
@@ -263,9 +271,18 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
// RVCT embedded assembly documentation:
// http://www.keil.com/support/man/docs/armcc/armcc_chddbeib.htm
-// save our pragma state and switch to ARM mode
-#pragma push
-#pragma arm
+#if __TARGET_ARCH_THUMB-0 < 4
+// save our pragma state and switch to ARM mode (unless using Thumb2)
+# pragma push
+# pragma arm
+#endif
+
+#ifndef Q_DATA_MEMORY_BARRIER
+# define Q_DATA_MEMORY_BARRIER __schedule_barrier()
+#endif
+#ifndef Q_COMPILER_MEMORY_BARRIER
+# define Q_COMPILER_MEMORY_BARRIER __schedule_barrier()
+#endif
inline bool QBasicAtomicInt::ref()
{
@@ -297,7 +314,7 @@ inline bool QBasicAtomicInt::deref()
return newValue != 0;
}
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
register int result;
retry:
@@ -311,7 +328,7 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
return result == 0;
}
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
register int originalValue;
register int result;
@@ -325,7 +342,7 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
return originalValue;
}
-inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
+inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
register int originalValue;
register int newValue;
@@ -342,7 +359,7 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
}
template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
register T *result;
retry:
@@ -357,7 +374,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValu
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
register T *originalValue;
register int result;
@@ -372,7 +389,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
register T *originalValue;
register T *newValue;
@@ -388,111 +405,153 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
return originalValue;
}
-// go back to the previous pragma state (probably Thumb mode)
-#pragma pop
+#if __TARGET_ARCH_THUMB-0 < 4
+# pragma pop
#endif
-// common code
+#endif
-inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
+// common code
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
- return testAndSetOrdered(expectedValue, newValue);
+ bool returnValue = testAndSetRelaxed(expectedValue, newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
- return testAndSetOrdered(expectedValue, newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return testAndSetRelaxed(expectedValue, newValue);
}
-inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
+inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
{
- return fetchAndStoreOrdered(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ bool returnValue = testAndSetRelaxed(expectedValue, newValue);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
}
inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
{
- return fetchAndStoreOrdered(newValue);
+ int returnValue = fetchAndStoreRelaxed(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
{
- return fetchAndStoreOrdered(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return fetchAndStoreRelaxed(newValue);
}
-inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
+inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
{
- return fetchAndAddOrdered(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ int returnValue = fetchAndStoreRelaxed(newValue);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
}
+
inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
{
- return fetchAndAddOrdered(valueToAdd);
+ int returnValue = fetchAndAddRelaxed(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
{
- return fetchAndAddOrdered(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ return fetchAndAddRelaxed(valueToAdd);
}
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
+inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
{
- return testAndSetOrdered(expectedValue, newValue);
+ Q_DATA_MEMORY_BARRIER;
+ int returnValue = fetchAndAddRelaxed(valueToAdd);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
{
- return testAndSetOrdered(expectedValue, newValue);
+ bool returnValue = testAndSetRelaxed(expectedValue, newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
{
- return testAndSetOrdered(expectedValue, newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return testAndSetRelaxed(expectedValue, newValue);
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
{
- return fetchAndStoreOrdered(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ bool returnValue = testAndSetAcquire(expectedValue, newValue);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
- return fetchAndStoreOrdered(newValue);
+ T *returnValue = fetchAndStoreRelaxed(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
- return fetchAndStoreOrdered(newValue);
+ Q_DATA_MEMORY_BARRIER;
+ return fetchAndStoreRelaxed(newValue);
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
{
- return fetchAndAddOrdered(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ T *returnValue = fetchAndStoreRelaxed(newValue);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
{
- return fetchAndAddOrdered(valueToAdd);
+ T *returnValue = fetchAndAddRelaxed(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ return returnValue;
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
{
- return fetchAndAddOrdered(valueToAdd);
+ Q_DATA_MEMORY_BARRIER;
+ return fetchAndAddRelaxed(valueToAdd);
}
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+{
+ Q_DATA_MEMORY_BARRIER;
+ T *returnValue = fetchAndAddRelaxed(valueToAdd);
+ Q_COMPILER_MEMORY_BARRIER;
+ return returnValue;
+}
+
+#undef Q_DATA_MEMORY_BARRIER
+#undef Q_COMPILER_MEMORY_BARRIER
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/arch/qatomic_armv7.h b/src/corelib/arch/qatomic_armv7.h
new file mode 100644
index 0000000..b35866b
--- /dev/null
+++ b/src/corelib/arch/qatomic_armv7.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 QATOMIC_ARMV7_H
+#define QATOMIC_ARMV7_H
+
+QT_BEGIN_HEADER
+
+// use the DMB instruction when compiling for ARMv7, ...
+#ifndef Q_CC_RCVT
+# define Q_DATA_MEMORY_BARRIER asm volatile("dmb\n":::"memory")
+#else
+# define Q_DATA_MEMORY_BARRIER do{__asm { dmb } __schedule_barrier();}while(0)
+#endif
+
+// ... but the implementation is otherwise identical to that for ARMv6
+QT_BEGIN_INCLUDE_HEADER
+#include "QtCore/qatomic_armv6.h"
+QT_END_INCLUDE_HEADER
+
+QT_END_HEADER
+
+#endif // QATOMIC_ARMV7_H
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/arch.pri b/src/corelib/arch/symbian/arch.pri
index 70daee3..2e2a9b6 100644
--- a/src/corelib/arch/symbian/arch.pri
+++ b/src/corelib/arch/symbian/arch.pri
@@ -2,7 +2,7 @@
# Symbian architecture
#
SOURCES += $$QT_ARCH_CPP/qatomic_symbian.cpp \
- $$QT_ARCH_CPP/../armv6/qatomic_generic_armv6.cpp \
+ $$QT_ARCH_CPP/qatomic_generic_armv6.cpp \
$$QT_ARCH_CPP/heap_hybrid.cpp \
$$QT_ARCH_CPP/debugfunction.cpp \
$$QT_ARCH_CPP/qt_heapsetup_symbian.cpp
diff --git a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp b/src/corelib/arch/symbian/qatomic_generic_armv6.cpp
index f9ce6fd..f9ce6fd 100644
--- a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp
+++ b/src/corelib/arch/symbian/qatomic_generic_armv6.cpp
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/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 4497b8c..053b3d2 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -173,6 +173,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
int invalidCount = 0;
int remainingCount = 0;
char *remainingBuffer = 0;
+ IconvState *temporaryState = 0;
IconvState **pstate;
if (convState) {
@@ -193,11 +194,11 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
// we're running after the Q_GLOBAL_STATIC has been deleted
// or before the QCoreApplication initialization
// bad programmer, no cookie for you
- return QString::fromLatin1(chars, len);
+ pstate = &temporaryState;
+ } else {
+ // stateless conversion -- use thread-local data
+ pstate = &toUnicodeState()->localData();
}
-
- // stateless conversion -- use thread-local data
- pstate = &toUnicodeState()->localData();
}
if (!*pstate) {
@@ -280,6 +281,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
}
+ delete temporaryState;
return QString::fromLatin1(chars, len);
}
} while (inBytesLeft != 0);
@@ -294,6 +296,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
}
+ delete temporaryState;
return s;
}
@@ -337,30 +340,22 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
char **inBytesPtr = &inBytes;
#endif
+ IconvState *temporaryState = 0;
QThreadStorage<QIconvCodec::IconvState *> *ts = fromUnicodeState();
- if (!qt_locale_initialized || !ts) {
- // we're running after the Q_GLOBAL_STATIC has been deleted
- // or before the QCoreApplication initialization
- // bad programmer, no cookie for you
- if (!len)
- // this is a special case - zero-sized string should be
- // translated to empty but not-null QByteArray.
- return QByteArray("");
- return QString::fromRawData(uc, len).toLatin1();
- }
- IconvState *&state = ts->localData();
+ IconvState *&state = (qt_locale_initialized && ts) ? ts->localData() : temporaryState;
if (!state) {
- state = new IconvState(QIconvCodec::createIconv_t(0, UTF16));
- if (state->cd == reinterpret_cast<iconv_t>(-1)) {
- if (!setByteOrder(state->cd)) {
+ iconv_t cd = QIconvCodec::createIconv_t(0, UTF16);
+ if (cd != reinterpret_cast<iconv_t>(-1)) {
+ if (!setByteOrder(cd)) {
perror("QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM");
- iconv_close(state->cd);
- state->cd = reinterpret_cast<iconv_t>(-1);
+ iconv_close(cd);
+ cd = reinterpret_cast<iconv_t>(-1);
return QString(uc, len).toLatin1();
}
}
+ state = new IconvState(cd);
}
if (state->cd == reinterpret_cast<iconv_t>(-1)) {
static int reported = 0;
@@ -368,6 +363,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
fprintf(stderr,
"QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed\n");
}
+ delete temporaryState;
return QString(uc, len).toLatin1();
}
@@ -430,6 +426,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
// reset to initial state
iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
+ delete temporaryState;
return QString(uc, len).toLatin1();
}
}
@@ -445,6 +442,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
if (convState)
convState->invalidChars = invalidCount;
+ delete temporaryState;
return ba;
}
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/qfuture.h b/src/corelib/concurrent/qfuture.h
index f638c98..e8a6e26 100644
--- a/src/corelib/concurrent/qfuture.h
+++ b/src/corelib/concurrent/qfuture.h
@@ -210,7 +210,7 @@ public:
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
-#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(Q_CC_XLC)
+#if !defined(Q_CC_XLC)
template <typename T>
QFuture(const QFuture<T> &other)
: d(other.d)
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index 641db71..ea12bc9 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -359,6 +359,15 @@ void QFutureWatcherBase::connectNotify(const char * signal)
Q_D(QFutureWatcherBase);
if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0)
d->resultAtConnected.ref();
+#ifndef QT_NO_DEBUG
+ if (qstrcmp(signal, SIGNAL(finished())) == 0) {
+ if (futureInterface().isRunning()) {
+ //connections should be established before calling stFuture to avoid race.
+ // (The future could finish before the connection is made.)
+ qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race");
+ }
+ }
+#endif
}
void QFutureWatcherBase::disconnectNotify(const char * signal)
diff --git a/src/corelib/concurrent/qtconcurrentcompilertest.h b/src/corelib/concurrent/qtconcurrentcompilertest.h
index d02b859..fad0c35 100644
--- a/src/corelib/concurrent/qtconcurrentcompilertest.h
+++ b/src/corelib/concurrent/qtconcurrentcompilertest.h
@@ -51,12 +51,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
-#ifdef Q_CC_MSVC
-# if _MSC_VER < 1300
-# define QT_CONURRENT_NONSTANDARD_COMPILER
-# endif
-#endif
-
#if defined (Q_CC_MSVC) && (_MSC_VER < 1300)
# define QT_TYPENAME
#else
diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.h b/src/corelib/concurrent/qtconcurrentiteratekernel.h
index a42aa9d..186f752 100644
--- a/src/corelib/concurrent/qtconcurrentiteratekernel.h
+++ b/src/corelib/concurrent/qtconcurrentiteratekernel.h
@@ -184,12 +184,9 @@ public:
#if defined (QT_NO_STL)
: begin(_begin), end(_end), current(_begin), currentIndex(0),
forIteration(false), progressReportingEnabled(true)
-#elif !defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION)
+#else
: begin(_begin), end(_end), current(_begin), currentIndex(0),
forIteration(selectIteration(typename std::iterator_traits<Iterator>::iterator_category())), progressReportingEnabled(true)
-#else
- : begin(_begin), end(_end), currentIndex(0),
- forIteration(selectIteration(std::iterator_category(_begin))), progressReportingEnabled(true)
#endif
{
#if defined (QT_NO_STL)
diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h
index 5dacc7b..f26a3e3 100644
--- a/src/corelib/concurrent/qtconcurrentrunbase.h
+++ b/src/corelib/concurrent/qtconcurrentrunbase.h
@@ -100,7 +100,18 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<T>::reportException(e);
+ } catch (...) {
+ QFutureInterface<T>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
+
this->reportResult(result);
this->reportFinished();
}
@@ -117,7 +128,17 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<void>::reportException(e);
+ } catch (...) {
+ QFutureInterface<void>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
this->reportFinished();
}
};
diff --git a/src/corelib/concurrent/qthreadpool.cpp b/src/corelib/concurrent/qthreadpool.cpp
index 49c59c9..1a07b5b 100644
--- a/src/corelib/concurrent/qthreadpool.cpp
+++ b/src/corelib/concurrent/qthreadpool.cpp
@@ -41,6 +41,7 @@
#include "qthreadpool.h"
#include "qthreadpool_p.h"
+#include "qelapsedtimer.h"
#ifndef QT_NO_THREAD
@@ -249,6 +250,7 @@ bool QThreadPoolPrivate::tooManyThreadsActive() const
void QThreadPoolPrivate::startThread(QRunnable *runnable)
{
QScopedPointer <QThreadPoolThread> thread(new QThreadPoolThread(this));
+ thread->setObjectName(QLatin1String("Thread (pooled)"));
allThreads.insert(thread.data());
++activeThreads;
@@ -288,11 +290,21 @@ void QThreadPoolPrivate::reset()
isExiting = false;
}
-void QThreadPoolPrivate::waitForDone()
+bool QThreadPoolPrivate::waitForDone(int msecs)
{
QMutexLocker locker(&mutex);
- while (!(queue.isEmpty() && activeThreads == 0))
- noActiveThreads.wait(locker.mutex());
+ if (msecs < 0) {
+ while (!(queue.isEmpty() && activeThreads == 0))
+ noActiveThreads.wait(locker.mutex());
+ } else {
+ QElapsedTimer timer;
+ timer.start();
+ int t;
+ while (!(queue.isEmpty() && activeThreads == 0) &&
+ ((t = msecs - timer.elapsed()) > 0))
+ noActiveThreads.wait(locker.mutex(), t);
+ }
+ return queue.isEmpty() && activeThreads == 0;
}
/*! \internal
@@ -617,6 +629,23 @@ void QThreadPool::waitForDone()
d->reset();
}
+/*!
+ \overload waitForDone()
+ \since 4.8
+
+ Waits up to \a msecs milliseconds for all threads to exit and removes all
+ threads from the thread pool. Returns true if all threads were removed;
+ otherwise it returns false.
+*/
+bool QThreadPool::waitForDone(int msecs)
+{
+ Q_D(QThreadPool);
+ bool rc = d->waitForDone(msecs);
+ if (rc)
+ d->reset();
+ return rc;
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/corelib/concurrent/qthreadpool.h b/src/corelib/concurrent/qthreadpool.h
index 9fc883d..d0326ca 100644
--- a/src/corelib/concurrent/qthreadpool.h
+++ b/src/corelib/concurrent/qthreadpool.h
@@ -85,6 +85,7 @@ public:
void releaseThread();
void waitForDone();
+ bool waitForDone(int msecs);
};
QT_END_NAMESPACE
diff --git a/src/corelib/concurrent/qthreadpool_p.h b/src/corelib/concurrent/qthreadpool_p.h
index 6986c16..8f38df7 100644
--- a/src/corelib/concurrent/qthreadpool_p.h
+++ b/src/corelib/concurrent/qthreadpool_p.h
@@ -82,7 +82,7 @@ public:
void startThread(QRunnable *runnable = 0);
void reset();
- void waitForDone();
+ bool waitForDone(int msecs = -1);
bool startFrontRunnable();
void stealRunnable(QRunnable *);
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 06aa191..58d2c7b 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -19,8 +19,14 @@ include(codecs/codecs.pri)
include(statemachine/statemachine.pri)
include(xml/xml.pri)
-mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
-
+!qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
+qpa {
+ contains(QT_CONFIG, coreservices) {
+ LIBS_PRIVATE += -framework CoreServices
+ }
+} else:mac|darwin {
+ LIBS_PRIVATE += -framework CoreFoundation
+}
mac:lib_bundle:DEFINES += QT_NO_DEBUG_PLUGIN_CHECK
win32:DEFINES-=QT_NO_CAST_TO_ASCII
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 8ff423e..68582bf 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -19,7 +19,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/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
new file mode 100644
index 0000000..a44391c
--- /dev/null
+++ b/src/corelib/global/qconfig-nacl.h
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#define QT_FONTS_ARE_RESOURCES
+
+/* Data structures */
+#ifndef QT_NO_QUUID_STRING
+# define QT_NO_QUUID_STRING
+#endif
+#ifndef QT_NO_STL
+# define QT_NO_STL
+#endif
+#ifndef QT_NO_TEXTDATE
+# define QT_NO_TEXTDATE
+#endif
+#ifndef QT_NO_DATESTRING
+# define QT_NO_DATESTRING
+#endif
+
+/* Dialogs */
+#ifndef QT_NO_FILEDIALOG
+# define QT_NO_FILEDIALOG
+#endif
+#ifndef QT_NO_PRINTDIALOG
+# define QT_NO_PRINTDIALOG
+#endif
+#ifndef QT_NO_PRINTPREVIEWDIALOG
+# define QT_NO_PRINTPREVIEWDIALOG
+#endif
+
+
+/* File I/O */
+#ifndef QT_NO_DOM
+# define QT_NO_DOM
+#endif
+#ifndef QT_NO_FILESYSTEMWATCHER
+# define QT_NO_FILESYSTEMWATCHER
+#endif
+#ifndef QT_NO_FSFILEENGINE
+# define QT_NO_FSFILEENGINE
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+# define QT_NO_FILESYSTEMMODEL
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+# define QT_NO_FILESYSTEMMODEL
+#endif
+#ifndef QT_NO_PROCESS
+# define QT_NO_PROCESS
+#endif
+#ifndef QT_NO_TEMPORARYFILE
+# define QT_NO_TEMPORARYFILE
+#endif
+#ifndef QT_NO_SETTINGS
+# define QT_NO_SETTINGS
+#endif
+#ifndef QT_NO_LIBRARY
+# define QT_NO_LIBRARY
+#endif
+
+/* Fonts */
+#ifndef QT_NO_QWS_QPF2
+# define QT_NO_QWS_QPF2
+#endif
+
+/* Images */
+#ifndef QT_NO_IMAGEFORMATPLUGIN
+# define QT_NO_IMAGEFORMATPLUGIN
+#endif
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
+# define QT_NO_IMAGE_HEURISTIC_MASK
+#endif
+#ifndef QT_NO_IMAGE_TEXT
+# define QT_NO_IMAGE_TEXT
+#endif
+#ifndef QT_NO_MOVIE
+# define QT_NO_MOVIE
+#endif
+
+/* Internationalization */
+#ifndef QT_NO_BIG_CODECS
+# define QT_NO_BIG_CODECS
+#endif
+#ifndef QT_NO_QWS_INPUTMETHODS
+# define QT_NO_QWS_INPUTMETHODS
+#endif
+#ifndef QT_NO_TEXTCODEC
+# define QT_NO_TEXTCODEC
+#endif
+#ifndef QT_NO_CODECS
+# define QT_NO_CODECS
+#endif
+#ifndef QT_NO_TEXTCODECPLUGIN
+# define QT_NO_TEXTCODECPLUGIN
+#endif
+#ifndef QT_NO_TRANSLATION
+# define QT_NO_TRANSLATION
+#endif
+#ifndef QT_NO_TRANSLATION_UTF8
+# define QT_NO_TRANSLATION_UTF8
+#endif
+
+/* ItemViews */
+
+#ifndef QT_NO_DIRMODEL
+# define QT_NO_DIRMODEL
+#endif
+
+/* Kernel */
+#ifndef QT_NO_CLIPBOARD
+# define QT_NO_CLIPBOARD
+#endif
+#ifndef QT_NO_CSSPARSER
+# define QT_NO_CSSPARSER
+#endif
+#ifndef QT_NO_CURSOR
+# define QT_NO_CURSOR
+#endif
+#ifndef QT_NO_DRAGANDDROP
+# define QT_NO_DRAGANDDROP
+#endif
+#ifndef QT_NO_EFFECTS
+# define QT_NO_EFFECTS
+#endif
+#ifndef QT_NO_SESSIONMANAGER
+# define QT_NO_SESSIONMANAGER
+#endif
+#ifndef QT_NO_SHAREDMEMORY
+# define QT_NO_SHAREDMEMORY
+#endif
+#ifndef QT_NO_SOUND
+# define QT_NO_SOUND
+#endif
+#ifndef QT_NO_SYSTEMLOCALE
+# define QT_NO_SYSTEMSEMAPHORE
+#endif
+#ifndef QT_NO_SYSTEMSEMAPHORE
+# define QT_NO_SYSTEMSEMAPHORE
+#endif
+#ifndef QT_NO_TABLETEVENT
+# define QT_NO_TABLETEVENT
+#endif
+#ifndef QT_NO_CRASHHANDLER
+# define QT_NO_CRASHHANDLER
+#endif
+#ifndef QT_NO_CONCURRENT
+# define QT_NO_CONCURRENT
+#endif
+#ifndef QT_NO_XMLSTREAM
+# define QT_NO_XMLSTREAM
+#endif
+#ifndef QT_NO_XMLSTREAMREADER
+# define QT_NO_XMLSTREAMREADER
+#endif
+#ifndef QT_NO_XMLSTREAMWRITER
+# define QT_NO_XMLSTREAMWRITER
+#endif
+
+/* Networking */
+#ifndef QT_NO_COP
+# define QT_NO_COP
+#endif
+#ifndef QT_NO_HOSTINFO
+# define QT_NO_HOSTINFO
+#endif
+#ifndef QT_NO_HTTP
+# define QT_NO_HTTP
+#endif
+#ifndef QT_NO_NETWORKPROXY
+# define QT_NO_NETWORKPROXY
+#endif
+#ifndef QT_NO_SOCKS5
+# define QT_NO_SOCKS5
+#endif
+#ifndef QT_NO_UDPSOCKET
+# define QT_NO_UDPSOCKET
+#endif
+#ifndef QT_NO_URLINFO
+# define QT_NO_URLINFO
+#endif
+#ifndef QT_NO_FTP
+# define QT_NO_FTP
+#endif
+
+/* Painting */
+#ifndef QT_NO_COLORNAMES
+# define QT_NO_COLORNAMES
+#endif
+#ifndef QT_NO_DIRECTPAINTER
+# define QT_NO_DIRECTPAINTER
+#endif
+#ifndef QT_NO_PAINTONSCREEN
+# define QT_NO_PAINTONSCREEN
+#endif
+#ifndef QT_NO_PAINT_DEBUG
+# define QT_NO_PAINT_DEBUG
+#endif
+#ifndef QT_NO_PICTURE
+# define QT_NO_PICTURE
+#endif
+#ifndef QT_NO_PRINTER
+# define QT_NO_PRINTER
+#endif
+#ifndef QT_NO_CUPS
+# define QT_NO_CUPS
+#endif
+
+/* Qt for Embedded Linux */
+#ifndef QT_NO_QWSEMBEDWIDGET
+# define QT_NO_QWSEMBEDWIDGET
+#endif
+#ifndef QT_NO_QWS_ALPHA_CURSOR
+# define QT_NO_QWS_ALPHA_CURSOR
+#endif
+#ifndef QT_NO_QWS_CURSOR
+# define QT_NO_QWS_CURSOR
+#endif
+#ifndef QT_NO_QWS_DECORATION_DEFAULT
+# define QT_NO_QWS_DECORATION_DEFAULT
+#endif
+#ifndef QT_NO_QWS_DECORATION_STYLED
+# define QT_NO_QWS_DECORATION_STYLED
+#endif
+#ifndef QT_NO_QWS_DECORATION_WINDOWS
+# define QT_NO_QWS_DECORATION_WINDOWS
+#endif
+#ifndef QT_NO_QWS_MANAGER
+# define QT_NO_QWS_MANAGER
+#endif
+#ifndef QT_NO_QWS_KEYBOARD
+# define QT_NO_QWS_KEYBOARD
+#endif
+#ifndef QT_NO_QWS_MOUSE
+# define QT_NO_QWS_MOUSE
+#endif
+#ifndef QT_NO_QWS_MOUSE_AUTO
+# define QT_NO_QWS_MOUSE_AUTO
+#endif
+#ifndef QT_NO_QWS_MOUSE_MANUAL
+# define QT_NO_QWS_MOUSE_MANUAL
+#endif
+#ifndef QT_NO_QWS_MULTIPROCESS
+# define QT_NO_QWS_MULTIPROCESS
+#endif
+#ifndef QT_NO_QWS_SOUNDSERVER
+# define QT_NO_QWS_SOUNDSERVER
+#endif
+#ifndef QT_NO_SXE
+# define QT_NO_SXE
+#endif
+#ifndef QT_NO_QWS_PROPERTIES
+# define QT_NO_QWS_PROPERTIES
+#endif
+#ifndef QT_NO_QWS_PROXYSCREEN
+# define QT_NO_QWS_PROXYSCREEN
+#endif
+#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
+# define QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
+#endif
+#ifndef QT_NO_QWS_LINUXFB
+# define QT_NO_QWS_LINUXFB
+#endif
+#ifndef QT_NO_QWS_MOUSE_PC
+# define QT_NO_QWS_MOUSE_PC
+#endif
+#ifndef QT_NO_QWS_MOUSE_LINUXTP
+# define QT_NO_QWS_MOUSE_LINUXTP
+#endif
+#ifndef QT_NO_QWS_QPF
+# define QT_NO_QWS_QPF
+#endif
+
+/* SVG */
+#ifndef QT_NO_SVG
+# define QT_NO_SVG
+#endif
+#ifndef QT_NO_GRAPHICSSVGITEM
+# define QT_NO_GRAPHICSSVGITEM
+#endif
+#ifndef QT_NO_SVGGENERATOR
+# define QT_NO_SVGGENERATOR
+#endif
+#ifndef QT_NO_SVGRENDERER
+# define QT_NO_SVGRENDERER
+#endif
+#ifndef QT_NO_SVGWIDGET
+# define QT_NO_SVGWIDGET
+#endif
+
+/* Styles */
+#ifndef QT_NO_STYLE_MOTIF
+# define QT_NO_STYLE_MOTIF
+#endif
+#ifndef QT_NO_STYLE_CDE
+# define QT_NO_STYLE_CDE
+#endif
+#ifndef QT_NO_STYLE_STYLESHEET
+# define QT_NO_STYLE_STYLESHEET
+#endif
+#ifndef QT_NO_STYLE_WINDOWSCE
+# define QT_NO_STYLE_WINDOWSCE
+#endif
+#ifndef QT_NO_STYLE_WINDOWSMOBILE
+# define QT_NO_STYLE_WINDOWSMOBILE
+#endif
+#ifndef QT_NO_STYLE_WINDOWSVISTA
+# define QT_NO_STYLE_WINDOWSVISTA
+#endif
+#ifndef QT_NO_STYLE_WINDOWSXP
+# define QT_NO_STYLE_WINDOWSXP
+#endif
+
+/* Utilities */
+#ifndef QT_NO_ACCESSIBILITY
+# define QT_NO_ACCESSIBILITY
+#endif
+#ifndef QT_NO_COMPLETER
+# define QT_NO_COMPLETER
+#endif
+#ifndef QT_NO_DESKTOPSERVICES
+# define QT_NO_DESKTOPSERVICES
+#endif
+#ifndef QT_NO_SCRIPT
+# define QT_NO_SCRIPT
+#endif
+#ifndef QT_NO_SYSTEMTRAYICON
+# define QT_NO_SYSTEMTRAYICON
+#endif
+
+/* Windows */
+#ifndef QT_NO_WIN_ACTIVEQT
+# define QT_NO_WIN_ACTIVEQT
+#endif
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 9d47638..566307b 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -88,7 +88,7 @@ template <typename T> inline void qToUnaligned(const T src, uchar *dest)
* and return the value in host-endian encoding.
* There is no requirement that \a src must be aligned.
*/
-#if defined Q_CC_MSVC && _MSC_VER < 1300 || defined Q_CC_SUN
+#if defined Q_CC_SUN
inline quint64 qFromLittleEndian_helper(const uchar *src, quint64 *dest)
{
return 0
@@ -176,7 +176,7 @@ template <> inline qint16 qFromLittleEndian<qint16>(const uchar *src)
* and return the value in host-endian encoding.
* There is no requirement that \a src must be aligned.
*/
-#if defined Q_CC_MSVC && _MSC_VER < 1300 || defined Q_CC_SUN
+#if defined Q_CC_SUN
inline quint64 qFromBigEndian_helper(const uchar *src, quint64 *dest)
{
return 0
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index de2ca85..604d08a 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -79,6 +79,9 @@
// Effects
//#define QT_NO_EFFECTS
+// QFileSystemIterator
+//#define QT_NO_FILESYSTEMITERATOR
+
// QFileSystemWatcher
//#define QT_NO_FILESYSTEMWATCHER
@@ -523,11 +526,6 @@
#define QT_NO_FTP
#endif
-// Hyper Text Transfer Protocol
-#if !defined(QT_NO_HTTP) && (defined(QT_NO_HOSTINFO))
-#define QT_NO_HTTP
-#endif
-
// QInputContext
#if !defined(QT_NO_IM) && (defined(QT_NO_LIBRARY))
#define QT_NO_IM
@@ -583,6 +581,11 @@
#define QT_NO_GRAPHICSVIEW
#endif
+// Hyper Text Transfer Protocol
+#if !defined(QT_NO_HTTP) && defined(QT_NO_HOSTINFO)
+#define QT_NO_HTTP
+#endif
+
// QMdiArea
#if !defined(QT_NO_MDIAREA) && (defined(QT_NO_SCROLLAREA))
#define QT_NO_MDIAREA
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index 4d938a9..6b861d4 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -242,6 +242,14 @@ Requires:
Name: QFileSystemWatcher
SeeAlso: ???
+Feature: FILESYSTEMITERATOR
+Description: Provides fast file-system iteration.
+for modications.
+Section: File I/O
+Requires:
+Name: QFileSystemIterator
+SeeAlso: ???
+
# Widgets
Feature: TREEWIDGET
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 35719b1..bcaed41 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -74,7 +74,7 @@
# include <envLib.h>
#endif
-#if defined(Q_CC_MWERKS) && defined(Q_OS_MACX)
+#if defined(Q_OS_MACX) && !defined(QT_NO_CORESERVICES)
#include <CoreServices/CoreServices.h>
#endif
@@ -1173,6 +1173,7 @@ bool qSharedBuild()
\value MV_10_4 Mac OS X 10.4
\value MV_10_5 Mac OS X 10.5
\value MV_10_6 Mac OS X 10.6
+ \value MV_10_7 Mac OS X 10.7
\value MV_Unknown An unknown and currently unsupported platform
\value MV_CHEETAH Apple codename for MV_10_0
@@ -1182,6 +1183,7 @@ bool qSharedBuild()
\value MV_TIGER Apple codename for MV_10_4
\value MV_LEOPARD Apple codename for MV_10_5
\value MV_SNOWLEOPARD Apple codename for MV_10_6
+ \value MV_LION Apple codename for MV_10_7
\sa WinVersion, SymbianVersion
*/
@@ -1232,7 +1234,7 @@ bool qSharedBuild()
Defined on Mac OS X.
- \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_S60
+ \sa Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_QPA, Q_WS_S60
*/
/*!
@@ -1241,7 +1243,7 @@ bool qSharedBuild()
Defined on Windows.
- \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_S60
+ \sa Q_WS_MAC, Q_WS_X11, Q_WS_QWS, Q_WS_QPA, Q_WS_S60
*/
/*!
@@ -1250,7 +1252,7 @@ bool qSharedBuild()
Defined on X11.
- \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_S60
+ \sa Q_WS_MAC, Q_WS_WIN, Q_WS_QWS, Q_WS_QPA, Q_WS_S60
*/
/*!
@@ -1259,7 +1261,16 @@ bool qSharedBuild()
Defined on Qt for Embedded Linux.
- \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_S60
+ \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QPA, Q_WS_S60
+*/
+
+/*!
+ \macro Q_WS_QPA
+ \relates <QtGlobal>
+
+ Defined on Qt for Embedded Linux, Lite version.
+
+ \sa Q_WS_MAC, Q_WS_WIN, Q_WS_X11, Q_WS_QWS, Q_WS_S60
*/
/*!
@@ -1634,7 +1645,7 @@ static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif
-#if !defined(QWS) && defined(Q_OS_MAC)
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
QT_BEGIN_INCLUDE_NAMESPACE
#include "private/qcore_mac_p.h"
@@ -1688,15 +1699,18 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
}
+#endif //!defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
-
+#if !defined(QWS) && defined(Q_OS_MAC)
static QSysInfo::MacVersion macVersion()
{
+#ifndef QT_NO_CORESERVICES
SInt32 gestalt_version;
if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
}
+#endif
return QSysInfo::MV_Unknown;
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = macVersion();
@@ -1726,7 +1740,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
@@ -2007,7 +2021,7 @@ QSysInfo::S60Version QSysInfo::s60Version()
*/
void qt_check_pointer(const char *n, int l)
{
- qWarning("In file %s, line %d: Out of memory", n, l);
+ qFatal("In file %s, line %d: Out of memory", n, l);
}
/* \internal
@@ -2238,7 +2252,8 @@ void qt_message_output(QtMsgType msgType, const char *buf)
_LIT(format, "[Qt Message] %S");
const int maxBlockSize = 256 - ((const TDesC &)format).Length();
const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
- HBufC* hbuffer = q_check_ptr(HBufC::New(qMin(maxBlockSize, ptr.Length())));
+ HBufC* hbuffer = HBufC::New(qMin(maxBlockSize, ptr.Length()));
+ Q_CHECK_PTR(hbuffer);
for (int i = 0; i < ptr.Length(); i += hbuffer->Length()) {
hbuffer->Des().Copy(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i)));
RDebug::Print(format, hbuffer);
@@ -2576,7 +2591,7 @@ bool qputenv(const char *varName, const QByteArray& value)
#endif
}
-#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
# if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500)
// older versions of INTEGRITY used a long instead of a uint for the seed.
@@ -2607,7 +2622,7 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
*/
void qsrand(uint seed)
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
SeedStorage *seedStorage = randTLS();
if (seedStorage) {
SeedStorageType *pseed = seedStorage->localData();
@@ -2615,10 +2630,10 @@ void qsrand(uint seed)
seedStorage->setLocalData(pseed = new SeedStorageType);
*pseed = seed;
} else {
- //golbal static seed storage should always exist,
+ //global static seed storage should always exist,
//except after being deleted by QGlobalStaticDeleter.
//But since it still can be called from destructor of another
- //global static object, fallback to sqrand(seed)
+ //global static object, fallback to srand(seed)
srand(seed);
}
#else
@@ -2646,7 +2661,7 @@ void qsrand(uint seed)
*/
int qrand()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
SeedStorage *seedStorage = randTLS();
if (seedStorage) {
SeedStorageType *pseed = seedStorage->localData();
@@ -2656,10 +2671,10 @@ int qrand()
}
return rand_r(pseed);
} else {
- //golbal static seed storage should always exist,
+ //global static seed storage should always exist,
//except after being deleted by QGlobalStaticDeleter.
//But since it still can be called from destructor of another
- //global static object, fallback to qrand()
+ //global static object, fallback to rand()
return rand();
}
#else
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 7768b46..d3b3e14 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -44,11 +44,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "4.7.4"
+#define QT_VERSION_STR "4.8.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x040704
+#define QT_VERSION 0x040800
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
@@ -64,6 +64,10 @@
#ifdef __cplusplus
+#ifndef QT_NO_STL
+#include <algorithm>
+#endif
+
#ifndef QT_NAMESPACE /* user namespace */
# define QT_PREPEND_NAMESPACE(name) ::name
@@ -216,6 +220,8 @@ namespace QT_NAMESPACE {}
# define Q_OS_ULTRIX
#elif defined(sinix)
# define Q_OS_RELIANT
+#elif defined(__native_client__)
+# define Q_OS_NACL
#elif defined(__linux__) || defined(__linux)
# define Q_OS_LINUX
#elif defined(__FreeBSD__) || defined(__DragonFly__)
@@ -284,7 +290,7 @@ namespace QT_NAMESPACE {}
# endif
#endif
-#if defined(Q_OS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) && !defined(QT_BOOTSTRAPPED)
+#if defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) && !defined(QT_BOOTSTRAPPED)
#error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."
#endif
@@ -316,7 +322,10 @@ namespace QT_NAMESPACE {}
# if !defined(MAC_OS_X_VERSION_10_6)
# define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1
# endif
-# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6)
+# if !defined(MAC_OS_X_VERSION_10_7)
+# define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1
+# endif
+# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_7)
# warning "This version of Mac OS X is unsupported"
# endif
#endif
@@ -356,13 +365,27 @@ namespace QT_NAMESPACE {}
GCCE - GCCE (Symbian GCCE builds)
RVCT - ARM Realview Compiler Suite
NOKIAX86 - Nokia x86 (Symbian WINSCW builds)
+ CLANG - C++ front-end for the LLVM compiler
Should be sorted most to least authoritative.
*/
#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 */
@@ -383,31 +406,12 @@ namespace QT_NAMESPACE {}
#elif defined(_MSC_VER)
# define Q_CC_MSVC
-/* proper support of bool for _MSC_VER >= 1100 */
+# define Q_CC_MSVC_NET
# define Q_CANNOT_DELETE_CONSTANT
# define Q_OUTOFLINE_TEMPLATE inline
# define Q_NO_TEMPLATE_FRIENDS
-# define QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
-# define Q_ALIGNOF(type) __alignof(type)
-# define Q_DECL_ALIGN(n) __declspec(align(n))
-
-/* Visual C++.Net issues for _MSC_VER >= 1300 */
-# if _MSC_VER >= 1300
-# define Q_CC_MSVC_NET
-# if _MSC_VER < 1310 || (defined(Q_OS_WIN64) && defined(_M_IA64))
-# define Q_TYPENAME
-# else
-# undef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
-# endif
-# else
-# define Q_NO_USING_KEYWORD
-# define QT_NO_MEMBER_TEMPLATES
-# endif
-# if _MSC_VER < 1310
-# define QT_NO_QOBJECT_CHECK
-# define Q_TYPENAME
-# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
-# endif
+# define Q_ALIGNOF(type) __alignof(type)
+# define Q_DECL_ALIGN(n) __declspec(align(n))
/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
# if defined(__INTEL_COMPILER)
# define Q_CC_INTEL
@@ -419,6 +423,19 @@ namespace QT_NAMESPACE {}
# undef QT_HAVE_3DNOW
# endif
+#if defined(Q_CC_MSVC) && _MSC_VER >= 1600
+# define Q_COMPILER_RVALUE_REFS
+# define Q_COMPILER_INITIALIZER_LISTS
+# define Q_COMPILER_AUTO_TYPE
+# define Q_COMPILER_LAMBDA
+//# define Q_COMPILER_VARIADIC_TEMPLATES
+//# define Q_COMPILER_CLASS_ENUM
+//# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+//# define Q_COMPILER_UNICODE_STRINGS
+//# define Q_COMPILER_EXTERN_TEMPLATES
+# endif
+
+
#elif defined(__BORLANDC__) || defined(__TURBOC__)
# define Q_CC_BOR
# define Q_INLINE_TEMPLATE
@@ -447,6 +464,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
@@ -456,7 +476,10 @@ 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 */
+# define Q_CC_CLANG
# endif
# ifdef __APPLE__
# define Q_NO_DEPRECATED_CONSTRUCTORS
@@ -493,6 +516,26 @@ namespace QT_NAMESPACE {}
# define QT_NO_ARM_EABI
# endif
# endif
+# if defined(__GXX_EXPERIMENTAL_CXX0X__)
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+ /* C++0x features supported in GCC 4.3: */
+# define Q_COMPILER_RVALUE_REFS
+# endif
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+ /* C++0x features supported in GCC 4.4: */
+# define Q_COMPILER_VARIADIC_TEMPLATES
+# define Q_COMPILER_AUTO_TYPE
+# define Q_COMPILER_EXTERN_TEMPLATES
+# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+# define Q_COMPILER_CLASS_ENUM
+# define Q_COMPILER_INITIALIZER_LISTS
+# endif
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+ /* C++0x features supported in GCC 4.5: */
+# define Q_COMPILER_LAMBDA
+# define Q_COMPILER_UNICODE_STRINGS
+# endif
+# endif
/* IBM compiler versions are a bit messy. There are actually two products:
the C product, and the C++ product. The C++ compiler is always packaged
@@ -712,7 +755,7 @@ namespace QT_NAMESPACE {}
# define Q_DECL_IMPORT __declspec(dllimport)
# endif
# if __HP_aCC-0 >= 061200
-# define Q_DECL_ALIGNED(n) __attribute__((aligned(n)))
+# define Q_DECL_ALIGN(n) __attribute__((aligned(n)))
# endif
# if __HP_aCC-0 >= 062000
# define Q_DECL_EXPORT __attribute__((visibility("default")))
@@ -735,6 +778,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
@@ -803,7 +864,7 @@ namespace QT_NAMESPACE {}
# define Q_WS_PM
# error "Qt does not work with OS/2 Presentation Manager or Workplace Shell"
#elif defined(Q_OS_UNIX)
-# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS)
+# if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
# define Q_WS_MAC
# define Q_WS_MACX
# if defined(Q_OS_MAC64)
@@ -815,7 +876,7 @@ namespace QT_NAMESPACE {}
# if !defined(QT_NO_S60)
# define Q_WS_S60
# endif
-# elif !defined(Q_WS_QWS)
+# elif !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
# define Q_WS_X11
# endif
#endif
@@ -924,10 +985,10 @@ redefine to built-in booleans to make autotests work properly */
#endif
/*
- Proper for-scoping in VC++6 and MIPSpro CC
+ Proper for-scoping in MIPSpro CC
*/
#ifndef QT_NO_KEYWORDS
-# if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
+# if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
# define for if(0){}else for
# endif
#endif
@@ -951,7 +1012,7 @@ redefine to built-in booleans to make autotests work properly */
# define Q_DECL_DEPRECATED Q_DECL_DEPRECATED
#elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT)
# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
-#elif defined(Q_CC_MSVC) && (_MSC_VER >= 1300)
+#elif defined(Q_CC_MSVC)
# define Q_DECL_DEPRECATED __declspec(deprecated)
# if defined (Q_CC_INTEL)
# define Q_DECL_VARIABLE_DEPRECATED
@@ -1050,12 +1111,12 @@ redefine to built-in booleans to make autotests work properly */
#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
# if defined(Q_CC_GNU)
-#if ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
+#if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332)
# define QT_FASTCALL __attribute__((regparm(3)))
#else
# define QT_FASTCALL
#endif
-# elif defined(Q_CC_MSVC) && (_MSC_VER > 1300 || defined(Q_CC_INTEL))
+# elif defined(Q_CC_MSVC)
# define QT_FASTCALL __fastcall
# else
# define QT_FASTCALL
@@ -1077,7 +1138,7 @@ redefine to built-in booleans to make autotests work properly */
typedef int QNoImplicitBoolCast;
-#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A)
+#if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A)
#define QT_NO_FPU
#endif
@@ -1098,14 +1159,14 @@ template <typename T>
inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
inline int qRound(qreal d)
-{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
+{ return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); }
#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
#else
inline qint64 qRound64(qreal d)
-{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); }
+{ return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); }
#endif
template <typename T>
@@ -1174,6 +1235,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)
@@ -1362,15 +1428,22 @@ class QDataStream;
# else
# define Q_GUI_EXPORT_INLINE inline
# endif
+# if defined(QT_BUILD_COMPAT_LIB)
+# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
+# else
+# define Q_COMPAT_EXPORT_INLINE inline
+# endif
#elif defined(Q_CC_RVCT)
// we force RVCT not to export inlines by passing --visibility_inlines_hidden
// so we need to just inline it, rather than exporting and inlining
// note: this affects the contents of the DEF files (ie. these functions do not appear)
# define Q_CORE_EXPORT_INLINE inline
# define Q_GUI_EXPORT_INLINE inline
+# define Q_COMPAT_EXPORT_INLINE inline
#else
# define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline
# define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline
+# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline
#endif
/*
@@ -1388,7 +1461,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.
@@ -1501,6 +1574,7 @@ public:
MV_10_4 = 0x0006,
MV_10_5 = 0x0007,
MV_10_6 = 0x0008,
+ MV_10_7 = 0x0009,
/* codenames */
MV_CHEETAH = MV_10_0,
@@ -1509,7 +1583,8 @@ public:
MV_PANTHER = MV_10_3,
MV_TIGER = MV_10_4,
MV_LEOPARD = MV_10_5,
- MV_SNOWLEOPARD = MV_10_6
+ MV_SNOWLEOPARD = MV_10_6,
+ MV_LION = MV_10_7
};
static const MacVersion MacintoshVersion;
#endif
@@ -1610,7 +1685,7 @@ inline void qUnused(T &x) { (void)x; }
#endif
#ifndef qPrintable
-# define qPrintable(string) (string).toLocal8Bit().constData()
+# define qPrintable(string) QString(string).toLocal8Bit().constData()
#endif
Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */
@@ -1702,7 +1777,7 @@ Q_CORE_EXPORT void qBadAlloc();
#ifdef QT_NO_EXCEPTIONS
# if defined(QT_NO_DEBUG)
-# define Q_CHECK_PTR(p) qt_noop();
+# define Q_CHECK_PTR(p) qt_noop()
# else
# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
# endif
@@ -1716,12 +1791,7 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
# define Q_FUNC_INFO __PRETTY_FUNCTION__
#elif defined(_MSC_VER)
- /* MSVC 2002 doesn't have __FUNCSIG__ nor can it handle QT_STRINGIFY. */
-# if _MSC_VER <= 1300
-# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
-# else
-# define Q_FUNC_INFO __FUNCSIG__
-# endif
+# define Q_FUNC_INFO __FUNCSIG__
#else
# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN)
# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
@@ -1763,32 +1833,32 @@ public:
inline ~QGlobalStatic() { pointer = 0; }
};
-#define Q_GLOBAL_STATIC(TYPE, NAME) \
- static TYPE *NAME() \
- { \
- static TYPE this_##NAME; \
- static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
- return global_##NAME.pointer; \
+#define Q_GLOBAL_STATIC(TYPE, NAME) \
+ static TYPE *NAME() \
+ { \
+ static TYPE thisVariable; \
+ static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
+ return thisGlobalStatic.pointer; \
}
-#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
- static TYPE *NAME() \
- { \
- static TYPE this_##NAME ARGS; \
- static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
- return global_##NAME.pointer; \
+#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
+ static TYPE *NAME() \
+ { \
+ static TYPE thisVariable ARGS; \
+ static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \
+ return thisGlobalStatic.pointer; \
}
-#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
- static TYPE *NAME() \
- { \
- static TYPE this_##NAME; \
- static QGlobalStatic<TYPE > global_##NAME(0); \
- if (!global_##NAME.pointer) { \
- TYPE *x = global_##NAME.pointer = &this_##NAME; \
- INITIALIZER; \
- } \
- return global_##NAME.pointer; \
+#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
+ static TYPE *NAME() \
+ { \
+ static TYPE thisVariable; \
+ static QGlobalStatic<TYPE > thisGlobalStatic(0); \
+ if (!thisGlobalStatic.pointer) { \
+ TYPE *x = thisGlobalStatic.pointer = &thisVariable; \
+ INITIALIZER; \
+ } \
+ return thisGlobalStatic.pointer; \
}
#else
@@ -1823,50 +1893,50 @@ public:
}
};
-#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
- static QGlobalStatic<TYPE > this_##NAME = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
-
-#define Q_GLOBAL_STATIC(TYPE, NAME) \
- Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
- static TYPE *NAME() \
- { \
- if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
- TYPE *x = new TYPE; \
- if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
- delete x; \
- else \
- static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
- } \
- return this_##NAME.pointer; \
+#define Q_GLOBAL_STATIC(TYPE, NAME) \
+ static TYPE *NAME() \
+ { \
+ static QGlobalStatic<TYPE > thisGlobalStatic \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
+ if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ TYPE *x = new TYPE; \
+ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ delete x; \
+ else \
+ static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ } \
+ return thisGlobalStatic.pointer; \
}
-#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
- Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
- static TYPE *NAME() \
- { \
- if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
- TYPE *x = new TYPE ARGS; \
- if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
- delete x; \
- else \
- static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
- } \
- return this_##NAME.pointer; \
+#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
+ static TYPE *NAME() \
+ { \
+ static QGlobalStatic<TYPE > thisGlobalStatic \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
+ if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ TYPE *x = new TYPE ARGS; \
+ if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ delete x; \
+ else \
+ static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ } \
+ return thisGlobalStatic.pointer; \
}
-#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
- Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
- static TYPE *NAME() \
- { \
- if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
- QScopedPointer<TYPE > x(new TYPE); \
- INITIALIZER; \
- if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) { \
- static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
- x.take(); \
- } \
- } \
- return this_##NAME.pointer; \
+#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
+ static TYPE *NAME() \
+ { \
+ static QGlobalStatic<TYPE > thisGlobalStatic \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
+ if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ QScopedPointer<TYPE > x(new TYPE); \
+ INITIALIZER; \
+ if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \
+ static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ x.take(); \
+ } \
+ } \
+ return thisGlobalStatic.pointer; \
}
#endif
@@ -1971,8 +2041,6 @@ static inline bool qIsNull(float f)
qIsDetached - data sharing functionality
*/
-#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
-
/*
The catch-all template.
*/
@@ -2005,28 +2073,6 @@ public:
};
};
-#else
-
-template <typename T> char QTypeInfoHelper(T*(*)());
-void* QTypeInfoHelper(...);
-
-template <typename T> inline bool qIsDetached(T &) { return true; }
-
-template <typename T>
-class QTypeInfo
-{
-public:
- enum {
- isPointer = (1 == sizeof(QTypeInfoHelper((T(*)())0))),
- isComplex = !isPointer,
- isStatic = !isPointer,
- isLarge = (sizeof(T)>sizeof(void*)),
- isDummy = false
- };
-};
-
-#endif /* QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION */
-
/*
Specialize a specific type with:
@@ -2043,8 +2089,7 @@ enum { /* TYPEINFO flags */
Q_DUMMY_TYPE = 0x4
};
-#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
-template <> \
+#define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) \
class QTypeInfo<TYPE > \
{ \
public: \
@@ -2058,12 +2103,22 @@ public: \
static inline const char *name() { return #TYPE; } \
}
+#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \
+template<> \
+Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
+
+
template <typename T>
inline void qSwap(T &value1, T &value2)
{
+#ifdef QT_NO_STL
const T t = value1;
value1 = value2;
value2 = t;
+#else
+ using std::swap;
+ swap(value1, value2);
+#endif
}
/*
@@ -2075,12 +2130,23 @@ inline void qSwap(T &value1, T &value2)
types must declare a 'bool isDetached(void) const;' member for this
to work.
*/
+#ifdef QT_NO_STL
+#define Q_DECLARE_SHARED_STL(TYPE)
+#else
+#define Q_DECLARE_SHARED_STL(TYPE) \
+QT_END_NAMESPACE \
+namespace std { \
+ template<> inline void swap<QT_PREPEND_NAMESPACE(TYPE)>(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \
+ { swap(value1.data_ptr(), value2.data_ptr()); } \
+} \
+QT_BEGIN_NAMESPACE
+#endif
+
#define Q_DECLARE_SHARED(TYPE) \
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
-{ \
- qSwap(value1.data_ptr(), value2.data_ptr()); \
-}
+{ qSwap(value1.data_ptr(), value2.data_ptr()); } \
+Q_DECLARE_SHARED_STL(TYPE)
/*
QTypeInfo primitive specializations
@@ -2140,10 +2206,6 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
# pragma warning(disable: 4710) /* function not inlined */
# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */
-# if _MSC_VER < 1300
-# pragma warning(disable: 4284) /* return type for 'type1::operator ->' is 'type2 *' */
- /* (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) */
-# endif
# elif defined(Q_CC_BOR)
# pragma option -w-inl
# pragma option -w-aus
@@ -2217,13 +2279,9 @@ public:
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
-#if defined Q_CC_MSVC && _MSC_VER < 1300
-# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
-#else
-# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
+#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
{ return QIncompatibleFlag(int(f1) | f2); }
-#endif
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
@@ -2280,9 +2338,9 @@ template <typename T>
inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *)
{ return static_cast<const QForeachContainer<T> *>(base); }
-#if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS)
+#if defined(Q_CC_MIPS)
/*
- Proper for-scoping in VC++6 and MIPSpro CC
+ Proper for-scoping in MIPSpro CC
*/
# define Q_FOREACH(variable,container) \
if(0){}else \
@@ -2650,12 +2708,6 @@ QT_LICENSED_MODULE(DBus)
# define QT_NO_QFUTURE
#endif
-// MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates,
-// but the QFuture class compiles.
-#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300)
-# define QT_NO_CONCURRENT
-#endif
-
// gcc 3 version has problems with some of the
// map/filter overloads.
#if defined(Q_CC_GNU) && (__GNUC__ < 4)
@@ -2674,6 +2726,12 @@ QT_LICENSED_MODULE(DBus)
# define QT_NO_PROCESS
#endif
+#if defined (__ELF__)
+# if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX)
+# define Q_OF_ELF
+# endif
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 1fecc26..aca1cb1 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -529,6 +529,9 @@ void qt_core_boilerplate()
#ifdef QT_BUILD_KEY_COMPAT2
"| " QT_BUILD_KEY_COMPAT2 " "
#endif
+#ifdef QT_BUILD_KEY_COMPAT3
+ "| " QT_BUILD_KEY_COMPAT3 " "
+#endif
"|\n"
"Build date: %s\n"
"Installation prefix: %s\n"
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 4d70744..f015ed0 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -526,6 +526,8 @@ public:
WA_X11DoNotAcceptFocus = 132,
+ WA_MacNoShadow = 133,
+
// Add new attributes before this line
WA_AttributeCount
};
@@ -542,6 +544,7 @@ public:
AA_MacDontSwapCtrlAndMeta = 7,
AA_S60DontConstructApplicationPanes = 8,
AA_S60DisablePartialScreenInputMode = 9,
+ AA_X11InitThreads = 10,
// Add new attributes before this line
AA_AttributeCount
@@ -1625,6 +1628,7 @@ public:
AccessibleDescriptionRole = 12,
// More general purpose
SizeHintRole = 13,
+ InitialSortOrderRole = 14,
// Internal UiLib roles. Start worrying when public roles go that high.
DisplayPropertyRole = 27,
DecorationPropertyRole = 28,
@@ -1667,7 +1671,7 @@ public:
typedef void *HANDLE;
#elif defined(Q_WS_X11)
typedef unsigned long HANDLE;
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
typedef void * HANDLE;
#elif defined(Q_OS_SYMBIAN)
typedef unsigned long int HANDLE; // equivalent to TUint32
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 22ad83b..07a9503 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -163,6 +163,10 @@
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
*/
@@ -1213,6 +1217,9 @@
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.
\omitvalue WA_SetLayoutDirection
\omitvalue WA_InputMethodTransparent
@@ -2636,19 +2643,22 @@
Roles describing appearance and meta data (with associated types):
- \value FontRole The font used for items rendered with the default
- delegate. (QFont)
- \value TextAlignmentRole The alignment of the text for items rendered with the
- default delegate. (Qt::AlignmentFlag)
- \value BackgroundRole The background brush used for items rendered with
- the default delegate. (QBrush)
- \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead.
- \value ForegroundRole The foreground brush (text color, typically)
- used for items rendered with the default delegate.
- (QBrush)
- \value TextColorRole This role is obsolete. Use ForegroundRole instead.
- \value CheckStateRole This role is used to obtain the checked state of
- an item. (Qt::CheckState)
+ \value FontRole The font used for items rendered with the default
+ delegate. (QFont)
+ \value TextAlignmentRole The alignment of the text for items rendered with the
+ default delegate. (Qt::AlignmentFlag)
+ \value BackgroundRole The background brush used for items rendered with
+ the default delegate. (QBrush)
+ \value BackgroundColorRole This role is obsolete. Use BackgroundRole instead.
+ \value ForegroundRole The foreground brush (text color, typically)
+ used for items rendered with the default delegate.
+ (QBrush)
+ \value TextColorRole This role is obsolete. Use ForegroundRole instead.
+ \value CheckStateRole This role is used to obtain the checked state of
+ an item. (Qt::CheckState)
+ \value InitialSortOrderRole This role is used to obtain the initial sort order
+ of a header view section. (Qt::SortOrder). This
+ role was introduced in Qt 4.8.
Accessibility roles (with associated types):
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 3d964c6..2b61192 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -9,6 +9,7 @@ HEADERS += \
io/qdataurl_p.h \
io/qdebug.h \
io/qdir.h \
+ io/qdir_p.h \
io/qdiriterator.h \
io/qfile.h \
io/qfileinfo.h \
@@ -29,7 +30,11 @@ HEADERS += \
io/qfsfileengine_p.h \
io/qfsfileengine_iterator_p.h \
io/qfilesystemwatcher.h \
- io/qfilesystemwatcher_p.h
+ io/qfilesystemwatcher_p.h \
+ io/qfilesystementry_p.h \
+ io/qfilesystemengine_p.h \
+ io/qfilesystemmetadata_p.h \
+ io/qfilesystemiterator_p.h
SOURCES += \
io/qabstractfileengine.cpp \
@@ -52,25 +57,35 @@ SOURCES += \
io/qsettings.cpp \
io/qfsfileengine.cpp \
io/qfsfileengine_iterator.cpp \
- io/qfilesystemwatcher.cpp
+ io/qfilesystemwatcher.cpp \
+ io/qfilesystementry.cpp \
+ io/qfilesystemengine.cpp
win32 {
SOURCES += io/qsettings_win.cpp
SOURCES += io/qprocess_win.cpp
SOURCES += io/qfsfileengine_win.cpp
- SOURCES += io/qfsfileengine_iterator_win.cpp
SOURCES += io/qfilesystemwatcher_win.cpp
HEADERS += io/qfilesystemwatcher_win_p.h
HEADERS += io/qwindowspipewriter_p.h
SOURCES += io/qwindowspipewriter.cpp
+ SOURCES += io/qfilesystemengine_win.cpp
+ SOURCES += io/qfilesystemiterator_win.cpp
} else:unix {
SOURCES += io/qfsfileengine_unix.cpp
- SOURCES += io/qfsfileengine_iterator_unix.cpp
- symbian:SOURCES += io/qprocess_symbian.cpp
- else:SOURCES += io/qprocess_unix.cpp
- macx-*: {
+ symbian {
+ SOURCES += io/qfilesystemengine_symbian.cpp
+ SOURCES += io/qprocess_symbian.cpp
+ SOURCES += io/qfilesystemiterator_symbian.cpp
+ } else {
+ SOURCES += io/qfilesystemengine_unix.cpp
+ SOURCES += io/qprocess_unix.cpp
+ SOURCES += io/qfilesystemiterator_unix.cpp
+ }
+ !nacl:macx-*: {
HEADERS += io/qfilesystemwatcher_fsevents_p.h
+ SOURCES += io/qfilesystemengine_mac.cpp
SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp
}
@@ -84,9 +99,11 @@ win32 {
io/qfilesystemwatcher_dnotify_p.h
}
- freebsd-*|macx-*|darwin-*|openbsd-*:{
- SOURCES += io/qfilesystemwatcher_kqueue.cpp
- HEADERS += io/qfilesystemwatcher_kqueue_p.h
+ !nacl {
+ freebsd-*|macx-*|darwin-*|openbsd-*:{
+ SOURCES += io/qfilesystemwatcher_kqueue.cpp
+ HEADERS += io/qfilesystemwatcher_kqueue_p.h
+ }
}
symbian {
@@ -96,3 +113,7 @@ win32 {
LIBS += -lplatformenv
}
}
+integrity {
+ SOURCES += io/qfsfileengine_unix.cpp \
+ io/qfsfileengine_iterator_unix.cpp
+}
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index 33b97ed..0a423c0 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -41,12 +41,20 @@
#include "qabstractfileengine.h"
#include "private/qabstractfileengine_p.h"
+#ifdef QT_BUILD_CORE_LIB
+#include "private/qresource_p.h"
+#endif
#include "qdatetime.h"
#include "qreadwritelock.h"
#include "qvariant.h"
// built-in handlers
#include "qfsfileengine.h"
#include "qdiriterator.h"
+#include "qstringbuilder.h"
+
+#include <QtCore/private/qfilesystementry_p.h>
+#include <QtCore/private/qfilesystemmetadata_p.h>
+#include <QtCore/private/qfilesystemengine_p.h>
QT_BEGIN_NAMESPACE
@@ -94,6 +102,8 @@ QT_BEGIN_NAMESPACE
\sa QAbstractFileEngine, QAbstractFileEngine::create()
*/
+static bool qt_file_engine_handlers_in_use = false;
+
/*
All application-wide handlers are stored in this list. The mutex must be
acquired to ensure thread safety.
@@ -123,6 +133,7 @@ Q_GLOBAL_STATIC(QAbstractFileEngineHandlerList, fileEngineHandlers)
QAbstractFileEngineHandler::QAbstractFileEngineHandler()
{
QWriteLocker locker(fileEngineHandlerMutex());
+ qt_file_engine_handlers_in_use = true;
fileEngineHandlers()->prepend(this);
}
@@ -134,8 +145,35 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler()
{
QWriteLocker locker(fileEngineHandlerMutex());
// Remove this handler from the handler list only if the list is valid.
- if (!qt_abstractfileenginehandlerlist_shutDown)
- fileEngineHandlers()->removeAll(this);
+ if (!qt_abstractfileenginehandlerlist_shutDown) {
+ QAbstractFileEngineHandlerList *handlers = fileEngineHandlers();
+ handlers->removeOne(this);
+ if (handlers->isEmpty())
+ qt_file_engine_handlers_in_use = false;
+ }
+}
+
+/*
+ \ìnternal
+
+ Handles calls to custom file engine handlers.
+*/
+QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path)
+{
+ QAbstractFileEngine *engine = 0;
+
+ if (qt_file_engine_handlers_in_use) {
+ QReadLocker locker(fileEngineHandlerMutex());
+
+ // check for registered handlers that can load the file
+ QAbstractFileEngineHandlerList *handlers = fileEngineHandlers();
+ for (int i = 0; i < handlers->size(); i++) {
+ if ((engine = handlers->at(i)->create(path)))
+ break;
+ }
+ }
+
+ return engine;
}
/*!
@@ -166,42 +204,17 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler()
*/
QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName)
{
- {
- QReadLocker locker(fileEngineHandlerMutex());
-
- // check for registered handlers that can load the file
- for (int i = 0; i < fileEngineHandlers()->size(); i++) {
- if (QAbstractFileEngine *ret = fileEngineHandlers()->at(i)->create(fileName))
- return ret;
- }
- }
-
-#ifdef QT_BUILD_CORE_LIB
- if (!fileName.startsWith(QLatin1Char('/'))) {
- int prefixSeparator = fileName.indexOf(QLatin1Char(':'));
- if (prefixSeparator > 1) {
- QString prefix = fileName.left(prefixSeparator);
- QString fileNameWithoutPrefix = fileName.mid(prefixSeparator + 1).prepend(QLatin1Char('/'));
- const QStringList &paths = QDir::searchPaths(prefix);
- for (int i = 0; i < paths.count(); i++) {
- QString path = paths.at(i);
- path.append(fileNameWithoutPrefix);
- QAbstractFileEngine *engine = create(path);
- if (engine && (engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) {
- return engine;
- }
- delete engine;
- }
- }
- }
+ QFileSystemEntry entry(fileName);
+ QFileSystemMetaData metaData;
+ QAbstractFileEngine *engine = QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, metaData);
+
+#ifndef QT_NO_FSFILEENGINE
+ if (!engine)
+ // fall back to regular file engine
+ return new QFSFileEngine(entry.filePath());
#endif
-#ifdef QT_NO_FSFILEENGINE
- return 0;
-#else
- // fall back to regular file engine
- return new QFSFileEngine(fileName);
-#endif
+ return engine;
}
/*!
diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h
index fe2b3cf..d64eaa5 100644
--- a/src/corelib/io/qabstractfileengine_p.h
+++ b/src/corelib/io/qabstractfileengine_p.h
@@ -74,6 +74,8 @@ public:
Q_DECLARE_PUBLIC(QAbstractFileEngine)
};
+QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path);
+
QT_END_NAMESPACE
#endif // QABSTRACTFILEENGINE_P_H
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index b36631b..0361d18 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -223,6 +223,7 @@ QT_BEGIN_NAMESPACE
\value ReadPastEnd The data stream has read past the end of the
data in the underlying device.
\value ReadCorruptData The data stream has read corrupt data.
+ \value WriteFailed The data stream cannot write to the underlying device.
*/
/*****************************************************************************
@@ -243,6 +244,11 @@ QT_BEGIN_NAMESPACE
}
#endif
+#define CHECK_STREAM_WRITE_PRECOND(retVal) \
+ CHECK_STREAM_PRECOND(retVal) \
+ if (q_status != Ok) \
+ return retVal;
+
enum {
DefaultStreamVersion = QDataStream::Qt_4_6
};
@@ -495,6 +501,9 @@ void QDataStream::resetStatus()
/*!
Sets the status of the data stream to the \a status given.
+ Subsequent calls to setStatus() are ignored until resetStatus()
+ is called.
+
\sa Status status() resetStatus()
*/
void QDataStream::setStatus(Status status)
@@ -992,8 +1001,9 @@ int QDataStream::readRawData(char *s, int len)
QDataStream &QDataStream::operator<<(qint8 i)
{
- CHECK_STREAM_PRECOND(*this)
- dev->putChar(i);
+ CHECK_STREAM_WRITE_PRECOND(*this)
+ if (!dev->putChar(i))
+ q_status = WriteFailed;
return *this;
}
@@ -1015,11 +1025,12 @@ QDataStream &QDataStream::operator<<(qint8 i)
QDataStream &QDataStream::operator<<(qint16 i)
{
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
if (!noswap) {
i = qbswap(i);
}
- dev->write((char *)&i, sizeof(qint16));
+ if (dev->write((char *)&i, sizeof(qint16)) != sizeof(qint16))
+ q_status = WriteFailed;
return *this;
}
@@ -1032,11 +1043,12 @@ QDataStream &QDataStream::operator<<(qint16 i)
QDataStream &QDataStream::operator<<(qint32 i)
{
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
if (!noswap) {
i = qbswap(i);
}
- dev->write((char *)&i, sizeof(qint32));
+ if (dev->write((char *)&i, sizeof(qint32)) != sizeof(qint32))
+ q_status = WriteFailed;
return *this;
}
@@ -1057,7 +1069,7 @@ QDataStream &QDataStream::operator<<(qint32 i)
QDataStream &QDataStream::operator<<(qint64 i)
{
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
if (version() < 6) {
quint32 i1 = i & 0xffffffff;
quint32 i2 = i >> 32;
@@ -1066,7 +1078,8 @@ QDataStream &QDataStream::operator<<(qint64 i)
if (!noswap) {
i = qbswap(i);
}
- dev->write((char *)&i, sizeof(qint64));
+ if (dev->write((char *)&i, sizeof(qint64)) != sizeof(qint64))
+ q_status = WriteFailed;
}
return *this;
}
@@ -1086,8 +1099,9 @@ QDataStream &QDataStream::operator<<(qint64 i)
QDataStream &QDataStream::operator<<(bool i)
{
- CHECK_STREAM_PRECOND(*this)
- dev->putChar(qint8(i));
+ CHECK_STREAM_WRITE_PRECOND(*this)
+ if (!dev->putChar(qint8(i)))
+ q_status = WriteFailed;
return *this;
}
@@ -1108,7 +1122,7 @@ QDataStream &QDataStream::operator<<(float f)
return *this;
}
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
float g = f; // fixes float-on-stack problem
if (!noswap) {
union {
@@ -1119,7 +1133,8 @@ QDataStream &QDataStream::operator<<(float f)
x.val2 = qbswap(x.val2);
g = x.val1;
}
- dev->write((char *)&g, sizeof(float));
+ if (dev->write((char *)&g, sizeof(float)) != sizeof(float))
+ q_status = WriteFailed;
return *this;
}
@@ -1141,10 +1156,11 @@ QDataStream &QDataStream::operator<<(double f)
return *this;
}
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
#ifndef Q_DOUBLE_FORMAT
if (noswap) {
- dev->write((char *)&f, sizeof(double));
+ if (dev->write((char *)&f, sizeof(double)) != sizeof(double))
+ q_status = WriteFailed;
} else {
union {
double val1;
@@ -1152,7 +1168,8 @@ QDataStream &QDataStream::operator<<(double f)
} x;
x.val1 = f;
x.val2 = qbswap(x.val2);
- dev->write((char *)&x.val2, sizeof(double));
+ if (dev->write((char *)&x.val2, sizeof(double)) != sizeof(double))
+ q_status = WriteFailed;
}
#else
union {
@@ -1181,7 +1198,8 @@ QDataStream &QDataStream::operator<<(double f)
b[Q_DF(1)] = *p++;
b[Q_DF(0)] = *p;
}
- dev->write(b, 8);
+ if (dev->write(b, 8) != 8)
+ q_status = WriteFailed;
#endif
return *this;
}
@@ -1221,7 +1239,7 @@ QDataStream &QDataStream::operator<<(const char *s)
QDataStream &QDataStream::writeBytes(const char *s, uint len)
{
- CHECK_STREAM_PRECOND(*this)
+ CHECK_STREAM_WRITE_PRECOND(*this)
*this << (quint32)len; // write length specifier
if (len)
writeRawData(s, len);
@@ -1239,8 +1257,11 @@ QDataStream &QDataStream::writeBytes(const char *s, uint len)
int QDataStream::writeRawData(const char *s, int len)
{
- CHECK_STREAM_PRECOND(-1)
- return dev->write(s, len);
+ CHECK_STREAM_WRITE_PRECOND(-1)
+ int ret = dev->write(s, len);
+ if (ret != len)
+ q_status = WriteFailed;
+ return ret;
}
/*!
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index dff172c..d19fcc5 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -85,10 +85,11 @@ public:
Qt_4_4 = 10,
Qt_4_5 = 11,
Qt_4_6 = 12,
- Qt_4_7 = Qt_4_6
-#if QT_VERSION >= 0x040800
-#error Add the datastream version for this Qt version
+ Qt_4_7 = Qt_4_6,
Qt_4_8 = Qt_4_7
+#if QT_VERSION >= 0x040900
+#error Add the datastream version for this Qt version
+ Qt_4_9 = Qt_4_8
#endif
};
@@ -100,7 +101,8 @@ public:
enum Status {
Ok,
ReadPastEnd,
- ReadCorruptData
+ ReadCorruptData,
+ WriteFailed
};
enum FloatingPointPrecision {
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 87d2a61..f463b75 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -137,10 +137,8 @@ public:
inline QNoDebug &nospace() { return *this; }
inline QNoDebug &maybeSpace() { return *this; }
-#ifndef QT_NO_MEMBER_TEMPLATES
template<typename T>
inline QNoDebug &operator<<(const T &) { return *this; }
-#endif
};
Q_CORE_EXPORT_INLINE QDebug qCritical() { return QDebug(QtCriticalMsg); }
@@ -285,11 +283,6 @@ Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); }
inline QNoDebug qDebug() { return QNoDebug(); }
#define qDebug QT_NO_QDEBUG_MACRO
-#ifdef QT_NO_MEMBER_TEMPLATES
-template<typename T>
-inline QNoDebug operator<<(QNoDebug debug, const T &) { return debug; }
-#endif
-
#endif
#if !defined(QT_NO_WARNING_OUTPUT)
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index c589dfe..166513a 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -41,6 +41,7 @@
#include "qplatformdefs.h"
#include "qdir.h"
+#include "qdir_p.h"
#include "qabstractfileengine.h"
#ifndef QT_NO_DEBUG_STREAM
#include "qdebug.h"
@@ -53,6 +54,10 @@
#include "qvector.h"
#include "qalgorithms.h"
#include "qvarlengtharray.h"
+#include "qfilesystementry_p.h"
+#include "qfilesystemmetadata_p.h"
+#include "qfilesystemengine_p.h"
+#include <qstringbuilder.h>
#ifdef QT_BUILD_CORE_LIB
# include "qresource.h"
@@ -81,129 +86,130 @@ static QString driveSpec(const QString &path)
}
//************* QDirPrivate
-class QDirPrivate
- : public QSharedData
-{
-public:
- QDirPrivate(const QString &path,
- const QStringList &nameFilters_ = QStringList(),
- QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase),
- QDir::Filters filters_ = QDir::AllEntries)
- : QSharedData()
- , nameFilters(nameFilters_)
- , sort(sort_)
- , filters(filters_)
+QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, QDir::SortFlags sort_, QDir::Filters filters_)
+ : QSharedData()
+ , nameFilters(nameFilters_)
+ , sort(sort_)
+ , filters(filters_)
#ifdef QT3_SUPPORT
- , filterSepChar(0)
- , matchAllDirs(false)
+ , filterSepChar(0)
+ , matchAllDirs(false)
#endif
- , fileListsInitialized(false)
- {
- setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
-
- bool empty = nameFilters.isEmpty();
- if (!empty) {
- empty = true;
- for (int i = 0; i < nameFilters.size(); ++i) {
- if (!nameFilters.at(i).isEmpty()) {
- empty = false;
- break;
- }
+ , fileListsInitialized(false)
+{
+ setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
+
+ bool empty = nameFilters.isEmpty();
+ if (!empty) {
+ empty = true;
+ for (int i = 0; i < nameFilters.size(); ++i) {
+ if (!nameFilters.at(i).isEmpty()) {
+ empty = false;
+ break;
}
}
- if (empty)
- nameFilters = QStringList(QString::fromLatin1("*"));
}
+ if (empty)
+ nameFilters = QStringList(QString::fromLatin1("*"));
+}
- QDirPrivate(const QDirPrivate &copy)
- : QSharedData(copy)
- , path(copy.path)
- , nameFilters(copy.nameFilters)
- , sort(copy.sort)
- , filters(copy.filters)
+QDirPrivate::QDirPrivate(const QDirPrivate &copy)
+ : QSharedData(copy)
+ , nameFilters(copy.nameFilters)
+ , sort(copy.sort)
+ , filters(copy.filters)
#ifdef QT3_SUPPORT
- , filterSepChar(copy.filterSepChar)
- , matchAllDirs(copy.matchAllDirs)
+ , filterSepChar(copy.filterSepChar)
+ , matchAllDirs(copy.matchAllDirs)
#endif
- , fileListsInitialized(false)
- {
- }
+ , fileListsInitialized(false)
+ , dirEntry(copy.dirEntry)
+ , metaData(copy.metaData)
+{
+}
- bool exists() const
- {
- const QAbstractFileEngine::FileFlags info =
- fileEngine->fileFlags(QAbstractFileEngine::DirectoryType
- | QAbstractFileEngine::ExistsFlag
- | QAbstractFileEngine::Refresh);
- if (!(info & QAbstractFileEngine::DirectoryType))
- return false;
- return info & QAbstractFileEngine::ExistsFlag;
+bool QDirPrivate::exists() const
+{
+ if (fileEngine.isNull()) {
+ QFileSystemEngine::fillMetaData(dirEntry, metaData,
+ QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat
+ return metaData.exists() && metaData.isDirectory();
}
+ const QAbstractFileEngine::FileFlags info =
+ fileEngine->fileFlags(QAbstractFileEngine::DirectoryType
+ | QAbstractFileEngine::ExistsFlag
+ | QAbstractFileEngine::Refresh);
+ if (!(info & QAbstractFileEngine::DirectoryType))
+ return false;
+ return info & QAbstractFileEngine::ExistsFlag;
+}
- void initFileEngine();
- void initFileLists() const;
-
- static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *);
-
- static inline QChar getFilterSepChar(const QString &nameFilter)
- {
- QChar sep(QLatin1Char(';'));
- int i = nameFilter.indexOf(sep, 0);
- if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1)
- sep = QChar(QLatin1Char(' '));
- return sep;
- }
+// static
+inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter)
+{
+ QChar sep(QLatin1Char(';'));
+ int i = nameFilter.indexOf(sep, 0);
+ if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1)
+ sep = QChar(QLatin1Char(' '));
+ return sep;
+}
- static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0)
- {
- if (sep == 0)
- sep = getFilterSepChar(nameFilter);
- QStringList ret = nameFilter.split(sep);
- for (int i = 0; i < ret.count(); ++i)
- ret[i] = ret[i].trimmed();
- return ret;
- }
+// static
+inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar sep)
+{
+ if (sep == 0)
+ sep = getFilterSepChar(nameFilter);
+ QStringList ret = nameFilter.split(sep);
+ for (int i = 0; i < ret.count(); ++i)
+ ret[i] = ret[i].trimmed();
+ return ret;
+}
- inline void setPath(QString p)
- {
- if ((p.endsWith(QLatin1Char('/')) || p.endsWith(QLatin1Char('\\')))
- && p.length() > 1) {
+inline void QDirPrivate::setPath(const QString &path)
+{
+ QString p = QDir::fromNativeSeparators(path);
+ if (p.endsWith(QLatin1Char('/'))
+ && p.length() > 1
#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- if (!(p.length() == 3 && p.at(1) == QLatin1Char(':')))
+ && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter()))
#endif
- p.truncate(p.length() - 1);
- }
-
- path = p;
- initFileEngine();
-
- // set the path to be the qt friendly version so then we can operate on it using just /
- path = fileEngine->fileName(QAbstractFileEngine::DefaultName);
- clearFileLists();
+ ) {
+ p.truncate(p.length() - 1);
}
- inline void clearFileLists() {
- fileListsInitialized = false;
- files.clear();
- fileInfos.clear();
- }
+ dirEntry = QFileSystemEntry(p, QFileSystemEntry::FromInternalPath());
+ metaData.clear();
+ initFileEngine();
+ clearFileLists();
+ absoluteDirEntry = QFileSystemEntry();
+}
- QString path;
- QStringList nameFilters;
- QDir::SortFlags sort;
- QDir::Filters filters;
+inline void QDirPrivate::clearFileLists()
+{
+ fileListsInitialized = false;
+ files.clear();
+ fileInfos.clear();
+}
-#ifdef QT3_SUPPORT
- QChar filterSepChar;
- bool matchAllDirs;
-#endif
+inline void QDirPrivate::resolveAbsoluteEntry() const
+{
+ if (!absoluteDirEntry.isEmpty() || dirEntry.isEmpty())
+ return;
+
+ QString absoluteName;
+ if (fileEngine.isNull()) {
+ if (!dirEntry.isRelative()) {
+ absoluteDirEntry = dirEntry;
+ return;
+ }
- QScopedPointer<QAbstractFileEngine> fileEngine;
+ absoluteName = QFileSystemEngine::absoluteName(dirEntry).filePath();
+ } else {
+ absoluteName = fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
+ }
- mutable bool fileListsInitialized;
- mutable QStringList files;
- mutable QFileInfoList fileInfos;
-};
+ absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(absoluteName), QFileSystemEntry::FromInternalPath());
+}
/* For sorting */
struct QDirSortItem
@@ -315,12 +321,11 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l,
}
}
}
-
-inline void QDirPrivate::initFileLists() const
+inline void QDirPrivate::initFileLists(const QDir &dir) const
{
if (!fileListsInitialized) {
QFileInfoList l;
- QDirIterator it(path, nameFilters, filters);
+ QDirIterator it(dir);
while (it.hasNext()) {
it.next();
l.append(it.fileInfo());
@@ -332,7 +337,7 @@ inline void QDirPrivate::initFileLists() const
inline void QDirPrivate::initFileEngine()
{
- fileEngine.reset(QAbstractFileEngine::create(path));
+ fileEngine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData));
}
/*!
@@ -597,7 +602,7 @@ void QDir::setPath(const QString &path)
QString QDir::path() const
{
const QDirPrivate* d = d_ptr.constData();
- return d->path;
+ return d->dirEntry.filePath();
}
/*!
@@ -611,10 +616,8 @@ QString QDir::path() const
QString QDir::absolutePath() const
{
const QDirPrivate* d = d_ptr.constData();
- QString ret = d->path;
- if (QDir::isRelativePath(ret))
- ret = absoluteFilePath(QString::fromLatin1(""));
- return cleanPath(ret);
+ d->resolveAbsoluteEntry();
+ return d->absoluteDirEntry.filePath();
}
/*!
@@ -635,7 +638,12 @@ QString QDir::absolutePath() const
*/
QString QDir::canonicalPath() const
{
- return cleanPath(d_ptr->fileEngine->fileName(QAbstractFileEngine::CanonicalName));
+ const QDirPrivate* d = d_ptr.constData();
+ if (d->fileEngine.isNull()) {
+ QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData);
+ return answer.filePath();
+ }
+ return d->fileEngine->fileName(QAbstractFileEngine::CanonicalName);
}
/*!
@@ -652,10 +660,7 @@ QString QDir::canonicalPath() const
QString QDir::dirName() const
{
const QDirPrivate* d = d_ptr.constData();
- int pos = d->path.lastIndexOf(QLatin1Char('/'));
- if (pos == -1)
- return d->path;
- return d->path.mid(pos + 1);
+ return d->dirEntry.fileName();
}
/*!
@@ -673,7 +678,7 @@ QString QDir::filePath(const QString &fileName) const
if (isAbsolutePath(fileName))
return QString(fileName);
- QString ret = d->path;
+ QString ret = d->dirEntry.filePath();
if (!fileName.isEmpty()) {
if (!ret.isEmpty() && ret[(int)ret.length()-1] != QLatin1Char('/') && fileName[0] != QLatin1Char('/'))
ret += QLatin1Char('/');
@@ -696,22 +701,12 @@ QString QDir::absoluteFilePath(const QString &fileName) const
if (isAbsolutePath(fileName))
return fileName;
- QString ret;
-#ifndef QT_NO_FSFILEENGINE
- if (isRelativePath(d->path)) //get pwd
- ret = QFSFileEngine::currentPath(fileName);
-#endif
- if (!d->path.isEmpty() && d->path != QLatin1String(".")) {
- if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
- ret += QLatin1Char('/');
- ret += d->path;
- }
- if (!fileName.isEmpty()) {
- if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
- ret += QLatin1Char('/');
- ret += fileName;
- }
- return ret;
+ d->resolveAbsoluteEntry();
+ if (fileName.isEmpty())
+ return d->absoluteDirEntry.filePath();
+ if (!d->absoluteDirEntry.isRoot())
+ return d->absoluteDirEntry.filePath() % QLatin1Char('/') % fileName;
+ return d->absoluteDirEntry.filePath() % fileName;
}
/*!
@@ -723,7 +718,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const
*/
QString QDir::relativeFilePath(const QString &fileName) const
{
- QString dir = absolutePath();
+ QString dir = cleanPath(absolutePath());
QString file = cleanPath(fileName);
if (isRelativePath(file) || isRelativePath(dir))
@@ -778,6 +773,7 @@ QString QDir::relativeFilePath(const QString &fileName) const
return result;
}
+#ifndef QT_NO_DEPRECATED
/*!
\obsolete
@@ -787,6 +783,7 @@ QString QDir::convertSeparators(const QString &pathName)
{
return toNativeSeparators(pathName);
}
+#endif
/*!
\since 4.2
@@ -857,21 +854,22 @@ bool QDir::cd(const QString &dirName)
if (dirName.isEmpty() || dirName == QLatin1String("."))
return true;
- QString newPath = d->path;
+ QString newPath;
if (isAbsolutePath(dirName)) {
newPath = cleanPath(dirName);
} else {
if (isRoot()) {
if (dirName == QLatin1String(".."))
return false;
+ newPath = d->dirEntry.filePath();
} else {
- newPath += QLatin1Char('/');
+ newPath = d->dirEntry.filePath() % QLatin1Char('/');
}
newPath += dirName;
if (dirName.indexOf(QLatin1Char('/')) >= 0
- || d->path == QLatin1String(".")
- || dirName == QLatin1String("..")) {
+ || dirName == QLatin1String("..")
+ || d->dirEntry.filePath() == QLatin1String(".")) {
newPath = cleanPath(newPath);
/*
If newPath starts with .., we convert it to absolute to
@@ -889,7 +887,6 @@ bool QDir::cd(const QString &dirName)
QScopedPointer<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
dir->setPath(newPath);
-
if (!dir->exists())
return false;
@@ -1202,7 +1199,7 @@ void QDir::setSorting(SortFlags sort)
uint QDir::count() const
{
const QDirPrivate* d = d_ptr.constData();
- d->initFileLists();
+ d->initFileLists(*this);
return d->files.count();
}
@@ -1216,7 +1213,7 @@ uint QDir::count() const
QString QDir::operator[](int pos) const
{
const QDirPrivate* d = d_ptr.constData();
- d->initFileLists();
+ d->initFileLists(*this);
return d->files[pos];
}
@@ -1299,12 +1296,12 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,
sort = d->sort;
if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) {
- d->initFileLists();
+ d->initFileLists(*this);
return d->files;
}
QFileInfoList l;
- QDirIterator it(d->path, nameFilters, filters);
+ QDirIterator it(d->dirEntry.filePath(), nameFilters, filters);
while (it.hasNext()) {
it.next();
l.append(it.fileInfo());
@@ -1345,12 +1342,12 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter
sort = d->sort;
if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) {
- d->initFileLists();
+ d->initFileLists(*this);
return d->fileInfos;
}
QFileInfoList l;
- QDirIterator it(d->path, nameFilters, filters);
+ QDirIterator it(d->dirEntry.filePath(), nameFilters, filters);
while (it.hasNext()) {
it.next();
l.append(it.fileInfo());
@@ -1365,8 +1362,11 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter
Returns true on success; otherwise returns false.
+ If the directory already exists when this function is called, it will return false.
+
\sa rmdir()
*/
+// ### Qt5: behaviour when directory already exists should be made consistent for mkdir and mkpath
bool QDir::mkdir(const QString &dirName) const
{
const QDirPrivate* d = d_ptr.constData();
@@ -1377,6 +1377,8 @@ bool QDir::mkdir(const QString &dirName) const
}
QString fn = filePath(dirName);
+ if (d->fileEngine.isNull())
+ return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false);
return d->fileEngine->mkdir(fn, false);
}
@@ -1399,6 +1401,9 @@ bool QDir::rmdir(const QString &dirName) const
}
QString fn = filePath(dirName);
+ if (d->fileEngine.isNull())
+ return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false);
+
return d->fileEngine->rmdir(fn, false);
}
@@ -1410,8 +1415,11 @@ bool QDir::rmdir(const QString &dirName) const
Returns true if successful; otherwise returns false.
+ If the path already exists when this function is called, it will return true.
+
\sa rmpath()
*/
+// ### Qt5: behaviour when directory already exists should be made consistent for mkdir and mkpath
bool QDir::mkpath(const QString &dirPath) const
{
const QDirPrivate* d = d_ptr.constData();
@@ -1422,6 +1430,8 @@ bool QDir::mkpath(const QString &dirPath) const
}
QString fn = filePath(dirPath);
+ if (d->fileEngine.isNull())
+ return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->mkdir(fn, true);
}
@@ -1446,6 +1456,8 @@ bool QDir::rmpath(const QString &dirPath) const
}
QString fn = filePath(dirPath);
+ if (d->fileEngine.isNull())
+ return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->rmdir(fn, true);
}
@@ -1462,6 +1474,13 @@ bool QDir::isReadable() const
{
const QDirPrivate* d = d_ptr.constData();
+ if (d->fileEngine.isNull()) {
+ if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
+ QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission);
+
+ return (d->metaData.permissions() & QFile::ReadUser) != 0;
+ }
+
const QAbstractFileEngine::FileFlags info =
d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType
| QAbstractFileEngine::PermsMask);
@@ -1500,6 +1519,8 @@ bool QDir::exists() const
*/
bool QDir::isRoot() const
{
+ if (d_ptr->fileEngine.isNull())
+ return d_ptr->dirEntry.isRoot();
return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag;
}
@@ -1530,6 +1551,8 @@ bool QDir::isRoot() const
*/
bool QDir::isRelative() const
{
+ if (d_ptr->fileEngine.isNull())
+ return d_ptr->dirEntry.isRelative();
return d_ptr->fileEngine->isRelativePath();
}
@@ -1541,20 +1564,23 @@ bool QDir::isRelative() const
\sa isAbsolute() isAbsolutePath() isRelative() cleanPath()
*/
-bool QDir::makeAbsolute() // ### What do the return values signify?
+bool QDir::makeAbsolute()
{
- QString absolutePath = d_ptr.constData()->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
- if (QDir::isRelativePath(absolutePath))
- return false;
-
- QScopedPointer<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
- dir->setPath(absolutePath);
-
- d_ptr = dir.take();
-
- if (!(d_ptr->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType))
- return false;
+ const QDirPrivate *d = d_ptr.constData();
+ QScopedPointer<QDirPrivate> dir;
+ if (!d->fileEngine.isNull()) {
+ QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
+ if (QDir::isRelativePath(absolutePath))
+ return false;
+ dir.reset(new QDirPrivate(*d_ptr.constData()));
+ dir->setPath(absolutePath);
+ } else { // native FS
+ d->resolveAbsoluteEntry();
+ dir.reset(new QDirPrivate(*d_ptr.constData()));
+ dir->setPath(d->absoluteDirEntry.filePath());
+ }
+ d_ptr = dir.take(); // actually detach
return true;
}
@@ -1574,17 +1600,24 @@ bool QDir::operator==(const QDir &dir) const
if (d == other)
return true;
- if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive())
- return false;
+ Qt::CaseSensitivity sensitive;
+ if (d->fileEngine.isNull() || other->fileEngine.isNull()) {
+ if (d->fileEngine.data() != other->fileEngine.data()) // one is native, the other is a custom file-engine
+ return false;
+
+ sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ } else {
+ if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive())
+ return false;
+ sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ }
+
if (d->filters == other->filters
&& d->sort == other->sort
&& d->nameFilters == other->nameFilters) {
- QString dir1 = absolutePath(), dir2 = dir.absolutePath();
- if (!other->fileEngine->caseSensitive())
- return (dir1.toLower() == dir2.toLower());
-
- return (dir1 == dir2);
-
+ d->resolveAbsoluteEntry();
+ other->resolveAbsoluteEntry();
+ return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0;
}
return false;
}
@@ -1733,12 +1766,7 @@ QChar QDir::separator()
*/
bool QDir::setCurrent(const QString &path)
{
-#ifdef QT_NO_FSFILEENGINE
- Q_UNUSED(path);
- return false;
-#else
- return QFSFileEngine::setCurrentPath(path);
-#endif
+ return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path));
}
/*!
@@ -1759,11 +1787,7 @@ bool QDir::setCurrent(const QString &path)
*/
QString QDir::currentPath()
{
-#ifdef QT_NO_FSFILEENGINE
- return QString();
-#else
- return QFSFileEngine::currentPath();
-#endif
+ return QFileSystemEngine::currentPath().filePath();
}
/*!
@@ -1821,11 +1845,7 @@ QString QDir::currentPath()
*/
QString QDir::homePath()
{
-#ifdef QT_NO_FSFILEENGINE
- return QString();
-#else
- return cleanPath(QFSFileEngine::homePath());
-#endif
+ return QFileSystemEngine::homePath();
}
/*!
@@ -1854,7 +1874,8 @@ QString QDir::homePath()
/*!
Returns the absolute path of the system's temporary directory.
- On Unix/Linux systems this is usually \c{/tmp}; on Windows this is
+ On Unix/Linux systems this is the path in the \c TMPDIR environment
+ variable or \c{/tmp} if \c TMPDIR is not defined. On Windows this is
usually the path in the \c TEMP or \c TMP environment
variable. Whether a directory separator is added to the end or
not, depends on the operating system.
@@ -1863,11 +1884,7 @@ QString QDir::homePath()
*/
QString QDir::tempPath()
{
-#ifdef QT_NO_FSFILEENGINE
- return QString();
-#else
- return cleanPath(QFSFileEngine::tempPath());
-#endif
+ return QFileSystemEngine::tempPath();
}
/*!
@@ -1894,11 +1911,7 @@ QString QDir::tempPath()
*/
QString QDir::rootPath()
{
-#ifdef QT_NO_FSFILEENGINE
- return QString();
-#else
- return QFSFileEngine::rootPath();
-#endif
+ return QFileSystemEngine::rootPath();
}
/*!
@@ -2095,6 +2108,7 @@ bool QDir::isRelativePath(const QString &path)
void QDir::refresh() const
{
QDirPrivate *d = const_cast<QDir*>(this)->d_ptr.data();
+ d->metaData.clear();
d->initFileEngine();
d->clearFileLists();
}
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e090b18..1804940 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -128,6 +128,10 @@ public:
QDir &operator=(const QDir &);
QDir &operator=(const QString &path);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QDir &operator=(QDir &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
void setPath(const QString &path);
QString path() const;
diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h
new file mode 100644
index 0000000..7f77a84
--- /dev/null
+++ b/src/corelib/io/qdir_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QDIR_PRIVATE_H
+#define QDIR_PRIVATE_H
+
+#include "qfilesystementry_p.h"
+#include "qfilesystemmetadata_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDirPrivate : public QSharedData
+{
+public:
+ QDirPrivate(const QString &path, const QStringList &nameFilters_ = QStringList(),
+ QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase),
+ QDir::Filters filters_ = QDir::AllEntries);
+
+ QDirPrivate(const QDirPrivate &copy);
+
+ bool exists() const;
+
+ void initFileEngine();
+ void initFileLists(const QDir &dir) const;
+
+ static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *);
+
+ static inline QChar getFilterSepChar(const QString &nameFilter);
+
+ static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0);
+
+ inline void setPath(const QString &path);
+
+ inline void clearFileLists();
+
+ inline void resolveAbsoluteEntry() const;
+
+ QStringList nameFilters;
+ QDir::SortFlags sort;
+ QDir::Filters filters;
+
+#ifdef QT3_SUPPORT
+ QChar filterSepChar;
+ bool matchAllDirs;
+#endif
+
+ QScopedPointer<QAbstractFileEngine> fileEngine;
+
+ mutable bool fileListsInitialized;
+ mutable QStringList files;
+ mutable QFileInfoList fileInfos;
+
+ QFileSystemEntry dirEntry;
+ mutable QFileSystemEntry absoluteDirEntry;
+ mutable QFileSystemMetaData metaData;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 3b4adc3..c7e56bd 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -90,6 +90,7 @@
*/
#include "qdiriterator.h"
+#include "qdir_p.h"
#include "qabstractfileengine.h"
@@ -97,36 +98,41 @@
#include <QtCore/qstack.h>
#include <QtCore/qvariant.h>
+#include <QtCore/private/qfilesystemiterator_p.h>
+#include <QtCore/private/qfilesystementry_p.h>
+#include <QtCore/private/qfilesystemmetadata_p.h>
+#include <QtCore/private/qfilesystemengine_p.h>
+#include <QtCore/qfsfileengine.h>
+#include <QtCore/private/qfileinfo_p.h>
+
QT_BEGIN_NAMESPACE
-class QDirIteratorPrivateIteratorStack : public QStack<QAbstractFileEngineIterator *>
+template <class Iterator>
+class QDirIteratorPrivateIteratorStack : public QStack<Iterator *>
{
public:
- ~QDirIteratorPrivateIteratorStack();
+ ~QDirIteratorPrivateIteratorStack()
+ {
+ qDeleteAll(*this);
+ }
};
-QDirIteratorPrivateIteratorStack::~QDirIteratorPrivateIteratorStack()
-{
- qDeleteAll(*this);
-}
-
-
class QDirIteratorPrivate
{
public:
- QDirIteratorPrivate(const QString &path, const QStringList &nameFilters,
- QDir::Filters filters, QDirIterator::IteratorFlags flags);
- ~QDirIteratorPrivate();
+ QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters,
+ QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine = true);
void advance();
+ bool entryMatches(const QString & fileName, const QFileInfo &fileInfo);
void pushDirectory(const QFileInfo &fileInfo);
void checkAndPushDirectory(const QFileInfo &);
bool matchesFilters(const QString &fileName, const QFileInfo &fi) const;
QScopedPointer<QAbstractFileEngine> engine;
- const QString path;
+ QFileSystemEntry dirEntry;
const QStringList nameFilters;
const QDir::Filters filters;
const QDirIterator::IteratorFlags iteratorFlags;
@@ -135,23 +141,24 @@ public:
QVector<QRegExp> nameRegExps;
#endif
- QDirIteratorPrivateIteratorStack fileEngineIterators;
+ QDirIteratorPrivateIteratorStack<QAbstractFileEngineIterator> fileEngineIterators;
+#ifndef QT_NO_FILESYSTEMITERATOR
+ QDirIteratorPrivateIteratorStack<QFileSystemIterator> nativeIterators;
+#endif
+
QFileInfo currentFileInfo;
QFileInfo nextFileInfo;
// Loop protection
QSet<QString> visitedLinks;
-
- QDirIterator *q;
};
/*!
\internal
*/
-QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList &nameFilters,
- QDir::Filters filters, QDirIterator::IteratorFlags flags)
- : engine(QAbstractFileEngine::create(path))
- , path(path)
+QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters,
+ QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine)
+ : dirEntry(entry)
, nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters)
, filters(QDir::NoFilter == filters ? QDir::AllEntries : filters)
, iteratorFlags(flags)
@@ -164,22 +171,19 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList
(filters & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive,
QRegExp::Wildcard));
#endif
+ QFileSystemMetaData metaData;
+ if (resolveEngine)
+ engine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData));
+ QFileInfo fileInfo(new QFileInfoPrivate(dirEntry, metaData));
// Populate fields for hasNext() and next()
- pushDirectory(QFileInfo(path));
+ pushDirectory(fileInfo);
advance();
}
/*!
\internal
*/
-QDirIteratorPrivate::~QDirIteratorPrivate()
-{
-}
-
-/*!
- \internal
-*/
void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
{
QString path = fileInfo.filePath();
@@ -201,34 +205,67 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
} else {
// No iterator; no entry list.
}
+ } else {
+#ifndef QT_NO_FILESYSTEMITERATOR
+ QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry,
+ filters, nameFilters, iteratorFlags);
+ nativeIterators << it;
+#endif
}
}
-/*!
- \internal
-*/
-void QDirIteratorPrivate::advance()
+inline bool QDirIteratorPrivate::entryMatches(const QString & fileName, const QFileInfo &fileInfo)
{
- while (!fileEngineIterators.isEmpty()) {
+ checkAndPushDirectory(fileInfo);
- // Find the next valid iterator that matches the filters.
- while (fileEngineIterators.top()->hasNext()) {
- QAbstractFileEngineIterator *it = fileEngineIterators.top();
- it->next();
+ if (matchesFilters(fileName, fileInfo)) {
+ currentFileInfo = nextFileInfo;
+ nextFileInfo = fileInfo;
- const QFileInfo info = it->currentFileInfo();
- checkAndPushDirectory(it->currentFileInfo());
+ //We found a matching entry.
+ return true;
+ }
- if (matchesFilters(it->currentFileName(), info)) {
- currentFileInfo = nextFileInfo;
- nextFileInfo = info;
+ return false;
+}
- //We found a matching entry.
- return;
+/*!
+ \internal
+*/
+void QDirIteratorPrivate::advance()
+{
+ if (engine) {
+ while (!fileEngineIterators.isEmpty()) {
+ // Find the next valid iterator that matches the filters.
+ QAbstractFileEngineIterator *it;
+ while (it = fileEngineIterators.top(), it->hasNext()) {
+ it->next();
+ if (entryMatches(it->currentFileName(), it->currentFileInfo()))
+ return;
}
+
+ fileEngineIterators.pop();
+ delete it;
}
+ } else {
+#ifndef QT_NO_FILESYSTEMITERATOR
+ QFileSystemEntry nextEntry;
+ QFileSystemMetaData nextMetaData;
+
+ while (!nativeIterators.isEmpty()) {
+ // Find the next valid iterator that matches the filters.
+ QFileSystemIterator *it;
+ while (it = nativeIterators.top(), it->advance(nextEntry, nextMetaData)) {
+ QFileInfo info(new QFileInfoPrivate(nextEntry, nextMetaData));
+
+ if (entryMatches(nextEntry.fileName(), info))
+ return;
+ }
- delete fileEngineIterators.pop();
+ nativeIterators.pop();
+ delete it;
+ }
+#endif
}
currentFileInfo = nextFileInfo;
@@ -262,7 +299,8 @@ void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo)
return;
// Stop link loops
- if (visitedLinks.contains(fileInfo.canonicalFilePath()))
+ if (!visitedLinks.isEmpty() &&
+ visitedLinks.contains(fileInfo.canonicalFilePath()))
return;
pushDirectory(fileInfo);
@@ -373,9 +411,11 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
\sa hasNext(), next(), IteratorFlags
*/
QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags)
- : d(new QDirIteratorPrivate(dir.path(), dir.nameFilters(), dir.filter(), flags))
{
- d->q = this;
+ // little trick to get hold of the QDirPrivate while there is no API on QDir to give it to us
+ class MyQDir : public QDir { public: const QDirPrivate *priv() const { return d_ptr.constData(); } };
+ const QDirPrivate *other = static_cast<const MyQDir*>(&dir)->priv();
+ d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, !other->fileEngine.isNull()));
}
/*!
@@ -392,9 +432,8 @@ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags)
\sa hasNext(), next(), IteratorFlags
*/
QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags)
- : d(new QDirIteratorPrivate(path, QStringList(), filters, flags))
+ : d(new QDirIteratorPrivate(QFileSystemEntry(path), QStringList(), filters, flags))
{
- d->q = this;
}
/*!
@@ -410,9 +449,8 @@ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorF
\sa hasNext(), next(), IteratorFlags
*/
QDirIterator::QDirIterator(const QString &path, IteratorFlags flags)
- : d(new QDirIteratorPrivate(path, QStringList(), QDir::NoFilter, flags))
+ : d(new QDirIteratorPrivate(QFileSystemEntry(path), QStringList(), QDir::NoFilter, flags))
{
- d->q = this;
}
/*!
@@ -430,9 +468,8 @@ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags)
*/
QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters,
QDir::Filters filters, IteratorFlags flags)
- : d(new QDirIteratorPrivate(path, nameFilters, filters, flags))
+ : d(new QDirIteratorPrivate(QFileSystemEntry(path), nameFilters, filters, flags))
{
- d->q = this;
}
/*!
@@ -466,7 +503,14 @@ QString QDirIterator::next()
*/
bool QDirIterator::hasNext() const
{
- return !d->fileEngineIterators.isEmpty();
+ if (d->engine)
+ return !d->fileEngineIterators.isEmpty();
+ else
+#ifndef QT_NO_FILESYSTEMITERATOR
+ return !d->nativeIterators.isEmpty();
+#else
+ return false;
+#endif
}
/*!
@@ -509,7 +553,7 @@ QFileInfo QDirIterator::fileInfo() const
*/
QString QDirIterator::path() const
{
- return d->path;
+ return d->dirEntry.filePath();
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index d0552b6..0ade573 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -48,6 +48,7 @@
#include "qfileinfo.h"
#include "private/qiodevice_p.h"
#include "private/qfile_p.h"
+#include "private/qsystemerror_p.h"
#if defined(QT_BUILD_CORE_LIB)
# include "qcoreapplication.h"
#endif
@@ -102,7 +103,7 @@ QFilePrivate::~QFilePrivate()
}
bool
-QFilePrivate::openExternalFile(int flags, int fd)
+QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags)
{
#ifdef QT_NO_FSFILEENGINE
Q_UNUSED(flags);
@@ -112,14 +113,13 @@ QFilePrivate::openExternalFile(int flags, int fd)
delete fileEngine;
fileEngine = 0;
QFSFileEngine *fe = new QFSFileEngine;
- fe->setFileName(fileName);
fileEngine = fe;
- return fe->open(QIODevice::OpenMode(flags), fd);
+ return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
#endif
}
bool
-QFilePrivate::openExternalFile(int flags, FILE *fh)
+QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags)
{
#ifdef QT_NO_FSFILEENGINE
Q_UNUSED(flags);
@@ -129,12 +129,28 @@ QFilePrivate::openExternalFile(int flags, FILE *fh)
delete fileEngine;
fileEngine = 0;
QFSFileEngine *fe = new QFSFileEngine;
- fe->setFileName(fileName);
fileEngine = fe;
- return fe->open(QIODevice::OpenMode(flags), fh);
+ return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
#endif
}
+#ifdef Q_OS_SYMBIAN
+bool QFilePrivate::openExternalFile(int flags, const RFile &f, QFile::FileHandleFlags handleFlags)
+{
+#ifdef QT_NO_FSFILEENGINE
+ Q_UNUSED(flags);
+ Q_UNUSED(fh);
+ return false;
+#else
+ delete fileEngine;
+ fileEngine = 0;
+ QFSFileEngine *fe = new QFSFileEngine;
+ fileEngine = fe;
+ return fe->open(QIODevice::OpenMode(flags), f, handleFlags);
+#endif
+}
+#endif
+
inline bool QFilePrivate::ensureFlushed() const
{
// This function ensures that the write buffer has been flushed (const
@@ -340,6 +356,20 @@ QFilePrivate::setError(QFile::FileError err, int errNum)
\snippet doc/src/snippets/ntfsp.cpp 1
*/
+/*!
+ \enum QFile::FileHandleFlag
+
+ This enum is used when opening a file to specify additional
+ options which only apply to files and not to a generic
+ QIODevice.
+
+ \value AutoCloseHandle The file handle passed into open() should be
+ closed by close(), the default behaviour is that close just flushes
+ the file and the app is responsible for closing the file handle. When
+ opening a file by name, this flag is ignored as Qt always "owns" the
+ file handle and must close it.
+ */
+
#ifdef QT3_SUPPORT
/*!
\typedef QFile::PermissionSpec
@@ -992,8 +1022,14 @@ bool QFile::open(OpenMode mode)
return false;
}
+#ifdef Q_OS_SYMBIAN
+ // For symbian, the unbuffered flag is used to control write-behind cache behaviour
+ if (fileEngine()->open(mode))
+#else
// QIODevice provides the buffering, so there's no need to request it from the file engine.
- if (fileEngine()->open(mode | QIODevice::Unbuffered)) {
+ if (fileEngine()->open(mode | QIODevice::Unbuffered))
+#endif
+ {
QIODevice::open(mode);
if (mode & Append)
seek(size());
@@ -1051,8 +1087,57 @@ bool QFile::open(OpenMode mode)
\snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 4
*/
+// ### Qt5: merge this into new overload with a default parameter
bool QFile::open(FILE *fh, OpenMode mode)
{
+ return open(fh, mode, DontCloseHandle);
+}
+
+/*!
+ \overload
+
+ Opens the existing file handle \a fh in the given \a mode.
+ Returns true if successful; otherwise returns false.
+
+ Example:
+ \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 3
+
+ When a QFile is opened using this function, behaviour of close() is
+ controlled by the AutoCloseHandle flag.
+ If AutoCloseHandle is specified, and this function succeeds,
+ then calling close() closes the adopted handle.
+ Otherwise, close() does not actually close the file, but only flushes it.
+
+ \bold{Warning:}
+ \list 1
+ \o If \a fh does not refer to a regular file, e.g., it is \c stdin,
+ \c stdout, or \c stderr, you may not be able to seek(). size()
+ returns \c 0 in those cases. See QIODevice::isSequential() for
+ more information.
+ \o Since this function opens the file without specifying the file name,
+ you cannot use this QFile with a QFileInfo.
+ \endlist
+
+ \note For Windows CE you may not be able to call resize().
+
+ \sa close(), {qmake Variable Reference#CONFIG}{qmake Variable Reference}
+
+ \bold{Note for the Windows Platform}
+
+ \a fh must be opened in binary mode (i.e., the mode string must contain
+ 'b', as in "rb" or "wb") when accessing files and other random-access
+ devices. Qt will translate the end-of-line characters if you pass
+ QIODevice::Text to \a mode. Sequential devices, such as stdin and stdout,
+ are unaffected by this limitation.
+
+ You need to enable support for console applications in order to use the
+ stdin, stdout and stderr streams at the console. To do this, add the
+ following declaration to your application's project file:
+
+ \snippet doc/src/snippets/code/src_corelib_io_qfile.cpp 4
+*/
+bool QFile::open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
+{
Q_D(QFile);
if (isOpen()) {
qWarning("QFile::open: File (%s) already open", qPrintable(fileName()));
@@ -1065,7 +1150,7 @@ bool QFile::open(FILE *fh, OpenMode mode)
qWarning("QFile::open: File access not specified");
return false;
}
- if(d->openExternalFile(mode, fh)) {
+ if (d->openExternalFile(mode, fh, handleFlags)) {
QIODevice::open(mode);
if (mode & Append) {
seek(size());
@@ -1111,8 +1196,44 @@ bool QFile::open(FILE *fh, OpenMode mode)
\sa close()
*/
+// ### Qt5: merge this into new overload with a default parameter
bool QFile::open(int fd, OpenMode mode)
{
+ return open(fd, mode, DontCloseHandle);
+}
+
+/*!
+ \overload
+
+ Opens the existing file descriptor \a fd in the given \a mode.
+ Returns true if successful; otherwise returns false.
+
+ When a QFile is opened using this function, behaviour of close() is
+ controlled by the AutoCloseHandle flag.
+ If AutoCloseHandle is specified, and this function succeeds,
+ then calling close() closes the adopted handle.
+ Otherwise, close() does not actually close the file, but only flushes it.
+
+ The QFile that is opened using this function is automatically set
+ to be in raw mode; this means that the file input/output functions
+ are slow. If you run into performance issues, you should try to
+ use one of the other open functions.
+
+ \warning If \a fd is not a regular file, e.g, it is 0 (\c stdin),
+ 1 (\c stdout), or 2 (\c stderr), you may not be able to seek(). In
+ those cases, size() returns \c 0. See QIODevice::isSequential()
+ for more information.
+
+ \warning For Windows CE you may not be able to call seek(), setSize(),
+ fileTime(). size() returns \c 0.
+
+ \warning Since this function opens the file without specifying the file name,
+ you cannot use this QFile with a QFileInfo.
+
+ \sa close()
+*/
+bool QFile::open(int fd, OpenMode mode, FileHandleFlags handleFlags)
+{
Q_D(QFile);
if (isOpen()) {
qWarning("QFile::open: File (%s) already open", qPrintable(fileName()));
@@ -1125,7 +1246,7 @@ bool QFile::open(int fd, OpenMode mode)
qWarning("QFile::open: File access not specified");
return false;
}
- if(d->openExternalFile(mode, fd)) {
+ if (d->openExternalFile(mode, fd, handleFlags)) {
QIODevice::open(mode);
if (mode & Append) {
seek(size());
@@ -1139,6 +1260,63 @@ bool QFile::open(int fd, OpenMode mode)
return false;
}
+#ifdef Q_OS_SYMBIAN
+/*!
+ \overload
+
+ Opens the existing file object \a f in the given \a mode.
+ Returns true if successful; otherwise returns false.
+
+ When a QFile is opened using this function, behaviour of close() is
+ controlled by the AutoCloseHandle flag.
+ If AutoCloseHandle is specified, and this function succeeds,
+ then calling close() closes the adopted handle.
+ Otherwise, close() does not actually close the file, but only flushes it.
+
+ \warning If the file handle is adopted from another process,
+ you may not be able to use this QFile with a QFileInfo.
+
+ \sa close()
+*/
+bool QFile::open(const RFile &f, OpenMode mode, FileHandleFlags handleFlags)
+{
+ Q_D(QFile);
+ if (isOpen()) {
+ qWarning("QFile::open: File (%s) already open", qPrintable(fileName()));
+ return false;
+ }
+ if (mode & Append)
+ mode |= WriteOnly;
+ unsetError();
+ if ((mode & (ReadOnly | WriteOnly)) == 0) {
+ qWarning("QFile::open: File access not specified");
+ return false;
+ }
+ if (d->openExternalFile(mode, f, handleFlags)) {
+ bool ok = QIODevice::open(mode);
+ if (ok) {
+ if (mode & Append) {
+ ok = seek(size());
+ } else {
+ qint64 pos = 0;
+ TInt err;
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ err = static_cast<const RFile64&>(f).Seek(ESeekCurrent, pos);
+#else
+ TInt pos32 = 0;
+ err = f.Seek(ESeekCurrent, pos32);
+ pos = pos32;
+#endif
+ ok = ok && (err == KErrNone);
+ ok = ok && seek(pos);
+ }
+ }
+ return ok;
+ }
+ return false;
+}
+#endif
+
/*!
Returns the file handle of the file.
@@ -1223,6 +1401,7 @@ bool QFile::unmap(uchar *address)
d->setError(d->fileEngine->error(), d->fileEngine->errorString());
return success;
}
+ d->setError(PermissionsError, tr("No file engine available or engine does not support UnMapExtension"));
return false;
}
@@ -1477,7 +1656,17 @@ bool QFile::atEnd() const
}
/*!
- \reimp
+ For random-access devices, this function sets the current position
+ to \a pos, returning true on success, or false if an error occurred.
+ For sequential devices, the default behavior is to do nothing and
+ return false.
+
+ Seeking beyond the end of a file:
+ If the position is beyond the end of a file, then seek() shall not
+ immediately extend the file. If a write is performed at this position,
+ then the file shall be extended. The content of the file between the
+ previous end of file and the newly written data is UNDEFINED and
+ varies between platforms and file systems.
*/
bool QFile::seek(qint64 off)
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index 9bfcfde..4183534 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -45,6 +45,9 @@
#include <QtCore/qiodevice.h>
#include <QtCore/qstring.h>
#include <stdio.h>
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
#ifdef open
#error qfile.h must be included before any header file that defines open
@@ -97,6 +100,12 @@ public:
};
Q_DECLARE_FLAGS(Permissions, Permission)
+ enum FileHandleFlag {
+ AutoCloseHandle = 0x0001,
+ DontCloseHandle = 0
+ };
+ Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)
+
QFile();
QFile(const QString &name);
#ifndef QT_NO_QOBJECT
@@ -145,6 +154,11 @@ public:
bool open(OpenMode flags);
bool open(FILE *f, OpenMode flags);
bool open(int fd, OpenMode flags);
+#ifdef Q_OS_SYMBIAN
+ bool open(const RFile &f, OpenMode flags, FileHandleFlags handleFlags = DontCloseHandle);
+#endif
+ bool open(FILE *f, OpenMode ioFlags, FileHandleFlags handleFlags);
+ bool open(int fd, OpenMode ioFlags, FileHandleFlags handleFlags);
virtual void close();
qint64 size() const;
diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h
index abe3db3..d647c95 100644
--- a/src/corelib/io/qfile_p.h
+++ b/src/corelib/io/qfile_p.h
@@ -67,8 +67,11 @@ protected:
QFilePrivate();
~QFilePrivate();
- bool openExternalFile(int flags, int fd);
- bool openExternalFile(int flags, FILE *fh);
+ bool openExternalFile(int flags, int fd, QFile::FileHandleFlags handleFlags);
+ bool openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handleFlags);
+#ifdef Q_OS_SYMBIAN
+ bool openExternalFile(int flags, const RFile& f, QFile::FileHandleFlags handleFlags);
+#endif
QString fileName;
mutable QAbstractFileEngine *fileEngine;
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 17160f4..6b9c82c 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -51,7 +51,47 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
{
if (cache_enabled && !fileNames[(int)name].isNull())
return fileNames[(int)name];
- QString ret = fileEngine->fileName(name);
+
+ QString ret;
+ if (fileEngine == 0) { // local file; use the QFileSystemEngine directly
+ switch (name) {
+ case QAbstractFileEngine::CanonicalName:
+ case QAbstractFileEngine::CanonicalPathName: {
+ QFileSystemEntry entry = QFileSystemEngine::canonicalName(fileEntry, metaData);
+ if (cache_enabled) { // be smart and store both
+ fileNames[QAbstractFileEngine::CanonicalName] = entry.filePath();
+ fileNames[QAbstractFileEngine::CanonicalPathName] = entry.path();
+ }
+ if (name == QAbstractFileEngine::CanonicalName)
+ ret = entry.filePath();
+ else
+ ret = entry.path();
+ break;
+ }
+ case QAbstractFileEngine::LinkName:
+ ret = QFileSystemEngine::getLinkTarget(fileEntry, metaData).filePath();
+ break;
+ case QAbstractFileEngine::BundleName:
+ ret = QFileSystemEngine::bundleName(fileEntry);
+ break;
+ case QAbstractFileEngine::AbsoluteName:
+ case QAbstractFileEngine::AbsolutePathName: {
+ QFileSystemEntry entry = QFileSystemEngine::absoluteName(fileEntry);
+ if (cache_enabled) { // be smart and store both
+ fileNames[QAbstractFileEngine::AbsoluteName] = entry.filePath();
+ fileNames[QAbstractFileEngine::AbsolutePathName] = entry.path();
+ }
+ if (name == QAbstractFileEngine::AbsoluteName)
+ ret = entry.filePath();
+ else
+ ret = entry.path();
+ break;
+ }
+ default: break;
+ }
+ } else {
+ ret = fileEngine->fileName(name);
+ }
if (ret.isNull())
ret = QLatin1String("");
if (cache_enabled)
@@ -63,7 +103,19 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const
{
if (cache_enabled && !fileOwners[(int)own].isNull())
return fileOwners[(int)own];
- QString ret = fileEngine->owner(own);
+ QString ret;
+ if (fileEngine == 0) {
+ switch (own) {
+ case QAbstractFileEngine::OwnerUser:
+ ret = QFileSystemEngine::resolveUserName(fileEntry, metaData);
+ break;
+ case QAbstractFileEngine::OwnerGroup:
+ ret = QFileSystemEngine::resolveGroupName(fileEntry, metaData);
+ break;
+ }
+ } else {
+ ret = fileEngine->owner(own);
+ }
if (ret.isNull())
ret = QLatin1String("");
if (cache_enabled)
@@ -73,6 +125,7 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const
uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const
{
+ Q_ASSERT(fileEngine); // should never be called when using the native FS
// We split the testing into tests for for LinkType, BundleType, PermsMask
// and the rest.
// Tests for file permissions on Windows can be slow, expecially on network
@@ -133,6 +186,7 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons
QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const
{
+ Q_ASSERT(fileEngine); // should never be called when using the native FS
if (!cache_enabled)
clearFlags();
uint cf;
@@ -237,6 +291,13 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
*/
/*!
+ \internal
+*/
+QFileInfo::QFileInfo(QFileInfoPrivate *p) : d_ptr(p)
+{
+}
+
+/*!
Constructs an empty QFileInfo object.
Note that an empty QFileInfo object contain no file reference.
@@ -330,23 +391,22 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const
return true;
if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
return false;
- if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
- return false;
- if (fileinfo.size() == size()) { //if the size isn't the same...
- QString file1 = canonicalFilePath(),
- file2 = fileinfo.canonicalFilePath();
- if (file1.length() == file2.length()) {
- if (!fileinfo.d_ptr->fileEngine->caseSensitive()) {
- for (int i = 0; i < file1.length(); i++) {
- if (file1.at(i).toLower() != file2.at(i).toLower())
- return false;
- }
- return true;
- }
- return (file1 == file2);
- }
+ Qt::CaseSensitivity sensitive;
+ if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
+ if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
+ return false;
+
+ sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ } else {
+ if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
+ return false;
+ sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
}
- return false;
+
+ if (fileinfo.size() != size()) //if the size isn't the same...
+ return false;
+
+ return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
/*!
@@ -502,7 +562,7 @@ QString QFileInfo::absolutePath() const
if (d->isDefaultConstructed) {
return QLatin1String("");
- } else if (d->fileName.isEmpty()) {
+ } else if (d->fileEntry.isEmpty()) {
qWarning("QFileInfo::absolutePath: Constructed with empty filename");
return QLatin1String("");
}
@@ -539,7 +599,7 @@ QString QFileInfo::path() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- return d->getFileName(QAbstractFileEngine::PathName);
+ return d->fileEntry.path();
}
/*!
@@ -563,6 +623,8 @@ bool QFileInfo::isRelative() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return true;
+ if (d->fileEngine == 0)
+ return d->fileEntry.isRelative();
return d->fileEngine->isRelativePath();
}
@@ -576,12 +638,10 @@ bool QFileInfo::isRelative() const
bool QFileInfo::makeAbsolute()
{
if (d_ptr.constData()->isDefaultConstructed
- || !d_ptr.constData()->fileEngine->isRelativePath())
+ || !d_ptr.constData()->fileEntry.isRelative())
return false;
- QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName);
- // QSharedDataPointer::operator->() will detach.
- setFile(absFileName);
+ setFile(absoluteFilePath());
return true;
}
@@ -596,6 +656,11 @@ bool QFileInfo::exists() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute);
+ return d->metaData.exists();
+ }
return d->getFileFlags(QAbstractFileEngine::ExistsFlag);
}
@@ -623,7 +688,7 @@ QString QFileInfo::filePath() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- return d->getFileName(QAbstractFileEngine::DefaultName);
+ return d->fileEntry.filePath();
}
/*!
@@ -642,7 +707,7 @@ QString QFileInfo::fileName() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- return d->getFileName(QAbstractFileEngine::BaseName);
+ return d->fileEntry.fileName();
}
/*!
@@ -686,7 +751,7 @@ QString QFileInfo::baseName() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0);
+ return d->fileEntry.baseName();
}
/*!
@@ -705,9 +770,7 @@ QString QFileInfo::completeBaseName() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- QString name = d->getFileName(QAbstractFileEngine::BaseName);
- int index = name.lastIndexOf(QLatin1Char('.'));
- return (index == -1) ? name : name.left(index);
+ return d->fileEntry.completeBaseName();
}
/*!
@@ -726,11 +789,7 @@ QString QFileInfo::completeSuffix() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- QString fileName = d->getFileName(QAbstractFileEngine::BaseName);
- int firstDot = fileName.indexOf(QLatin1Char('.'));
- if (firstDot == -1)
- return QLatin1String("");
- return fileName.mid(firstDot + 1);
+ return d->fileEntry.completeSuffix();
}
/*!
@@ -753,11 +812,7 @@ QString QFileInfo::suffix() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QLatin1String("");
- QString fileName = d->getFileName(QAbstractFileEngine::BaseName);
- int lastDot = fileName.lastIndexOf(QLatin1Char('.'));
- if (lastDot == -1)
- return QLatin1String("");
- return fileName.mid(lastDot + 1);
+ return d->fileEntry.suffix();
}
@@ -781,8 +836,9 @@ QString QFileInfo::suffix() const
*/
QDir QFileInfo::dir() const
{
+ Q_D(const QFileInfo);
// ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do?
- return QDir(path());
+ return QDir(d->fileEntry.path());
}
/*!
@@ -818,6 +874,11 @@ bool QFileInfo::isReadable() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserReadPermission);
+ return (d->metaData.permissions() & QFile::ReadUser) != 0;
+ }
return d->getFileFlags(QAbstractFileEngine::ReadUserPerm);
}
@@ -831,6 +892,11 @@ bool QFileInfo::isWritable() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserWritePermission))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserWritePermission);
+ return (d->metaData.permissions() & QFile::WriteUser) != 0;
+ }
return d->getFileFlags(QAbstractFileEngine::WriteUserPerm);
}
@@ -844,6 +910,11 @@ bool QFileInfo::isExecutable() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserExecutePermission))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserExecutePermission);
+ return (d->metaData.permissions() & QFile::ExeUser) != 0;
+ }
return d->getFileFlags(QAbstractFileEngine::ExeUserPerm);
}
@@ -858,6 +929,11 @@ bool QFileInfo::isHidden() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::HiddenAttribute))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::HiddenAttribute);
+ return d->metaData.isHidden();
+ }
return d->getFileFlags(QAbstractFileEngine::HiddenFlag);
}
@@ -873,6 +949,11 @@ bool QFileInfo::isFile() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::FileType))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::FileType);
+ return d->metaData.isFile();
+ }
return d->getFileFlags(QAbstractFileEngine::FileType);
}
@@ -887,6 +968,11 @@ bool QFileInfo::isDir() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::DirectoryType))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::DirectoryType);
+ return d->metaData.isDirectory();
+ }
return d->getFileFlags(QAbstractFileEngine::DirectoryType);
}
@@ -903,6 +989,11 @@ bool QFileInfo::isBundle() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::BundleType))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::BundleType);
+ return d->metaData.isBundle();
+ }
return d->getFileFlags(QAbstractFileEngine::BundleType);
}
@@ -928,6 +1019,11 @@ bool QFileInfo::isSymLink() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::LegacyLinkType))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::LegacyLinkType);
+ return d->metaData.isLegacyLink();
+ }
return d->getFileFlags(QAbstractFileEngine::LinkType);
}
@@ -941,6 +1037,20 @@ bool QFileInfo::isRoot() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return true;
+ if (d->fileEngine == 0) {
+ if (d->fileEntry.isRoot()) {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ //the path is a drive root, but the drive may not exist
+ //for backward compatibility, return true only if the drive exists
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute);
+ return d->metaData.exists();
+#else
+ return true;
+#endif
+ }
+ return false;
+ }
return d->getFileFlags(QAbstractFileEngine::RootFlag);
}
@@ -1003,6 +1113,11 @@ uint QFileInfo::ownerId() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return 0;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserId))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserId);
+ return d->metaData.userId();
+ }
return d->fileEngine->ownerId(QAbstractFileEngine::OwnerUser);
}
@@ -1037,6 +1152,11 @@ uint QFileInfo::groupId() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return 0;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupId))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::GroupId);
+ return d->metaData.groupId();
+ }
return d->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup);
}
@@ -1058,6 +1178,13 @@ bool QFileInfo::permission(QFile::Permissions permissions) const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return false;
+ if (d->fileEngine == 0) {
+ // the QFileSystemMetaData::MetaDataFlag and QFile::Permissions overlap, so just static cast.
+ QFileSystemMetaData::MetaDataFlag permissionFlags = static_cast<QFileSystemMetaData::MetaDataFlag>((int)permissions);
+ if (!d->cache_enabled || !d->metaData.hasFlags(permissionFlags))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, permissionFlags);
+ return (d->metaData.permissions() & permissions) == permissions;
+ }
return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions;
}
@@ -1070,6 +1197,11 @@ QFile::Permissions QFileInfo::permissions() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return 0;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::Permissions))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::Permissions);
+ return d->metaData.permissions();
+ }
return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask);
}
@@ -1085,6 +1217,11 @@ qint64 QFileInfo::size() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return 0;
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::SizeAttribute))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::SizeAttribute);
+ return d->metaData.size();
+ }
if (!d->getCachedFlag(QFileInfoPrivate::CachedSize)) {
d->setCachedFlag(QFileInfoPrivate::CachedSize);
d->fileSize = d->fileEngine->size();
@@ -1110,6 +1247,11 @@ QDateTime QFileInfo::created() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QDateTime();
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::CreationTime))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::CreationTime);
+ return d->metaData.creationTime();
+ }
return d->getFileTime(QAbstractFileEngine::CreationTime);
}
@@ -1123,6 +1265,11 @@ QDateTime QFileInfo::lastModified() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QDateTime();
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ModificationTime))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ModificationTime);
+ return d->metaData.modificationTime();
+ }
return d->getFileTime(QAbstractFileEngine::ModificationTime);
}
@@ -1139,6 +1286,11 @@ QDateTime QFileInfo::lastRead() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return QDateTime();
+ if (d->fileEngine == 0) {
+ if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::AccessTime))
+ QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::AccessTime);
+ return d->metaData.accessTime();
+ }
return d->getFileTime(QAbstractFileEngine::AccessTime);
}
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index e368af2..5cfefb3 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -53,12 +53,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QDir;
+class QDirIteratorPrivate;
class QDateTime;
class QFileInfoPrivate;
class Q_CORE_EXPORT QFileInfo
{
+ friend class QDirIteratorPrivate;
public:
+ explicit QFileInfo(QFileInfoPrivate *d);
+
QFileInfo();
QFileInfo(const QString &file);
QFileInfo(const QFile &file);
@@ -67,6 +71,10 @@ public:
~QFileInfo();
QFileInfo &operator=(const QFileInfo &fileinfo);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QFileInfo&operator=(QFileInfo &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
bool operator==(const QFileInfo &fileinfo); // 5.0 - remove me
bool operator==(const QFileInfo &fileinfo) const;
inline bool operator!=(const QFileInfo &fileinfo) { return !(operator==(fileinfo)); } // 5.0 - remove me
diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h
index d094513..db904c7 100644
--- a/src/corelib/io/qfileinfo_p.h
+++ b/src/corelib/io/qfileinfo_p.h
@@ -58,13 +58,16 @@
#include "qdatetime.h"
#include "qatomic.h"
#include "qshareddata.h"
+#include "qfilesystemengine_p.h"
+
+#include <QtCore/private/qfilesystementry_p.h>
+#include <QtCore/private/qfilesystemmetadata_p.h>
QT_BEGIN_NAMESPACE
class QFileInfoPrivate : public QSharedData
{
public:
-
enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04,
CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40,
CachedSize =0x08, CachedPerms=0x80 };
@@ -76,8 +79,10 @@ public:
cache_enabled(true), fileFlags(0), fileSize(0)
{}
inline QFileInfoPrivate(const QFileInfoPrivate &copy)
- : QSharedData(copy), fileEngine(QAbstractFileEngine::create(copy.fileName)),
- fileName(copy.fileName),
+ : QSharedData(copy),
+ fileEntry(copy.fileEntry),
+ metaData(copy.metaData),
+ fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)),
cachedFlags(0),
#ifndef QT_NO_FSFILEENGINE
isDefaultConstructed(false),
@@ -87,8 +92,8 @@ public:
cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0)
{}
inline QFileInfoPrivate(const QString &file)
- : QSharedData(), fileEngine(QAbstractFileEngine::create(file)),
- fileName(file),
+ : fileEntry(QDir::fromNativeSeparators(file)),
+ fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)),
cachedFlags(0),
#ifndef QT_NO_FSFILEENGINE
isDefaultConstructed(false),
@@ -99,6 +104,16 @@ public:
{
}
+ inline QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data)
+ : QSharedData(),
+ fileEntry(file),
+ metaData(data),
+ cachedFlags(0),
+ isDefaultConstructed(false),
+ cache_enabled(true), fileFlags(0), fileSize(0)
+ {
+ }
+
inline void clearFlags() const {
fileFlags = 0;
cachedFlags = 0;
@@ -106,6 +121,7 @@ public:
(void)fileEngine->fileFlags(QAbstractFileEngine::Refresh);
}
inline void clear() {
+ metaData.clear();
clearFlags();
for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i)
fileNames[i].clear();
@@ -118,9 +134,11 @@ public:
QString getFileName(QAbstractFileEngine::FileName) const;
QString getFileOwner(QAbstractFileEngine::FileOwner own) const;
+ QFileSystemEntry fileEntry;
+ mutable QFileSystemMetaData metaData;
+
QScopedPointer<QAbstractFileEngine> const fileEngine;
- mutable QString fileName;
mutable QString fileNames[QAbstractFileEngine::NFileNames];
mutable QString fileOwners[2];
@@ -134,6 +152,7 @@ public:
{ return cache_enabled ? (cachedFlags & c) : 0; }
inline void setCachedFlag(uint c) const
{ if (cache_enabled) cachedFlags |= c; }
+
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
new file mode 100644
index 0000000..00c33bd
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -0,0 +1,391 @@
+/****************************************************************************
+**
+** 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 "qfilesystemengine_p.h"
+#include <QtCore/qdir.h>
+#include <QtCore/qset.h>
+#include <QtCore/qstringbuilder.h>
+#include <QtCore/private/qabstractfileengine_p.h>
+#ifdef QT_BUILD_CORE_LIB
+#include <QtCore/private/qresource_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ Returns the canonicalized form of \a path (i.e., with all symlinks
+ resolved, and all redundant path elements removed.
+*/
+QString QFileSystemEngine::slowCanonicalized(const QString &path)
+{
+ if (path.isEmpty())
+ return path;
+
+ QFileInfo fi;
+ const QChar slash(QLatin1Char('/'));
+ QString tmpPath = path;
+ int separatorPos = 0;
+ QSet<QString> nonSymlinks;
+ QSet<QString> known;
+
+ known.insert(path);
+ do {
+#ifdef Q_OS_WIN
+ if (separatorPos == 0) {
+ if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) {
+ // UNC, skip past the first two elements
+ separatorPos = tmpPath.indexOf(slash, 2);
+ } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) {
+ // volume root, skip since it can not be a symlink
+ separatorPos = 2;
+ }
+ }
+ if (separatorPos != -1)
+#endif
+ separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
+ QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
+ if (
+#ifdef Q_OS_SYMBIAN
+ // Symbian doesn't support directory symlinks, so do not check for link unless we
+ // are handling the last path element. This not only slightly improves performance,
+ // but also saves us from lot of unnecessary platform security check failures
+ // when dealing with files under *:/private directories.
+ separatorPos == -1 &&
+#endif
+ !nonSymlinks.contains(prefix)) {
+ fi.setFile(prefix);
+ if (fi.isSymLink()) {
+ QString target = fi.symLinkTarget();
+ if(QFileInfo(target).isRelative())
+ target = fi.absolutePath() + slash + target;
+ if (separatorPos != -1) {
+ if (fi.isDir() && !target.endsWith(slash))
+ target.append(slash);
+ target.append(tmpPath.mid(separatorPos));
+ }
+ tmpPath = QDir::cleanPath(target);
+ separatorPos = 0;
+
+ if (known.contains(tmpPath))
+ return QString();
+ known.insert(tmpPath);
+ } else {
+ nonSymlinks.insert(prefix);
+ }
+ }
+ } while (separatorPos != -1);
+
+ return QDir::cleanPath(tmpPath);
+}
+
+static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data, bool resolvingEntry)
+{
+ if (resolvingEntry) {
+ if (!QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute)
+ || !data.exists()) {
+ data.clear();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEntry)
+{
+ if (resolvingEntry) {
+ if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) {
+ delete engine;
+ engine = 0;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QAbstractFileEngine *&engine, bool resolvingEntry = false)
+{
+ QString const &filePath = entry.filePath();
+ if ((engine = qt_custom_file_engine_handler_create(filePath)))
+ return _q_checkEntry(engine, resolvingEntry);
+
+#if defined(QT_BUILD_CORE_LIB)
+ for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) {
+ QChar const ch = filePath[prefixSeparator];
+ if (ch == QLatin1Char('/'))
+ break;
+
+ if (ch == QLatin1Char(':')) {
+ if (prefixSeparator == 0) {
+ engine = new QResourceFileEngine(filePath);
+ return _q_checkEntry(engine, resolvingEntry);
+ }
+
+ if (prefixSeparator == 1)
+ break;
+
+ const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator));
+ for (int i = 0; i < paths.count(); i++) {
+ entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)));
+ // Recurse!
+ if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true))
+ return true;
+ }
+
+ // entry may have been clobbered at this point.
+ return false;
+ }
+
+ // There's no need to fully validate the prefix here. Consulting the
+ // unicode tables could be expensive and validation is already
+ // performed in QDir::setSearchPaths.
+ //
+ // if (!ch.isLetterOrNumber())
+ // break;
+ }
+#endif // defined(QT_BUILD_CORE_LIB)
+
+ return _q_checkEntry(entry, data, resolvingEntry);
+}
+
+/*!
+ \internal
+
+ Resolves the \a entry (see QDir::searchPaths) and returns an engine for
+ it, but never a QFSFileEngine.
+
+ \returns a file engine that can be used to access the entry. Returns 0 if
+ QFileSystemEngine API should be used to query and interact with the file
+ system object.
+*/
+QAbstractFileEngine *QFileSystemEngine::resolveEntryAndCreateLegacyEngine(
+ QFileSystemEntry &entry, QFileSystemMetaData &data) {
+ QFileSystemEntry copy = entry;
+ QAbstractFileEngine *engine = 0;
+
+ if (_q_resolveEntryAndCreateLegacyEngine_recursive(copy, data, engine))
+ // Reset entry to resolved copy.
+ entry = copy;
+ else
+ data.clear();
+
+ return engine;
+}
+
+//these unix functions are in this file, because they are shared by symbian port
+//for open C file handles.
+#ifdef Q_OS_UNIX
+//static
+bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data)
+{
+ data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
+ data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags;
+
+ QT_STATBUF statBuffer;
+ if (QT_FSTAT(fd, &statBuffer) == 0) {
+ data.fillFromStatBuf(statBuffer);
+ return true;
+ }
+
+ return false;
+}
+
+void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
+{
+ // Permissions
+ if (statBuffer.st_mode & S_IRUSR)
+ entryFlags |= QFileSystemMetaData::OwnerReadPermission;
+ if (statBuffer.st_mode & S_IWUSR)
+ entryFlags |= QFileSystemMetaData::OwnerWritePermission;
+ if (statBuffer.st_mode & S_IXUSR)
+ entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
+
+ if (statBuffer.st_mode & S_IRGRP)
+ entryFlags |= QFileSystemMetaData::GroupReadPermission;
+ if (statBuffer.st_mode & S_IWGRP)
+ entryFlags |= QFileSystemMetaData::GroupWritePermission;
+ if (statBuffer.st_mode & S_IXGRP)
+ entryFlags |= QFileSystemMetaData::GroupExecutePermission;
+
+ if (statBuffer.st_mode & S_IROTH)
+ entryFlags |= QFileSystemMetaData::OtherReadPermission;
+ if (statBuffer.st_mode & S_IWOTH)
+ entryFlags |= QFileSystemMetaData::OtherWritePermission;
+ if (statBuffer.st_mode & S_IXOTH)
+ entryFlags |= QFileSystemMetaData::OtherExecutePermission;
+
+ // Type
+ if ((statBuffer.st_mode & S_IFMT) == S_IFREG)
+ entryFlags |= QFileSystemMetaData::FileType;
+ else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR)
+ entryFlags |= QFileSystemMetaData::DirectoryType;
+ else
+ entryFlags |= QFileSystemMetaData::SequentialType;
+
+ // Attributes
+ entryFlags |= QFileSystemMetaData::ExistsAttribute;
+ size_ = statBuffer.st_size;
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \
+ && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if (statBuffer.st_flags & UF_HIDDEN) {
+ entryFlags |= QFileSystemMetaData::HiddenAttribute;
+ knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
+ }
+#endif
+
+ // Times
+#ifdef Q_OS_SYMBIAN
+ modificationTime_ = qt_symbian_time_t_To_TTime(statBuffer.st_mtime);
+#else
+ creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime;
+ modificationTime_ = statBuffer.st_mtime;
+ accessTime_ = statBuffer.st_atime;
+ userId_ = statBuffer.st_uid;
+ groupId_ = statBuffer.st_gid;
+#endif
+}
+
+void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
+{
+#if defined(_DIRENT_HAVE_D_TYPE) || defined(Q_OS_BSD4) || defined(Q_OS_SYMBIAN)
+ // BSD4 includes Mac OS X
+
+ // ### This will clear all entry flags and knownFlagsMask
+ switch (entry.d_type)
+ {
+ case DT_DIR:
+ knownFlagsMask = QFileSystemMetaData::LinkType
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ entryFlags = QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ break;
+
+ case DT_BLK:
+ case DT_CHR:
+ case DT_FIFO:
+ case DT_SOCK:
+ // ### System attribute
+ knownFlagsMask = QFileSystemMetaData::LinkType
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::BundleType
+ | QFileSystemMetaData::AliasType
+ | QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ entryFlags = QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ break;
+
+ case DT_LNK:
+ knownFlagsMask = QFileSystemMetaData::LinkType;
+ entryFlags = QFileSystemMetaData::LinkType;
+ break;
+
+ case DT_REG:
+ knownFlagsMask = QFileSystemMetaData::LinkType
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::BundleType
+ | QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ entryFlags = QFileSystemMetaData::FileType
+ | QFileSystemMetaData::ExistsAttribute;
+
+ break;
+
+ case DT_UNKNOWN:
+ default:
+ clear();
+ }
+#else
+ Q_UNUSED(entry)
+#endif
+}
+
+#endif
+
+//static
+QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
+{
+#if defined (Q_OS_SYMBIAN)
+ Q_UNUSED(entry);
+ Q_UNUSED(metaData);
+ return QString();
+#elif defined(Q_OS_WIN)
+ Q_UNUSED(metaData);
+ return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerUser);
+#else //(Q_OS_UNIX)
+ if (!metaData.hasFlags(QFileSystemMetaData::UserId))
+ QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId);
+ return resolveUserName(metaData.userId());
+#endif
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData)
+{
+#if defined (Q_OS_SYMBIAN)
+ Q_UNUSED(entry);
+ Q_UNUSED(metaData);
+ return QString();
+#elif defined(Q_OS_WIN)
+ Q_UNUSED(metaData);
+ return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerGroup);
+#else //(Q_OS_UNIX)
+ if (!metaData.hasFlags(QFileSystemMetaData::GroupId))
+ QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId);
+ return resolveGroupName(metaData.groupId());
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp
new file mode 100644
index 0000000..1c0056b
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine_mac.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 "qfilesystemengine_p.h"
+
+QT_BEGIN_NAMESPACE
+
+// Mac-specific implementations only!
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h
new file mode 100644
index 0000000..d6033e6
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine_p.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** 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 QFILESYSTEMENGINE_P_H_INCLUDED
+#define QFILESYSTEMENGINE_P_H_INCLUDED
+
+//
+// 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 "qfile.h"
+#include "qfilesystementry_p.h"
+#include "qfilesystemmetadata_p.h"
+#include <QtCore/private/qsystemerror_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QFileSystemEngine
+{
+public:
+ static bool isCaseSensitive();
+
+ static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data);
+ static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
+ static QFileSystemEntry absoluteName(const QFileSystemEntry &entry);
+ static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
+ static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data);
+
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+ static QString resolveUserName(uint userId);
+ static QString resolveGroupName(uint groupId);
+#endif
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ static QString bundleName(const QFileSystemEntry &entry);
+#else
+ static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); }
+#endif
+
+ static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what);
+#if defined(Q_OS_UNIX)
+ static bool fillMetaData(int fd, QFileSystemMetaData &data); // what = PosixStatFlags
+#endif
+#if defined(Q_OS_WIN)
+
+ static bool uncListSharesOnServer(const QString &server, QStringList *list); //Used also by QFSFileEngineIterator::hasNext()
+ static bool fillMetaData(int fd, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what);
+ static bool fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what);
+ static bool fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what);
+ static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own);
+ static QString nativeAbsoluteFilePath(const QString &path);
+#endif
+ //homePath, rootPath and tempPath shall return clean paths
+ static QString homePath();
+ static QString rootPath();
+ static QString tempPath();
+
+ static bool createDirectory(const QFileSystemEntry &entry, bool createParents);
+ static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents);
+
+ static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
+
+ static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
+ static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error);
+ static bool removeFile(const QFileSystemEntry &entry, QSystemError &error);
+
+ static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error,
+ QFileSystemMetaData *data = 0);
+
+ static bool setCurrentPath(const QFileSystemEntry &entry);
+ static QFileSystemEntry currentPath();
+
+ static QAbstractFileEngine *resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry,
+ QFileSystemMetaData &data);
+private:
+ static QString slowCanonicalized(const QString &path);
+#if defined(Q_OS_WIN)
+ static void clearWinStatData(QFileSystemMetaData &data);
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif // include guard
diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp
new file mode 100644
index 0000000..41a550a
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine_symbian.cpp
@@ -0,0 +1,408 @@
+/****************************************************************************
+**
+** 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 "qfilesystemengine_p.h"
+#include "qfsfileengine.h"
+#include <QtCore/private/qcore_symbian_p.h>
+#include <QtCore/qcoreapplication.h>
+
+#include <f32file.h>
+#include <pathinfo.h>
+#include <wchar.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QFileSystemEngine::isCaseSensitive()
+{
+ return false;
+}
+
+//TODO: resolve this with QDir::cleanPath, without breaking the behaviour of that
+//function which is documented only by autotest
+//input: a dirty absolute path, e.g. c:/../../foo/./
+//output: a clean absolute path, e.g. c:/foo/
+static QString symbianCleanAbsolutePath(const QString& path)
+{
+ bool isDir = path.endsWith(QLatin1Char('/'));
+ //using SkipEmptyParts flag to eliminate duplicated slashes
+ QStringList components = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
+ int cdups = 0;
+ for(int i=components.count() - 1; i>=0; --i) {
+ if(components.at(i) == QLatin1String("..")) {
+ components.removeAt(i);
+ cdups++;
+ }
+ else if(components.at(i) == QLatin1String(".")) {
+ components.removeAt(i);
+ }
+ else if(cdups && i > 0) {
+ --cdups;
+ components.removeAt(i);
+ }
+ }
+ QString result = components.join(QLatin1String("/"));
+ if ((isDir&& !result.endsWith(QLatin1Char('/')))
+ || (result.length() == 2 && result.at(1).unicode() == ':'))
+ result.append(QLatin1Char('/'));
+ return result;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
+{
+ Q_UNUSED(data);
+ return link;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
+{
+ if (entry.isEmpty() || entry.isRoot())
+ return entry;
+
+ QFileSystemEntry result = absoluteName(entry);
+ if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute))
+ fillMetaData(result, data, QFileSystemMetaData::ExistsAttribute);
+ if (!data.exists()) {
+ // file doesn't exist
+ return QFileSystemEntry();
+ } else {
+ return result;
+ }
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+{
+ QString orig = entry.filePath();
+ const bool isAbsolute = entry.isAbsolute();
+ const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) ||
+ orig.contains(QLatin1String("//")) ||
+ orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/.")));
+ if (isAbsolute && !isDirty)
+ return entry;
+
+ const bool isRelative = entry.isRelative();
+ const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/');
+ const bool isDriveLetter = !needsDrive && !isAbsolute && !isRelative && orig.length() == 2;
+ const bool isDriveRelative = !needsDrive && !isAbsolute && !isRelative && orig.length() > 2;
+
+ QString result;
+ if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) {
+ QFileSystemEntry cur(currentPath());
+ if(needsDrive)
+ result = cur.filePath().left(2);
+ else if(isDriveRelative && cur.filePath().at(0) != orig.at(0))
+ result = orig.left(2); // for BC, see tst_QFileInfo::absolutePath(<not current drive>:my.dll)
+ else
+ result = cur.filePath();
+ if(isDriveLetter) {
+ result[0] = orig.at(0); //copy drive letter
+ orig.clear();
+ }
+ if(isDriveRelative) {
+ orig = orig.mid(2); //discard the drive specifier from orig
+ }
+ }
+ if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) {
+ if (!result.isEmpty() && !result.endsWith(QLatin1Char('/')))
+ result.append(QLatin1Char('/'));
+ result.append(orig);
+ }
+
+ return QFileSystemEntry(symbianCleanAbsolutePath(result), QFileSystemEntry::FromInternalPath());
+}
+
+void QFileSystemMetaData::fillFromTEntry(const TEntry& entry)
+{
+ entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
+ knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags;
+ //Symbian doesn't have unix type file permissions
+ entryFlags |= QFileSystemMetaData::ReadPermissions;
+ if(!entry.IsReadOnly()) {
+ entryFlags |= QFileSystemMetaData::WritePermissions;
+ }
+ //set the type
+ if(entry.IsDir())
+ entryFlags |= (QFileSystemMetaData::DirectoryType | QFileSystemMetaData::ExecutePermissions);
+ else
+ entryFlags |= QFileSystemMetaData::FileType;
+
+ //set the attributes
+ entryFlags |= QFileSystemMetaData::ExistsAttribute;
+ if(entry.IsHidden())
+ entryFlags |= QFileSystemMetaData::HiddenAttribute;
+
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ size_ = entry.FileSize();
+#else
+ size_ = (TUint)(entry.iSize);
+#endif
+
+ modificationTime_ = entry.iModified;
+}
+
+void QFileSystemMetaData::fillFromVolumeInfo(const TVolumeInfo& info)
+{
+ entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
+ knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags;
+ entryFlags |= QFileSystemMetaData::ExistsAttribute;
+ entryFlags |= QFileSystemMetaData::Permissions;
+ if(info.iDrive.iDriveAtt & KDriveAttRom) {
+ entryFlags &= ~(QFileSystemMetaData::WritePermissions);
+ }
+ entryFlags |= QFileSystemMetaData::DirectoryType;
+ size_ = info.iSize;
+ modificationTime_ = qt_symbian_time_t_To_TTime(0);
+}
+
+//static
+bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
+{
+ if (what & QFileSystemMetaData::SymbianTEntryFlags) {
+ RFs& fs(qt_s60GetRFs());
+ TInt err;
+ QFileSystemEntry absentry(absoluteName(entry));
+ if (entry.isEmpty()) {
+ err = KErrNotFound;
+ } else if (absentry.isRoot()) {
+ //Root directories don't have an entry, and Entry() returns KErrBadName.
+ //Therefore get information about the volume instead.
+ TInt drive;
+ err = RFs::CharToDrive(TChar(absentry.nativeFilePath().at(0).unicode()), drive);
+ if (!err) {
+ TVolumeInfo info;
+ err = fs.Volume(info, drive);
+ if (!err)
+ data.fillFromVolumeInfo(info);
+ }
+ } else {
+ TEntry ent;
+ err = fs.Entry(qt_QString2TPtrC(absentry.nativeFilePath()), ent);
+ if (!err)
+ data.fillFromTEntry(ent);
+ }
+ if (err) {
+ data.size_ = 0;
+ data.modificationTime_ = TTime(0);
+ data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
+ }
+ //files in /sys/bin on any drive are executable, even though we don't normally have permission to check whether they exist or not
+ if(absentry.filePath().midRef(1,10).compare(QLatin1String(":/sys/bin/"), Qt::CaseInsensitive) == 0)
+ data.entryFlags |= QFileSystemMetaData::ExecutePermissions;
+ }
+ return data.hasFlags(what);
+}
+
+//static
+bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
+{
+ QString abspath = absoluteName(entry).nativeFilePath();
+ if (!abspath.endsWith(QLatin1Char('\\')))
+ abspath.append(QLatin1Char('\\'));
+ TInt r;
+ if (createParents)
+ r = qt_s60GetRFs().MkDirAll(qt_QString2TPtrC(abspath));
+ else
+ r = qt_s60GetRFs().MkDir(qt_QString2TPtrC(abspath));
+ if (createParents && r == KErrAlreadyExists)
+ return true; //# Qt5 - QDir::mkdir returns false for existing dir, QDir::mkpath returns true (should be made consistent in Qt 5)
+ return (r == KErrNone);
+}
+
+//static
+bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
+{
+ QString abspath = absoluteName(entry).nativeFilePath();
+ if (!abspath.endsWith(QLatin1Char('\\')))
+ abspath.append(QLatin1Char('\\'));
+ TPtrC dir(qt_QString2TPtrC(abspath));
+ RFs& fs = qt_s60GetRFs();
+ bool ok = false;
+ //behaviour of FS file engine:
+ //returns true if the directory could be removed
+ //success/failure of removing parent directories does not matter
+ while (KErrNone == fs.RmDir(dir)) {
+ ok = true;
+ if (!removeEmptyParents)
+ break;
+ //RFs::RmDir treats "c:\foo\bar" and "c:\foo\" the same, so it is sufficient to remove the last \ to the end
+ dir.Set(dir.Left(dir.LocateReverse(TChar('\\'))));
+ }
+ return ok;
+}
+
+//static
+bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ Q_UNUSED(source)
+ Q_UNUSED(target)
+ error = QSystemError(KErrNotSupported, QSystemError::NativeError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ //CFileMan is allocated each time because it is not thread-safe
+ CFileMan *fm = 0;
+ TRAPD(err, fm = CFileMan::NewL(qt_s60GetRFs()));
+ if (err == KErrNone) {
+ err = fm->Copy(qt_QString2TPtrC(absoluteName(source).nativeFilePath()), qt_QString2TPtrC(absoluteName(target).nativeFilePath()), 0);
+ delete fm;
+ }
+ if (err == KErrNone)
+ return true;
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ QString sourcepath = absoluteName(source).nativeFilePath();
+ QString targetpath = absoluteName(target).nativeFilePath();
+ RFs& fs(qt_s60GetRFs());
+ TInt err = fs.Rename(qt_QString2TPtrC(sourcepath), qt_QString2TPtrC(targetpath));
+ if (err == KErrNone)
+ return true;
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error)
+{
+ QString targetpath = absoluteName(entry).nativeFilePath();
+ RFs& fs(qt_s60GetRFs());
+ TInt err = fs.Delete(qt_QString2TPtrC(targetpath));
+ if (err == KErrNone)
+ return true;
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
+{
+ QString targetpath = absoluteName(entry).nativeFilePath();
+ TUint setmask = 0;
+ TUint clearmask = 0;
+ RFs& fs(qt_s60GetRFs());
+ if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther))
+ clearmask = KEntryAttReadOnly; //if anyone can write, it's not read-only
+ else
+ setmask = KEntryAttReadOnly;
+ TInt err = fs.SetAtt(qt_QString2TPtrC(targetpath), setmask, clearmask);
+ if (data && !err) {
+ data->entryFlags &= ~QFileSystemMetaData::Permissions;
+ data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
+ data->knownFlagsMask |= QFileSystemMetaData::Permissions;
+ }
+ if (err == KErrNone)
+ return true;
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+}
+
+QString QFileSystemEngine::homePath()
+{
+ QString home = QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath()));
+ if(home.endsWith(QLatin1Char('/')))
+ home.chop(1);
+ return home;
+}
+
+QString QFileSystemEngine::rootPath()
+{
+ TChar drive;
+ TInt err = RFs::DriveToChar(RFs::GetSystemDrive(), drive); //RFs::GetSystemDriveChar not supported on S60 3.1
+ Q_ASSERT(err == KErrNone); //RFs::GetSystemDrive() shall always return a convertible drive number on a valid OS configuration
+ return QString(QChar(drive)).append(QLatin1String(":/"));
+}
+
+QString QFileSystemEngine::tempPath()
+{
+ return rootPath().append(QLatin1String("system/temp"));
+}
+
+//static
+bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
+{
+ QFileSystemMetaData meta;
+ QFileSystemEntry absname = absoluteName(entry);
+ fillMetaData(absname, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType);
+ if(!(meta.exists() && meta.isDirectory()))
+ return false;
+
+ RFs& fs = qt_s60GetRFs();
+ QString abspath = absname.nativeFilePath();
+ if(!abspath.endsWith(QLatin1Char('\\')))
+ abspath.append(QLatin1Char('\\'));
+ TInt r = fs.SetSessionPath(qt_QString2TPtrC(abspath));
+ //SetSessionPath succeeds for non existent directory, which is why it's checked above
+ if (r == KErrNone) {
+ __ASSERT_COMPILE(sizeof(wchar_t) == sizeof(unsigned short));
+ //attempt to set open C to the same path
+ r = ::wchdir(reinterpret_cast<const wchar_t *>(absname.filePath().utf16()));
+ if (r < 0)
+ qWarning("failed to sync path to open C");
+ return true;
+ }
+ return false;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::currentPath()
+{
+ TFileName fn;
+ QFileSystemEntry ret;
+ TInt r = qt_s60GetRFs().SessionPath(fn);
+ if(r == KErrNone) {
+ //remove terminating slash from non root paths (session path is clean, absolute and always ends in a \)
+ if(fn.Length() > 3 && fn[fn.Length() - 1] == '\\')
+ fn.SetLength(fn.Length() - 1);
+ ret = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath());
+ }
+ return ret;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
new file mode 100644
index 0000000..c9ebaa4
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -0,0 +1,660 @@
+/****************************************************************************
+**
+** 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 "qplatformdefs.h"
+#include "qfilesystemengine_p.h"
+#include "qplatformdefs.h"
+#include "qfsfileengine.h"
+#include "qfile.h"
+
+#include <QtCore/qvarlengtharray.h>
+
+#include <stdlib.h> // for realpath()
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+#if defined(Q_OS_MAC)
+# include <QtCore/private/qcore_mac_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+static inline bool _q_isMacHidden(const char *nativePath)
+{
+ OSErr err;
+
+ FSRef fsRef;
+ err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(nativePath),
+ kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0);
+ if (err != noErr)
+ return false;
+
+ FSCatalogInfo catInfo;
+ err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
+ if (err != noErr)
+ return false;
+
+ FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo);
+ return (fileInfo->finderFlags & kIsInvisible);
+}
+#else
+static inline bool _q_isMacHidden(const char *nativePath)
+{
+ Q_UNUSED(nativePath);
+ // no-op
+ return false;
+}
+#endif
+
+bool QFileSystemEngine::isCaseSensitive()
+{
+ return true;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
+{
+#if defined(__GLIBC__) && !defined(PATH_MAX)
+#define PATH_CHUNK_SIZE 256
+ char *s = 0;
+ int len = -1;
+ int size = PATH_CHUNK_SIZE;
+
+ while (1) {
+ s = (char *) ::realloc(s, size);
+ Q_CHECK_PTR(s);
+ len = ::readlink(link.nativeFilePath().constData(), s, size);
+ if (len < 0) {
+ ::free(s);
+ break;
+ }
+ if (len < size) {
+ break;
+ }
+ size *= 2;
+ }
+#else
+ char s[PATH_MAX+1];
+ int len = readlink(link.nativeFilePath().constData(), s, PATH_MAX);
+#endif
+ if (len > 0) {
+ QString ret;
+ if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
+ fillMetaData(link, data, QFileSystemMetaData::DirectoryType);
+ if (data.isDirectory() && s[0] != '/') {
+ QDir parent(link.filePath());
+ parent.cdUp();
+ ret = parent.path();
+ if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
+ ret += QLatin1Char('/');
+ }
+ s[len] = '\0';
+ ret += QFile::decodeName(QByteArray(s));
+#if defined(__GLIBC__) && !defined(PATH_MAX)
+ ::free(s);
+#endif
+
+ if (!ret.startsWith(QLatin1Char('/'))) {
+ if (link.filePath().startsWith(QLatin1Char('/'))) {
+ ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
+ + QLatin1Char('/'));
+ } else {
+ ret.prepend(QDir::currentPath() + QLatin1Char('/'));
+ }
+ }
+ ret = QDir::cleanPath(ret);
+ if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
+ ret.chop(1);
+ return QFileSystemEntry(ret);
+ }
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ {
+ FSRef fref;
+ if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) {
+ // TODO get the meta data info from the QFileSystemMetaData object
+ Boolean isAlias, isFolder;
+ if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) {
+ AliasHandle alias;
+ if (FSNewAlias(0, &fref, &alias) == noErr && alias) {
+ QCFString cfstr;
+ if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr)
+ return QFileSystemEntry(QCFString::toQString(cfstr));
+ }
+ }
+ }
+ }
+#endif
+ return QFileSystemEntry();
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
+{
+ if (entry.isEmpty() || entry.isRoot())
+ return entry;
+
+#if !defined(Q_OS_MAC) && _POSIX_VERSION < 200809L
+ // realpath(X,0) is not supported
+ Q_UNUSED(data);
+ return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
+#else
+ char *ret = 0;
+# if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
+ // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here.
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
+ ret = realpath(entry.nativeFilePath().constData(), (char*)0);
+ } else {
+ // on 10.5 we can use FSRef to resolve the file path.
+ QString path = QDir::cleanPath(entry.filePath());
+ FSRef fsref;
+ if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) {
+ CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref);
+ CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
+ QString ret = QCFString::toQString(canonicalPath);
+ CFRelease(canonicalPath);
+ CFRelease(urlref);
+ return QFileSystemEntry(ret);
+ }
+ }
+# else
+ ret = realpath(entry.nativeFilePath().constData(), (char*)0);
+# endif
+ if (ret) {
+ data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
+ data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
+ QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
+ free(ret);
+ return QFileSystemEntry(canonicalPath);
+ } else if (errno == ENOENT) { // file doesn't exist
+ data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
+ data.entryFlags &= ~(QFileSystemMetaData::ExistsAttribute);
+ return QFileSystemEntry();
+ }
+ return entry;
+#endif
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+{
+ if (entry.isAbsolute())
+ return entry;
+
+ QByteArray orig = entry.nativeFilePath();
+ QByteArray result;
+ if (orig.isEmpty() || !orig.startsWith('/')) {
+ QFileSystemEntry cur(currentPath());
+ result = cur.nativeFilePath();
+ }
+ if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) {
+ if (!result.isEmpty() && !result.endsWith('/'))
+ result.append('/');
+ result.append(orig);
+ }
+
+ if (result.length() == 1 && result[0] == '/')
+ return QFileSystemEntry(result, QFileSystemEntry::FromNativePath());
+ const bool isDir = result.endsWith('/');
+
+ /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here.
+ * ideally we never convert to a string since that loses information. Please fix after
+ * we get a QByteArray version of QDir::cleanPath()
+ */
+ QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
+ QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
+ if (isDir)
+ stringVersion.append(QLatin1Char('/'));
+ return QFileSystemEntry(stringVersion);
+}
+
+//static
+QString QFileSystemEngine::resolveUserName(uint userId)
+{
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+ int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size_max == -1)
+ size_max = 1024;
+ QVarLengthArray<char, 1024> buf(size_max);
+#endif
+
+ struct passwd *pw = 0;
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+ struct passwd entry;
+ getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw);
+#else
+ pw = getpwuid(userId);
+#endif
+ if (pw)
+ return QFile::decodeName(QByteArray(pw->pw_name));
+ return QString();
+}
+
+//static
+QString QFileSystemEngine::resolveGroupName(uint groupId)
+{
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+ int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size_max == -1)
+ size_max = 1024;
+ QVarLengthArray<char, 1024> buf(size_max);
+#endif
+
+ struct group *gr = 0;
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
+ size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (size_max == -1)
+ size_max = 1024;
+ buf.resize(size_max);
+ struct group entry;
+ // Some large systems have more members than the POSIX max size
+ // Loop over by doubling the buffer size (upper limit 250k)
+ for (unsigned size = size_max; size < 256000; size += size)
+ {
+ buf.resize(size);
+ // ERANGE indicates that the buffer was too small
+ if (!getgrgid_r(groupId, &entry, buf.data(), buf.size(), &gr)
+ || errno != ERANGE)
+ break;
+ }
+#else
+ gr = getgrgid(groupId);
+#endif
+ if (gr)
+ return QFile::decodeName(QByteArray(gr->gr_name));
+ return QString();
+}
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+//static
+QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
+{
+ QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()),
+ kCFURLPOSIXPathStyle, true);
+ if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) {
+ if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {
+ if (CFGetTypeID(name) == CFStringGetTypeID())
+ return QCFString::toQString((CFStringRef)name);
+ }
+ }
+ return QString();
+}
+#endif
+
+//static
+bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what)
+{
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ if (what & QFileSystemMetaData::BundleType) {
+ if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
+ what |= QFileSystemMetaData::DirectoryType;
+ }
+#endif
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \
+ && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if (what & QFileSystemMetaData::HiddenAttribute) {
+ // Mac OS >= 10.5: st_flags & UF_HIDDEN
+ what |= QFileSystemMetaData::PosixStatFlags;
+ }
+#endif
+
+ if (what & QFileSystemMetaData::PosixStatFlags)
+ what |= QFileSystemMetaData::PosixStatFlags;
+
+ if (what & QFileSystemMetaData::ExistsAttribute) {
+ // FIXME: Would other queries being performed provide this bit?
+ what |= QFileSystemMetaData::PosixStatFlags;
+ }
+
+ data.entryFlags &= ~what;
+
+ const char * nativeFilePath;
+ int nativeFilePathLength;
+ {
+ const QByteArray &path = entry.nativeFilePath();
+ nativeFilePath = path.constData();
+ nativeFilePathLength = path.size();
+ }
+
+ bool entryExists = true; // innocent until proven otherwise
+
+ QT_STATBUF statBuffer;
+ bool statBufferValid = false;
+ if (what & QFileSystemMetaData::LinkType) {
+ if (QT_LSTAT(nativeFilePath, &statBuffer) == 0) {
+ if (S_ISLNK(statBuffer.st_mode)) {
+ data.entryFlags |= QFileSystemMetaData::LinkType;
+ } else {
+ statBufferValid = true;
+ data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags;
+ }
+ } else {
+ entryExists = false;
+ }
+
+ data.knownFlagsMask |= QFileSystemMetaData::LinkType;
+ }
+
+ if (statBufferValid || (what & QFileSystemMetaData::PosixStatFlags)) {
+ if (entryExists && !statBufferValid)
+ statBufferValid = (QT_STAT(nativeFilePath, &statBuffer) == 0);
+
+ if (statBufferValid)
+ data.fillFromStatBuf(statBuffer);
+ else {
+ entryExists = false;
+ data.creationTime_ = 0;
+ data.modificationTime_ = 0;
+ data.accessTime_ = 0;
+ data.size_ = 0;
+ data.userId_ = (uint) -2;
+ data.groupId_ = (uint) -2;
+ }
+
+ // reset the mask
+ data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags
+ | QFileSystemMetaData::ExistsAttribute;
+ }
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ if (what & QFileSystemMetaData::AliasType)
+ {
+ if (entryExists) {
+ FSRef fref;
+ if (FSPathMakeRef((const UInt8 *)nativeFilePath, &fref, NULL) == noErr) {
+ Boolean isAlias, isFolder;
+ if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) {
+ if (isAlias)
+ data.entryFlags |= QFileSystemMetaData::AliasType;
+ }
+ }
+ }
+ data.knownFlagsMask |= QFileSystemMetaData::AliasType;
+ }
+#endif
+
+ if (what & QFileSystemMetaData::UserPermissions) {
+ // calculate user permissions
+
+ if (entryExists) {
+ if (what & QFileSystemMetaData::UserReadPermission) {
+ if (QT_ACCESS(nativeFilePath, R_OK) == 0)
+ data.entryFlags |= QFileSystemMetaData::UserReadPermission;
+ }
+ if (what & QFileSystemMetaData::UserWritePermission) {
+ if (QT_ACCESS(nativeFilePath, W_OK) == 0)
+ data.entryFlags |= QFileSystemMetaData::UserWritePermission;
+ }
+ if (what & QFileSystemMetaData::UserExecutePermission) {
+ if (QT_ACCESS(nativeFilePath, X_OK) == 0)
+ data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
+ }
+ }
+ data.knownFlagsMask |= (what & QFileSystemMetaData::UserPermissions);
+ }
+
+ if (what & QFileSystemMetaData::HiddenAttribute
+ && !data.isHidden()) {
+ QString fileName = entry.fileName();
+ if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
+ || (entryExists && _q_isMacHidden(nativeFilePath)))
+ data.entryFlags |= QFileSystemMetaData::HiddenAttribute;
+ data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
+ }
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ if (what & QFileSystemMetaData::BundleType) {
+ if (entryExists && data.isDirectory()) {
+ QCFType<CFStringRef> path = CFStringCreateWithBytes(0,
+ (const UInt8*)nativeFilePath, nativeFilePathLength,
+ kCFStringEncodingUTF8, false);
+ QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path,
+ kCFURLPOSIXPathStyle, true);
+
+ UInt32 type, creator;
+ if (CFBundleGetPackageInfoInDirectory(url, &type, &creator))
+ data.entryFlags |= QFileSystemMetaData::BundleType;
+ }
+
+ data.knownFlagsMask |= QFileSystemMetaData::BundleType;
+ }
+#endif
+
+ return data.hasFlags(what);
+}
+
+//static
+bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
+{
+ QString dirName = entry.filePath();
+ if (createParents) {
+ dirName = QDir::cleanPath(dirName);
+ for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
+ slash = dirName.indexOf(QDir::separator(), oldslash+1);
+ if (slash == -1) {
+ if (oldslash == dirName.length())
+ break;
+ slash = dirName.length();
+ }
+ if (slash) {
+ QByteArray chunk = QFile::encodeName(dirName.left(slash));
+ QT_STATBUF st;
+ if (QT_STAT(chunk, &st) != -1) {
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ return false;
+ } else if (QT_MKDIR(chunk, 0777) != 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
+ if (dirName.endsWith(QLatin1Char('/')))
+ dirName.chop(1);
+#endif
+ return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
+}
+
+//static
+bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
+{
+ if (removeEmptyParents) {
+ QString dirName = QDir::cleanPath(entry.filePath());
+ for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
+ QByteArray chunk = QFile::encodeName(dirName.left(slash));
+ QT_STATBUF st;
+ if (QT_STAT(chunk, &st) != -1) {
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ return false;
+ if (::rmdir(chunk) != 0)
+ return oldslash != 0;
+ } else {
+ return false;
+ }
+ slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
+ }
+ return true;
+ }
+ return rmdir(QFile::encodeName(entry.filePath())) == 0;
+}
+
+//static
+bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
+ return true;
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ Q_UNUSED(source);
+ Q_UNUSED(target);
+ error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented
+ return false;
+}
+
+//static
+bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0)
+ return true;
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ return false;
+}
+
+//static
+bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error)
+{
+ if (unlink(entry.nativeFilePath().constData()) == 0)
+ return true;
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ return false;
+
+}
+
+//static
+bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
+{
+ mode_t mode = 0;
+ if (permissions & QFile::ReadOwner)
+ mode |= S_IRUSR;
+ if (permissions & QFile::WriteOwner)
+ mode |= S_IWUSR;
+ if (permissions & QFile::ExeOwner)
+ mode |= S_IXUSR;
+ if (permissions & QFile::ReadUser)
+ mode |= S_IRUSR;
+ if (permissions & QFile::WriteUser)
+ mode |= S_IWUSR;
+ if (permissions & QFile::ExeUser)
+ mode |= S_IXUSR;
+ if (permissions & QFile::ReadGroup)
+ mode |= S_IRGRP;
+ if (permissions & QFile::WriteGroup)
+ mode |= S_IWGRP;
+ if (permissions & QFile::ExeGroup)
+ mode |= S_IXGRP;
+ if (permissions & QFile::ReadOther)
+ mode |= S_IROTH;
+ if (permissions & QFile::WriteOther)
+ mode |= S_IWOTH;
+ if (permissions & QFile::ExeOther)
+ mode |= S_IXOTH;
+
+ bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0;
+ if (success && data) {
+ data->entryFlags &= ~QFileSystemMetaData::Permissions;
+ data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
+ data->knownFlagsMask |= QFileSystemMetaData::Permissions;
+ }
+ if (!success)
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ return success;
+}
+
+QString QFileSystemEngine::homePath()
+{
+ QString home = QFile::decodeName(qgetenv("HOME"));
+ if (home.isNull())
+ home = rootPath();
+ return QDir::cleanPath(home);
+}
+
+QString QFileSystemEngine::rootPath()
+{
+ return QLatin1String("/");
+}
+
+QString QFileSystemEngine::tempPath()
+{
+#ifdef QT_UNIX_TEMP_PATH_OVERRIDE
+ return QLatin1String(QT_UNIX_TEMP_PATH_OVERRIDE);
+#else
+ QString temp = QFile::decodeName(qgetenv("TMPDIR"));
+ if (temp.isEmpty())
+ temp = QLatin1String("/tmp/");
+ return QDir::cleanPath(temp);
+#endif
+}
+
+bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path)
+{
+ int r;
+ r = QT_CHDIR(path.nativeFilePath());
+ return r >= 0;
+}
+
+QFileSystemEntry QFileSystemEngine::currentPath()
+{
+ QFileSystemEntry result;
+ QT_STATBUF st;
+ if (QT_STAT(".", &st) == 0) {
+#if defined(__GLIBC__) && !defined(PATH_MAX)
+ char *currentName = ::get_current_dir_name();
+ if (currentName) {
+ result = QFile::decodeName(QByteArray(currentName));
+ ::free(currentName);
+ }
+#else
+ char currentName[PATH_MAX+1];
+ if (::getcwd(currentName, PATH_MAX))
+ result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath());
+# if defined(QT_DEBUG)
+ if (result.isEmpty())
+ qWarning("QFSFileEngine::currentPath: getcwd() failed");
+# endif
+#endif
+ } else {
+# if defined(QT_DEBUG)
+ qWarning("QFSFileEngine::currentPath: stat(\".\") failed");
+# endif
+ }
+ return result;
+}
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
new file mode 100644
index 0000000..82c6eba
--- /dev/null
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -0,0 +1,1218 @@
+/****************************************************************************
+**
+** 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 "qfilesystemengine_p.h"
+
+#define _POSIX_
+#include "qplatformdefs.h"
+#include "qabstractfileengine.h"
+#include "private/qfsfileengine_p.h"
+#include <private/qsystemlibrary_p.h>
+#include <qdebug.h>
+
+#include "qfile.h"
+#include "qdir.h"
+#include "private/qmutexpool_p.h"
+#include "qvarlengtharray.h"
+#include "qdatetime.h"
+#include "qt_windows.h"
+
+#if !defined(Q_OS_WINCE)
+# include <sys/types.h>
+# include <direct.h>
+# include <winioctl.h>
+#else
+# include <types.h>
+#endif
+#include <objbase.h>
+#include <shlobj.h>
+#include <initguid.h>
+#include <accctrl.h>
+#include <ctype.h>
+#include <limits.h>
+#define SECURITY_WIN32
+#include <security.h>
+
+#ifndef SPI_GETPLATFORMTYPE
+#define SPI_GETPLATFORMTYPE 257
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX FILENAME_MAX
+#endif
+
+#ifndef _INTPTR_T_DEFINED
+#ifdef _WIN64
+typedef __int64 intptr_t;
+#else
+#ifdef _W64
+typedef _W64 int intptr_t;
+#else
+typedef INT_PTR intptr_t;
+#endif
+#endif
+#define _INTPTR_T_DEFINED
+#endif
+
+#ifndef INVALID_FILE_ATTRIBUTES
+# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
+#endif
+
+#if !defined(Q_OS_WINCE)
+# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+typedef struct _REPARSE_DATA_BUFFER {
+ ULONG ReparseTag;
+ USHORT ReparseDataLength;
+ USHORT Reserved;
+ union {
+ struct {
+ USHORT SubstituteNameOffset;
+ USHORT SubstituteNameLength;
+ USHORT PrintNameOffset;
+ USHORT PrintNameLength;
+ ULONG Flags;
+ WCHAR PathBuffer[1];
+ } SymbolicLinkReparseBuffer;
+ struct {
+ USHORT SubstituteNameOffset;
+ USHORT SubstituteNameLength;
+ USHORT PrintNameOffset;
+ USHORT PrintNameLength;
+ WCHAR PathBuffer[1];
+ } MountPointReparseBuffer;
+ struct {
+ UCHAR DataBuffer[1];
+ } GenericReparseBuffer;
+ };
+} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
+# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
+# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+
+# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
+# endif
+# ifndef IO_REPARSE_TAG_SYMLINK
+# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+# endif
+# ifndef FSCTL_GET_REPARSE_POINT
+# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+# endif
+#endif // !defined(Q_OS_WINCE)
+
+QT_BEGIN_NAMESPACE
+
+Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
+
+#if defined(Q_OS_WINCE)
+static QString qfsPrivateCurrentDir = QLatin1String("");
+// As none of the functions we try to resolve do exist on Windows CE
+// we use QT_NO_LIBRARY to shorten everything up a little bit.
+#define QT_NO_LIBRARY 1
+#endif
+
+#if !defined(QT_NO_LIBRARY)
+QT_BEGIN_INCLUDE_NAMESPACE
+typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
+static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0;
+typedef BOOL (WINAPI *PtrLookupAccountSidW)(LPCWSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE);
+static PtrLookupAccountSidW ptrLookupAccountSidW = 0;
+typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID);
+static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0;
+typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK);
+static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
+static TRUSTEE_W currentUserTrusteeW;
+static TRUSTEE_W worldTrusteeW;
+
+typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
+static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
+typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
+static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
+QT_END_INCLUDE_NAMESPACE
+
+
+static void resolveLibs()
+{
+ static bool triedResolve = false;
+ if (!triedResolve) {
+ // need to resolve the security info functions
+
+ // protect initialization
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
+ // check triedResolve again, since another thread may have already
+ // done the initialization
+ if (triedResolve) {
+ // another thread did initialize the security function pointers,
+ // so we shouldn't do it again.
+ return;
+ }
+#endif
+
+ triedResolve = true;
+#if !defined(Q_OS_WINCE)
+ HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
+ if (advapiHnd) {
+ ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
+ ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW");
+ ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW");
+ ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW");
+ }
+ if (ptrBuildTrusteeWithSidW) {
+ // Create TRUSTEE for current user
+ HANDLE hnd = ::GetCurrentProcess();
+ HANDLE token = 0;
+ if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) {
+ TOKEN_USER tu;
+ DWORD retsize;
+ if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize))
+ ptrBuildTrusteeWithSidW(&currentUserTrusteeW, tu.User.Sid);
+ ::CloseHandle(token);
+ }
+
+ typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
+ PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid");
+ typedef PVOID (WINAPI *PtrFreeSid)(PSID);
+ PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid");
+ if (ptrAllocateAndInitializeSid && ptrFreeSid) {
+ // Create TRUSTEE for Everyone (World)
+ SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
+ PSID pWorld = 0;
+ if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld))
+ ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld);
+ ptrFreeSid(pWorld);
+ }
+ }
+ HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
+ if (userenvHnd)
+ ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
+ HINSTANCE kernel32 = LoadLibrary(L"kernel32");
+ if(kernel32)
+ ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
+#endif
+ }
+}
+#endif // QT_NO_LIBRARY
+
+typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD);
+static PtrNetShareEnum ptrNetShareEnum = 0;
+typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID);
+static PtrNetApiBufferFree ptrNetApiBufferFree = 0;
+typedef struct _SHARE_INFO_1 {
+ LPWSTR shi1_netname;
+ DWORD shi1_type;
+ LPWSTR shi1_remark;
+} SHARE_INFO_1;
+
+
+static bool resolveUNCLibs()
+{
+ static bool triedResolve = false;
+ if (!triedResolve) {
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
+ if (triedResolve) {
+ return ptrNetShareEnum && ptrNetApiBufferFree;
+ }
+#endif
+ triedResolve = true;
+#if !defined(Q_OS_WINCE)
+ HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
+ if (hLib) {
+ ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
+ if (ptrNetShareEnum)
+ ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
+ }
+#endif
+ }
+ return ptrNetShareEnum && ptrNetApiBufferFree;
+}
+
+static QString readSymLink(const QFileSystemEntry &link)
+{
+ QString result;
+#if !defined(Q_OS_WINCE)
+ HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(),
+ FILE_READ_EA,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ 0,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
+ 0);
+ if (handle != INVALID_HANDLE_VALUE) {
+ DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
+ REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
+ DWORD retsize = 0;
+ if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
+ if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
+ int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
+ int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
+ const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset];
+ result = QString::fromWCharArray(PathBuffer, length);
+ } else if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+ int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
+ int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
+ const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset];
+ result = QString::fromWCharArray(PathBuffer, length);
+ }
+ // cut-off "//?/" and "/??/"
+ if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\'))
+ result = result.mid(4);
+ }
+ qFree(rdb);
+ CloseHandle(handle);
+
+#if !defined(QT_NO_LIBRARY)
+ resolveLibs();
+ if (ptrGetVolumePathNamesForVolumeNameW) {
+ QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
+ if(matchVolName.indexIn(result) == 0) {
+ DWORD len;
+ wchar_t buffer[MAX_PATH];
+ QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
+ if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
+ result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
+ }
+ }
+#endif
+ }
+#else
+ Q_UNUSED(link);
+#endif // Q_OS_WINCE
+ return result;
+}
+
+static QString readLink(const QFileSystemEntry &link)
+{
+#if !defined(Q_OS_WINCE)
+#if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS)
+ QString ret;
+
+ bool neededCoInit = false;
+ IShellLink *psl; // pointer to IShellLink i/f
+ WIN32_FIND_DATA wfd;
+ wchar_t szGotPath[MAX_PATH];
+
+ // Get pointer to the IShellLink interface.
+ HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
+
+ if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized
+ neededCoInit = true;
+ CoInitialize(NULL);
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellLink, (LPVOID *)&psl);
+ }
+ if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface.
+ IPersistFile *ppf;
+ hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf);
+ if (SUCCEEDED(hres)) {
+ hres = ppf->Load((LPOLESTR)link.nativeFilePath().utf16(), STGM_READ);
+ //The original path of the link is retrieved. If the file/folder
+ //was moved, the return value still have the old path.
+ if (SUCCEEDED(hres)) {
+ if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR)
+ ret = QString::fromWCharArray(szGotPath);
+ }
+ ppf->Release();
+ }
+ psl->Release();
+ }
+ if (neededCoInit)
+ CoUninitialize();
+
+ return ret;
+#else
+ Q_UNUSED(link);
+ return QString();
+#endif // QT_NO_LIBRARY
+#else
+ wchar_t target[MAX_PATH];
+ QString result;
+ if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
+ result = QString::fromWCharArray(target);
+ if (result.startsWith(QLatin1Char('"')))
+ result.remove(0,1);
+ if (result.endsWith(QLatin1Char('"')))
+ result.remove(result.size()-1,1);
+ }
+ return result;
+#endif // Q_OS_WINCE
+}
+
+static bool uncShareExists(const QString &server)
+{
+ // This code assumes the UNC path is always like \\?\UNC\server...
+ QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ if (parts.count() >= 3) {
+ QStringList shares;
+ if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
+ return parts.count() >= 4 ? shares.contains(parts.at(3), Qt::CaseInsensitive) : true;
+ }
+ return false;
+}
+
+static inline bool getFindData(QString path, WIN32_FIND_DATA &findData)
+{
+ // path should not end with a trailing slash
+ while (path.endsWith(QLatin1Char('\\')))
+ path.chop(1);
+
+ // can't handle drives
+ if (!path.endsWith(QLatin1Char(':'))) {
+ HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ ::FindClose(hFind);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList *list)
+{
+ if (resolveUNCLibs()) {
+ SHARE_INFO_1 *BufPtr, *p;
+ DWORD res;
+ DWORD er = 0, tr = 0, resume = 0, i;
+ do {
+ res = ptrNetShareEnum((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume);
+ if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) {
+ p = BufPtr;
+ for (i = 1; i <= er; ++i) {
+ if (list && p->shi1_type == 0)
+ list->append(QString::fromWCharArray(p->shi1_netname));
+ p++;
+ }
+ }
+ ptrNetApiBufferFree(BufPtr);
+ } while (res == ERROR_MORE_DATA);
+ return res == ERROR_SUCCESS;
+ }
+ return false;
+}
+
+void QFileSystemEngine::clearWinStatData(QFileSystemMetaData &data)
+{
+ data.size_ = 0;
+ data.fileAttribute_ = 0;
+ data.creationTime_ = FILETIME();
+ data.lastAccessTime_ = FILETIME();
+ data.lastWriteTime_ = FILETIME();
+}
+
+bool QFileSystemEngine::isCaseSensitive()
+{
+ return false;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
+ QFileSystemMetaData &data)
+{
+ if (data.missingFlags(QFileSystemMetaData::LinkType))
+ QFileSystemEngine::fillMetaData(link, data, QFileSystemMetaData::LinkType);
+
+ QString ret;
+ if (data.isLnkFile())
+ ret = readLink(link);
+ else if (data.isLink())
+ ret = readSymLink(link);
+ return QFileSystemEntry(ret);
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
+{
+ if (data.missingFlags(QFileSystemMetaData::ExistsAttribute))
+ QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute);
+
+ if (data.exists())
+ return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
+ else
+ return QFileSystemEntry();
+}
+
+//static
+QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
+{
+ // can be //server or //server/share
+ QString absPath;
+#if !defined(Q_OS_WINCE)
+ QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
+ wchar_t *fileName = 0;
+ DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
+ if (retLen > (DWORD)buf.size()) {
+ buf.resize(retLen);
+ retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
+ }
+ if (retLen != 0)
+ absPath = QString::fromWCharArray(buf.data(), retLen);
+#else
+ if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\')))
+ absPath = QDir::toNativeSeparators(path);
+ else
+ absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path));
+#endif
+ // This is really ugly, but GetFullPathName strips off whitespace at the end.
+ // If you for instance write ". " in the lineedit of QFileDialog,
+ // (which is an invalid filename) this function will strip the space off and viola,
+ // the file is later reported as existing. Therefore, we re-add the whitespace that
+ // was at the end of path in order to keep the filename invalid.
+ if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' '))
+ absPath.append(QLatin1Char(' '));
+ return absPath;
+}
+
+//static
+QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+{
+ QString ret;
+
+ if (!entry.isRelative()) {
+#if !defined(Q_OS_WINCE)
+ if (entry.isAbsolute()
+ && !entry.filePath().contains(QLatin1String("/../"))
+ && !entry.filePath().contains(QLatin1String("/./"))
+ && !entry.filePath().endsWith(QLatin1String("/.."))
+ && !entry.filePath().endsWith(QLatin1String("/."))) {
+ ret = entry.filePath();
+ } else {
+ ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
+ }
+#else
+ ret = entry.filePath();
+#endif
+ } else {
+ ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
+ }
+
+ // The path should be absolute at this point.
+ // From the docs :
+ // Absolute paths begin with the directory separator "/"
+ // (optionally preceded by a drive specification under Windows).
+ if (ret.at(0) != QLatin1Char('/')) {
+ Q_ASSERT(ret.length() >= 2);
+ Q_ASSERT(ret.at(0).isLetter());
+ Q_ASSERT(ret.at(1) == QLatin1Char(':'));
+
+ // Force uppercase drive letters.
+ ret[0] = ret.at(0).toUpper();
+ }
+ return QFileSystemEntry(ret);
+}
+
+//static
+QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own)
+{
+ QString name;
+#if !defined(QT_NO_LIBRARY)
+ extern int qt_ntfs_permission_lookup;
+ if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
+ resolveLibs();
+ if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) {
+ PSID pOwner = 0;
+ PSECURITY_DESCRIPTOR pSD;
+ if (ptrGetNamedSecurityInfoW((wchar_t*)entry.nativeFilePath().utf16(), SE_FILE_OBJECT,
+ own == QAbstractFileEngine::OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION,
+ own == QAbstractFileEngine::OwnerUser ? &pOwner : 0, own == QAbstractFileEngine::OwnerGroup ? &pOwner : 0,
+ 0, 0, &pSD) == ERROR_SUCCESS) {
+ DWORD lowner = 64;
+ DWORD ldomain = 64;
+ QVarLengthArray<wchar_t, 64> owner(lowner);
+ QVarLengthArray<wchar_t, 64> domain(ldomain);
+ SID_NAME_USE use = SidTypeUnknown;
+ // First call, to determine size of the strings (with '\0').
+ if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner,
+ (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) {
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ if (lowner > (DWORD)owner.size())
+ owner.resize(lowner);
+ if (ldomain > (DWORD)domain.size())
+ domain.resize(ldomain);
+ // Second call, try on resized buf-s
+ if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner,
+ (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) {
+ lowner = 0;
+ }
+ } else {
+ lowner = 0;
+ }
+ }
+ if (lowner != 0)
+ name = QString::fromWCharArray(owner.data());
+ LocalFree(pSD);
+ }
+ }
+ }
+#else
+ Q_UNUSED(own);
+#endif
+ return name;
+}
+
+//static
+bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what)
+{
+ QAbstractFileEngine::FileFlags ret = 0;
+
+#if !defined(QT_NO_LIBRARY)
+ if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
+ resolveLibs();
+ if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) {
+ enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 };
+
+ QString fname = entry.filePath();
+ PSID pOwner = 0;
+ PSID pGroup = 0;
+ PACL pDacl;
+ PSECURITY_DESCRIPTOR pSD;
+ DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT,
+ OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
+ &pOwner, &pGroup, &pDacl, 0, &pSD);
+ if(res == ERROR_SUCCESS) {
+ ACCESS_MASK access_mask;
+ TRUSTEE_W trustee;
+ if (what & QFileSystemMetaData::UserPermissions) { // user
+ data.knownFlagsMask |= QFileSystemMetaData::UserPermissions;
+ if(ptrGetEffectiveRightsFromAclW(pDacl, &currentUserTrusteeW, &access_mask) != ERROR_SUCCESS)
+ access_mask = (ACCESS_MASK)-1;
+ if(access_mask & ReadMask)
+ data.entryFlags |= QFileSystemMetaData::UserReadPermission;
+ if(access_mask & WriteMask)
+ data.entryFlags|= QFileSystemMetaData::UserWritePermission;
+ if(access_mask & ExecMask)
+ data.entryFlags|= QFileSystemMetaData::UserExecutePermission;
+ }
+ if (what & QFileSystemMetaData::OwnerPermissions) { // owner
+ data.knownFlagsMask |= QFileSystemMetaData::OwnerPermissions;
+ ptrBuildTrusteeWithSidW(&trustee, pOwner);
+ if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
+ access_mask = (ACCESS_MASK)-1;
+ if(access_mask & ReadMask)
+ data.entryFlags |= QFileSystemMetaData::OwnerReadPermission;
+ if(access_mask & WriteMask)
+ data.entryFlags |= QFileSystemMetaData::OwnerWritePermission;
+ if(access_mask & ExecMask)
+ data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
+ }
+ if (what & QFileSystemMetaData::GroupPermissions) { // group
+ data.knownFlagsMask |= QFileSystemMetaData::GroupPermissions;
+ ptrBuildTrusteeWithSidW(&trustee, pGroup);
+ if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
+ access_mask = (ACCESS_MASK)-1;
+ if(access_mask & ReadMask)
+ data.entryFlags |= QFileSystemMetaData::GroupReadPermission;
+ if(access_mask & WriteMask)
+ data.entryFlags |= QFileSystemMetaData::GroupWritePermission;
+ if(access_mask & ExecMask)
+ data.entryFlags |= QFileSystemMetaData::GroupExecutePermission;
+ }
+ if (what & QFileSystemMetaData::OtherPermissions) { // other (world)
+ data.knownFlagsMask |= QFileSystemMetaData::OtherPermissions;
+ if(ptrGetEffectiveRightsFromAclW(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS)
+ access_mask = (ACCESS_MASK)-1; // ###
+ if(access_mask & ReadMask)
+ data.entryFlags |= QFileSystemMetaData::OtherReadPermission;
+ if(access_mask & WriteMask)
+ data.entryFlags |= QFileSystemMetaData::OtherWritePermission;
+ if(access_mask & ExecMask)
+ data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission;
+ }
+ LocalFree(pSD);
+ }
+ }
+ } else
+#endif
+ {
+ //### what to do with permissions if we don't use NTFS
+ // for now just add all permissions and what about exe missions ??
+ // also qt_ntfs_permission_lookup is now not set by default ... should it ?
+ data.entryFlags |= QFileSystemMetaData::OwnerReadPermission
+ | QFileSystemMetaData::GroupReadPermission
+ | QFileSystemMetaData::OtherReadPermission;
+
+ if (!(data.fileAttribute_ & FILE_ATTRIBUTE_READONLY)) {
+ data.entryFlags |= QFileSystemMetaData::OwnerWritePermission
+ | QFileSystemMetaData::GroupWritePermission
+ | QFileSystemMetaData::OtherWritePermission;
+ }
+
+ QString fname = entry.filePath();
+ QString ext = fname.right(4).toLower();
+ if (data.isDirectory() ||
+ ext == QLatin1String(".exe") || ext == QLatin1String(".com") || ext == QLatin1String(".bat") ||
+ ext == QLatin1String(".pif") || ext == QLatin1String(".cmd")) {
+ data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission | QFileSystemMetaData::GroupExecutePermission
+ | QFileSystemMetaData::OtherExecutePermission | QFileSystemMetaData::UserExecutePermission;
+ }
+ data.knownFlagsMask |= QFileSystemMetaData::OwnerPermissions | QFileSystemMetaData::GroupPermissions
+ | QFileSystemMetaData::OtherPermissions | QFileSystemMetaData::UserExecutePermission;
+ // calculate user permissions
+ if (what & QFileSystemMetaData::UserReadPermission) {
+ if (::_waccess((wchar_t*)entry.nativeFilePath().utf16(), R_OK) == 0)
+ data.entryFlags |= QFileSystemMetaData::UserReadPermission;
+ data.knownFlagsMask |= QFileSystemMetaData::UserReadPermission;
+ }
+ if (what & QFileSystemMetaData::UserWritePermission) {
+ if (::_waccess((wchar_t*)entry.nativeFilePath().utf16(), W_OK) == 0)
+ data.entryFlags |= QFileSystemMetaData::UserWritePermission;
+ data.knownFlagsMask |= QFileSystemMetaData::UserReadPermission;
+ }
+ }
+
+ return data.hasFlags(what);
+}
+
+static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaData &data)
+{
+ bool entryExists = false;
+ DWORD fileAttrib = 0;
+#if !defined(Q_OS_WINCE)
+ if (fname.isDriveRoot()) {
+ // a valid drive ??
+ DWORD drivesBitmask = ::GetLogicalDrives();
+ int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode());
+ if (drivesBitmask & drivebit) {
+ fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM;
+ entryExists = true;
+ }
+ } else {
+#endif
+ const QString &path = fname.nativeFilePath();
+ bool is_dir = false;
+ if (path.startsWith(QLatin1String("\\\\?\\UNC"))) {
+ // UNC - stat doesn't work for all cases (Windows bug)
+ int s = path.indexOf(path.at(0),7);
+ if (s > 0) {
+ // "\\?\UNC\server\..."
+ s = path.indexOf(path.at(0),s+1);
+ if (s > 0) {
+ // "\\?\UNC\server\share\..."
+ if (s == path.size() - 1) {
+ // "\\?\UNC\server\share\"
+ is_dir = true;
+ } else {
+ // "\\?\UNC\server\share\notfound"
+ }
+ } else {
+ // "\\?\UNC\server\share"
+ is_dir = true;
+ }
+ } else {
+ // "\\?\UNC\server"
+ is_dir = true;
+ }
+ }
+ if (is_dir && uncShareExists(path)) {
+ // looks like a UNC dir, is a dir.
+ fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
+ entryExists = true;
+ }
+#if !defined(Q_OS_WINCE)
+ }
+#endif
+ if (entryExists)
+ data.fillFromFileAttribute(fileAttrib);
+ return entryExists;
+}
+
+static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &data)
+{
+ bool filledData = false;
+ // This assumes the last call to a Windows API failed.
+ int errorCode = GetLastError();
+ if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
+ WIN32_FIND_DATA findData;
+ if (getFindData(fname.nativeFilePath(), findData)
+ && findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
+ data.fillFromFindData(findData, true, fname.isDriveRoot());
+ filledData = true;
+ }
+ }
+ return filledData;
+}
+
+#if !defined(Q_OS_WINCE)
+//static
+bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what)
+{
+ HANDLE fHandle = (HANDLE)_get_osfhandle(fd);
+ if (fHandle != INVALID_HANDLE_VALUE) {
+ return fillMetaData(fHandle, data, what);
+ }
+ return false;
+}
+#endif
+
+//static
+bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what)
+{
+ data.entryFlags &= ~what;
+ clearWinStatData(data);
+ BY_HANDLE_FILE_INFORMATION fileInfo;
+ UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+ if (GetFileInformationByHandle(fHandle , &fileInfo)) {
+ data.fillFromFindInfo(fileInfo);
+ }
+ SetErrorMode(oldmode);
+ return data.hasFlags(what);
+}
+
+//static
+bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
+ QFileSystemMetaData::MetaDataFlags what)
+{
+ what |= QFileSystemMetaData::WinLnkType | QFileSystemMetaData::WinStatFlags;
+ data.entryFlags &= ~what;
+
+ QFileSystemEntry fname;
+ data.knownFlagsMask |= QFileSystemMetaData::WinLnkType;
+ if(entry.filePath().endsWith(QLatin1String(".lnk"))) {
+ data.entryFlags |= QFileSystemMetaData::WinLnkType;
+ fname = QFileSystemEntry(readLink(entry));
+ } else {
+ fname = entry;
+ }
+
+ if (fname.isEmpty()) {
+ data.knownFlagsMask |= what;
+ clearWinStatData(data);
+ return false;
+ }
+
+ if (what & QFileSystemMetaData::WinStatFlags) {
+ UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+ clearWinStatData(data);
+ WIN32_FIND_DATA findData;
+ // The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA
+ // for all members used by fillFindData().
+ bool ok = ::GetFileAttributesEx((wchar_t*)fname.nativeFilePath().utf16(), GetFileExInfoStandard,
+ reinterpret_cast<WIN32_FILE_ATTRIBUTE_DATA *>(&findData));
+ if (ok) {
+ data.fillFromFindData(findData, false, fname.isDriveRoot());
+ } else {
+ if (!tryFindFallback(fname, data))
+ tryDriveUNCFallback(fname, data);
+ }
+ SetErrorMode(oldmode);
+ }
+
+ if (what & QFileSystemMetaData::Permissions)
+ fillPermissions(fname, data, what);
+ if ((what & QFileSystemMetaData::LinkType)
+ && data.missingFlags(QFileSystemMetaData::LinkType)) {
+ data.knownFlagsMask |= QFileSystemMetaData::LinkType;
+ if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) {
+ WIN32_FIND_DATA findData;
+ if (getFindData(fname.nativeFilePath(), findData))
+ data.fillFromFindData(findData, true);
+ }
+ }
+ data.knownFlagsMask |= what;
+ return data.hasFlags(what);
+}
+
+static inline bool mkDir(const QString &path)
+{
+#if defined(Q_OS_WINCE)
+ // Unfortunately CreateDirectory returns true for paths longer than
+ // 256, but does not create a directory. It starts to fail, when
+ // path length > MAX_PATH, which is 260 usually on CE.
+ // This only happens on a Windows Mobile device. Windows CE seems
+ // not to be affected by this.
+ static int platformId = 0;
+ if (platformId == 0) {
+ wchar_t platformString[64];
+ if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
+ if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
+ platformId = 1;
+ else
+ platformId = 2;
+ }
+ }
+ if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
+ return false;
+#endif
+ return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0);
+}
+
+static inline bool rmDir(const QString &path)
+{
+ return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
+}
+
+static bool isDirPath(const QString &dirPath, bool *existed)
+{
+ QString path = dirPath;
+ if (path.length() == 2 && path.at(1) == QLatin1Char(':'))
+ path += QLatin1Char('\\');
+
+ DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
+ if (fileAttrib == INVALID_FILE_ATTRIBUTES) {
+ int errorCode = GetLastError();
+ if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
+ WIN32_FIND_DATA findData;
+ if (getFindData(QFSFileEnginePrivate::longFileName(path), findData))
+ fileAttrib = findData.dwFileAttributes;
+ }
+ }
+
+ if (existed)
+ *existed = fileAttrib != INVALID_FILE_ATTRIBUTES;
+
+ if (fileAttrib == INVALID_FILE_ATTRIBUTES)
+ return false;
+
+ return fileAttrib & FILE_ATTRIBUTE_DIRECTORY;
+}
+
+//static
+bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
+{
+ QString dirName = entry.filePath();
+ if (createParents) {
+ dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
+ // We spefically search for / so \ would break it..
+ int oldslash = -1;
+ if (dirName.startsWith(QLatin1String("\\\\"))) {
+ // Don't try to create the root path of a UNC path;
+ // CreateDirectory() will just return ERROR_INVALID_NAME.
+ for (int i = 0; i < dirName.size(); ++i) {
+ if (dirName.at(i) != QDir::separator()) {
+ oldslash = i;
+ break;
+ }
+ }
+ if (oldslash != -1)
+ oldslash = dirName.indexOf(QDir::separator(), oldslash);
+ }
+ for (int slash=0; slash != -1; oldslash = slash) {
+ slash = dirName.indexOf(QDir::separator(), oldslash+1);
+ if (slash == -1) {
+ if (oldslash == dirName.length())
+ break;
+ slash = dirName.length();
+ }
+ if (slash) {
+ QString chunk = dirName.left(slash);
+ bool existed = false;
+ if (!isDirPath(chunk, &existed)) {
+ if (!existed) {
+ if (!mkDir(chunk))
+ return false;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ return mkDir(entry.filePath());
+}
+
+//static
+bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
+{
+ QString dirName = entry.filePath();
+ if (removeEmptyParents) {
+ dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
+ for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
+ QString chunk = dirName.left(slash);
+ if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':'))
+ break;
+ if (!isDirPath(chunk, 0))
+ return false;
+ if (!rmDir(chunk))
+ return oldslash != 0;
+ slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
+ }
+ return true;
+ }
+ return rmDir(entry.filePath());
+}
+
+//static
+QString QFileSystemEngine::rootPath()
+{
+#if defined(Q_OS_WINCE)
+ QString ret = QLatin1String("/");
+#elif defined(Q_FS_FAT)
+ QString ret = QString::fromLatin1(qgetenv("SystemDrive").constData());
+ if (ret.isEmpty())
+ ret = QLatin1String("c:");
+ ret.append(QLatin1Char('/'));
+#elif defined(Q_OS_OS2EMX)
+ char dir[4];
+ _abspath(dir, QLatin1String("/"), _MAX_PATH);
+ QString ret(dir);
+#endif
+ return ret;
+}
+
+//static
+QString QFileSystemEngine::homePath()
+{
+ QString ret;
+#if !defined(QT_NO_LIBRARY)
+ resolveLibs();
+ if (ptrGetUserProfileDirectoryW) {
+ HANDLE hnd = ::GetCurrentProcess();
+ HANDLE token = 0;
+ BOOL ok = ::OpenProcessToken(hnd, TOKEN_QUERY, &token);
+ if (ok) {
+ DWORD dwBufferSize = 0;
+ // First call, to determine size of the strings (with '\0').
+ ok = ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize);
+ if (!ok && dwBufferSize != 0) { // We got the required buffer size
+ wchar_t *userDirectory = new wchar_t[dwBufferSize];
+ // Second call, now we can fill the allocated buffer.
+ ok = ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize);
+ if (ok)
+ ret = QString::fromWCharArray(userDirectory);
+ delete [] userDirectory;
+ }
+ ::CloseHandle(token);
+ }
+ }
+#endif
+ if (ret.isEmpty() || !QFile::exists(ret)) {
+ ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData());
+ if (ret.isEmpty() || !QFile::exists(ret)) {
+ ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE").constData())
+ + QString::fromLocal8Bit(qgetenv("HOMEPATH").constData());
+ if (ret.isEmpty() || !QFile::exists(ret)) {
+ ret = QString::fromLocal8Bit(qgetenv("HOME").constData());
+ if (ret.isEmpty() || !QFile::exists(ret)) {
+#if defined(Q_OS_WINCE)
+ ret = QLatin1String("\\My Documents");
+ if (!QFile::exists(ret))
+#endif
+ ret = rootPath();
+ }
+ }
+ }
+ }
+ return QDir::fromNativeSeparators(ret);
+}
+
+QString QFileSystemEngine::tempPath()
+{
+ QString ret;
+ wchar_t tempPath[MAX_PATH];
+ DWORD len = GetTempPath(MAX_PATH, tempPath);
+ if (len)
+ ret = QString::fromWCharArray(tempPath, len);
+ if (!ret.isEmpty()) {
+ while (ret.endsWith(QLatin1Char('\\')))
+ ret.chop(1);
+ ret = QDir::fromNativeSeparators(ret);
+ }
+ if (ret.isEmpty()) {
+#if !defined(Q_OS_WINCE)
+ ret = QLatin1String("c:/tmp");
+#else
+ ret = QLatin1String("/Temp");
+#endif
+ }
+ return ret;
+}
+
+bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
+{
+ QFileSystemMetaData meta;
+ fillMetaData(entry, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType);
+ if(!(meta.exists() && meta.isDirectory()))
+ return false;
+
+#if !defined(Q_OS_WINCE)
+ //TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
+ //which causes many problems later on when it's returned through currentPath()
+ return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
+#else
+ qfsPrivateCurrentDir = entry.filePath();
+ return true;
+#endif
+}
+
+QFileSystemEntry QFileSystemEngine::currentPath()
+{
+ QString ret;
+#if !defined(Q_OS_WINCE)
+ DWORD size = 0;
+ wchar_t currentName[PATH_MAX];
+ size = ::GetCurrentDirectory(PATH_MAX, currentName);
+ if (size != 0) {
+ if (size > PATH_MAX) {
+ wchar_t *newCurrentName = new wchar_t[size];
+ if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0)
+ ret = QString::fromWCharArray(newCurrentName, size);
+ delete [] newCurrentName;
+ } else {
+ ret = QString::fromWCharArray(currentName, size);
+ }
+ }
+ if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
+ ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
+#else
+ Q_UNUSED(fileName);
+ //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
+ if (qfsPrivateCurrentDir.isEmpty())
+ qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
+
+ ret = qfsPrivateCurrentDir;
+#endif
+ return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
+}
+
+//static
+bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ Q_ASSERT(false);
+ Q_UNUSED(source)
+ Q_UNUSED(target)
+ Q_UNUSED(error)
+
+ return false; // TODO implement; - code needs to be moved from qfsfileengine_win.cpp
+}
+
+//static
+bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(),
+ (wchar_t*)target.nativeFilePath().utf16(), true) != 0;
+ if(!ret)
+ error = QSystemError(::GetLastError(), QSystemError::NativeError);
+ return ret;
+}
+
+//static
+bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
+{
+ bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(),
+ (wchar_t*)target.nativeFilePath().utf16()) != 0;
+ if(!ret)
+ error = QSystemError(::GetLastError(), QSystemError::NativeError);
+ return ret;
+}
+
+//static
+bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error)
+{
+ bool ret = ::DeleteFile((wchar_t*)entry.nativeFilePath().utf16()) != 0;
+ if(!ret)
+ error = QSystemError(::GetLastError(), QSystemError::NativeError);
+ return ret;
+}
+
+//static
+bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error,
+ QFileSystemMetaData *data)
+{
+ Q_UNUSED(data);
+ int mode = 0;
+
+ if (permissions & QFile::ReadOwner || permissions & QFile::ReadUser
+ || permissions & QFile::ReadGroup || permissions & QFile::ReadOther)
+ mode |= _S_IREAD;
+ if (permissions & QFile::WriteOwner || permissions & QFile::WriteUser
+ || permissions & QFile::WriteGroup || permissions & QFile::WriteOther)
+ mode |= _S_IWRITE;
+
+ if (mode == 0) // not supported
+ return false;
+
+ bool ret = (::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0);
+ if(!ret)
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ return ret;
+}
+
+static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
+{
+ QDateTime ret;
+
+#if defined(Q_OS_WINCE)
+ SYSTEMTIME systime;
+ FILETIME ftime;
+ systime.wYear = 1970;
+ systime.wMonth = 1;
+ systime.wDay = 1;
+ systime.wHour = 0;
+ systime.wMinute = 0;
+ systime.wSecond = 0;
+ systime.wMilliseconds = 0;
+ systime.wDayOfWeek = 4;
+ SystemTimeToFileTime(&systime, &ftime);
+ unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
+ FileTimeToSystemTime(time, &systime);
+ unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
+ unsigned __int64 difftime = acttime - time1970;
+ difftime /= 10000000;
+ ret.setTime_t((unsigned int)difftime);
+#else
+ SYSTEMTIME sTime, lTime;
+ FileTimeToSystemTime(time, &sTime);
+ SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
+ ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
+ ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
+#endif
+
+ return ret;
+}
+
+QDateTime QFileSystemMetaData::creationTime() const
+{
+ return fileTimeToQDateTime(&creationTime_);
+}
+QDateTime QFileSystemMetaData::modificationTime() const
+{
+ return fileTimeToQDateTime(&lastWriteTime_);
+}
+QDateTime QFileSystemMetaData::accessTime() const
+{
+ return fileTimeToQDateTime(&lastAccessTime_);
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
new file mode 100644
index 0000000..ccbb10d
--- /dev/null
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -0,0 +1,383 @@
+/****************************************************************************
+**
+** 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 "qfilesystementry_p.h"
+
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/private/qfsfileengine_p.h>
+#ifdef Q_OS_WIN
+#include <QtCore/qstringbuilder.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_WIN
+static bool isUncRoot(const QString &server)
+{
+ QString localPath = QDir::toNativeSeparators(server);
+ if (!localPath.startsWith(QLatin1String("\\\\")))
+ return false;
+
+ int idx = localPath.indexOf(QLatin1Char('\\'), 2);
+ if (idx == -1 || idx + 1 == localPath.length())
+ return true;
+
+ localPath = localPath.right(localPath.length() - idx - 1).trimmed();
+ return localPath.isEmpty();
+}
+
+static inline QString fixIfRelativeUncPath(const QString &path)
+{
+ QString currentPath = QDir::currentPath();
+ if (currentPath.startsWith(QLatin1String("//")))
+ return currentPath % QChar(QLatin1Char('/')) % path;
+ return path;
+}
+#endif
+
+QFileSystemEntry::QFileSystemEntry()
+ : m_lastSeparator(0),
+ m_firstDotInFileName(0),
+ m_lastDotInFileName(0)
+{
+}
+
+/*!
+ \internal
+ Use this constructor when the path is supplied by user code, as it may contain a mix
+ of '/' and the native separator.
+ */
+QFileSystemEntry::QFileSystemEntry(const QString &filePath)
+ : m_filePath(QDir::fromNativeSeparators(filePath)),
+ m_lastSeparator(-2),
+ m_firstDotInFileName(-2),
+ m_lastDotInFileName(0)
+{
+}
+
+/*!
+ \internal
+ Use this constructor when the path is guaranteed to be in internal format, i.e. all
+ directory separators are '/' and not the native separator.
+ */
+QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath /* dummy */)
+ : m_filePath(filePath),
+ m_lastSeparator(-2),
+ m_firstDotInFileName(-2),
+ m_lastDotInFileName(0)
+{
+}
+
+/*!
+ \internal
+ Use this constructor when the path comes from a native API
+ */
+QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath /* dummy */)
+ : m_nativeFilePath(nativeFilePath),
+ m_lastSeparator(-2),
+ m_firstDotInFileName(-2),
+ m_lastDotInFileName(0)
+{
+}
+
+QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath)
+ : m_filePath(QDir::fromNativeSeparators(filePath)),
+ m_nativeFilePath(nativeFilePath),
+ m_lastSeparator(-2),
+ m_firstDotInFileName(-2),
+ m_lastDotInFileName(0)
+{
+}
+
+QString QFileSystemEntry::filePath() const
+{
+ resolveFilePath();
+ return m_filePath;
+}
+
+QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const
+{
+ resolveNativeFilePath();
+ return m_nativeFilePath;
+}
+
+void QFileSystemEntry::resolveFilePath() const
+{
+ if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) {
+#if defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16)
+ m_filePath = QDir::fromNativeSeparators(m_nativeFilePath);
+#ifdef Q_OS_WIN
+ if (m_filePath.startsWith(QLatin1String("//?/UNC/")))
+ m_filePath = m_filePath.remove(2,6);
+ if (m_filePath.startsWith(QLatin1String("//?/")))
+ m_filePath = m_filePath.remove(0,4);
+#endif
+#else
+ m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath));
+#endif
+ }
+}
+
+void QFileSystemEntry::resolveNativeFilePath() const
+{
+ if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) {
+#ifdef Q_OS_WIN
+ QString filePath = m_filePath;
+ if (isRelative())
+ filePath = fixIfRelativeUncPath(m_filePath);
+ m_nativeFilePath = QFSFileEnginePrivate::longFileName(QDir::toNativeSeparators(filePath));
+#elif defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16)
+ m_nativeFilePath = QDir::toNativeSeparators(m_filePath);
+#else
+ m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath));
+#endif
+ }
+}
+
+QString QFileSystemEntry::fileName() const
+{
+ findLastSeparator();
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ return m_filePath.mid(2);
+#endif
+ return m_filePath.mid(m_lastSeparator + 1);
+}
+
+QString QFileSystemEntry::path() const
+{
+ findLastSeparator();
+ if (m_lastSeparator == -1) {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ return m_filePath.left(2);
+#endif
+ return QString(QLatin1Char('.'));
+ }
+ if (m_lastSeparator == 0)
+ return QString(QLatin1Char('/'));
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (m_lastSeparator == 2 && m_filePath.at(1) == QLatin1Char(':'))
+ return m_filePath.left(m_lastSeparator + 1);
+#endif
+ return m_filePath.left(m_lastSeparator);
+}
+
+QString QFileSystemEntry::baseName() const
+{
+ findFileNameSeparators();
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ return m_filePath.mid(2);
+#endif
+ int length = -1;
+ if (m_firstDotInFileName >= 0) {
+ length = m_firstDotInFileName;
+ if (m_lastSeparator != -1) // avoid off by one
+ length--;
+ }
+ return m_filePath.mid(m_lastSeparator + 1, length);
+}
+
+QString QFileSystemEntry::completeBaseName() const
+{
+ findFileNameSeparators();
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ return m_filePath.mid(2);
+#endif
+ int length = -1;
+ if (m_firstDotInFileName >= 0) {
+ length = m_firstDotInFileName + m_lastDotInFileName;
+ if (m_lastSeparator != -1) // avoid off by one
+ length--;
+ }
+ return m_filePath.mid(m_lastSeparator + 1, length);
+}
+
+QString QFileSystemEntry::suffix() const
+{
+ findFileNameSeparators();
+
+ if (m_lastDotInFileName == -1)
+ return QString();
+
+ return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + m_lastDotInFileName + 1);
+}
+
+QString QFileSystemEntry::completeSuffix() const
+{
+ findFileNameSeparators();
+ if (m_firstDotInFileName == -1)
+ return QString();
+
+ return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + 1);
+}
+
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+bool QFileSystemEntry::isRelative() const
+{
+ resolveFilePath();
+ return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/')
+ && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':'))));
+}
+
+bool QFileSystemEntry::isAbsolute() const
+{
+ resolveFilePath();
+ return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3
+ && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/'))
+#ifdef Q_OS_WIN
+ || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))
+#endif
+ ));
+}
+#else
+bool QFileSystemEntry::isRelative() const
+{
+ return !isAbsolute();
+}
+
+bool QFileSystemEntry::isAbsolute() const
+{
+ resolveFilePath();
+ return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/'));
+}
+#endif
+
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+bool QFileSystemEntry::isDriveRoot() const
+{
+ resolveFilePath();
+ return (m_filePath.length() == 3
+ && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':')
+ && m_filePath.at(2) == QLatin1Char('/'));
+}
+#endif
+
+bool QFileSystemEntry::isRoot() const
+{
+ resolveFilePath();
+ if (m_filePath == QLatin1String("/")
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ || isDriveRoot()
+#if defined(Q_OS_WIN)
+ || isUncRoot(m_filePath)
+#endif
+#endif
+ )
+ return true;
+
+ return false;
+}
+
+bool QFileSystemEntry::isEmpty() const
+{
+ resolveNativeFilePath();
+ return m_nativeFilePath.isEmpty();
+}
+
+// private methods
+
+void QFileSystemEntry::findLastSeparator() const
+{
+ if (m_lastSeparator == -2) {
+ resolveFilePath();
+ m_lastSeparator = -1;
+ for (int i = m_filePath.size() - 1; i >= 0; --i) {
+ if (m_filePath[i].unicode() == '/') {
+ m_lastSeparator = i;
+ break;
+ }
+ }
+ }
+}
+
+void QFileSystemEntry::findFileNameSeparators() const
+{
+ if (m_firstDotInFileName == -2) {
+ resolveFilePath();
+ int firstDotInFileName = -1;
+ int lastDotInFileName = -1;
+ int lastSeparator = m_lastSeparator;
+
+ int stop;
+ if (lastSeparator < 0) {
+ lastSeparator = -1;
+ stop = 0;
+ } else {
+ stop = lastSeparator;
+ }
+
+ int i = m_filePath.size() - 1;
+ for (; i >= stop; --i) {
+ if (m_filePath[i].unicode() == '.') {
+ firstDotInFileName = lastDotInFileName = i;
+ break;
+ } else if (m_filePath[i].unicode() == '/') {
+ lastSeparator = i;
+ break;
+ }
+ }
+
+ if (lastSeparator != i) {
+ for (--i; i >= stop; --i) {
+ if (m_filePath[i].unicode() == '.')
+ firstDotInFileName = i;
+ else if (m_filePath[i].unicode() == '/') {
+ lastSeparator = i;
+ break;
+ }
+ }
+ }
+ m_lastSeparator = lastSeparator;
+ m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - qMax(0, lastSeparator);
+ if (lastDotInFileName == -1)
+ m_lastDotInFileName = -1;
+ else if (firstDotInFileName == lastDotInFileName)
+ m_lastDotInFileName = 0;
+ else
+ m_lastDotInFileName = lastDotInFileName - firstDotInFileName;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
new file mode 100644
index 0000000..d4d16d0
--- /dev/null
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QFILESYSTEMENTRY_P_H_INCLUDED
+#define QFILESYSTEMENTRY_P_H_INCLUDED
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qstring.h>
+#include <QtCore/qbytearray.h>
+
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+#define QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QFileSystemEntry
+{
+public:
+
+#ifndef QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16
+ typedef QByteArray NativePath;
+#else
+ typedef QString NativePath;
+#endif
+ struct FromNativePath{};
+ struct FromInternalPath{};
+
+ QFileSystemEntry();
+ explicit QFileSystemEntry(const QString &filePath);
+
+ QFileSystemEntry(const QString &filePath, FromInternalPath dummy);
+ QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy);
+ QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath);
+
+ QString filePath() const;
+ QString fileName() const;
+ QString path() const;
+ NativePath nativeFilePath() const;
+ QString baseName() const;
+ QString completeBaseName() const;
+ QString suffix() const;
+ QString completeSuffix() const;
+ bool isAbsolute() const;
+ bool isRelative() const;
+
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ bool isDriveRoot() const;
+#endif
+ bool isRoot() const;
+
+ bool isEmpty() const;
+ void clear()
+ {
+ *this = QFileSystemEntry();
+ }
+
+private:
+ // creates the QString version out of the bytearray version
+ void resolveFilePath() const;
+ // creates the bytearray version out of the QString version
+ void resolveNativeFilePath() const;
+ // resolves the separator
+ void findLastSeparator() const;
+ // resolves the dots and the separator
+ void findFileNameSeparators() const;
+
+ mutable QString m_filePath; // always has slashes as separator
+ mutable NativePath m_nativeFilePath; // native encoding and separators
+
+ mutable qint16 m_lastSeparator; // index in m_filePath of last separator
+ mutable qint16 m_firstDotInFileName; // index after m_filePath for first dot (.)
+ mutable qint16 m_lastDotInFileName; // index after m_firstDotInFileName for last dot (.)
+};
+
+QT_END_NAMESPACE
+
+#endif // include guard
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
new file mode 100644
index 0000000..fb8bfe6
--- /dev/null
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** 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 QFILESYSTEMITERATOR_P_H_INCLUDED
+#define QFILESYSTEMITERATOR_P_H_INCLUDED
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_FILESYSTEMITERATOR
+
+#include <QtCore/qdir.h>
+#include <QtCore/qdiriterator.h>
+#include <QtCore/qstringlist.h>
+
+#include <QtCore/private/qfilesystementry_p.h>
+#include <QtCore/private/qfilesystemmetadata_p.h>
+
+// Platform-specific headers
+#if defined(Q_OS_WIN)
+#elif defined (Q_OS_SYMBIAN)
+#include <f32file.h>
+#else
+#include <QtCore/qscopedpointer.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QFileSystemIterator
+{
+public:
+ QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
+ const QStringList &nameFilters, QDirIterator::IteratorFlags flags
+ = QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
+ ~QFileSystemIterator();
+
+ bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData);
+
+private:
+ QFileSystemEntry::NativePath nativePath;
+
+ // Platform-specific data
+#if defined(Q_OS_WIN)
+ QFileSystemEntry::NativePath dirPath;
+ HANDLE findFileHandle;
+ QStringList uncShares;
+ bool uncFallback;
+ int uncShareIndex;
+ bool onlyDirs;
+#elif defined (Q_OS_SYMBIAN)
+ RDir dirHandle;
+ TEntryArray entries;
+ TInt lastError;
+ TInt entryIndex;
+#else
+ QT_DIR *dir;
+ QT_DIRENT *dirEntry;
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+ // for readdir_r
+ QScopedPointer<QT_DIRENT, QScopedPointerPodDeleter> mt_file;
+#endif
+ int lastError;
+#endif
+
+ Q_DISABLE_COPY(QFileSystemIterator)
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_FILESYSTEMITERATOR
+
+#endif // include guard
diff --git a/src/corelib/io/qfilesystemiterator_symbian.cpp b/src/corelib/io/qfilesystemiterator_symbian.cpp
new file mode 100644
index 0000000..23c726a
--- /dev/null
+++ b/src/corelib/io/qfilesystemiterator_symbian.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** 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 "qfilesystemiterator_p.h"
+#include "qfilesystemengine_p.h"
+#include <QtCore/private/qcore_symbian_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &path, QDir::Filters filters,
+ const QStringList &nameFilters, QDirIterator::IteratorFlags iteratorFlags)
+ : lastError(KErrNone), entryIndex(-1)
+{
+ RFs& fs = qt_s60GetRFs();
+
+ nativePath = path.nativeFilePath();
+ if (!nativePath.endsWith(QLatin1Char('\\')))
+ nativePath.append(QLatin1Char('\\'));
+
+ QString absPath = QFileSystemEngine::absoluteName(path).nativeFilePath();
+
+ if (!absPath.endsWith(QLatin1Char('\\')))
+ absPath.append(QLatin1Char('\\'));
+
+ int pathLen = absPath.length();
+ if (pathLen > KMaxFileName) {
+ lastError = KErrBadName;
+ return;
+ }
+
+ //set up server side filtering to reduce IPCs
+ //RDir won't accept all valid name filters e.g. "*. bar"
+ if (nameFilters.count() == 1 && !(filters & QDir::AllDirs) && iteratorFlags
+ == QDirIterator::NoIteratorFlags && pathLen + nameFilters[0].length()
+ <= KMaxFileName) {
+ //server side supports one mask - skip this for recursive mode or if only files should be filtered
+ absPath.append(nameFilters[0]);
+ }
+
+ TUint symbianMask = 0;
+ if ((filters & QDir::Dirs) || (filters & QDir::AllDirs) || (iteratorFlags
+ & QDirIterator::Subdirectories))
+ symbianMask |= KEntryAttDir; //include directories
+ if (filters & QDir::Hidden)
+ symbianMask |= KEntryAttHidden;
+ if (filters & QDir::System)
+ symbianMask |= KEntryAttSystem;
+ if (((filters & QDir::Files) == 0) && symbianMask == KEntryAttDir)
+ symbianMask |= KEntryAttMatchExclusive; //exclude non-directories
+ else if (symbianMask == 0) {
+ if ((filters & QDir::PermissionMask) == QDir::Writable)
+ symbianMask = KEntryAttMatchExclude | KEntryAttReadOnly;
+ else if ((filters & QDir::PermissionMask) == QDir::Readable)
+ symbianMask = KEntryAttMatchExclusive | KEntryAttReadOnly;
+ }
+
+ lastError = dirHandle.Open(fs, qt_QString2TPtrC(absPath), symbianMask);
+}
+
+QFileSystemIterator::~QFileSystemIterator()
+{
+ dirHandle.Close();
+}
+
+bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
+{
+ //1st time, lastError is result of dirHandle.Open(), entries.Count() is 0 and entryIndex is -1 so initial read is triggered
+ //subsequent times, read is triggered each time we reach the end of the entry list
+ //final time, lastError is KErrEof so we don't need to read anymore.
+ ++entryIndex;
+ if (lastError == KErrNone && entryIndex >= entries.Count()) {
+ lastError = dirHandle.Read(entries);
+ entryIndex = 0;
+ }
+
+ //each call to advance() gets the next entry from the entry list.
+ //from the final (or only) read call, KErrEof is returned together with a full buffer so we still need to go through the list
+ if ((lastError == KErrNone || lastError == KErrEof) && entryIndex < entries.Count()) {
+ Q_ASSERT(entryIndex >= 0);
+ const TEntry &entry(entries[entryIndex]);
+ fileEntry = QFileSystemEntry(nativePath + qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath());
+ metaData.fillFromTEntry(entry);
+ return true;
+ }
+
+ //TODO: error reporting, to allow user to distinguish empty directory from error condition.
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
new file mode 100644
index 0000000..3d6012b
--- /dev/null
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** 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 "qplatformdefs.h"
+#include "qfilesystemiterator_p.h"
+
+#ifndef QT_NO_FILESYSTEMITERATOR
+
+#include <stdlib.h>
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
+ const QStringList &nameFilters, QDirIterator::IteratorFlags flags)
+ : nativePath(entry.nativeFilePath())
+ , dir(0)
+ , dirEntry(0)
+ , lastError(0)
+{
+ Q_UNUSED(filters)
+ Q_UNUSED(nameFilters)
+ Q_UNUSED(flags)
+
+ if ((dir = QT_OPENDIR(nativePath.constData())) == 0) {
+ lastError = errno;
+ } else {
+
+ if (!nativePath.endsWith('/'))
+ nativePath.append('/');
+
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+ // ### Race condition; we should use fpathconf and dirfd().
+ size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX);
+ if (maxPathName == size_t(-1))
+ maxPathName = FILENAME_MAX;
+ maxPathName += sizeof(QT_DIRENT) + 1;
+
+ QT_DIRENT *p = reinterpret_cast<QT_DIRENT*>(::malloc(maxPathName));
+ Q_CHECK_PTR(p);
+
+ mt_file.reset(p);
+#endif
+ }
+}
+
+QFileSystemIterator::~QFileSystemIterator()
+{
+ if (dir)
+ QT_CLOSEDIR(dir);
+}
+
+bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
+{
+ if (!dir)
+ return false;
+
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+ lastError = QT_READDIR_R(dir, mt_file.data(), &dirEntry);
+ if (lastError)
+ return false;
+#else
+ // ### add local lock to prevent breaking reentrancy
+ dirEntry = QT_READDIR(dir);
+#endif // _POSIX_THREAD_SAFE_FUNCTIONS
+
+ if (dirEntry) {
+ fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
+ metaData.fillFromDirEnt(*dirEntry);
+ return true;
+ }
+
+ lastError = errno;
+ return false;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_FILESYSTEMITERATOR
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
new file mode 100644
index 0000000..0e94130
--- /dev/null
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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$
+**
+****************************************************************************/
+
+#if _WIN32_WINNT < 0x0500
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#endif
+
+#include "qfilesystemiterator_p.h"
+#include "qfilesystemengine_p.h"
+#include "qplatformdefs.h"
+
+#include <QtCore/qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+
+bool done = true;
+
+QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
+ const QStringList &nameFilters, QDirIterator::IteratorFlags flags)
+ : nativePath(entry.nativeFilePath())
+ , dirPath(entry.filePath())
+ , findFileHandle(INVALID_HANDLE_VALUE)
+ , uncFallback(false)
+ , uncShareIndex(0)
+ , onlyDirs(false)
+{
+ Q_UNUSED(nameFilters)
+ Q_UNUSED(flags)
+ if (nativePath.endsWith(QLatin1String(".lnk"))) {
+ QFileSystemMetaData metaData;
+ QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData);
+ nativePath = link.nativeFilePath();
+ }
+ if (!nativePath.endsWith(QLatin1Char('\\')))
+ nativePath.append(QLatin1Char('\\'));
+ nativePath.append(QLatin1Char('*'));
+ if (!dirPath.endsWith(QLatin1Char('/')))
+ dirPath.append(QLatin1Char('/'));
+ if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files))))
+ onlyDirs = true;
+}
+
+QFileSystemIterator::~QFileSystemIterator()
+{
+ if (findFileHandle != INVALID_HANDLE_VALUE)
+ FindClose(findFileHandle);
+}
+
+bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
+{
+ bool haveData = false;
+ WIN32_FIND_DATA findData;
+
+ if (findFileHandle == INVALID_HANDLE_VALUE && !uncFallback) {
+ haveData = true;
+ int infoLevel = 0 ; // FindExInfoStandard;
+ DWORD dwAdditionalFlags = 0;
+ if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
+ dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
+ infoLevel = 1 ; // FindExInfoBasic;
+ }
+ int searchOps = 0; // FindExSearchNameMatch
+ if (onlyDirs)
+ searchOps = 1 ; // FindExSearchLimitToDirectories
+ findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData,
+ FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags);
+ if (findFileHandle == INVALID_HANDLE_VALUE) {
+ if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) {
+ QStringList parts = nativePath.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer(
+ QLatin1String("\\\\") + parts.at(2), &uncShares)) {
+ if (uncShares.isEmpty())
+ return false; // No shares found in the server
+ else
+ uncFallback = true;
+ }
+ }
+ }
+ }
+ if (findFileHandle == INVALID_HANDLE_VALUE && !uncFallback)
+ return false;
+ // Retrieve the new file information.
+ if (!haveData) {
+ if (uncFallback) {
+ if (++uncShareIndex >= uncShares.count())
+ return false;
+ } else {
+ if (!FindNextFile(findFileHandle, &findData))
+ return false;
+ }
+ }
+ // Create the new file system entry & meta data.
+ if (uncFallback) {
+ fileEntry = QFileSystemEntry(dirPath + uncShares.at(uncShareIndex));
+ metaData.fillFromFileAttribute(FILE_ATTRIBUTE_DIRECTORY);
+ return true;
+ } else {
+ QString fileName = QString::fromWCharArray(findData.cFileName);
+ fileEntry = QFileSystemEntry(dirPath + fileName);
+ metaData = QFileSystemMetaData();
+ if (!fileName.endsWith(QLatin1String(".lnk"))) {
+ metaData.fillFromFindData(findData, true);
+ }
+ return true;
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
new file mode 100644
index 0000000..f7f1fa1
--- /dev/null
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -0,0 +1,400 @@
+/****************************************************************************
+**
+** 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 QFILESYSTEMMETADATA_P_H_INCLUDED
+#define QFILESYSTEMMETADATA_P_H_INCLUDED
+
+//
+// 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 "qplatformdefs.h"
+#include <QtCore/qglobal.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qabstractfileengine.h>
+
+// Platform-specific includes
+#if defined(Q_OS_WIN)
+#ifndef IO_REPARSE_TAG_SYMLINK
+#define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+#endif
+#elif defined(Q_OS_SYMBIAN)
+#include <f32file.h>
+#include <QtCore/private/qdatetime_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QFileSystemEngine;
+
+class QFileSystemMetaData
+{
+public:
+ QFileSystemMetaData()
+ : knownFlagsMask(0)
+ {
+ }
+
+ enum MetaDataFlag {
+ // Permissions, overlaps with QFile::Permissions
+ OtherReadPermission = 0x00000004, OtherWritePermission = 0x00000002, OtherExecutePermission = 0x00000001,
+ GroupReadPermission = 0x00000040, GroupWritePermission = 0x00000020, GroupExecutePermission = 0x00000010,
+ UserReadPermission = 0x00000400, UserWritePermission = 0x00000200, UserExecutePermission = 0x00000100,
+ OwnerReadPermission = 0x00004000, OwnerWritePermission = 0x00002000, OwnerExecutePermission = 0x00001000,
+
+ OtherPermissions = OtherReadPermission | OtherWritePermission | OtherExecutePermission,
+ GroupPermissions = GroupReadPermission | GroupWritePermission | GroupExecutePermission,
+ UserPermissions = UserReadPermission | UserWritePermission | UserExecutePermission,
+ OwnerPermissions = OwnerReadPermission | OwnerWritePermission | OwnerExecutePermission,
+
+ ReadPermissions = OtherReadPermission | GroupReadPermission | UserReadPermission | OwnerReadPermission,
+ WritePermissions = OtherWritePermission | GroupWritePermission | UserWritePermission | OwnerWritePermission,
+ ExecutePermissions = OtherExecutePermission | GroupExecutePermission | UserExecutePermission | OwnerExecutePermission,
+
+ Permissions = OtherPermissions | GroupPermissions | UserPermissions | OwnerPermissions,
+
+ // Type
+#ifdef Q_OS_SYMBIAN
+ LinkType = 0,
+#else
+ LinkType = 0x00010000,
+#endif
+ FileType = 0x00020000,
+ DirectoryType = 0x00040000,
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+ BundleType = 0x00080000,
+ AliasType = 0x08000000,
+#else
+ BundleType = 0x0,
+ AliasType = 0x0,
+#endif
+#if defined(Q_OS_WIN)
+ WinLnkType = 0x08000000, // Note: Uses the same position for AliasType on Mac
+#else
+ WinLnkType = 0x0,
+#endif
+ SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag
+
+ LegacyLinkType = LinkType | AliasType | WinLnkType,
+
+ Type = LinkType | FileType | DirectoryType | BundleType | SequentialType | AliasType,
+
+ // Attributes
+ HiddenAttribute = 0x00100000,
+ SizeAttribute = 0x00200000, // Note: overlaps with QAbstractFileEngine::LocalDiskFlag
+ ExistsAttribute = 0x00400000,
+
+ Attributes = HiddenAttribute | SizeAttribute | ExistsAttribute,
+
+ // Times
+ CreationTime = 0x01000000, // Note: overlaps with QAbstractFileEngine::Refresh
+ ModificationTime = 0x02000000,
+ AccessTime = 0x04000000,
+
+ Times = CreationTime | ModificationTime | AccessTime,
+
+ // Owner IDs
+ UserId = 0x10000000,
+ GroupId = 0x20000000,
+
+ OwnerIds = UserId | GroupId,
+
+ PosixStatFlags = QFileSystemMetaData::OtherPermissions
+ | QFileSystemMetaData::GroupPermissions
+ | QFileSystemMetaData::OwnerPermissions
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::SizeAttribute
+ | QFileSystemMetaData::Times
+ | QFileSystemMetaData::OwnerIds,
+
+ SymbianTEntryFlags = QFileSystemMetaData::Permissions
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::SequentialType
+ | QFileSystemMetaData::Attributes
+ | QFileSystemMetaData::Times,
+#if defined(Q_OS_WIN)
+ WinStatFlags = QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::HiddenAttribute
+ | QFileSystemMetaData::ExistsAttribute
+ | QFileSystemMetaData::SizeAttribute
+ | QFileSystemMetaData::Times,
+#endif
+
+ AllMetaDataFlags = 0xFFFFFFFF
+
+ };
+ Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag)
+
+ bool hasFlags(MetaDataFlags flags) const
+ {
+ return ((knownFlagsMask & flags) == flags);
+ }
+
+ MetaDataFlags missingFlags(MetaDataFlags flags)
+ {
+ return flags & ~knownFlagsMask;
+ }
+
+ void clear()
+ {
+ knownFlagsMask = 0;
+ }
+
+ void clearFlags(MetaDataFlags flags = AllMetaDataFlags)
+ {
+ knownFlagsMask &= ~flags;
+ }
+
+ bool exists() const { return (entryFlags & ExistsAttribute); }
+
+ bool isLink() const { return (entryFlags & LinkType); }
+ bool isFile() const { return (entryFlags & FileType); }
+ bool isDirectory() const { return (entryFlags & DirectoryType); }
+ bool isBundle() const;
+ bool isAlias() const;
+ bool isLegacyLink() const { return (entryFlags & LegacyLinkType); }
+ bool isSequential() const { return (entryFlags & SequentialType); }
+ bool isHidden() const { return (entryFlags & HiddenAttribute); }
+#if defined(Q_OS_WIN)
+ bool isLnkFile() const { return (entryFlags & WinLnkType); }
+#else
+ bool isLnkFile() const { return false; }
+#endif
+
+ qint64 size() const { return size_; }
+
+ QFile::Permissions permissions() const { return QFile::Permissions(Permissions & entryFlags); }
+
+ QDateTime creationTime() const;
+ QDateTime modificationTime() const;
+ QDateTime accessTime() const;
+
+ QDateTime fileTime(QAbstractFileEngine::FileTime time) const;
+ uint userId() const;
+ uint groupId() const;
+ uint ownerId(QAbstractFileEngine::FileOwner owner) const;
+
+#ifdef Q_OS_UNIX
+ void fillFromStatBuf(const QT_STATBUF &statBuffer);
+ void fillFromDirEnt(const QT_DIRENT &statBuffer);
+#endif
+#ifdef Q_OS_SYMBIAN
+ void fillFromTEntry(const TEntry& entry);
+ void fillFromVolumeInfo(const TVolumeInfo& info);
+#endif
+
+#if defined(Q_OS_WIN)
+ inline void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot = false);
+ inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false);
+ inline void fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo);
+#endif
+private:
+ friend class QFileSystemEngine;
+
+ MetaDataFlags knownFlagsMask;
+ MetaDataFlags entryFlags;
+
+ qint64 size_;
+
+ // Platform-specific data goes here:
+#if defined(Q_OS_WIN)
+ DWORD fileAttribute_;
+ FILETIME creationTime_;
+ FILETIME lastAccessTime_;
+ FILETIME lastWriteTime_;
+#elif defined(Q_OS_SYMBIAN)
+ TTime modificationTime_;
+#else
+ time_t creationTime_;
+ time_t modificationTime_;
+ time_t accessTime_;
+
+ uint userId_;
+ uint groupId_;
+#endif
+
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags)
+
+#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC)
+inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); }
+inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); }
+#else
+inline bool QFileSystemMetaData::isBundle() const { return false; }
+inline bool QFileSystemMetaData::isAlias() const { return false; }
+#endif
+
+#if (defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN)) || defined (Q_OS_WIN)
+inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const
+{
+ switch (time) {
+ case QAbstractFileEngine::ModificationTime:
+ return modificationTime();
+
+ case QAbstractFileEngine::AccessTime:
+ return accessTime();
+
+ case QAbstractFileEngine::CreationTime:
+ return creationTime();
+ }
+
+ return QDateTime();
+}
+#endif
+
+#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN)
+inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); }
+inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); }
+inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); }
+
+inline uint QFileSystemMetaData::userId() const { return userId_; }
+inline uint QFileSystemMetaData::groupId() const { return groupId_; }
+
+inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const
+{
+ if (owner == QAbstractFileEngine::OwnerUser)
+ return userId();
+ else
+ return groupId();
+}
+#endif
+
+#ifdef Q_OS_SYMBIAN
+inline QDateTime QFileSystemMetaData::creationTime() const { return modificationTime(); }
+inline QDateTime QFileSystemMetaData::modificationTime() const { return qt_symbian_TTime_To_QDateTime(modificationTime_); }
+inline QDateTime QFileSystemMetaData::accessTime() const { return modificationTime(); }
+
+inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const
+{
+ Q_UNUSED(time);
+ return modificationTime();
+}
+inline uint QFileSystemMetaData::userId() const { return (uint) -2; }
+inline uint QFileSystemMetaData::groupId() const { return (uint) -2; }
+inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const
+{
+ Q_UNUSED(owner);
+ return (uint) -2;
+}
+#endif
+
+#if defined(Q_OS_WIN)
+inline uint QFileSystemMetaData::userId() const { return (uint) -2; }
+inline uint QFileSystemMetaData::groupId() const { return (uint) -2; }
+inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const
+{
+ if (owner == QAbstractFileEngine::OwnerUser)
+ return userId();
+ else
+ return groupId();
+}
+
+inline void QFileSystemMetaData::fillFromFileAttribute(DWORD fileAttribute,bool isDriveRoot)
+{
+ fileAttribute_ = fileAttribute;
+ // Ignore the hidden attribute for drives.
+ if (!isDriveRoot && (fileAttribute_ & FILE_ATTRIBUTE_HIDDEN))
+ entryFlags |= HiddenAttribute;
+ entryFlags |= ((fileAttribute & FILE_ATTRIBUTE_DIRECTORY) ? DirectoryType: FileType);
+ entryFlags |= ExistsAttribute;
+ knownFlagsMask |= FileType | DirectoryType | HiddenAttribute | ExistsAttribute;
+}
+
+inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot)
+{
+ fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot);
+ creationTime_ = findData.ftCreationTime;
+ lastAccessTime_ = findData.ftLastAccessTime;
+ lastWriteTime_ = findData.ftLastWriteTime;
+ if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) {
+ size_ = 0;
+ } else {
+ size_ = findData.nFileSizeHigh;
+ size_ <<= 32;
+ size_ += findData.nFileSizeLow;
+ }
+ knownFlagsMask |= Times | SizeAttribute;
+ if (setLinkType) {
+ knownFlagsMask |= LinkType;
+ entryFlags &= ~LinkType;
+#if !defined(Q_OS_WINCE)
+ if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT)
+ && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK
+ || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) {
+ entryFlags |= LinkType;
+ }
+#endif
+
+ }
+}
+
+inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo)
+{
+ fillFromFileAttribute(fileInfo.dwFileAttributes);
+ creationTime_ = fileInfo.ftCreationTime;
+ lastAccessTime_ = fileInfo.ftLastAccessTime;
+ lastWriteTime_ = fileInfo.ftLastWriteTime;
+ if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) {
+ size_ = 0;
+ } else {
+ size_ = fileInfo.nFileSizeHigh;
+ size_ <<= 32;
+ size_ += fileInfo.nFileSizeLow;
+ }
+ knownFlagsMask |= Times | SizeAttribute;
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // include guard
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index e45c972..e0f2f44 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -198,7 +198,7 @@ QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &path
void QPollingFileSystemWatcherEngine::stop()
{
- QMetaObject::invokeMethod(this, "quit");
+ quit();
}
void QPollingFileSystemWatcherEngine::timeout()
@@ -432,11 +432,6 @@ QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent
/*!
Destroys the file system watcher.
-
- \note To avoid deadlocks on shutdown, all instances of QFileSystemWatcher
- need to be destroyed before QCoreApplication. Note that passing
- QCoreApplication::instance() as the parent object when creating
- QFileSystemWatcher is not sufficient.
*/
QFileSystemWatcher::~QFileSystemWatcher()
{
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp
index 20846da..19b720c 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp
@@ -45,6 +45,8 @@
#include "qfilesystemwatcher.h"
#include "qfilesystemwatcher_fsevents_p.h"
+#ifndef QT_NO_FILESYSTEMWATCHER
+
#include <qdebug.h>
#include <qfile.h>
#include <qdatetime.h>
@@ -487,3 +489,4 @@ void QFSEventsFileSystemWatcherEngine::run()
}
QT_END_NAMESPACE
+#endif //QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
index b5bbe3a..bbfdd32 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
@@ -56,6 +56,8 @@
#include "qfilesystemwatcher_p.h"
+#ifndef QT_NO_FILESYSTEMWATCHER
+
#include <QtCore/qmutex.h>
#include <QtCore/qwaitcondition.h>
#include <QtCore/qthread.h>
@@ -123,6 +125,8 @@ private:
#endif
};
+#endif //QT_NO_FILESYSTEMWATCHER
+
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 1ceb011..8fc2d31 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -340,7 +340,7 @@ QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &path
void QInotifyFileSystemWatcherEngine::stop()
{
- QMetaObject::invokeMethod(this, "quit");
+ quit();
}
void QInotifyFileSystemWatcherEngine::readFromInotify()
@@ -353,24 +353,24 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd, buffer.data(), buffSize);
- const char *at = buffer.data();
- const char * const end = at + buffSize;
+ char *at = buffer.data();
+ char * const end = at + buffSize;
- QMap<int, inotify_event> eventForId;
+ QHash<int, inotify_event *> eventForId;
while (at < end) {
- const inotify_event *event = reinterpret_cast<const inotify_event *>(at);
+ inotify_event *event = reinterpret_cast<inotify_event *>(at);
if (eventForId.contains(event->wd))
- eventForId[event->wd].mask |= event->mask;
+ eventForId[event->wd]->mask |= event->mask;
else
- eventForId.insert(event->wd, *event);
+ eventForId.insert(event->wd, event);
at += sizeof(inotify_event) + event->len;
}
- QMap<int, inotify_event>::const_iterator it = eventForId.constBegin();
+ QHash<int, inotify_event *>::const_iterator it = eventForId.constBegin();
while (it != eventForId.constEnd()) {
- inotify_event event = *it;
+ const inotify_event &event = **it;
++it;
// qDebug() << "inotify event, wd" << event.wd << "mask" << hex << event.mask;
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
index 6466441..6c36a82 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp
+++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
@@ -45,6 +45,8 @@
#include "qfilesystemwatcher_kqueue_p.h"
#include "private/qcore_unix_p.h"
+#ifndef QT_NO_FILESYSTEMWATCHER
+
#include <qdebug.h>
#include <qfile.h>
#include <qsocketnotifier.h>
@@ -327,4 +329,6 @@ void QKqueueFileSystemWatcherEngine::run()
}
}
+#endif //QT_NO_FILESYSTEMWATCHER
+
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue_p.h b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
index 1432064..38b8937 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue_p.h
+++ b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
@@ -60,6 +60,7 @@
#include <QtCore/qthread.h>
#include <QtCore/qvector.h>
+#ifndef QT_NO_FILESYSTEMWATCHER
struct kevent;
QT_BEGIN_NAMESPACE
@@ -92,4 +93,5 @@ private:
QT_END_NAMESPACE
+#endif //QT_NO_FILESYSTEMWATCHER
#endif // FILEWATCHER_KQUEUE_P_H
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index 5ee27bd..29ec77a 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -215,7 +215,7 @@ void QSymbianFileSystemWatcherEngine::emitPathChanged(QNotifyChangeEvent *e)
void QSymbianFileSystemWatcherEngine::stop()
{
- QMetaObject::invokeMethod(this, "quit");
+ quit();
wait();
}
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index e7bc8e0..26b83b2 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -86,7 +86,8 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
while (it.hasNext()) {
QString path = it.next();
QString normalPath = path;
- if ((normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\')))
+ if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/")))
+ || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))
#ifdef Q_OS_WINCE
&& normalPath.size() > 1)
#else
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 0950dc0..802d394 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -41,6 +41,7 @@
#include "qfsfileengine_p.h"
#include "qfsfileengine_iterator_p.h"
+#include "qfilesystemengine_p.h"
#include "qdatetime.h"
#include "qdiriterator.h"
#include "qset.h"
@@ -119,6 +120,9 @@ void QFSFileEnginePrivate::init()
openMode = QIODevice::NotOpen;
fd = -1;
fh = 0;
+#ifdef Q_OS_SYMBIAN
+ fileHandleForMaps = -1;
+#endif
lastIOCommand = IOFlushCommand;
lastFlushFailed = false;
closeFileHandle = false;
@@ -133,109 +137,13 @@ void QFSFileEnginePrivate::init()
}
/*!
- \internal
-
- Returns the canonicalized form of \a path (i.e., with all symlinks
- resolved, and all redundant path elements removed.
-*/
-QString QFSFileEnginePrivate::canonicalized(const QString &path)
-{
- if (path.isEmpty())
- return path;
-
- // FIXME let's see if this stuff works, then we might be able to remove some of the other code.
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- if (path.size() == 1 && path.at(0) == QLatin1Char('/'))
- return path;
-#endif
-#if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN) || defined(Q_OS_MAC)
- // ... but Linux with uClibc does not have it
-#if !defined(__UCLIBC__)
- char *ret = 0;
-#if defined(Q_OS_MAC)
- // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here.
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
- ret = realpath(path.toLocal8Bit().constData(), (char*)0);
- } else {
- // on 10.5 we can use FSRef to resolve the file path.
- FSRef fsref;
- if (FSPathMakeRef((const UInt8 *)QDir::cleanPath(path).toUtf8().data(), &fsref, 0) == noErr) {
- CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref);
- CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
- QString ret = QCFString::toQString(canonicalPath);
- CFRelease(canonicalPath);
- CFRelease(urlref);
- return ret;
- }
- }
-#else
- ret = realpath(path.toLocal8Bit().constData(), (char*)0);
-#endif
- if (ret) {
- QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
- free(ret);
- return canonicalPath;
- }
-#endif
-#endif
-
- QFileInfo fi;
- const QChar slash(QLatin1Char('/'));
- QString tmpPath = path;
- int separatorPos = 0;
- QSet<QString> nonSymlinks;
- QSet<QString> known;
-
- known.insert(path);
- do {
-#ifdef Q_OS_WIN
- // UNC, skip past the first two elements
- if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//")))
- separatorPos = tmpPath.indexOf(slash, 2);
- if (separatorPos != -1)
-#endif
- separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
- QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
- if (
-#ifdef Q_OS_SYMBIAN
- // Symbian doesn't support directory symlinks, so do not check for link unless we
- // are handling the last path element. This not only slightly improves performance,
- // but also saves us from lot of unnecessary platform security check failures
- // when dealing with files under *:/private directories.
- separatorPos == -1 &&
-#endif
- !nonSymlinks.contains(prefix)) {
- fi.setFile(prefix);
- if (fi.isSymLink()) {
- QString target = fi.symLinkTarget();
- if (separatorPos != -1) {
- if (fi.isDir() && !target.endsWith(slash))
- target.append(slash);
- target.append(tmpPath.mid(separatorPos));
- }
- tmpPath = QDir::cleanPath(target);
- separatorPos = 0;
-
- if (known.contains(tmpPath))
- return QString();
- known.insert(tmpPath);
- } else {
- nonSymlinks.insert(prefix);
- }
- }
- } while (separatorPos != -1);
-
- return QDir::cleanPath(tmpPath);
-}
-
-/*!
Constructs a QFSFileEngine for the file name \a file.
*/
-QFSFileEngine::QFSFileEngine(const QString &file) : QAbstractFileEngine(*new QFSFileEnginePrivate)
+QFSFileEngine::QFSFileEngine(const QString &file)
+ : QAbstractFileEngine(*new QFSFileEnginePrivate)
{
Q_D(QFSFileEngine);
- d->filePath = QDir::fromNativeSeparators(file);
- d->nativeInitFileName();
+ d->fileEntry = QFileSystemEntry(file);
}
/*!
@@ -284,8 +192,7 @@ void QFSFileEngine::setFileName(const QString &file)
{
Q_D(QFSFileEngine);
d->init();
- d->filePath = QDir::fromNativeSeparators(file);
- d->nativeInitFileName();
+ d->fileEntry = QFileSystemEntry(file);
}
/*!
@@ -294,7 +201,7 @@ void QFSFileEngine::setFileName(const QString &file)
bool QFSFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
- if (d->filePath.isEmpty()) {
+ if (d->fileEntry.isEmpty()) {
qWarning("QFSFileEngine::open: No file name specified");
setError(QFile::OpenError, QLatin1String("No file name specified"));
return false;
@@ -323,6 +230,11 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode)
*/
bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh)
{
+ return open(openMode, fh, QFile::DontCloseHandle);
+}
+
+bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh, QFile::FileHandleFlags handleFlags)
+{
Q_D(QFSFileEngine);
// Append implies WriteOnly.
@@ -335,9 +247,8 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh)
d->openMode = openMode;
d->lastFlushFailed = false;
- d->closeFileHandle = false;
- d->nativeFilePath.clear();
- d->filePath.clear();
+ d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
+ d->fileEntry.clear();
d->tried_stat = 0;
d->fd = -1;
@@ -380,6 +291,11 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
*/
bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
{
+ return open(openMode, fd, QFile::DontCloseHandle);
+}
+
+bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandleFlags handleFlags)
+{
Q_D(QFSFileEngine);
// Append implies WriteOnly.
@@ -392,9 +308,8 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
d->openMode = openMode;
d->lastFlushFailed = false;
- d->closeFileHandle = false;
- d->nativeFilePath.clear();
- d->filePath.clear();
+ d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
+ d->fileEntry.clear();
d->fh = 0;
d->fd = -1;
d->tried_stat = 0;
@@ -450,7 +365,12 @@ bool QFSFileEngine::close()
bool QFSFileEnginePrivate::closeFdFh()
{
Q_Q(QFSFileEngine);
- if (fd == -1 && !fh)
+ if (fd == -1 && !fh
+#ifdef Q_OS_SYMBIAN
+ && !symbianFile.SubSessionHandle()
+ && fileHandleForMaps == -1
+#endif
+ )
return false;
// Flush the file if it's buffered, and if the last flush didn't fail.
@@ -458,10 +378,24 @@ bool QFSFileEnginePrivate::closeFdFh()
bool closed = true;
tried_stat = 0;
+#ifdef Q_OS_SYMBIAN
+ // Map handle is always owned by us so always close it
+ if (fileHandleForMaps >= 0) {
+ QT_CLOSE(fileHandleForMaps);
+ fileHandleForMaps = -1;
+ }
+#endif
+
// Close the file if we created the handle.
if (closeFileHandle) {
int ret;
do {
+#ifdef Q_OS_SYMBIAN
+ if (symbianFile.SubSessionHandle()) {
+ symbianFile.Close();
+ ret = 0;
+ } else
+#endif
if (fh) {
// Close buffered file.
ret = fclose(fh) != 0 ? -1 : 0;
@@ -541,28 +475,19 @@ qint64 QFSFileEngine::size() const
/*!
\internal
*/
+#ifndef Q_OS_WIN
qint64 QFSFileEnginePrivate::sizeFdFh() const
{
Q_Q(const QFSFileEngine);
- // ### Fix this function, it should not stat unless the file is closed.
- QT_STATBUF st;
- int ret = 0;
const_cast<QFSFileEngine *>(q)->flush();
- if (fh && nativeFilePath.isEmpty()) {
- // Buffered stdlib mode.
- // ### This should really be an ftell
- ret = QT_FSTAT(QT_FILENO(fh), &st);
- } else if (fd == -1) {
- // Stateless stat.
- ret = QT_STAT(nativeFilePath.constData(), &st);
- } else {
- // Unbuffered stdio mode.
- ret = QT_FSTAT(fd, &st);
- }
- if (ret == -1)
+
+ tried_stat = 0;
+ metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
+ if (!doStat(QFileSystemMetaData::SizeAttribute))
return 0;
- return st.st_size;
+ return metaData.size();
}
+#endif
/*!
\reimp
@@ -869,18 +794,14 @@ bool QFSFileEngine::isSequential() const
/*!
\internal
*/
+#ifdef Q_OS_UNIX
bool QFSFileEnginePrivate::isSequentialFdFh() const
{
- if (!tried_stat)
- doStat();
- if (could_stat) {
-#ifdef Q_OS_UNIX
- return (st.st_mode & S_IFMT) != S_IFREG;
- // ### WINDOWS!
-#endif
- }
+ if (doStat(QFileSystemMetaData::SequentialType))
+ return metaData.isSequential();
return true;
}
+#endif
/*!
\reimp
diff --git a/src/corelib/io/qfsfileengine.h b/src/corelib/io/qfsfileengine.h
index 95ab33e..726d581 100644
--- a/src/corelib/io/qfsfileengine.h
+++ b/src/corelib/io/qfsfileengine.h
@@ -43,6 +43,9 @@
#define QFSFILEENGINE_H
#include <QtCore/qabstractfileengine.h>
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
#ifndef QT_NO_FSFILEENGINE
@@ -101,6 +104,11 @@ public:
//FS only!!
bool open(QIODevice::OpenMode flags, int fd);
+ bool open(QIODevice::OpenMode flags, int fd, QFile::FileHandleFlags handleFlags);
+ bool open(QIODevice::OpenMode flags, FILE *fh, QFile::FileHandleFlags handleFlags);
+#ifdef Q_OS_SYMBIAN
+ bool open(QIODevice::OpenMode flags, const RFile &f, QFile::FileHandleFlags handleFlags);
+#endif
static bool setCurrentPath(const QString &path);
static QString currentPath(const QString &path = QString());
static QString homePath();
diff --git a/src/corelib/io/qfsfileengine_iterator.cpp b/src/corelib/io/qfsfileengine_iterator.cpp
index 99abb34..d4c0e3f 100644
--- a/src/corelib/io/qfsfileengine_iterator.cpp
+++ b/src/corelib/io/qfsfileengine_iterator.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qfsfileengine_iterator_p.h"
+#include "qfileinfo_p.h"
#include "qvariant.h"
#ifndef QT_NO_FSFILEENGINE
@@ -48,13 +49,23 @@ QT_BEGIN_NAMESPACE
QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames)
: QAbstractFileEngineIterator(filters, filterNames)
+ , done(false)
{
- newPlatformSpecifics();
}
QFSFileEngineIterator::~QFSFileEngineIterator()
{
- deletePlatformSpecifics();
+}
+
+bool QFSFileEngineIterator::hasNext() const
+{
+ if (!done && !nativeIterator) {
+ nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()),
+ filters(), nameFilters()));
+ advance();
+ }
+
+ return !done;
}
QString QFSFileEngineIterator::next()
@@ -66,14 +77,28 @@ QString QFSFileEngineIterator::next()
return currentFilePath();
}
+void QFSFileEngineIterator::advance() const
+{
+ currentInfo = nextInfo;
+
+ QFileSystemEntry entry;
+ QFileSystemMetaData data;
+ if (nativeIterator->advance(entry, data)) {
+ nextInfo = QFileInfo(new QFileInfoPrivate(entry, data));
+ } else {
+ done = true;
+ nativeIterator.reset();
+ }
+}
+
QString QFSFileEngineIterator::currentFileName() const
{
- return currentEntry;
+ return currentInfo.fileName();
}
QFileInfo QFSFileEngineIterator::currentFileInfo() const
{
- return QAbstractFileEngineIterator::currentFileInfo();
+ return currentInfo;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfsfileengine_iterator_p.h b/src/corelib/io/qfsfileengine_iterator_p.h
index 8ff5f6e..d4155d6 100644
--- a/src/corelib/io/qfsfileengine_iterator_p.h
+++ b/src/corelib/io/qfsfileengine_iterator_p.h
@@ -54,6 +54,7 @@
//
#include "qabstractfileengine.h"
+#include "qfilesystemiterator_p.h"
#include "qdir.h"
#ifndef QT_NO_FSFILEENGINE
@@ -76,13 +77,11 @@ public:
QFileInfo currentFileInfo() const;
private:
- QFSFileEngineIteratorPlatformSpecificData *platform;
- friend class QFSFileEngineIteratorPlatformSpecificData;
- void newPlatformSpecifics();
- void deletePlatformSpecifics();
- void advance();
-
- QString currentEntry;
+ void advance() const;
+ mutable QScopedPointer<QFileSystemIterator> nativeIterator;
+ mutable QFileInfo currentInfo;
+ mutable QFileInfo nextInfo;
+ mutable bool done;
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfsfileengine_iterator_unix.cpp b/src/corelib/io/qfsfileengine_iterator_unix.cpp
deleted file mode 100644
index 6c78f3c..0000000
--- a/src/corelib/io/qfsfileengine_iterator_unix.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the 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 "qplatformdefs.h"
-#include "qfsfileengine_iterator_p.h"
-
-#include <QtCore/qvariant.h>
-
-#ifndef QT_NO_FSFILEENGINE
-
-QT_BEGIN_NAMESPACE
-
-class QFSFileEngineIteratorPlatformSpecificData
-{
-public:
- inline QFSFileEngineIteratorPlatformSpecificData()
- : dir(0), dirEntry(0), done(false)
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- , mt_file(0)
-#endif
- {}
-
- QT_DIR *dir;
- QT_DIRENT *dirEntry;
- bool done;
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- // for readdir_r
- QT_DIRENT *mt_file;
-#endif
-};
-
-void QFSFileEngineIterator::advance()
-{
- currentEntry = platform->dirEntry ? QFile::decodeName(QByteArray(platform->dirEntry->d_name)) : QString();
-
- if (!platform->dir)
- return;
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- if (QT_READDIR_R(platform->dir, platform->mt_file, &platform->dirEntry) != 0)
- platform->done = true;
-#else
- // ### add local lock to prevent breaking reentrancy
- platform->dirEntry = QT_READDIR(platform->dir);
-#endif // _POSIX_THREAD_SAFE_FUNCTIONS
- if (!platform->dirEntry) {
- QT_CLOSEDIR(platform->dir);
- platform->dir = 0;
- platform->done = true;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- delete [] platform->mt_file;
- platform->mt_file = 0;
-#endif
- }
-}
-
-void QFSFileEngineIterator::newPlatformSpecifics()
-{
- platform = new QFSFileEngineIteratorPlatformSpecificData;
-}
-
-void QFSFileEngineIterator::deletePlatformSpecifics()
-{
- if (platform->dir) {
- QT_CLOSEDIR(platform->dir);
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- delete [] platform->mt_file;
- platform->mt_file = 0;
-#endif
- }
- delete platform;
- platform = 0;
-}
-
-bool QFSFileEngineIterator::hasNext() const
-{
- if (!platform->done && !platform->dir) {
- QFSFileEngineIterator *that = const_cast<QFSFileEngineIterator *>(this);
- if ((that->platform->dir = QT_OPENDIR(QFile::encodeName(path()).data())) == 0) {
- that->platform->done = true;
- } else {
- // ### Race condition; we should use fpathconf and dirfd().
- long maxPathName = ::pathconf(QFile::encodeName(path()).data(), _PC_NAME_MAX);
- if ((int) maxPathName == -1)
- maxPathName = FILENAME_MAX;
- maxPathName += sizeof(QT_DIRENT) + 1;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN)
- if (that->platform->mt_file)
- delete [] that->platform->mt_file;
- that->platform->mt_file = (QT_DIRENT *)new char[maxPathName];
-#endif
-
- that->advance();
- }
- }
- return !platform->done;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_FSFILEENGINE
diff --git a/src/corelib/io/qfsfileengine_iterator_win.cpp b/src/corelib/io/qfsfileengine_iterator_win.cpp
deleted file mode 100644
index 883b36f..0000000
--- a/src/corelib/io/qfsfileengine_iterator_win.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the 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 "qfsfileengine_iterator_p.h"
-#include "qfsfileengine_p.h"
-#include "qplatformdefs.h"
-
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_NAMESPACE
-
-class QFSFileEngineIteratorPlatformSpecificData
-{
-public:
- inline QFSFileEngineIteratorPlatformSpecificData()
- : uncShareIndex(-1), findFileHandle(INVALID_HANDLE_VALUE),
- done(false), uncFallback(false)
- {}
-
- QFSFileEngineIterator *it;
-
- QStringList uncShares;
- int uncShareIndex;
-
- HANDLE findFileHandle;
- WIN32_FIND_DATA findData;
- bool done;
- bool uncFallback;
-
- void saveCurrentFileName();
-};
-
-void QFSFileEngineIteratorPlatformSpecificData::saveCurrentFileName()
-{
- if (uncFallback) {
- // Windows share / UNC path
- it->currentEntry = uncShares.at(uncShareIndex - 1);
- } else {
- // Local directory
- it->currentEntry = QString::fromWCharArray(findData.cFileName);
- }
-}
-
-void QFSFileEngineIterator::advance()
-{
- platform->saveCurrentFileName();
-
- if (platform->done)
- return;
-
- if (platform->uncFallback) {
- ++platform->uncShareIndex;
- } else if (platform->findFileHandle != INVALID_HANDLE_VALUE) {
- if (!FindNextFile(platform->findFileHandle, &platform->findData)) {
- platform->done = true;
- FindClose(platform->findFileHandle);
- }
- }
-}
-
-void QFSFileEngineIterator::newPlatformSpecifics()
-{
- platform = new QFSFileEngineIteratorPlatformSpecificData;
- platform->it = this;
-}
-
-void QFSFileEngineIterator::deletePlatformSpecifics()
-{
- delete platform;
- platform = 0;
-}
-
-bool QFSFileEngineIterator::hasNext() const
-{
- if (platform->done)
- return false;
-
- if (platform->uncFallback)
- return platform->uncShareIndex > 0 && platform->uncShareIndex <= platform->uncShares.size();
-
- if (platform->findFileHandle == INVALID_HANDLE_VALUE) {
- QString path = this->path();
- // Local directory
- if (path.endsWith(QLatin1String(".lnk")))
- path = QFileInfo(path).readLink();
-
- if (!path.endsWith(QLatin1Char('/')))
- path.append(QLatin1Char('/'));
- path.append(QLatin1String("*.*"));
-
- QString fileName = QFSFileEnginePrivate::longFileName(path);
- platform->findFileHandle = FindFirstFile((const wchar_t *)fileName.utf16(), &platform->findData);
-
- if (platform->findFileHandle == INVALID_HANDLE_VALUE) {
- if (path.startsWith(QLatin1String("//"))) {
- path = this->path();
- // UNC
- QStringList parts = QDir::toNativeSeparators(path).split(QLatin1Char('\\'), QString::SkipEmptyParts);
-
- if (parts.count() == 1 && QFSFileEnginePrivate::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0),
- &platform->uncShares)) {
- if (platform->uncShares.isEmpty()) {
- platform->done = true;
- } else {
- platform->uncShareIndex = 1;
- }
- platform->uncFallback = true;
- } else {
- platform->done = true;
- }
- } else {
- platform->done = true;
- }
- }
-
- if (!platform->done && (!platform->uncFallback || !platform->uncShares.isEmpty()))
- platform->saveCurrentFileName();
- }
-
- return !platform->done;
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 9f3e8b2..253f461 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -56,8 +56,14 @@
#include "qplatformdefs.h"
#include "QtCore/qfsfileengine.h"
#include "private/qabstractfileengine_p.h"
+#include <QtCore/private/qfilesystementry_p.h>
+#include <QtCore/private/qfilesystemmetadata_p.h>
#include <qhash.h>
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
+
#ifndef QT_NO_FSFILEENGINE
QT_BEGIN_NAMESPACE
@@ -74,13 +80,10 @@ public:
#ifdef Q_WS_WIN
static QString longFileName(const QString &path);
#endif
- static QString canonicalized(const QString &path);
- QString filePath;
- QByteArray nativeFilePath;
+ QFileSystemEntry fileEntry;
QIODevice::OpenMode openMode;
- void nativeInitFileName();
bool nativeOpen(QIODevice::OpenMode openMode);
bool openFh(QIODevice::OpenMode flags, FILE *fh);
bool openFd(QIODevice::OpenMode flags, int fd);
@@ -89,7 +92,9 @@ public:
bool nativeFlush();
bool flushFh();
qint64 nativeSize() const;
+#ifndef Q_OS_WIN
qint64 sizeFdFh() const;
+#endif
qint64 nativePos() const;
qint64 posFdFh() const;
bool nativeSeek(qint64);
@@ -102,12 +107,42 @@ public:
qint64 writeFdFh(const char *data, qint64 len);
int nativeHandle() const;
bool nativeIsSequential() const;
+#ifndef Q_OS_WIN
bool isSequentialFdFh() const;
+#endif
uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags);
bool unmap(uchar *ptr);
+ mutable QFileSystemMetaData metaData;
+
FILE *fh;
+#ifdef Q_OS_SYMBIAN
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ RFile64 symbianFile;
+ TInt64 symbianFilePos;
+#else
+ RFile symbianFile;
+
+ /**
+ * The cursor position in the underlying file. This differs
+ * from devicePos because the latter is updated on calls to
+ * writeData, even if no data was physically transferred to
+ * the file, but instead stored in the write buffer.
+ *
+ * iFilePos is updated on calls to RFile::Read and
+ * RFile::Write. It is also updated on calls to seek() but
+ * RFile::Seek is not called when that happens because
+ * Symbian supports positioned reads and writes, saving a file
+ * server call, and because Symbian does not support seeking
+ * past the end of a file.
+ */
+ TInt symbianFilePos;
+#endif
+ mutable int fileHandleForMaps;
+ int getMapHandle();
+#endif
+
#ifdef Q_WS_WIN
HANDLE fileHandle;
HANDLE mapHandle;
@@ -120,7 +155,6 @@ public:
mutable DWORD fileAttrib;
#else
QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
- mutable QT_STATBUF st;
#endif
int fd;
@@ -142,23 +176,17 @@ public:
mutable uint is_link : 1;
#endif
- bool doStat() const;
+#if defined(Q_OS_WIN)
+ bool doStat(QFileSystemMetaData::MetaDataFlags flags) const;
+#else
+ bool doStat(QFileSystemMetaData::MetaDataFlags flags = QFileSystemMetaData::PosixStatFlags) const;
+#endif
bool isSymlink() const;
#if defined(Q_OS_WIN32)
int sysOpen(const QString &, int flags);
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- static void resolveLibs();
- static bool resolveUNCLibs();
- static bool uncListSharesOnServer(const QString &server, QStringList *list);
-#endif
-
-#ifdef Q_OS_SYMBIAN
- void setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString);
-#endif
-
protected:
QFSFileEnginePrivate();
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index c1d45ea..6c03b32 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -43,6 +43,8 @@
#include "qabstractfileengine.h"
#include "private/qfsfileengine_p.h"
#include "private/qcore_unix_p.h"
+#include "qfilesystementry_p.h"
+#include "qfilesystemengine_p.h"
#ifndef QT_NO_FSFILEENGINE
@@ -67,7 +69,6 @@
QT_BEGIN_NAMESPACE
-
#if defined(Q_OS_SYMBIAN)
/*!
\internal
@@ -82,56 +83,25 @@ static bool isRelativePathSymbian(const QString& fileName)
|| (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/')))));
}
-/*!
- \internal
- convert symbian error code to the one suitable for setError.
- example usage: setSymbianError(err, QFile::CopyError, QLatin1String("copy error"))
-*/
-void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString)
-{
- Q_Q(QFSFileEngine);
- switch (symbianError) {
- case KErrNone:
- q->setError(QFile::NoError, QLatin1String(""));
- break;
- case KErrAccessDenied:
- q->setError(QFile::PermissionsError, QLatin1String("access denied"));
- break;
- case KErrPermissionDenied:
- q->setError(QFile::PermissionsError, QLatin1String("permission denied"));
- break;
- case KErrAbort:
- q->setError(QFile::AbortError, QLatin1String("aborted"));
- break;
- case KErrCancel:
- q->setError(QFile::AbortError, QLatin1String("cancelled"));
- break;
- case KErrTimedOut:
- q->setError(QFile::TimeOutError, QLatin1String("timed out"));
- break;
- default:
- q->setError(defaultError, defaultString);
- break;
- }
-}
-
#endif
+#ifndef Q_OS_SYMBIAN
/*!
\internal
Returns the stdlib open string corresponding to a QIODevice::OpenMode.
*/
-static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QByteArray &fileName)
+static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QFileSystemEntry &fileEntry,
+ QFileSystemMetaData &metaData)
{
QByteArray mode;
if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) {
mode = "rb";
if (flags & QIODevice::WriteOnly) {
- QT_STATBUF statBuf;
- if (!fileName.isEmpty()
- && QT_STAT(fileName, &statBuf) == 0
- && (statBuf.st_mode & S_IFMT) == S_IFREG) {
+ metaData.clearFlags(QFileSystemMetaData::FileType);
+ if (!fileEntry.isEmpty()
+ && QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType)
+ && metaData.isFile()) {
mode += '+';
} else {
mode = "wb+";
@@ -155,6 +125,7 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QB
return mode;
}
+#endif
/*!
\internal
@@ -184,6 +155,7 @@ static inline int openModeToOpenFlags(QIODevice::OpenMode mode)
return oflags;
}
+#ifndef Q_OS_SYMBIAN
/*!
\internal
@@ -194,15 +166,151 @@ static inline bool setCloseOnExec(int fd)
{
return fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) != -1;
}
+#endif
+#ifdef Q_OS_SYMBIAN
/*!
\internal
*/
-void QFSFileEnginePrivate::nativeInitFileName()
+bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
{
- nativeFilePath = QFile::encodeName(filePath);
+ Q_Q(QFSFileEngine);
+
+ fh = 0;
+ fd = -1;
+
+ QString fn(QFileSystemEngine::absoluteName(fileEntry).nativeFilePath());
+ RFs& fs = qt_s60GetRFs();
+
+ TUint symbianMode = 0;
+
+ if(openMode & QIODevice::ReadOnly)
+ symbianMode |= EFileRead;
+ if(openMode & QIODevice::WriteOnly)
+ symbianMode |= EFileWrite;
+ if(openMode & QIODevice::Text)
+ symbianMode |= EFileStreamText;
+
+ // pre Symbian 9.4, file I/O is always unbuffered, and the enum values don't exist
+ if(QSysInfo::symbianVersion() >= QSysInfo::SV_9_4) {
+ if (openMode & QFile::Unbuffered) {
+ if (openMode & QIODevice::WriteOnly)
+ symbianMode |= 0x00001000; //EFileWriteDirectIO;
+ // ### Unbuffered read is not used, because it prevents file open in /resource
+ // ### and has no obvious benefits
+ } else {
+ if (openMode & QIODevice::WriteOnly)
+ symbianMode |= 0x00000800; //EFileWriteBuffered;
+ // use implementation defaults for read buffering
+ }
+ }
+
+ // Until Qt supports file sharing, we can't support EFileShareReadersOrWriters safely,
+ // but Qt does this on other platforms and autotests rely on it.
+ // The reason is that Unix locks are only advisory - the application needs to test the
+ // lock after opening the file. Symbian and Windows locks are mandatory - opening a
+ // locked file will fail.
+ symbianMode |= EFileShareReadersOrWriters;
+
+ TInt r;
+ //note QIODevice::Truncate only has meaning for read/write access
+ //write-only files are always truncated unless append is specified
+ //reference openModeToOpenFlags in qfsfileengine_unix.cpp
+ if ((openMode & QIODevice::Truncate) || (!(openMode & QIODevice::ReadOnly) && !(openMode & QIODevice::Append))) {
+ r = symbianFile.Replace(fs, qt_QString2TPtrC(fn), symbianMode);
+ } else {
+ r = symbianFile.Open(fs, qt_QString2TPtrC(fn), symbianMode);
+ if (r == KErrNotFound && (openMode & QIODevice::WriteOnly)) {
+ r = symbianFile.Create(fs, qt_QString2TPtrC(fn), symbianMode);
+ }
+ }
+
+ if (r == KErrNone) {
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ TInt64 size;
+#else
+ TInt size;
+#endif
+ r = symbianFile.Size(size);
+ if (r==KErrNone) {
+ if (openMode & QIODevice::Append)
+ symbianFilePos = size;
+ else
+ symbianFilePos = 0;
+ //TODO: port this (QFileSystemMetaData in open?)
+ //cachedSize = size;
+ }
+ }
+
+ if (r != KErrNone) {
+ q->setError(QFile::OpenError, QSystemError(r, QSystemError::NativeError).toString());
+ symbianFile.Close();
+ return false;
+ }
+
+ closeFileHandle = true;
+ return true;
}
+bool QFSFileEngine::open(QIODevice::OpenMode openMode, const RFile &file, QFile::FileHandleFlags handleFlags)
+{
+ Q_D(QFSFileEngine);
+
+ // Append implies WriteOnly.
+ if (openMode & QFile::Append)
+ openMode |= QFile::WriteOnly;
+
+ // WriteOnly implies Truncate if neither ReadOnly nor Append are sent.
+ if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
+ openMode |= QFile::Truncate;
+
+ d->openMode = openMode;
+ d->lastFlushFailed = false;
+ d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
+ d->fileEntry.clear();
+ d->fh = 0;
+ d->fd = -1;
+ d->tried_stat = 0;
+
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ //RFile64 adds only functions to RFile, no data members
+ d->symbianFile = static_cast<const RFile64&>(file);
+#else
+ d->symbianFile = file;
+#endif
+ TInt ret;
+ d->symbianFilePos = 0;
+ if (openMode & QFile::Append) {
+ // Seek to the end when in Append mode.
+ ret = d->symbianFile.Size(d->symbianFilePos);
+ } else {
+ // Seek to current otherwise
+ ret = d->symbianFile.Seek(ESeekCurrent, d->symbianFilePos);
+ }
+
+ if (ret != KErrNone) {
+ setError(QFile::OpenError, QSystemError(ret, QSystemError::NativeError).toString());
+
+ d->openMode = QIODevice::NotOpen;
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ d->symbianFile = RFile64();
+#else
+ d->symbianFile = RFile();
+#endif
+ return false;
+ }
+
+ // Extract filename (best effort)
+ TFileName fn;
+ TInt err = d->symbianFile.FullName(fn);
+ if (err == KErrNone)
+ d->fileEntry = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath());
+ else
+ d->fileEntry.clear();
+
+ return true;
+}
+#else
/*!
\internal
*/
@@ -215,7 +323,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
// Try to open the file in unbuffered mode.
do {
- fd = QT_OPEN(nativeFilePath.constData(), flags, 0666);
+ fd = QT_OPEN(fileEntry.nativeFilePath().constData(), flags, 0666);
} while (fd == -1 && errno == EINTR);
// On failure, return and report the error.
@@ -228,13 +336,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
if (!(openMode & QIODevice::WriteOnly)) {
// we don't need this check if we tried to open for writing because then
// we had received EISDIR anyway.
- QT_STATBUF statBuf;
- if (QT_FSTAT(fd, &statBuf) != -1) {
- if ((statBuf.st_mode & S_IFMT) == S_IFDIR) {
- q->setError(QFile::OpenError, QLatin1String("file to open is a directory"));
- QT_CLOSE(fd);
- return false;
- }
+ if (QFileSystemEngine::fillMetaData(fd, metaData)
+ && metaData.isDirectory()) {
+ q->setError(QFile::OpenError, QLatin1String("file to open is a directory"));
+ QT_CLOSE(fd);
+ return false;
}
}
@@ -254,11 +360,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
fh = 0;
} else {
- QByteArray fopenMode = openModeToFopenMode(openMode, nativeFilePath.constData());
+ QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry, metaData);
// Try to open the file in buffered mode.
do {
- fh = QT_FOPEN(nativeFilePath.constData(), fopenMode.constData());
+ fh = QT_FOPEN(fileEntry.nativeFilePath().constData(), fopenMode.constData());
} while (!fh && errno == EINTR);
// On failure, return and report the error.
@@ -271,13 +377,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
if (!(openMode & QIODevice::WriteOnly)) {
// we don't need this check if we tried to open for writing because then
// we had received EISDIR anyway.
- QT_STATBUF statBuf;
- if (QT_FSTAT(fileno(fh), &statBuf) != -1) {
- if ((statBuf.st_mode & S_IFMT) == S_IFDIR) {
- q->setError(QFile::OpenError, QLatin1String("file to open is a directory"));
- fclose(fh);
- return false;
- }
+ if (QFileSystemEngine::fillMetaData(QT_FILENO(fh), metaData)
+ && metaData.isDirectory()) {
+ q->setError(QFile::OpenError, QLatin1String("file to open is a directory"));
+ fclose(fh);
+ return false;
}
}
@@ -303,6 +407,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
closeFileHandle = true;
return true;
}
+#endif
/*!
\internal
@@ -318,6 +423,10 @@ bool QFSFileEnginePrivate::nativeClose()
*/
bool QFSFileEnginePrivate::nativeFlush()
{
+#ifdef Q_OS_SYMBIAN
+ if (symbianFile.SubSessionHandle())
+ return (KErrNone == symbianFile.Flush());
+#endif
return fh ? flushFh() : fd != -1;
}
@@ -328,6 +437,24 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len)
{
Q_Q(QFSFileEngine);
+#ifdef Q_OS_SYMBIAN
+ if (symbianFile.SubSessionHandle()) {
+ if(len > KMaxTInt) {
+ //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..)
+ q->setError(QFile::ReadError, QLatin1String("Maximum 2GB in single read on this platform"));
+ return -1;
+ }
+ TPtr8 ptr(reinterpret_cast<TUint8*>(data), static_cast<TInt>(len));
+ TInt r = symbianFile.Read(symbianFilePos, ptr);
+ if (r != KErrNone)
+ {
+ q->setError(QFile::ReadError, QSystemError(r, QSystemError::NativeError).toString());
+ return -1;
+ }
+ symbianFilePos += ptr.Length();
+ return qint64(ptr.Length());
+ }
+#endif
if (fh && nativeIsSequential()) {
size_t readBytes = 0;
int oldFlags = fcntl(QT_FILENO(fh), F_GETFL);
@@ -395,6 +522,40 @@ qint64 QFSFileEnginePrivate::nativeReadLine(char *data, qint64 maxlen)
*/
qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len)
{
+#ifdef Q_OS_SYMBIAN
+ Q_Q(QFSFileEngine);
+ if (symbianFile.SubSessionHandle()) {
+ if(len > KMaxTInt) {
+ //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..)
+ q->setError(QFile::WriteError, QLatin1String("Maximum 2GB in single write on this platform"));
+ return -1;
+ }
+ const TPtrC8 ptr(reinterpret_cast<const TUint8*>(data), static_cast<TInt>(len));
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ TInt64 eofpos = 0;
+#else
+ TInt eofpos = 0;
+#endif
+ //The end of file position is not cached because QFile is read/write sharable, therefore another
+ //process may have altered the file size.
+ TInt r = symbianFile.Seek(ESeekEnd, eofpos);
+ if (r == KErrNone && symbianFilePos > eofpos) {
+ //seek position is beyond end of file so file needs to be extended before write.
+ //note that SetSize does not zero-initialise (c.f. posix lseek)
+ r = symbianFile.SetSize(symbianFilePos);
+ }
+ if (r == KErrNone) {
+ //write to specific position in the file (i.e. use our own cursor rather than calling seek)
+ r = symbianFile.Write(symbianFilePos, ptr);
+ }
+ if (r != KErrNone) {
+ q->setError(QFile::WriteError, QSystemError(r, QSystemError::NativeError).toString());
+ return -1;
+ }
+ symbianFilePos += len;
+ return len;
+ }
+#endif
return writeFdFh(data, len);
}
@@ -403,6 +564,12 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len)
*/
qint64 QFSFileEnginePrivate::nativePos() const
{
+#ifdef Q_OS_SYMBIAN
+ const Q_Q(QFSFileEngine);
+ if (symbianFile.SubSessionHandle()) {
+ return symbianFilePos;
+ }
+#endif
return posFdFh();
}
@@ -411,6 +578,19 @@ qint64 QFSFileEnginePrivate::nativePos() const
*/
bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
{
+#ifdef Q_OS_SYMBIAN
+ Q_Q(QFSFileEngine);
+ if (symbianFile.SubSessionHandle()) {
+#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ if(pos > KMaxTInt) {
+ q->setError(QFile::PositionError, QLatin1String("Maximum 2GB file position on this platform"));
+ return false;
+ }
+#endif
+ symbianFilePos = pos;
+ return true;
+ }
+#endif
return seekFdFh(pos);
}
@@ -422,139 +602,110 @@ int QFSFileEnginePrivate::nativeHandle() const
return fh ? fileno(fh) : fd;
}
+#ifdef Q_OS_SYMBIAN
+int QFSFileEnginePrivate::getMapHandle()
+{
+ if (symbianFile.SubSessionHandle()) {
+ // Symbian file handle can't be used for open C mmap() so open the file with open C as well.
+ if (fileHandleForMaps < 0) {
+ int flags = openModeToOpenFlags(openMode);
+ flags &= ~(O_CREAT | O_TRUNC);
+ fileHandleForMaps = ::wopen((wchar_t*)(fileEntry.nativeFilePath().utf16()), flags, 0666);
+ }
+ return fileHandleForMaps;
+ }
+ return nativeHandle();
+}
+#endif
+
/*!
\internal
*/
bool QFSFileEnginePrivate::nativeIsSequential() const
{
+#ifdef Q_OS_SYMBIAN
+ if (symbianFile.SubSessionHandle())
+ return false;
+#endif
return isSequentialFdFh();
}
bool QFSFileEngine::remove()
{
Q_D(QFSFileEngine);
- bool ret = unlink(d->nativeFilePath.constData()) == 0;
- if (!ret)
- setError(QFile::RemoveError, qt_error_string(errno));
+ QSystemError error;
+ bool ret = QFileSystemEngine::removeFile(d->fileEntry, error);
+ d->metaData.clear();
+ if (!ret) {
+ setError(QFile::RemoveError, error.toString());
+ }
return ret;
}
bool QFSFileEngine::copy(const QString &newName)
{
-#if defined(Q_OS_SYMBIAN)
Q_D(QFSFileEngine);
- RFs rfs = qt_s60GetRFs();
- CFileMan* fm = NULL;
- QString oldNative(QDir::toNativeSeparators(d->filePath));
- TPtrC oldPtr(qt_QString2TPtrC(oldNative));
- QFileInfo fi(newName);
- QString absoluteNewName = fi.absoluteFilePath();
- QString newNative(QDir::toNativeSeparators(absoluteNewName));
- TPtrC newPtr(qt_QString2TPtrC(newNative));
- TRAPD (err,
- fm = CFileMan::NewL(rfs);
- RFile rfile;
- err = rfile.Open(rfs, oldPtr, EFileShareReadersOrWriters);
- if (err == KErrNone) {
- err = fm->Copy(rfile, newPtr);
- rfile.Close();
- }
- ) // End TRAP
- delete fm;
- if (err == KErrNone)
- return true;
- d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error"));
- return false;
-#else
- Q_UNUSED(newName);
- // ### Add copy code for Unix here
- setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
- return false;
-#endif
+ QSystemError error;
+ bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error);
+ if (!ret) {
+ setError(QFile::CopyError, error.toString());
+ }
+ return ret;
}
bool QFSFileEngine::rename(const QString &newName)
{
Q_D(QFSFileEngine);
- bool ret = ::rename(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0;
- if (!ret)
- setError(QFile::RenameError, qt_error_string(errno));
+ QSystemError error;
+ bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error);
+
+ if (!ret) {
+ setError(QFile::RenameError, error.toString());
+ }
+
return ret;
}
bool QFSFileEngine::link(const QString &newName)
{
Q_D(QFSFileEngine);
- bool ret = ::symlink(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0;
- if (!ret)
- setError(QFile::RenameError, qt_error_string(errno));
+ QSystemError error;
+ bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error);
+ if (!ret) {
+ setError(QFile::RenameError, error.toString());
+ }
return ret;
}
qint64 QFSFileEnginePrivate::nativeSize() const
{
+#ifdef Q_OS_SYMBIAN
+ const Q_Q(QFSFileEngine);
+ if (symbianFile.SubSessionHandle()) {
+#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+ qint64 size;
+#else
+ TInt size;
+#endif
+ TInt err = symbianFile.Size(size);
+ if(err != KErrNone) {
+ const_cast<QFSFileEngine*>(q)->setError(QFile::PositionError, QSystemError(err, QSystemError::NativeError).toString());
+ return 0;
+ }
+ return size;
+ }
+#endif
return sizeFdFh();
}
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
- QString dirName = name;
- if (createParentDirectories) {
- dirName = QDir::cleanPath(dirName);
-#if defined(Q_OS_SYMBIAN)
- dirName = QDir::toNativeSeparators(dirName);
-#endif
- for(int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
- slash = dirName.indexOf(QDir::separator(), oldslash+1);
- if (slash == -1) {
- if (oldslash == dirName.length())
- break;
- slash = dirName.length();
- }
- if (slash) {
- QByteArray chunk = QFile::encodeName(dirName.left(slash));
- QT_STATBUF st;
- if (QT_STAT(chunk, &st) != -1) {
- if ((st.st_mode & S_IFMT) != S_IFDIR)
- return false;
- } else if (QT_MKDIR(chunk, 0777) != 0) {
- return false;
- }
- }
- }
- return true;
- }
-#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
- if (dirName.endsWith(QLatin1Char('/')))
- dirName.chop(1);
-#endif
- return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
+ return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
}
bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const
{
- QString dirName = name;
- if (recurseParentDirectories) {
- dirName = QDir::cleanPath(dirName);
-#if defined(Q_OS_SYMBIAN)
- dirName = QDir::toNativeSeparators(dirName);
-#endif
- for(int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
- QByteArray chunk = QFile::encodeName(dirName.left(slash));
- QT_STATBUF st;
- if (QT_STAT(chunk, &st) != -1) {
- if ((st.st_mode & S_IFMT) != S_IFDIR)
- return false;
- if (::rmdir(chunk) != 0)
- return oldslash != 0;
- } else {
- return false;
- }
- slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
- }
- return true;
- }
- return ::rmdir(QFile::encodeName(dirName)) == 0;
+ return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
}
bool QFSFileEngine::caseSensitive() const
@@ -568,94 +719,27 @@ bool QFSFileEngine::caseSensitive() const
bool QFSFileEngine::setCurrentPath(const QString &path)
{
- int r;
- r = QT_CHDIR(QFile::encodeName(path));
- return r >= 0;
+ return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path));
}
QString QFSFileEngine::currentPath(const QString &)
{
- QString result;
- QT_STATBUF st;
-#if defined(Q_OS_SYMBIAN)
- char nativeCurrentName[PATH_MAX+1];
- if (::getcwd(nativeCurrentName, PATH_MAX))
- result = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(nativeCurrentName)));
- if (result.isEmpty()) {
-# if defined(QT_DEBUG)
- qWarning("QFSFileEngine::currentPath: getcwd() failed");
-# endif
- } else
-#endif
- if (QT_STAT(".", &st) == 0) {
-#if defined(__GLIBC__) && !defined(PATH_MAX)
- char *currentName = ::get_current_dir_name();
- if (currentName) {
- result = QFile::decodeName(QByteArray(currentName));
- ::free(currentName);
- }
-#elif !defined(Q_OS_SYMBIAN)
- char currentName[PATH_MAX+1];
- if (::getcwd(currentName, PATH_MAX))
- result = QFile::decodeName(QByteArray(currentName));
-# if defined(QT_DEBUG)
- if (result.isNull())
- qWarning("QFSFileEngine::currentPath: getcwd() failed");
-# endif
-#endif
- } else {
-#if defined(Q_OS_SYMBIAN)
- // If current dir returned by Open C doesn't exist,
- // try to create it (can happen with application private dirs)
- // Ignore mkdir failures; we want to be consistent with Open C
- // current path regardless.
- QT_MKDIR(QFile::encodeName(QLatin1String(nativeCurrentName)), 0777);
-#else
-# if defined(QT_DEBUG)
- qWarning("QFSFileEngine::currentPath: stat(\".\") failed");
-# endif
-#endif
- }
- return result;
+ return QFileSystemEngine::currentPath().filePath();
}
QString QFSFileEngine::homePath()
{
-#if defined(Q_OS_SYMBIAN)
- QString home = rootPath();
-#else
- QString home = QFile::decodeName(qgetenv("HOME"));
- if (home.isNull())
- home = rootPath();
-#endif
- return home;
+ return QFileSystemEngine::homePath();
}
QString QFSFileEngine::rootPath()
{
-#if defined(Q_OS_SYMBIAN)
- TFileName symbianPath = PathInfo::PhoneMemoryRootPath();
- return QDir::cleanPath(QDir::fromNativeSeparators(qt_TDesC2QString(symbianPath)));
-#else
- return QLatin1String("/");
-#endif
+ return QFileSystemEngine::rootPath();
}
QString QFSFileEngine::tempPath()
{
-#if defined(Q_OS_SYMBIAN)
- TFileName symbianPath = PathInfo::PhoneMemoryRootPath();
- QString temp = QDir::fromNativeSeparators(qt_TDesC2QString(symbianPath));
- temp += QLatin1String( "temp/");
-
- // Just to verify that folder really exist on hardware
- QT_MKDIR(QFile::encodeName(temp), 0777);
-#else
- QString temp = QFile::decodeName(qgetenv("TMPDIR"));
- if (temp.isEmpty())
- temp = QLatin1String("/tmp/");
-#endif
- return temp;
+ return QFileSystemEngine::tempPath();
}
QFileInfoList QFSFileEngine::drives()
@@ -683,123 +767,30 @@ QFileInfoList QFSFileEngine::drives()
return ret;
}
-bool QFSFileEnginePrivate::doStat() const
+bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const
{
- if (!tried_stat) {
- tried_stat = true;
- could_stat = false;
-
- if (fh && nativeFilePath.isEmpty()) {
- // ### actually covers two cases: d->fh and when the file is not open
- could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0);
- } else if (fd == -1) {
- // ### actually covers two cases: d->fh and when the file is not open
-#if defined(Q_OS_SYMBIAN)
- // Optimization for Symbian where fileFlags() calls both doStat() and isSymlink(), but rarely on real links.
- // When the filename is not a link, lstat will return the same info as stat, but this also removes
- // any need for a further call to lstat to check if the file is a link.
- need_lstat = false;
- could_stat = (QT_LSTAT(nativeFilePath.constData(), &st) == 0);
- is_link = could_stat ? S_ISLNK(st.st_mode) : false;
- // if it turns out this was a link, we can call stat too.
- if (is_link)
-#endif
- could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0);
- } else {
- could_stat = (QT_FSTAT(fd, &st) == 0);
- }
- }
- return could_stat;
-}
+ if (!tried_stat || !metaData.hasFlags(flags)) {
+ tried_stat = 1;
-bool QFSFileEnginePrivate::isSymlink() const
-{
- if (need_lstat) {
- need_lstat = false;
+ int localFd = fd;
+ if (fh && fileEntry.isEmpty())
+ localFd = QT_FILENO(fh);
+ if (localFd != -1)
+ QFileSystemEngine::fillMetaData(localFd, metaData);
- QT_STATBUF st; // don't clobber our main one
- is_link = (QT_LSTAT(nativeFilePath.constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false;
+ if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
+ QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
}
- return is_link;
-}
-
-#if defined(Q_OS_SYMBIAN)
-static bool _q_isSymbianHidden(const QString &path, bool isDir)
-{
- RFs rfs = qt_s60GetRFs();
- QFileInfo fi(path);
- QString absPath = fi.absoluteFilePath();
- if (isDir && !absPath.endsWith(QLatin1Char('/')))
- absPath.append(QLatin1Char('/'));
- QString native(QDir::toNativeSeparators(absPath));
- TPtrC ptr(qt_QString2TPtrC(native));
- TUint attributes;
- TInt err = rfs.Att(ptr, attributes);
- return (err == KErrNone && (attributes & KEntryAttHidden));
-}
-#endif
-
-#if !defined(QWS) && defined(Q_OS_MAC)
-static bool _q_isMacHidden(const QString &path)
-{
- OSErr err = noErr;
-
- FSRef fsRef;
- err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(QFile::encodeName(QDir::cleanPath(path)).constData()),
- kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0);
- if (err != noErr)
- return false;
-
- FSCatalogInfo catInfo;
- err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL);
- if (err != noErr)
- return false;
-
- FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo);
- bool result = (fileInfo->finderFlags & kIsInvisible);
- return result;
+ return metaData.exists();
}
-#endif
-QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFileEngine::FileFlags type) const
+bool QFSFileEnginePrivate::isSymlink() const
{
- QAbstractFileEngine::FileFlags ret = 0;
-
- if (st.st_mode & S_IRUSR)
- ret |= QAbstractFileEngine::ReadOwnerPerm;
- if (st.st_mode & S_IWUSR)
- ret |= QAbstractFileEngine::WriteOwnerPerm;
- if (st.st_mode & S_IXUSR)
- ret |= QAbstractFileEngine::ExeOwnerPerm;
- if (st.st_mode & S_IRGRP)
- ret |= QAbstractFileEngine::ReadGroupPerm;
- if (st.st_mode & S_IWGRP)
- ret |= QAbstractFileEngine::WriteGroupPerm;
- if (st.st_mode & S_IXGRP)
- ret |= QAbstractFileEngine::ExeGroupPerm;
- if (st.st_mode & S_IROTH)
- ret |= QAbstractFileEngine::ReadOtherPerm;
- if (st.st_mode & S_IWOTH)
- ret |= QAbstractFileEngine::WriteOtherPerm;
- if (st.st_mode & S_IXOTH)
- ret |= QAbstractFileEngine::ExeOtherPerm;
-
- // calculate user permissions
- if (type & QAbstractFileEngine::ReadUserPerm) {
- if (QT_ACCESS(nativeFilePath.constData(), R_OK) == 0)
- ret |= QAbstractFileEngine::ReadUserPerm;
- }
- if (type & QAbstractFileEngine::WriteUserPerm) {
- if (QT_ACCESS(nativeFilePath.constData(), W_OK) == 0)
- ret |= QAbstractFileEngine::WriteUserPerm;
- }
- if (type & QAbstractFileEngine::ExeUserPerm) {
- if (QT_ACCESS(nativeFilePath.constData(), X_OK) == 0)
- ret |= QAbstractFileEngine::ExeUserPerm;
- }
+ if (!metaData.hasFlags(QFileSystemMetaData::LinkType))
+ QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType);
- return ret;
+ return metaData.isLink();
}
/*!
@@ -808,360 +799,111 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFil
QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const
{
Q_D(const QFSFileEngine);
- // Force a stat, so that we're guaranteed to get up-to-date results
- if (type & Refresh) {
- d->tried_stat = 0;
- d->need_lstat = 1;
- }
+
+ if (type & Refresh)
+ d->metaData.clear();
QAbstractFileEngine::FileFlags ret = 0;
+
if (type & FlagsMask)
ret |= LocalDiskFlag;
- bool exists = d->doStat();
- if (!exists && !d->isSymlink())
+
+ bool exists;
+ {
+ QFileSystemMetaData::MetaDataFlags queryFlags = 0;
+
+ queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type))
+ & QFileSystemMetaData::Permissions;
+
+ if (type & TypesMask)
+ queryFlags |= QFileSystemMetaData::AliasType
+ | QFileSystemMetaData::LinkType
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::BundleType;
+
+ if (type & FlagsMask)
+ queryFlags |= QFileSystemMetaData::HiddenAttribute
+ | QFileSystemMetaData::ExistsAttribute;
+
+ queryFlags |= QFileSystemMetaData::LinkType;
+
+ exists = d->doStat(queryFlags);
+ }
+
+ if (!exists && !d->metaData.isLink())
return ret;
if (exists && (type & PermsMask))
- ret |= d->getPermissions(type);
+ ret |= FileFlags(uint(d->metaData.permissions()));
+
if (type & TypesMask) {
-#if !defined(QWS) && defined(Q_OS_MAC)
- bool foundAlias = false;
- {
- FSRef fref;
- if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(),
- &fref, NULL) == noErr) {
- Boolean isAlias, isFolder;
- if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr && isAlias) {
- foundAlias = true;
- ret |= LinkType;
- }
- }
- }
- if (!foundAlias)
-#endif
- {
- if ((type & LinkType) && d->isSymlink())
+ if (d->metaData.isAlias()) {
+ ret |= LinkType;
+ } else {
+ if ((type & LinkType) && d->metaData.isLink())
ret |= LinkType;
- if (exists && (d->st.st_mode & S_IFMT) == S_IFREG)
- ret |= FileType;
- else if (exists && (d->st.st_mode & S_IFMT) == S_IFDIR)
- ret |= DirectoryType;
-#if !defined(QWS) && defined(Q_OS_MAC)
- if ((ret & DirectoryType) && (type & BundleType)) {
- QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),
- kCFURLPOSIXPathStyle, true);
- UInt32 type, creator;
- if (CFBundleGetPackageInfoInDirectory(url, &type, &creator))
- ret |= BundleType;
+ if (exists) {
+ if (d->metaData.isFile()) {
+ ret |= FileType;
+ } else if (d->metaData.isDirectory()) {
+ ret |= DirectoryType;
+ if ((type & BundleType) && d->metaData.isBundle())
+ ret |= BundleType;
+ }
}
-#endif
}
}
+
if (type & FlagsMask) {
if (exists)
ret |= ExistsFlag;
-#if defined(Q_OS_SYMBIAN)
- if (d->filePath == QLatin1String("/")
- || (d->filePath.length() == 3 && d->filePath.at(0).isLetter()
- && d->filePath.at(1) == QLatin1Char(':') && d->filePath.at(2) == QLatin1Char('/'))) {
- ret |= RootFlag;
- } else {
- // In Symbian, all symlinks have hidden attribute for some reason;
- // lets make them visible for better compatibility with other platforms.
- // If somebody actually wants a hidden link, then they are out of luck.
- if (!d->isSymlink() && _q_isSymbianHidden(d->filePath, ret & DirectoryType))
- ret |= HiddenFlag;
- }
-#else
- if (d->filePath == QLatin1String("/")) {
+ if (d->fileEntry.isRoot())
ret |= RootFlag;
- } else {
- QString baseName = fileName(BaseName);
- if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.'))
-# if !defined(QWS) && defined(Q_OS_MAC)
- || _q_isMacHidden(d->filePath)
-# endif
- ) {
- ret |= HiddenFlag;
- }
- }
-#endif
+ else if (d->metaData.isHidden())
+ ret |= HiddenFlag;
}
- return ret;
-}
-#if defined(Q_OS_SYMBIAN)
-QString QFSFileEngine::fileName(FileName file) const
-{
- Q_D(const QFSFileEngine);
- const QLatin1Char slashChar('/');
- if(file == BaseName) {
- int slash = d->filePath.lastIndexOf(slashChar);
- if(slash == -1) {
- int colon = d->filePath.lastIndexOf(QLatin1Char(':'));
- if(colon != -1)
- return d->filePath.mid(colon + 1);
- return d->filePath;
- }
- return d->filePath.mid(slash + 1);
- } else if(file == PathName) {
- if(!d->filePath.size())
- return d->filePath;
-
- int slash = d->filePath.lastIndexOf(slashChar);
- if(slash == -1) {
- if(d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':'))
- return d->filePath.left(2);
- return QLatin1String(".");
- } else {
- if(!slash)
- return QLatin1String("/");
- if(slash == 2 && d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':'))
- slash++;
- return d->filePath.left(slash);
- }
- } else if(file == AbsoluteName || file == AbsolutePathName) {
- QString ret;
- if (!isRelativePathSymbian(d->filePath)) {
- if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':')
- && d->filePath.at(2) != slashChar){
- // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt,
- // or if it's different drive than current, Z:a.txt -> Z:/a.txt
- QString currentPath = QDir::currentPath();
- if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive))
- ret = currentPath + slashChar + d->filePath.mid(2);
- else
- ret = d->filePath.left(2) + slashChar + d->filePath.mid(2);
- } else if (d->filePath.startsWith(slashChar)) {
- // It's a absolute path to the current drive, so /a.txt -> C:/a.txt
- ret = QDir::currentPath().left(2) + d->filePath;
- } else {
- ret = d->filePath;
- }
- } else {
- ret = QDir::currentPath() + slashChar + d->filePath;
- }
-
- // The path should be absolute at this point.
- // From the docs :
- // Absolute paths begin with the directory separator "/"
- // (optionally preceded by a drive specification under Windows).
- if (ret.at(0) != slashChar) {
- Q_ASSERT(ret.length() >= 2);
- Q_ASSERT(ret.at(0).isLetter());
- Q_ASSERT(ret.at(1) == QLatin1Char(':'));
-
- // Force uppercase drive letters.
- ret[0] = ret.at(0).toUpper();
- }
-
- // Clean up the path
- bool isDir = ret.endsWith(slashChar);
- ret = QDir::cleanPath(ret);
- if (isDir && !ret.endsWith(slashChar))
- ret += slashChar;
-
- if (file == AbsolutePathName) {
- int slash = ret.lastIndexOf(slashChar);
- if (slash < 0)
- return ret;
- else if (ret.at(0) != slashChar && slash == 2)
- return ret.left(3); // include the slash
- else
- return ret.left(slash > 0 ? slash : 1);
- }
- return ret;
- } else if(file == CanonicalName || file == CanonicalPathName) {
- if (!(fileFlags(ExistsFlag) & ExistsFlag))
- return QString();
-
- QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName));
- if (file == CanonicalPathName && !ret.isEmpty()) {
- int slash = ret.lastIndexOf(slashChar);
- if (slash == -1)
- ret = QDir::fromNativeSeparators(QDir::currentPath());
- else if (slash == 0)
- ret = QLatin1String("/");
- ret = ret.left(slash);
- }
- return ret;
- } else if(file == LinkName) {
- if (d->isSymlink()) {
- char s[PATH_MAX+1];
- int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX);
- if (len > 0) {
- s[len] = '\0';
- QString ret = QFile::decodeName(QByteArray(s));
-
- if (isRelativePathSymbian(ret)) {
- if (!isRelativePathSymbian(d->filePath)) {
- ret.prepend(d->filePath.left(d->filePath.lastIndexOf(slashChar))
- + slashChar);
- } else {
- ret.prepend(QDir::currentPath() + slashChar);
- }
- }
- ret = QDir::cleanPath(ret);
- if (ret.size() > 1 && ret.endsWith(slashChar))
- ret.chop(1);
- return ret;
- }
- }
- return QString();
- } else if(file == BundleName) {
- return QString();
- }
- return d->filePath;
+ return ret;
}
-#else
-
QString QFSFileEngine::fileName(FileName file) const
{
Q_D(const QFSFileEngine);
if (file == BundleName) {
-#if !defined(QWS) && defined(Q_OS_MAC)
- QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath),
- kCFURLPOSIXPathStyle, true);
- if (QCFType<CFDictionaryRef> dict = CFBundleCopyInfoDictionaryForURL(url)) {
- if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) {
- if (CFGetTypeID(name) == CFStringGetTypeID())
- return QCFString::toQString((CFStringRef)name);
- }
- }
-#endif
- return QString();
+ return QFileSystemEngine::bundleName(d->fileEntry);
} else if (file == BaseName) {
- int slash = d->filePath.lastIndexOf(QLatin1Char('/'));
- if (slash != -1)
- return d->filePath.mid(slash + 1);
+ return d->fileEntry.fileName();
} else if (file == PathName) {
- int slash = d->filePath.lastIndexOf(QLatin1Char('/'));
- if (slash == -1)
- return QLatin1String(".");
- else if (!slash)
- return QLatin1String("/");
- return d->filePath.left(slash);
+ return d->fileEntry.path();
} else if (file == AbsoluteName || file == AbsolutePathName) {
- QString ret;
- if (d->filePath.isEmpty() || !d->filePath.startsWith(QLatin1Char('/')))
- ret = QDir::currentPath();
- if (!d->filePath.isEmpty() && d->filePath != QLatin1String(".")) {
- if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
- ret += QLatin1Char('/');
- ret += d->filePath;
- }
- if (ret == QLatin1String("/"))
- return ret;
- bool isDir = ret.endsWith(QLatin1Char('/'));
- ret = QDir::cleanPath(ret);
- if (isDir)
- ret += QLatin1Char('/');
+ QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry));
if (file == AbsolutePathName) {
- int slash = ret.lastIndexOf(QLatin1Char('/'));
- if (slash == -1)
- return QDir::currentPath();
- else if (!slash)
- return QLatin1String("/");
- return ret.left(slash);
+ return entry.path();
}
- return ret;
+ return entry.filePath();
} else if (file == CanonicalName || file == CanonicalPathName) {
- if (!(fileFlags(ExistsFlag) & ExistsFlag))
- return QString();
-
- QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName));
- if (file == CanonicalPathName && !ret.isEmpty()) {
- int slash = ret.lastIndexOf(QLatin1Char('/'));
- if (slash == -1)
- ret = QDir::currentPath();
- else if (slash == 0)
- ret = QLatin1String("/");
- ret = ret.left(slash);
- }
- return ret;
+ QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData));
+ if (file == CanonicalPathName)
+ return entry.path();
+ return entry.filePath();
} else if (file == LinkName) {
if (d->isSymlink()) {
-#if defined(__GLIBC__) && !defined(PATH_MAX)
-#define PATH_CHUNK_SIZE 256
- char *s = 0;
- int len = -1;
- int size = PATH_CHUNK_SIZE;
-
- while (1) {
- s = q_check_ptr((char *) ::realloc(s, size));
- len = ::readlink(d->nativeFilePath.constData(), s, size);
- if (len < 0) {
- ::free(s);
- break;
- }
- if (len < size) {
- break;
- }
- size *= 2;
- }
-#else
- char s[PATH_MAX+1];
- int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX);
-#endif
- if (len > 0) {
- QString ret;
- if (d->doStat() && S_ISDIR(d->st.st_mode) && s[0] != '/') {
- QDir parent(d->filePath);
- parent.cdUp();
- ret = parent.path();
- if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
- ret += QLatin1Char('/');
- }
- s[len] = '\0';
- ret += QFile::decodeName(QByteArray(s));
-#if defined(__GLIBC__) && !defined(PATH_MAX)
- ::free(s);
-#endif
-
- if (!ret.startsWith(QLatin1Char('/'))) {
- if (d->filePath.startsWith(QLatin1Char('/'))) {
- ret.prepend(d->filePath.left(d->filePath.lastIndexOf(QLatin1Char('/')))
- + QLatin1Char('/'));
- } else {
- ret.prepend(QDir::currentPath() + QLatin1Char('/'));
- }
- }
- ret = QDir::cleanPath(ret);
- if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
- ret.chop(1);
- return ret;
- }
- }
-#if !defined(QWS) && defined(Q_OS_MAC)
- {
- FSRef fref;
- if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == noErr) {
- Boolean isAlias, isFolder;
- if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) {
- AliasHandle alias;
- if (FSNewAlias(0, &fref, &alias) == noErr && alias) {
- QCFString cfstr;
- if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr)
- return QCFString::toQString(cfstr);
- }
- }
- }
+ QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData);
+ return entry.filePath();
}
-#endif
return QString();
}
- return d->filePath;
+ return d->fileEntry.filePath();
}
-#endif // Q_OS_SYMBIAN
bool QFSFileEngine::isRelativePath() const
{
Q_D(const QFSFileEngine);
#if defined(Q_OS_SYMBIAN)
- return isRelativePathSymbian(d->filePath);
+ return isRelativePathSymbian(d->fileEntry.filePath());
#else
- return d->filePath.length() ? d->filePath[0] != QLatin1Char('/') : true;
+ return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true;
#endif
}
@@ -1169,101 +911,73 @@ uint QFSFileEngine::ownerId(FileOwner own) const
{
Q_D(const QFSFileEngine);
static const uint nobodyID = (uint) -2;
- if (d->doStat()) {
- if (own == OwnerUser)
- return d->st.st_uid;
- else
- return d->st.st_gid;
- }
+
+ if (d->doStat(QFileSystemMetaData::OwnerIds))
+ return d->metaData.ownerId(own);
+
return nobodyID;
}
QString QFSFileEngine::owner(FileOwner own) const
{
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- int size_max = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (size_max == -1)
- size_max = 1024;
- QVarLengthArray<char, 1024> buf(size_max);
-#endif
-
- if (own == OwnerUser) {
- struct passwd *pw = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- struct passwd entry;
- getpwuid_r(ownerId(own), &entry, buf.data(), buf.size(), &pw);
-#else
- pw = getpwuid(ownerId(own));
-#endif
- if (pw)
- return QFile::decodeName(QByteArray(pw->pw_name));
- } else if (own == OwnerGroup) {
-#if !defined(Q_OS_SYMBIAN)
- struct group *gr = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD)
- size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
- if (size_max == -1)
- size_max = 1024;
- buf.resize(size_max);
- struct group entry;
- // Some large systems have more members than the POSIX max size
- // Loop over by doubling the buffer size (upper limit 250k)
- for (unsigned size = size_max; size < 256000; size += size)
- {
- buf.resize(size);
- // ERANGE indicates that the buffer was too small
- if (!getgrgid_r(ownerId(own), &entry, buf.data(), buf.size(), &gr)
- || errno != ERANGE)
- break;
- }
+#ifndef Q_OS_SYMBIAN
+ if (own == OwnerUser)
+ return QFileSystemEngine::resolveUserName(ownerId(own));
+ return QFileSystemEngine::resolveGroupName(ownerId(own));
#else
- gr = getgrgid(ownerId(own));
-#endif
- if (gr)
- return QFile::decodeName(QByteArray(gr->gr_name));
-#endif
- }
return QString();
+#endif
}
bool QFSFileEngine::setPermissions(uint perms)
{
Q_D(QFSFileEngine);
+ QSystemError error;
+ if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) {
+ setError(QFile::PermissionsError, error.toString());
+ return false;
+ }
+ return true;
+}
+
+#ifdef Q_OS_SYMBIAN
+bool QFSFileEngine::setSize(qint64 size)
+{
+ Q_D(QFSFileEngine);
bool ret = false;
- mode_t mode = 0;
- if (perms & ReadOwnerPerm)
- mode |= S_IRUSR;
- if (perms & WriteOwnerPerm)
- mode |= S_IWUSR;
- if (perms & ExeOwnerPerm)
- mode |= S_IXUSR;
- if (perms & ReadUserPerm)
- mode |= S_IRUSR;
- if (perms & WriteUserPerm)
- mode |= S_IWUSR;
- if (perms & ExeUserPerm)
- mode |= S_IXUSR;
- if (perms & ReadGroupPerm)
- mode |= S_IRGRP;
- if (perms & WriteGroupPerm)
- mode |= S_IWGRP;
- if (perms & ExeGroupPerm)
- mode |= S_IXGRP;
- if (perms & ReadOtherPerm)
- mode |= S_IROTH;
- if (perms & WriteOtherPerm)
- mode |= S_IWOTH;
- if (perms & ExeOtherPerm)
- mode |= S_IXOTH;
- if (d->fd != -1)
- ret = fchmod(d->fd, mode) == 0;
- else
- ret = ::chmod(d->nativeFilePath.constData(), mode) == 0;
- if (!ret)
- setError(QFile::PermissionsError, qt_error_string(errno));
+ TInt err = KErrNone;
+ if (d->symbianFile.SubSessionHandle()) {
+ TInt err = d->symbianFile.SetSize(size);
+ ret = (err == KErrNone);
+ if (ret && d->symbianFilePos > size)
+ d->symbianFilePos = size;
+ }
+ else if (d->fd != -1)
+ ret = QT_FTRUNCATE(d->fd, size) == 0;
+ else if (d->fh)
+ ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0;
+ else {
+ RFile tmp;
+ QString symbianFilename(d->fileEntry.nativeFilePath());
+ err = tmp.Open(qt_s60GetRFs(), qt_QString2TPtrC(symbianFilename), EFileWrite);
+ if (err == KErrNone)
+ {
+ err = tmp.SetSize(size);
+ tmp.Close();
+ }
+ ret = (err == KErrNone);
+ }
+ if (!ret) {
+ QSystemError error;
+ if (err)
+ error = QSystemError(err, QSystemError::NativeError);
+ else
+ error = QSystemError(errno, QSystemError::StandardLibraryError);
+ setError(QFile::ResizeError, error.toString());
+ }
return ret;
}
-
+#else
bool QFSFileEngine::setSize(qint64 size)
{
Q_D(QFSFileEngine);
@@ -1273,25 +987,21 @@ bool QFSFileEngine::setSize(qint64 size)
else if (d->fh)
ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0;
else
- ret = QT_TRUNCATE(d->nativeFilePath.constData(), size) == 0;
+ ret = QT_TRUNCATE(d->fileEntry.nativeFilePath().constData(), size) == 0;
if (!ret)
setError(QFile::ResizeError, qt_error_string(errno));
return ret;
}
+#endif
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
- QDateTime ret;
- if (d->doStat()) {
- if (time == CreationTime)
- ret.setTime_t(d->st.st_ctime ? d->st.st_ctime : d->st.st_mtime);
- else if (time == ModificationTime)
- ret.setTime_t(d->st.st_mtime);
- else if (time == AccessTime)
- ret.setTime_t(d->st.st_atime);
- }
- return ret;
+
+ if (d->doStat(QFileSystemMetaData::Times))
+ return d->metaData.fileTime(time);
+
+ return QDateTime();
}
uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags)
@@ -1311,15 +1021,19 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
// If we know the mapping will extend beyond EOF, fail early to avoid
// undefined behavior. Otherwise, let mmap have its say.
- if (doStat()
- && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset)))
+ if (doStat(QFileSystemMetaData::SizeAttribute)
+ && (QT_OFF_T(size) > metaData.size() - QT_OFF_T(offset)))
qWarning("QFSFileEngine::map: Mapping a file beyond its size is not portable");
int access = 0;
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)) {
@@ -1334,7 +1048,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
#ifdef Q_OS_SYMBIAN
void *mapAddress;
TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize,
- access, MAP_SHARED, nativeHandle(), realOffset));
+ access, MAP_SHARED, getMapHandle(), realOffset));
if (err != KErrNone) {
qWarning("OpenC bug: leave from mmap %d", err);
mapAddress = MAP_FAILED;
@@ -1369,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));
@@ -1383,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/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index d51cae4..9c858c2 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -43,7 +43,7 @@
#include "qplatformdefs.h"
#include "qabstractfileengine.h"
#include "private/qfsfileengine_p.h"
-#include <private/qsystemlibrary_p.h>
+#include "qfilesystemengine_p.h"
#include <qdebug.h>
#include "qfile.h"
@@ -69,226 +69,12 @@
#define SECURITY_WIN32
#include <security.h>
-#ifndef _INTPTR_T_DEFINED
-#ifdef _WIN64
-typedef __int64 intptr_t;
-#else
-#ifdef _W64
-typedef _W64 int intptr_t;
-#else
-typedef INT_PTR intptr_t;
-#endif
-#endif
-#define _INTPTR_T_DEFINED
-#endif
-
-#ifndef INVALID_FILE_ATTRIBUTES
-# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
+#ifndef PATH_MAX
+#define PATH_MAX FILENAME_MAX
#endif
-#if !defined(Q_OS_WINCE)
-# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-typedef struct _REPARSE_DATA_BUFFER {
- ULONG ReparseTag;
- USHORT ReparseDataLength;
- USHORT Reserved;
- union {
- struct {
- USHORT SubstituteNameOffset;
- USHORT SubstituteNameLength;
- USHORT PrintNameOffset;
- USHORT PrintNameLength;
- ULONG Flags;
- WCHAR PathBuffer[1];
- } SymbolicLinkReparseBuffer;
- struct {
- USHORT SubstituteNameOffset;
- USHORT SubstituteNameLength;
- USHORT PrintNameOffset;
- USHORT PrintNameLength;
- WCHAR PathBuffer[1];
- } MountPointReparseBuffer;
- struct {
- UCHAR DataBuffer[1];
- } GenericReparseBuffer;
- };
-} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
-# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-
-# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
-# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
-# endif
-# ifndef IO_REPARSE_TAG_SYMLINK
-# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
-# endif
-# ifndef FSCTL_GET_REPARSE_POINT
-# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
-# endif
-#endif // !defined(Q_OS_WINCE)
-
QT_BEGIN_NAMESPACE
-static QString readLink(const QString &link);
-
-Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
-
-#if defined(Q_OS_WINCE)
-static QString qfsPrivateCurrentDir = QLatin1String("");
-// As none of the functions we try to resolve do exist on Windows CE
-// we use QT_NO_LIBRARY to shorten everything up a little bit.
-#define QT_NO_LIBRARY 1
-#endif
-
-#if !defined(QT_NO_LIBRARY)
-QT_BEGIN_INCLUDE_NAMESPACE
-typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
-static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0;
-typedef BOOL (WINAPI *PtrLookupAccountSidW)(LPCWSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE);
-static PtrLookupAccountSidW ptrLookupAccountSidW = 0;
-typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID);
-static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0;
-typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK);
-static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
-static TRUSTEE_W currentUserTrusteeW;
-static TRUSTEE_W worldTrusteeW;
-
-typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
-static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
-QT_END_INCLUDE_NAMESPACE
-
-
-void QFSFileEnginePrivate::resolveLibs()
-{
- static bool triedResolve = false;
- if (!triedResolve) {
- // need to resolve the security info functions
-
- // protect initialization
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- // check triedResolve again, since another thread may have already
- // done the initialization
- if (triedResolve) {
- // another thread did initialize the security function pointers,
- // so we shouldn't do it again.
- return;
- }
-#endif
-
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
- if (advapiHnd) {
- ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
- ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW");
- ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW");
- ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW");
- }
- if (ptrBuildTrusteeWithSidW) {
- // Create TRUSTEE for current user
- HANDLE hnd = ::GetCurrentProcess();
- HANDLE token = 0;
- if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) {
- TOKEN_USER tu;
- DWORD retsize;
- if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize))
- ptrBuildTrusteeWithSidW(&currentUserTrusteeW, tu.User.Sid);
- ::CloseHandle(token);
- }
-
- typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
- PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid");
- typedef PVOID (WINAPI *PtrFreeSid)(PSID);
- PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid");
- if (ptrAllocateAndInitializeSid && ptrFreeSid) {
- // Create TRUSTEE for Everyone (World)
- SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
- PSID pWorld = 0;
- if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld))
- ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld);
- ptrFreeSid(pWorld);
- }
- }
- HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
- if (userenvHnd)
- ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
-#endif
- }
-}
-#endif // QT_NO_LIBRARY
-
-typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD);
-static PtrNetShareEnum ptrNetShareEnum = 0;
-typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID);
-static PtrNetApiBufferFree ptrNetApiBufferFree = 0;
-typedef struct _SHARE_INFO_1 {
- LPWSTR shi1_netname;
- DWORD shi1_type;
- LPWSTR shi1_remark;
-} SHARE_INFO_1;
-
-
-bool QFSFileEnginePrivate::resolveUNCLibs()
-{
- static bool triedResolve = false;
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- if (triedResolve) {
- return ptrNetShareEnum && ptrNetApiBufferFree;
- }
-#endif
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
- if (hLib) {
- ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
- if (ptrNetShareEnum)
- ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
- }
-#endif
- }
- return ptrNetShareEnum && ptrNetApiBufferFree;
-}
-
-bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringList *list)
-{
- if (resolveUNCLibs()) {
- SHARE_INFO_1 *BufPtr, *p;
- DWORD res;
- DWORD er = 0, tr = 0, resume = 0, i;
- do {
- res = ptrNetShareEnum((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume);
- if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) {
- p = BufPtr;
- for (i = 1; i <= er; ++i) {
- if (list && p->shi1_type == 0)
- list->append(QString::fromWCharArray(p->shi1_netname));
- p++;
- }
- }
- ptrNetApiBufferFree(BufPtr);
- } while (res == ERROR_MORE_DATA);
- return res == ERROR_SUCCESS;
- }
- return false;
-}
-
-static bool isUncRoot(const QString &server)
-{
- QString localPath = QDir::toNativeSeparators(server);
- if (!localPath.startsWith(QLatin1String("\\\\")))
- return false;
-
- int idx = localPath.indexOf(QLatin1Char('\\'), 2);
- if (idx == -1 || idx + 1 == localPath.length())
- return true;
-
- localPath = localPath.right(localPath.length() - idx - 1).trimmed();
- return localPath.isEmpty();
-}
-
#if !defined(Q_OS_WINCE)
static inline bool isUncPath(const QString &path)
{
@@ -298,73 +84,6 @@ static inline bool isUncPath(const QString &path)
}
#endif
-static inline bool isRelativePath(const QString &path)
-{
- // drive, e.g. "a:", or UNC root, e.q. "//"
- return !(path.startsWith(QLatin1Char('/'))
- || (path.length() >= 2
- && ((path.at(0).isLetter() && path.at(1) == QLatin1Char(':'))
- || (path.at(0) == QLatin1Char('/') && path.at(1) == QLatin1Char('/')))));
-}
-
-static QString fixIfRelativeUncPath(const QString &path)
-{
- if (isRelativePath(path)) {
- QString currentPath = QDir::currentPath() + QLatin1Char('/');
- if (currentPath.startsWith(QLatin1String("//")))
- return QString(path).prepend(currentPath);
- }
- return path;
-}
-
-// can be //server or //server/share
-static bool uncShareExists(const QString &server)
-{
- QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts);
- if (parts.count()) {
- QStringList shares;
- if (QFSFileEnginePrivate::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0), &shares))
- return parts.count() >= 2 ? shares.contains(parts.at(1), Qt::CaseInsensitive) : true;
- }
- return false;
-}
-
-static inline bool isDriveRoot(const QString &path)
-{
- return (path.length() == 3
- && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')
- && path.at(2) == QLatin1Char('/'));
-}
-
-static QString nativeAbsoluteFilePath(const QString &path)
-{
- QString absPath;
-#if !defined(Q_OS_WINCE)
- QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
- wchar_t *fileName = 0;
- DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
- if (retLen > (DWORD)buf.size()) {
- buf.resize(retLen);
- retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
- }
- if (retLen != 0)
- absPath = QString::fromWCharArray(buf.data(), retLen);
-#else
- if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\')))
- absPath = QDir::toNativeSeparators(path);
- else
- absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path));
-#endif
- // This is really ugly, but GetFullPathName strips off whitespace at the end.
- // If you for instance write ". " in the lineedit of QFileDialog,
- // (which is an invalid filename) this function will strip the space off and viola,
- // the file is later reported as existing. Therefore, we re-add the whitespace that
- // was at the end of path in order to keep the filename invalid.
- if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' '))
- absPath.append(QLatin1Char(' '));
- return absPath;
-}
-
/*!
\internal
*/
@@ -373,7 +92,7 @@ QString QFSFileEnginePrivate::longFileName(const QString &path)
if (path.startsWith(QLatin1String("\\\\.\\")))
return path;
- QString absPath = nativeAbsoluteFilePath(path);
+ QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path);
#if !defined(Q_OS_WINCE)
QString prefix = QLatin1String("\\\\?\\");
if (isUncPath(absPath)) {
@@ -389,15 +108,6 @@ QString QFSFileEnginePrivate::longFileName(const QString &path)
/*
\internal
*/
-void QFSFileEnginePrivate::nativeInitFileName()
-{
- QString path = longFileName(QDir::toNativeSeparators(fixIfRelativeUncPath(filePath)));
- nativeFilePath = QByteArray((const char *)path.utf16(), path.size() * 2 + 1);
-}
-
-/*
- \internal
-*/
bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
{
Q_Q(QFSFileEngine);
@@ -415,9 +125,8 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
// WriteOnly can create files, ReadOnly cannot.
DWORD creationDisp = (openMode & QIODevice::WriteOnly) ? OPEN_ALWAYS : OPEN_EXISTING;
-
// Create the file handle.
- fileHandle = CreateFile((const wchar_t*)nativeFilePath.constData(),
+ fileHandle = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(),
accessRights,
shareMode,
&securityAtts,
@@ -507,17 +216,9 @@ qint64 QFSFileEnginePrivate::nativeSize() const
// ### Don't flush; for buffered files, we should get away with ftell.
thatQ->flush();
-#if !defined(Q_OS_WINCE)
- // stdlib/stdio mode.
- if (fh || fd != -1) {
- qint64 fileSize = _filelengthi64(fh ? QT_FILENO(fh) : fd);
- if (fileSize == -1) {
- fileSize = 0;
- thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
- }
- return fileSize;
- }
-#else // Q_OS_WINCE
+ // Always retrive the current information
+ metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
+#if defined(Q_OS_WINCE)
// Buffered stdlib mode.
if (fh) {
QT_OFF_T oldPos = QT_FTELL(fh);
@@ -530,70 +231,22 @@ qint64 QFSFileEnginePrivate::nativeSize() const
}
return fileSize;
}
-#endif
-
- // Not-open mode, where the file name is known: We'll check the
- // file system directly.
- if (openMode == QIODevice::NotOpen && !nativeFilePath.isEmpty()) {
- WIN32_FILE_ATTRIBUTE_DATA attribData;
- bool ok = ::GetFileAttributesEx((const wchar_t*)nativeFilePath.constData(),
- GetFileExInfoStandard, &attribData);
- if (!ok) {
- int errorCode = GetLastError();
- if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
- QByteArray path = nativeFilePath;
- // path for the FindFirstFile should not end with a trailing slash
- while (!path.isEmpty() && reinterpret_cast<const wchar_t *>(
- path.constData() + path.length())[-1] == '\\')
- path.chop(2);
-
- // FindFirstFile can not handle drives
- if (!path.isEmpty() && reinterpret_cast<const wchar_t *>(
- path.constData() + path.length())[-1] != ':') {
- WIN32_FIND_DATA findData;
- HANDLE hFind = ::FindFirstFile((const wchar_t*)path.constData(),
- &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- ::FindClose(hFind);
- ok = true;
- attribData.nFileSizeHigh = findData.nFileSizeHigh;
- attribData.nFileSizeLow = findData.nFileSizeLow;
- }
- }
- }
- }
- if (ok) {
- qint64 size = attribData.nFileSizeHigh;
- size <<= 32;
- size += attribData.nFileSizeLow;
- return size;
- }
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
- return 0;
- }
-
-#if defined(Q_OS_WINCE)
- // Unbuffed stdio mode
if (fd != -1) {
thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
return 0;
}
#endif
+ bool filled = false;
+ if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen )
+ filled = QFileSystemEngine::fillMetaData(fileHandle, metaData,
+ QFileSystemMetaData::SizeAttribute);
+ else
+ filled = doStat(QFileSystemMetaData::SizeAttribute);
- // Windows native mode.
- if (fileHandle == INVALID_HANDLE_VALUE)
- return 0;
-
- BY_HANDLE_FILE_INFORMATION fileInfo;
- if (!GetFileInformationByHandle(fileHandle, &fileInfo)) {
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
- return 0;
+ if (!filled) {
+ thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
}
-
- qint64 size = fileInfo.nFileSizeHigh;
- size <<= 32;
- size += fileInfo.nFileSizeLow;
- return size;
+ return metaData.size();
}
/*
@@ -827,159 +480,41 @@ bool QFSFileEnginePrivate::nativeIsSequential() const
bool QFSFileEngine::remove()
{
Q_D(QFSFileEngine);
- bool ret = ::DeleteFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16()) != 0;
+ QSystemError error;
+ bool ret = QFileSystemEngine::removeFile(d->fileEntry, error);
if (!ret)
- setError(QFile::RemoveError, qt_error_string());
+ setError(QFile::RemoveError, error.toString());
return ret;
}
bool QFSFileEngine::copy(const QString &copyName)
{
Q_D(QFSFileEngine);
- bool ret = ::CopyFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(),
- (wchar_t*)QFSFileEnginePrivate::longFileName(copyName).utf16(), true) != 0;
+ QSystemError error;
+ bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error);
if (!ret)
- setError(QFile::CopyError, qt_error_string());
+ setError(QFile::CopyError, error.toString());
return ret;
}
bool QFSFileEngine::rename(const QString &newName)
{
Q_D(QFSFileEngine);
- bool ret = ::MoveFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(),
- (wchar_t*)QFSFileEnginePrivate::longFileName(newName).utf16()) != 0;
+ QSystemError error;
+ bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error);
if (!ret)
- setError(QFile::RenameError, qt_error_string());
+ setError(QFile::RenameError, error.toString());
return ret;
}
-static inline bool mkDir(const QString &path)
-{
-#if defined(Q_OS_WINCE)
- // Unfortunately CreateDirectory returns true for paths longer than
- // 256, but does not create a directory. It starts to fail, when
- // path length > MAX_PATH, which is 260 usually on CE.
- // This only happens on a Windows Mobile device. Windows CE seems
- // not to be affected by this.
- static int platformId = 0;
- if (platformId == 0) {
- wchar_t platformString[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
- if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
- platformId = 1;
- else
- platformId = 2;
- }
- }
- if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
- return false;
-#endif
- return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0);
-}
-
-static inline bool rmDir(const QString &path)
-{
- return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
-}
-
-static bool isDirPath(const QString &dirPath, bool *existed)
-{
- QString path = dirPath;
- if (path.length() == 2 && path.at(1) == QLatin1Char(':'))
- path += QLatin1Char('\\');
-
- DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
- if (fileAttrib == INVALID_FILE_ATTRIBUTES) {
- int errorCode = GetLastError();
- if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
- // path for the FindFirstFile should not end with a trailing slash
- while (path.endsWith(QLatin1Char('\\')))
- path.chop(1);
-
- // FindFirstFile can not handle drives
- if (!path.endsWith(QLatin1Char(':'))) {
- WIN32_FIND_DATA findData;
- HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(),
- &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- ::FindClose(hFind);
- fileAttrib = findData.dwFileAttributes;
- }
- }
- }
- }
-
- if (existed)
- *existed = fileAttrib != INVALID_FILE_ATTRIBUTES;
-
- if (fileAttrib == INVALID_FILE_ATTRIBUTES)
- return false;
-
- return fileAttrib & FILE_ATTRIBUTE_DIRECTORY;
-}
-
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
- QString dirName = name;
- if (createParentDirectories) {
- dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
- // We spefically search for / so \ would break it..
- int oldslash = -1;
- if (dirName.startsWith(QLatin1String("\\\\"))) {
- // Don't try to create the root path of a UNC path;
- // CreateDirectory() will just return ERROR_INVALID_NAME.
- for (int i = 0; i < dirName.size(); ++i) {
- if (dirName.at(i) != QDir::separator()) {
- oldslash = i;
- break;
- }
- }
- if (oldslash != -1)
- oldslash = dirName.indexOf(QDir::separator(), oldslash);
- }
- for (int slash=0; slash != -1; oldslash = slash) {
- slash = dirName.indexOf(QDir::separator(), oldslash+1);
- if (slash == -1) {
- if (oldslash == dirName.length())
- break;
- slash = dirName.length();
- }
- if (slash) {
- QString chunk = dirName.left(slash);
- bool existed = false;
- if (!isDirPath(chunk, &existed)) {
- if (!existed) {
- if (!mkDir(chunk))
- return false;
- } else {
- return false;
- }
- }
- }
- }
- return true;
- }
- return mkDir(name);
+ return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
}
bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const
{
- QString dirName = name;
- if (recurseParentDirectories) {
- dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
- for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
- QString chunk = dirName.left(slash);
- if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':'))
- break;
- if (!isDirPath(chunk, 0))
- return false;
- if (!rmDir(chunk))
- return oldslash != 0;
- slash = dirName.lastIndexOf(QDir::separator(), oldslash-1);
- }
- return true;
- }
- return rmDir(name);
+ return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
}
bool QFSFileEngine::caseSensitive() const
@@ -989,15 +524,7 @@ bool QFSFileEngine::caseSensitive() const
bool QFSFileEngine::setCurrentPath(const QString &path)
{
- if (!QDir(path).exists())
- return false;
-
-#if !defined(Q_OS_WINCE)
- return ::SetCurrentDirectory((wchar_t*)path.utf16()) != 0;
-#else
- qfsPrivateCurrentDir = QFSFileEnginePrivate::longFileName(path);
- return true;
-#endif
+ return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path));
}
QString QFSFileEngine::currentPath(const QString &fileName)
@@ -1016,115 +543,30 @@ QString QFSFileEngine::currentPath(const QString &fileName)
}
if (ret.isEmpty()) {
//just the pwd
- DWORD size = 0;
- wchar_t currentName[PATH_MAX];
- size = ::GetCurrentDirectory(PATH_MAX, currentName);
- if (size != 0) {
- if (size > PATH_MAX) {
- wchar_t *newCurrentName = new wchar_t[size];
- if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0)
- ret = QString::fromWCharArray(newCurrentName);
- delete [] newCurrentName;
- } else {
- ret = QString::fromWCharArray(currentName);
- }
- }
+ ret = QFileSystemEngine::currentPath().filePath();
}
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
- return QDir::fromNativeSeparators(ret);
+ return ret;
#else
Q_UNUSED(fileName);
- if (qfsPrivateCurrentDir.isEmpty())
- qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
-
- return QDir::fromNativeSeparators(qfsPrivateCurrentDir);
+ return QFileSystemEngine::currentPath();
#endif
}
QString QFSFileEngine::homePath()
{
- QString ret;
-#if !defined(QT_NO_LIBRARY)
- QFSFileEnginePrivate::resolveLibs();
- if (ptrGetUserProfileDirectoryW) {
- HANDLE hnd = ::GetCurrentProcess();
- HANDLE token = 0;
- BOOL ok = ::OpenProcessToken(hnd, TOKEN_QUERY, &token);
- if (ok) {
- DWORD dwBufferSize = 0;
- // First call, to determine size of the strings (with '\0').
- ok = ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize);
- if (!ok && dwBufferSize != 0) { // We got the required buffer size
- wchar_t *userDirectory = new wchar_t[dwBufferSize];
- // Second call, now we can fill the allocated buffer.
- ok = ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize);
- if (ok)
- ret = QString::fromWCharArray(userDirectory);
-
- delete [] userDirectory;
- }
- ::CloseHandle(token);
- }
- }
-#endif
- if (ret.isEmpty() || !QFile::exists(ret)) {
- ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData());
- if (ret.isEmpty() || !QFile::exists(ret)) {
- ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE").constData()) + QString::fromLocal8Bit(qgetenv("HOMEPATH").constData());
- if (ret.isEmpty() || !QFile::exists(ret)) {
- ret = QString::fromLocal8Bit(qgetenv("HOME").constData());
- if (ret.isEmpty() || !QFile::exists(ret)) {
-#if defined(Q_OS_WINCE)
- ret = QLatin1String("\\My Documents");
- if (!QFile::exists(ret))
-#endif
- ret = rootPath();
- }
- }
- }
- }
- return QDir::fromNativeSeparators(ret);
+ return QFileSystemEngine::homePath();
}
QString QFSFileEngine::rootPath()
{
-#if defined(Q_OS_WINCE)
- QString ret = QLatin1String("/");
-#elif defined(Q_FS_FAT)
- QString ret = QString::fromLatin1(qgetenv("SystemDrive").constData());
- if (ret.isEmpty())
- ret = QLatin1String("c:");
- ret.append(QLatin1Char('/'));
-#elif defined(Q_OS_OS2EMX)
- char dir[4];
- _abspath(dir, QLatin1String("/"), _MAX_PATH);
- QString ret(dir);
-#endif
- return ret;
+ return QFileSystemEngine::rootPath();
}
QString QFSFileEngine::tempPath()
{
- QString ret;
- {
- wchar_t tempPath[MAX_PATH];
- if (GetTempPath(MAX_PATH, tempPath))
- ret = QString::fromWCharArray(tempPath);
- if (!ret.isEmpty()) {
- while (ret.endsWith(QLatin1Char('\\')))
- ret.chop(1);
- ret = QDir::fromNativeSeparators(ret);
- }
- }
- if (ret.isEmpty()) {
-#if !defined(Q_OS_WINCE)
- ret = QLatin1String("c:/tmp");
-#else
- ret = QLatin1String("/Temp");
-#endif
- }
- return ret;
+ return QFileSystemEngine::tempPath();
}
QFileInfoList QFSFileEngine::drives()
@@ -1154,213 +596,25 @@ QFileInfoList QFSFileEngine::drives()
#endif
}
-bool QFSFileEnginePrivate::doStat() const
+bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const
{
- if (!tried_stat) {
+ if (!tried_stat || !metaData.hasFlags(flags)) {
tried_stat = true;
- could_stat = false;
-
- if (filePath.isEmpty())
- return could_stat;
- QString fname;
- if(filePath.endsWith(QLatin1String(".lnk"))) {
- fname = readLink(filePath);
- if(fname.isEmpty())
- return could_stat;
- }
- else
- fname = filePath;
-
- fname = fixIfRelativeUncPath(fname);
-
- UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
-
- if (fd != -1) {
#if !defined(Q_OS_WINCE)
- HANDLE fh = (HANDLE)_get_osfhandle(fd);
- if (fh != INVALID_HANDLE_VALUE) {
- BY_HANDLE_FILE_INFORMATION fileInfo;
- if (GetFileInformationByHandle(fh, &fileInfo)) {
- could_stat = true;
- fileAttrib = fileInfo.dwFileAttributes;
- }
- }
-#else
- DWORD tmpAttributes = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16());
- if (tmpAttributes != -1) {
- fileAttrib = tmpAttributes;
- could_stat = true;
- }
+ int localFd = fd;
+ if (fh && fileEntry.isEmpty())
+ localFd = QT_FILENO(fh);
+ if (localFd != -1)
+ QFileSystemEngine::fillMetaData(localFd, metaData, flags);
#endif
- } else {
- fileAttrib = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16());
- if (fileAttrib == INVALID_FILE_ATTRIBUTES) {
- int errorCode = GetLastError();
- if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
- QString path = QDir::toNativeSeparators(fname);
- // path for the FindFirstFile should not end with a trailing slash
- while (path.endsWith(QLatin1Char('\\')))
- path.chop(1);
-
- // FindFirstFile can not handle drives
- if (!path.endsWith(QLatin1Char(':'))) {
- WIN32_FIND_DATA findData;
- HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(),
- &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- ::FindClose(hFind);
- fileAttrib = findData.dwFileAttributes;
- }
- }
- }
- }
- could_stat = fileAttrib != INVALID_FILE_ATTRIBUTES;
- if (!could_stat) {
-#if !defined(Q_OS_WINCE)
- if (isDriveRoot(fname)) {
- // a valid drive ??
- DWORD drivesBitmask = ::GetLogicalDrives();
- int drivebit = 1 << (fname.at(0).toUpper().unicode() - QLatin1Char('A').unicode());
- if (drivesBitmask & drivebit) {
- fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM;
- could_stat = true;
- }
- } else {
-#endif
- QString path = QDir::toNativeSeparators(fname);
- bool is_dir = false;
- if (path.startsWith(QLatin1String("\\\\"))) {
- // UNC - stat doesn't work for all cases (Windows bug)
- int s = path.indexOf(path.at(0),2);
- if (s > 0) {
- // "\\server\..."
- s = path.indexOf(path.at(0),s+1);
- if (s > 0) {
- // "\\server\share\..."
- if (s == path.size() - 1) {
- // "\\server\share\"
- is_dir = true;
- } else {
- // "\\server\share\notfound"
- }
- } else {
- // "\\server\share"
- is_dir = true;
- }
- } else {
- // "\\server"
- is_dir = true;
- }
- }
- if (is_dir && uncShareExists(path)) {
- // looks like a UNC dir, is a dir.
- fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
- could_stat = true;
- }
-#if !defined(Q_OS_WINCE)
- }
-#endif
- }
- }
-
- SetErrorMode(oldmode);
+ if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
+ QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
}
- return could_stat;
-}
-
-static QString readSymLink(const QString &link)
-{
- QString result;
-#if !defined(Q_OS_WINCE)
- HANDLE handle = CreateFile((wchar_t*)QFSFileEnginePrivate::longFileName(link).utf16(),
- FILE_READ_EA,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- 0,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
- 0);
- if (handle != INVALID_HANDLE_VALUE) {
- DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
- REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
- DWORD retsize = 0;
- if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
- if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
- int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
- int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
- const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset];
- result = QString::fromWCharArray(PathBuffer, length);
- }
- // cut-off "//?/" and "/??/"
- if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\'))
- result = result.mid(4);
- }
- qFree(rdb);
- CloseHandle(handle);
- }
-#else
- Q_UNUSED(link);
-#endif // Q_OS_WINCE
- return result;
+ return metaData.exists();
}
-static QString readLink(const QString &link)
-{
-#if !defined(Q_OS_WINCE)
-#if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS)
- QString ret;
-
- bool neededCoInit = false;
- IShellLink *psl; // pointer to IShellLink i/f
- WIN32_FIND_DATA wfd;
- wchar_t szGotPath[MAX_PATH];
-
- // Get pointer to the IShellLink interface.
- HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
-
- if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized
- neededCoInit = true;
- CoInitialize(NULL);
- hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellLink, (LPVOID *)&psl);
- }
- if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface.
- IPersistFile *ppf;
- hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf);
- if (SUCCEEDED(hres)) {
- hres = ppf->Load((LPOLESTR)link.utf16(), STGM_READ);
- //The original path of the link is retrieved. If the file/folder
- //was moved, the return value still have the old path.
- if (SUCCEEDED(hres)) {
- if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR)
- ret = QString::fromWCharArray(szGotPath);
- }
- ppf->Release();
- }
- psl->Release();
- }
- if (neededCoInit)
- CoUninitialize();
-
- return ret;
-#else
- Q_UNUSED(link);
- return QString();
-#endif // QT_NO_LIBRARY
-#else
- wchar_t target[MAX_PATH];
- QString result;
- if (SHGetShortcutTarget((wchar_t*)QFileInfo(link).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
- result = QString::fromWCharArray(target);
- if (result.startsWith(QLatin1Char('"')))
- result.remove(0,1);
- if (result.endsWith(QLatin1Char('"')))
- result.remove(result.size()-1,1);
- }
- return result;
-#endif // Q_OS_WINCE
-}
bool QFSFileEngine::link(const QString &newName)
{
@@ -1425,191 +679,63 @@ bool QFSFileEngine::link(const QString &newName)
#endif // Q_OS_WINCE
}
-QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFileEngine::FileFlags type) const
+/*!
+ \reimp
+*/
+QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const
{
+ Q_D(const QFSFileEngine);
+
+ if (type & Refresh)
+ d->metaData.clear();
+
QAbstractFileEngine::FileFlags ret = 0;
-#if !defined(QT_NO_LIBRARY)
- if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
- resolveLibs();
- if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) {
- enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 };
-
- QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath;
- PSID pOwner = 0;
- PSID pGroup = 0;
- PACL pDacl;
- PSECURITY_DESCRIPTOR pSD;
- DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT,
- OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
- &pOwner, &pGroup, &pDacl, 0, &pSD);
- if(res == ERROR_SUCCESS) {
- ACCESS_MASK access_mask;
- TRUSTEE_W trustee;
- if (type & 0x0700) { // user
- if(ptrGetEffectiveRightsFromAclW(pDacl, &currentUserTrusteeW, &access_mask) != ERROR_SUCCESS)
- access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
- ret |= QAbstractFileEngine::ReadUserPerm;
- if(access_mask & WriteMask)
- ret |= QAbstractFileEngine::WriteUserPerm;
- if(access_mask & ExecMask)
- ret |= QAbstractFileEngine::ExeUserPerm;
- }
- if (type & 0x7000) { // owner
- ptrBuildTrusteeWithSidW(&trustee, pOwner);
- if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
- access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
- ret |= QAbstractFileEngine::ReadOwnerPerm;
- if(access_mask & WriteMask)
- ret |= QAbstractFileEngine::WriteOwnerPerm;
- if(access_mask & ExecMask)
- ret |= QAbstractFileEngine::ExeOwnerPerm;
- }
- if (type & 0x0070) { // group
- ptrBuildTrusteeWithSidW(&trustee, pGroup);
- if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS)
- access_mask = (ACCESS_MASK)-1;
- if(access_mask & ReadMask)
- ret |= QAbstractFileEngine::ReadGroupPerm;
- if(access_mask & WriteMask)
- ret |= QAbstractFileEngine::WriteGroupPerm;
- if(access_mask & ExecMask)
- ret |= QAbstractFileEngine::ExeGroupPerm;
- }
- if (type & 0x0007) { // other (world)
- if(ptrGetEffectiveRightsFromAclW(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS)
- access_mask = (ACCESS_MASK)-1; // ###
- if(access_mask & ReadMask)
- ret |= QAbstractFileEngine::ReadOtherPerm;
- if(access_mask & WriteMask)
- ret |= QAbstractFileEngine::WriteOtherPerm;
- if(access_mask & ExecMask)
- ret |= QAbstractFileEngine::ExeOtherPerm;
- }
- LocalFree(pSD);
- }
- }
- } else
-#endif
+ if (type & FlagsMask)
+ ret |= LocalDiskFlag;
+
+ bool exists;
{
- //### what to do with permissions if we don't use NTFS
- // for now just add all permissions and what about exe missions ??
- // also qt_ntfs_permission_lookup is now not set by default ... should it ?
- ret |= QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadGroupPerm
- | QAbstractFileEngine::ReadOtherPerm;
-
- if (!(fileAttrib & FILE_ATTRIBUTE_READONLY)) {
- ret |= QAbstractFileEngine::WriteOwnerPerm | QAbstractFileEngine::WriteGroupPerm
- | QAbstractFileEngine::WriteOtherPerm;
- }
+ QFileSystemMetaData::MetaDataFlags queryFlags = 0;
- QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath;
- QString ext = fname.right(4).toLower();
- if ((fileAttrib & FILE_ATTRIBUTE_DIRECTORY) ||
- ext == QLatin1String(".exe") || ext == QLatin1String(".com") || ext == QLatin1String(".bat") ||
- ext == QLatin1String(".pif") || ext == QLatin1String(".cmd")) {
- ret |= QAbstractFileEngine::ExeOwnerPerm | QAbstractFileEngine::ExeGroupPerm
- | QAbstractFileEngine::ExeOtherPerm | QAbstractFileEngine::ExeUserPerm;
- }
+ queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type))
+ & QFileSystemMetaData::Permissions;
- // calculate user permissions
- if (type & QAbstractFileEngine::ReadUserPerm) {
- if (::_waccess((wchar_t*)longFileName(fname).utf16(), R_OK) == 0)
- ret |= QAbstractFileEngine::ReadUserPerm;
- }
- if (type & QAbstractFileEngine::WriteUserPerm) {
- if (::_waccess((wchar_t*)longFileName(fname).utf16(), W_OK) == 0)
- ret |= QAbstractFileEngine::WriteUserPerm;
- }
- }
- return ret;
-}
+ // AliasType and BundleType are 0x0
+ if (type & TypesMask)
+ queryFlags |= QFileSystemMetaData::AliasType
+ | QFileSystemMetaData::LinkType
+ | QFileSystemMetaData::FileType
+ | QFileSystemMetaData::DirectoryType
+ | QFileSystemMetaData::BundleType;
-/*!
- \internal
-*/
-bool QFSFileEnginePrivate::isSymlink() const
-{
-#if !defined(Q_OS_WINCE)
- if (need_lstat) {
- need_lstat = false;
- is_link = false;
-
- if (fileAttrib & FILE_ATTRIBUTE_REPARSE_POINT) {
- QString path = QDir::toNativeSeparators(filePath);
- // path for the FindFirstFile should not end with a trailing slash
- while (path.endsWith(QLatin1Char('\\')))
- path.chop(1);
-
- WIN32_FIND_DATA findData;
- HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(),
- &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- ::FindClose(hFind);
- if ((findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
- && findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
- is_link = true;
- }
- }
- }
- }
- return is_link;
-#else
- return false;
-#endif // Q_OS_WINCE
-}
+ if (type & FlagsMask)
+ queryFlags |= QFileSystemMetaData::HiddenAttribute
+ | QFileSystemMetaData::ExistsAttribute;
-/*!
- \reimp
-*/
-QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const
-{
- Q_D(const QFSFileEngine);
- QAbstractFileEngine::FileFlags ret = 0;
- // Force a stat, so that we're guaranteed to get up-to-date results
- if (type & Refresh) {
- d->tried_stat = 0;
-#if !defined(Q_OS_WINCE)
- d->need_lstat = 1;
-#endif
- }
+ queryFlags |= QFileSystemMetaData::LinkType;
- if (type & PermsMask) {
- if (d->doStat()) {
- ret |= ExistsFlag;
- ret |= d->getPermissions(type);
- }
+ exists = d->doStat(queryFlags);
}
+
+ if (exists && (type & PermsMask))
+ ret |= FileFlags(uint(d->metaData.permissions()));
+
if (type & TypesMask) {
- if (d->filePath.endsWith(QLatin1String(".lnk"))) {
+ if ((type & LinkType) && d->metaData.isLegacyLink())
ret |= LinkType;
- QString l = readLink(d->filePath);
- if (!l.isEmpty()) {
- bool existed = false;
- if (isDirPath(l, &existed) && existed)
- ret |= DirectoryType;
- else if (existed)
- ret |= FileType;
- }
- } else if (d->doStat()) {
- if ((type & LinkType) && d->isSymlink())
- ret |= LinkType;
- if (d->fileAttrib & FILE_ATTRIBUTE_DIRECTORY) {
- ret |= DirectoryType;
- } else {
- ret |= FileType;
- }
+ if (d->metaData.isDirectory()) {
+ ret |= DirectoryType;
+ } else {
+ ret |= FileType;
}
}
if (type & FlagsMask) {
- ret |= LocalDiskFlag;
- if (d->doStat()) {
+ if (d->metaData.exists()) {
ret |= ExistsFlag;
- if (d->filePath == QLatin1String("/") || isDriveRoot(d->filePath) || isUncRoot(d->filePath))
+ if (d->fileEntry.isRoot())
ret |= RootFlag;
- else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN)
+ else if (d->metaData.isHidden())
ret |= HiddenFlag;
}
}
@@ -1620,48 +746,28 @@ QString QFSFileEngine::fileName(FileName file) const
{
Q_D(const QFSFileEngine);
if (file == BaseName) {
- int slash = d->filePath.lastIndexOf(QLatin1Char('/'));
- if (slash == -1) {
- int colon = d->filePath.lastIndexOf(QLatin1Char(':'));
- if (colon != -1)
- return d->filePath.mid(colon + 1);
- return d->filePath;
- }
- return d->filePath.mid(slash + 1);
+ return d->fileEntry.fileName();
} else if (file == PathName) {
- if (!d->filePath.size())
- return d->filePath;
-
- int slash = d->filePath.lastIndexOf(QLatin1Char('/'));
- if (slash == -1) {
- if (d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':'))
- return d->filePath.left(2);
- return QString(QLatin1Char('.'));
- } else {
- if (!slash)
- return QString(QLatin1Char('/'));
- if (slash == 2 && d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':'))
- slash++;
- return d->filePath.left(slash);
- }
+ return d->fileEntry.path();
} else if (file == AbsoluteName || file == AbsolutePathName) {
QString ret;
if (!isRelativePath()) {
#if !defined(Q_OS_WINCE)
- if ((d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':')
- && d->filePath.at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
- d->filePath.startsWith(QLatin1Char('/')) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
- ) {
- ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->filePath));
- } else {
- ret = d->filePath;
+ if (d->fileEntry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
+ d->fileEntry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended
+ (d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
+ d->fileEntry.filePath().contains(QLatin1String("/../")) || d->fileEntry.filePath().contains(QLatin1String("/./")) ||
+ d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/.")))
+ {
+ ret = QDir::fromNativeSeparators(QFileSystemEngine::nativeAbsoluteFilePath(d->fileEntry.filePath()));
+ } else
+#endif
+ {
+ ret = d->fileEntry.filePath();
}
-#else
- ret = d->filePath;
-#endif
} else {
- ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + d->filePath);
+ ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + d->fileEntry.filePath());
}
// The path should be absolute at this point.
@@ -1690,38 +796,24 @@ QString QFSFileEngine::fileName(FileName file) const
} else if (file == CanonicalName || file == CanonicalPathName) {
if (!(fileFlags(ExistsFlag) & ExistsFlag))
return QString();
+ QFileSystemEntry entry(QFileSystemEngine::canonicalName(QFileSystemEntry(fileName(AbsoluteName)), d->metaData));
- QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName));
- if (!ret.isEmpty() && file == CanonicalPathName) {
- int slash = ret.lastIndexOf(QLatin1Char('/'));
- if (slash == -1)
- ret = QDir::currentPath();
- else if (slash == 0)
- ret = QString(QLatin1Char('/'));
- ret = ret.left(slash);
- }
- return ret;
+ if (file == CanonicalPathName)
+ return entry.path();
+ return entry.filePath();
} else if (file == LinkName) {
- QString ret;
- if (d->filePath.endsWith(QLatin1String(".lnk")))
- ret = readLink(d->filePath);
- else if (d->doStat() && d->isSymlink())
- ret = readSymLink(d->filePath);
- return QDir::fromNativeSeparators(ret);
+ return QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData).filePath();
} else if (file == BundleName) {
return QString();
}
- return d->filePath;
+ return d->fileEntry.filePath();
}
bool QFSFileEngine::isRelativePath() const
{
Q_D(const QFSFileEngine);
// drive, e.g. "a:", or UNC root, e.q. "//"
- return !(d->filePath.startsWith(QLatin1Char('/'))
- || (d->filePath.length() >= 2
- && ((d->filePath.at(0).isLetter() && d->filePath.at(1) == QLatin1Char(':'))
- || (d->filePath.at(0) == QLatin1Char('/') && d->filePath.at(1) == QLatin1Char('/')))));
+ return d->fileEntry.isRelative();
}
uint QFSFileEngine::ownerId(FileOwner /*own*/) const
@@ -1732,69 +824,17 @@ uint QFSFileEngine::ownerId(FileOwner /*own*/) const
QString QFSFileEngine::owner(FileOwner own) const
{
- QString name;
-#if !defined(QT_NO_LIBRARY)
Q_D(const QFSFileEngine);
- if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
- QFSFileEnginePrivate::resolveLibs();
- if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) {
- PSID pOwner = 0;
- PSECURITY_DESCRIPTOR pSD;
- if (ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT,
- own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION,
- own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0,
- 0, 0, &pSD) == ERROR_SUCCESS) {
- DWORD lowner = 64;
- DWORD ldomain = 64;
- QVarLengthArray<wchar_t, 64> owner(lowner);
- QVarLengthArray<wchar_t, 64> domain(ldomain);
- SID_NAME_USE use = SidTypeUnknown;
- // First call, to determine size of the strings (with '\0').
- if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner,
- (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) {
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- if (lowner > (DWORD)owner.size())
- owner.resize(lowner);
- if (ldomain > (DWORD)domain.size())
- domain.resize(ldomain);
- // Second call, try on resized buf-s
- if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner,
- (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) {
- lowner = 0;
- }
- } else {
- lowner = 0;
- }
- }
- if (lowner != 0)
- name = QString::fromWCharArray(owner.data());
- LocalFree(pSD);
- }
- }
- }
-#else
- Q_UNUSED(own);
-#endif
- return name;
+ return QFileSystemEngine::owner(d->fileEntry, own);
}
bool QFSFileEngine::setPermissions(uint perms)
{
Q_D(QFSFileEngine);
- bool ret = false;
- int mode = 0;
-
- if (perms & QFile::ReadOwner || perms & QFile::ReadUser || perms & QFile::ReadGroup || perms & QFile::ReadOther)
- mode |= _S_IREAD;
- if (perms & QFile::WriteOwner || perms & QFile::WriteUser || perms & QFile::WriteGroup || perms & QFile::WriteOther)
- mode |= _S_IWRITE;
-
- if (mode == 0) // not supported
- return false;
-
- ret = ::_wchmod((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), mode) == 0;
+ QSystemError error;
+ bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error);
if (!ret)
- setError(QFile::PermissionsError, qt_error_string(errno));
+ setError(QFile::PermissionsError, error.toString());
return ret;
}
@@ -1802,12 +842,16 @@ bool QFSFileEngine::setSize(qint64 size)
{
Q_D(QFSFileEngine);
- if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1) {
+ if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1 || d->fh) {
// resize open file
HANDLE fh = d->fileHandle;
#if !defined(Q_OS_WINCE)
- if (fh == INVALID_HANDLE_VALUE)
- fh = (HANDLE)_get_osfhandle(d->fd);
+ if (fh == INVALID_HANDLE_VALUE) {
+ if (d->fh)
+ fh = (HANDLE)_get_osfhandle(QT_FILENO(d->fh));
+ else
+ fh = (HANDLE)_get_osfhandle(d->fd);
+ }
#endif
if (fh == INVALID_HANDLE_VALUE)
return false;
@@ -1822,9 +866,9 @@ bool QFSFileEngine::setSize(qint64 size)
return false;
}
- if (!d->nativeFilePath.isEmpty()) {
+ if (!d->fileEntry.isEmpty()) {
// resize file on disk
- QFile file(d->filePath);
+ QFile file(d->fileEntry.filePath());
if (file.open(QFile::ReadWrite)) {
bool ret = file.resize(size);
if (!ret)
@@ -1836,94 +880,14 @@ bool QFSFileEngine::setSize(qint64 size)
}
-static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
-{
- QDateTime ret;
-
-#if defined(Q_OS_WINCE)
- SYSTEMTIME systime;
- FILETIME ftime;
- systime.wYear = 1970;
- systime.wMonth = 1;
- systime.wDay = 1;
- systime.wHour = 0;
- systime.wMinute = 0;
- systime.wSecond = 0;
- systime.wMilliseconds = 0;
- systime.wDayOfWeek = 4;
- SystemTimeToFileTime(&systime, &ftime);
- unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
- FileTimeToSystemTime(time, &systime);
- unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
- unsigned __int64 difftime = acttime - time1970;
- difftime /= 10000000;
- ret.setTime_t((unsigned int)difftime);
-#else
- SYSTEMTIME sTime, lTime;
- FileTimeToSystemTime(time, &sTime);
- SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
- ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
- ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
-#endif
-
- return ret;
-}
-
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
- QDateTime ret;
- if (d->fd != -1) {
-#if !defined(Q_OS_WINCE)
- HANDLE fh = (HANDLE)_get_osfhandle(d->fd);
- if (fh != INVALID_HANDLE_VALUE) {
- FILETIME creationTime, lastAccessTime, lastWriteTime;
- if (GetFileTime(fh, &creationTime, &lastAccessTime, &lastWriteTime)) {
- if(time == CreationTime)
- ret = fileTimeToQDateTime(&creationTime);
- else if(time == ModificationTime)
- ret = fileTimeToQDateTime(&lastWriteTime);
- else if(time == AccessTime)
- ret = fileTimeToQDateTime(&lastAccessTime);
- }
- }
-#endif
- } else {
- WIN32_FILE_ATTRIBUTE_DATA attribData;
- bool ok = ::GetFileAttributesEx((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), GetFileExInfoStandard, &attribData);
- if (!ok) {
- int errorCode = GetLastError();
- if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
- QString path = QDir::toNativeSeparators(d->filePath);
- // path for the FindFirstFile should not end with a trailing slash
- while (path.endsWith(QLatin1Char('\\')))
- path.chop(1);
-
- // FindFirstFile can not handle drives
- if (!path.endsWith(QLatin1Char(':'))) {
- WIN32_FIND_DATA findData;
- HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(),
- &findData);
- if (hFind != INVALID_HANDLE_VALUE) {
- ::FindClose(hFind);
- ok = true;
- attribData.ftCreationTime = findData.ftCreationTime;
- attribData.ftLastWriteTime = findData.ftLastWriteTime;
- attribData.ftLastAccessTime = findData.ftLastAccessTime;
- }
- }
- }
- }
- if (ok) {
- if(time == CreationTime)
- ret = fileTimeToQDateTime(&attribData.ftCreationTime);
- else if(time == ModificationTime)
- ret = fileTimeToQDateTime(&attribData.ftLastWriteTime);
- else if(time == AccessTime)
- ret = fileTimeToQDateTime(&attribData.ftLastAccessTime);
- }
- }
- return ret;
+
+ if (d->doStat(QFileSystemMetaData::Times))
+ return d->metaData.fileTime(time);
+
+ return QDateTime();
}
uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
@@ -1952,7 +916,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
#ifdef Q_USE_DEPRECATED_MAP_API
nativeClose();
// handle automatically closed by kernel with mapHandle (below).
- handle = ::CreateFileForMapping((const wchar_t*)nativeFilePath.constData(),
+ handle = ::CreateFileForMapping((const wchar_t*)fileEntry.nativeFilePath().utf16(),
GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0),
0,
NULL,
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 7134ae9..8759f8b 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1637,6 +1637,12 @@ QString QIODevice::errorString() const
This function is called by QIODevice. Reimplement this function
when creating a subclass of QIODevice.
+ When reimplementing this function it is important that this function
+ reads all the required data before returning. This is required in order
+ for QDataStream to be able to operate on the class. QDataStream assumes
+ all the requested information was read and therefore does not retry reading
+ if there was a problem.
+
\sa read() readLine() writeData()
*/
@@ -1649,6 +1655,12 @@ QString QIODevice::errorString() const
This function is called by QIODevice. Reimplement this function
when creating a subclass of QIODevice.
+ When reimplementing this function it is important that this function
+ writes all the data available before returning. This is required in order
+ for QDataStream to be able to operate on the class. QDataStream assumes
+ all the information was written and therefore does not retry writing if
+ there was a problem.
+
\sa read() write()
*/
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index 235f671..71cf92d 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -153,6 +153,7 @@ void QNonContiguousByteDevice::disableReset()
resetDisabled = true;
}
+// FIXME we should scrap this whole implementation and instead change the ByteArrayImpl to be able to cope with sub-arrays?
QNonContiguousByteDeviceBufferImpl::QNonContiguousByteDeviceBufferImpl(QBuffer *b) : QNonContiguousByteDevice()
{
buffer = b;
@@ -244,7 +245,7 @@ qint64 QNonContiguousByteDeviceByteArrayImpl::size()
return byteArray->size();
}
-QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QRingBuffer *rb)
+QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb)
: QNonContiguousByteDevice(), currentPosition(0)
{
ringBuffer = rb;
@@ -355,6 +356,11 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount)
// normal advancement
currentReadBufferPosition += amount;
+ if (size() == -1)
+ emit readProgress(totalAdvancements, totalAdvancements);
+ else
+ emit readProgress(totalAdvancements, size());
+
// advancing over that what has actually been read before
if (currentReadBufferPosition > currentReadBufferAmount) {
qint64 i = currentReadBufferPosition - currentReadBufferAmount;
@@ -370,10 +376,6 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount)
currentReadBufferAmount = 0;
}
- if (size() == -1)
- emit readProgress(totalAdvancements, totalAdvancements);
- else
- emit readProgress(totalAdvancements, size());
return true;
}
@@ -505,7 +507,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev
\internal
*/
-QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer)
+QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer)
{
return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer);
}
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index ff946ed..5e0b1bb 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qbuffer.h>
#include <QtCore/qiodevice.h>
+#include <QtCore/QSharedPointer>
#include "private/qringbuffer_p.h"
QT_BEGIN_NAMESPACE
@@ -70,6 +71,7 @@ public:
virtual bool atEnd() = 0;
virtual bool reset() = 0;
void disableReset();
+ bool isResetDisabled() { return resetDisabled; }
virtual qint64 size() = 0;
virtual ~QNonContiguousByteDevice();
@@ -89,7 +91,7 @@ class Q_CORE_EXPORT QNonContiguousByteDeviceFactory
public:
static QNonContiguousByteDevice* create(QIODevice *device);
static QNonContiguousByteDevice* create(QByteArray *byteArray);
- static QNonContiguousByteDevice* create(QRingBuffer *ringBuffer);
+ static QNonContiguousByteDevice* create(QSharedPointer<QRingBuffer> ringBuffer);
static QIODevice* wrap(QNonContiguousByteDevice* byteDevice);
};
@@ -114,7 +116,7 @@ protected:
class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice
{
public:
- QNonContiguousByteDeviceRingBufferImpl(QRingBuffer *rb);
+ QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb);
~QNonContiguousByteDeviceRingBufferImpl();
const char* readPointer(qint64 maximumLength, qint64 &len);
bool advanceReadPointer(qint64 amount);
@@ -122,13 +124,14 @@ public:
bool reset();
qint64 size();
protected:
- QRingBuffer* ringBuffer;
+ QSharedPointer<QRingBuffer> ringBuffer;
qint64 currentPosition;
};
class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice
{
+ Q_OBJECT
public:
QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d);
~QNonContiguousByteDeviceIoDeviceImpl();
@@ -150,6 +153,7 @@ protected:
class QNonContiguousByteDeviceBufferImpl : public QNonContiguousByteDevice
{
+ Q_OBJECT
public:
QNonContiguousByteDeviceBufferImpl(QBuffer *b);
~QNonContiguousByteDeviceBufferImpl();
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 1ce1256..e11cef9 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -963,9 +963,6 @@ bool QProcessPrivate::_q_canWrite()
destroyPipe(stdinChannel.pipe);
processError = QProcess::WriteError;
q->setErrorString(QProcess::tr("Error writing to process"));
-#if defined(QPROCESS_DEBUG) && !defined(Q_OS_WINCE)
- qDebug("QProcessPrivate::canWrite(), failed to write (%s)", strerror(errno));
-#endif
emit q->error(processError);
return false;
}
@@ -974,11 +971,13 @@ bool QProcessPrivate::_q_canWrite()
qDebug("QProcessPrivate::canWrite(), wrote %d bytes to the process input", int(written));
#endif
- writeBuffer.free(written);
- if (!emittedBytesWritten) {
- emittedBytesWritten = true;
- emit q->bytesWritten(written);
- emittedBytesWritten = false;
+ if (written != 0) {
+ writeBuffer.free(written);
+ if (!emittedBytesWritten) {
+ emittedBytesWritten = true;
+ emit q->bytesWritten(written);
+ emittedBytesWritten = false;
+ }
}
if (stdinChannel.notifier && !writeBuffer.isEmpty())
stdinChannel.notifier->setEnabled(true);
@@ -2233,10 +2232,10 @@ bool QProcess::startDetached(const QString &program)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+#elif defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) || (defined(Q_OS_MAC) && defined(QT_NO_CORESERVICES))
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 024d210..ba61bda 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -95,7 +95,7 @@ QT_END_NAMESPACE
#include <qfile.h>
#include <qfileinfo.h>
#include <qlist.h>
-#include <qmap.h>
+#include <qhash.h>
#include <qmutex.h>
#include <qsemaphore.h>
#include <qsocketnotifier.h>
@@ -163,7 +163,7 @@ public:
private:
QMutex mutex;
- QMap<int, QProcessInfo *> children;
+ QHash<int, QProcessInfo *> children;
};
@@ -267,7 +267,7 @@ void QProcessManager::catchDeadChildren()
// try to catch all children whose pid we have registered, and whose
// deathPipe is still valid (i.e, we have not already notified it).
- QMap<int, QProcessInfo *>::Iterator it = children.begin();
+ QHash<int, QProcessInfo *>::Iterator it = children.begin();
while (it != children.end()) {
// notify all children that they may have died. they need to run
// waitpid() in their own thread.
@@ -306,15 +306,11 @@ void QProcessManager::remove(QProcess *process)
QMutexLocker locker(&mutex);
int serial = process->d_func()->serial;
- QProcessInfo *info = children.value(serial);
- if (!info)
- return;
-
+ QProcessInfo *info = children.take(serial);
#if defined (QPROCESS_DEBUG)
- qDebug() << "QProcessManager::remove() removing pid" << info->pid << "process" << info->process;
+ if (info)
+ qDebug() << "QProcessManager::remove() removing pid" << info->pid << "process" << info->process;
#endif
-
- children.remove(serial);
delete info;
}
@@ -649,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);
@@ -852,7 +848,14 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
#if defined QPROCESS_DEBUG
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)", 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.
+ // Otherwise, it will return -1 and set errno to EAGAIN
+ if (written == -1 && errno == EAGAIN)
+ written = 0;
return written;
}
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 207cda3..cd8c1a3 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -580,7 +580,7 @@ QResource::addSearchPath(const QString &path)
\obsolete
Use QDir::searchPaths() instead.
-
+
Returns the current search path list. This list is consulted when
creating a relative resource.
@@ -928,7 +928,7 @@ public:
}
};
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined (Q_OS_NACL) && !defined(Q_OS_INTEGRITY)
#define QT_USE_MMAP
#endif
@@ -1185,21 +1185,6 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
return false;
}
-//file type handler
-class QResourceFileEngineHandler : public QAbstractFileEngineHandler
-{
-public:
- QResourceFileEngineHandler() { }
- ~QResourceFileEngineHandler() { }
- QAbstractFileEngine *create(const QString &path) const;
-};
-QAbstractFileEngine *QResourceFileEngineHandler::create(const QString &path) const
-{
- if (path.size() > 0 && path.startsWith(QLatin1Char(':')))
- return new QResourceFileEngine(path);
- return 0;
-}
-
//resource engine
class QResourceFileEnginePrivate : public QAbstractFileEnginePrivate
{
@@ -1506,12 +1491,6 @@ bool QResourceFileEnginePrivate::unmap(uchar *ptr)
return true;
}
-//Initialization and cleanup
-Q_GLOBAL_STATIC(QResourceFileEngineHandler, resource_file_handler)
-
-static int qt_force_resource_init() { resource_file_handler(); return 1; }
-Q_CORE_EXPORT void qInitResourceIO() { resource_file_handler(); }
-static int qt_forced_resource_init = qt_force_resource_init();
-Q_CONSTRUCTOR_FUNCTION(qt_force_resource_init)
+Q_CORE_EXPORT void qInitResourceIO() { } // ### Qt 5: remove
QT_END_NAMESPACE
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 7d5434e..b084ca5 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -258,9 +258,7 @@ bool QConfFile::isWritable() const
} else {
// Create the directories to the file.
QDir dir(fileInfo.absolutePath());
- if (dir.exists() && dir.isReadable()) {
- return true;
- } else {
+ if (!dir.exists()) {
if (!dir.mkpath(dir.absolutePath()))
return false;
}
@@ -1006,7 +1004,7 @@ void QConfFileSettingsPrivate::initFormat()
readFunc = 0;
writeFunc = 0;
#if defined(Q_OS_MAC)
- caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : IniCaseSensitivity;
#else
caseSensitivity = IniCaseSensitivity;
#endif
@@ -1132,7 +1130,7 @@ static void initDefaultPaths(QMutexLocker *locker)
if (env == 0) {
userPath = homePath;
userPath += QLatin1Char('/');
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
userPath += QLatin1String("Settings");
#else
userPath += QLatin1String(".config");
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index 8c666d7..ec5b6bb 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -70,7 +70,7 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
#define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
#endif
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 44542cf..56ed746 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -295,7 +295,7 @@ public:
: QFSFileEngine(), filePathIsTemplate(fileIsTemplate)
{
Q_D(QFSFileEngine);
- d->filePath = file;
+ d->fileEntry = QFileSystemEntry(file);
if (!filePathIsTemplate)
QFSFileEngine::setFileName(file);
@@ -325,6 +325,9 @@ bool QTemporaryFileEngine::isReallyOpen()
Q_D(QFSFileEngine);
if (!((0 == d->fh) && (-1 == d->fd)
+#if defined (Q_OS_SYMBIAN)
+ && (0 == d->symbianFile.SubSessionHandle())
+#endif
#if defined Q_OS_WIN
&& (INVALID_HANDLE_VALUE == d->fileHandle)
#endif
@@ -346,7 +349,7 @@ void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate)
{
Q_D(QFSFileEngine);
if (filePathIsTemplate)
- d->filePath = fileTemplate;
+ d->fileEntry = QFileSystemEntry(fileTemplate);
}
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
@@ -359,7 +362,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
if (!filePathIsTemplate)
return QFSFileEngine::open(openMode);
- QString qfilename = d->filePath;
+ QString qfilename = d->fileEntry.filePath();
if(!qfilename.contains(QLatin1String("XXXXXX")))
qfilename += QLatin1String(".XXXXXX");
@@ -377,9 +380,8 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
d->closeFileHandle = true;
// Restore the file names (open() resets them).
- d->filePath = QString::fromLocal8Bit(filename); //changed now!
+ d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(filename)); //note that filename is NOT a native path
filePathIsTemplate = false;
- d->nativeInitFileName();
delete [] filename;
return true;
}
@@ -395,9 +397,8 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
return false;
}
- QString template_ = d->filePath;
- d->filePath = QString::fromLocal8Bit(filename);
- d->nativeInitFileName();
+ QString template_ = d->fileEntry.filePath();
+ d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(filename));
delete [] filename;
if (QFSFileEngine::open(openMode)) {
@@ -405,8 +406,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
return true;
}
- d->filePath = template_;
- d->nativeFilePath.clear();
+ d->fileEntry = QFileSystemEntry(template_);
return false;
#endif
}
@@ -418,7 +418,7 @@ bool QTemporaryFileEngine::remove()
// we must explicitly call QFSFileEngine::close() before we remove it.
QFSFileEngine::close();
if (QFSFileEngine::remove()) {
- d->filePath.clear();
+ d->fileEntry.clear();
return true;
}
return false;
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 20a438a..a5837cb 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -224,6 +224,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
\value ReadPastEnd The text stream has read past the end of the
data in the underlying device.
\value ReadCorruptData The text stream has read corrupt data.
+ \value WriteFailed The text stream cannot write to the underlying device.
\sa status()
*/
@@ -396,19 +397,19 @@ public:
npsInvalidPrefix
};
- inline bool write(const QString &data);
inline bool getChar(QChar *ch);
inline void ungetChar(const QChar &ch);
NumberParsingStatus getNumber(qulonglong *l);
bool getReal(double *f);
- bool putNumber(qulonglong number, bool negative);
- inline bool putString(const QString &ch, bool number = false);
+ inline void write(const QString &data);
+ inline void putString(const QString &ch, bool number = false);
+ void putNumber(qulonglong number, bool negative);
// buffers
bool fillReadBuffer(qint64 maxBytes = -1);
void resetReadBuffer();
- bool flushWriteBuffer();
+ void flushWriteBuffer();
QString writeBuffer;
QString readBuffer;
int readBufferOffset;
@@ -642,14 +643,20 @@ void QTextStreamPrivate::resetReadBuffer()
/*! \internal
*/
-bool QTextStreamPrivate::flushWriteBuffer()
+void QTextStreamPrivate::flushWriteBuffer()
{
// no buffer next to the QString itself; this function should only
// be called internally, for devices.
if (string || !device)
- return false;
+ return;
+
+ // Stream went bye-bye already. Appending further data may succeed again,
+ // but would create a corrupted stream anyway.
+ if (status != QTextStream::Ok)
+ return;
+
if (writeBuffer.isEmpty())
- return true;
+ return;
#if defined (Q_OS_WIN)
// handle text translation and bypass the Text flag in the device.
@@ -681,8 +688,10 @@ bool QTextStreamPrivate::flushWriteBuffer()
qDebug("QTextStreamPrivate::flushWriteBuffer(), device->write(\"%s\") == %d",
qt_prettyDebug(data.constData(), qMin(data.size(),32), data.size()).constData(), int(bytesWritten));
#endif
- if (bytesWritten <= 0)
- return false;
+ if (bytesWritten <= 0) {
+ status = QTextStream::WriteFailed;
+ return;
+ }
#if defined (Q_OS_WIN)
// replace the text flag
@@ -693,7 +702,7 @@ bool QTextStreamPrivate::flushWriteBuffer()
// flush the file
#ifndef QT_NO_QOBJECT
QFile *file = qobject_cast<QFile *>(device);
- bool flushed = file && file->flush();
+ bool flushed = !file || file->flush();
#else
bool flushed = true;
#endif
@@ -702,7 +711,8 @@ bool QTextStreamPrivate::flushWriteBuffer()
qDebug("QTextStreamPrivate::flushWriteBuffer() wrote %d bytes",
int(bytesWritten));
#endif
- return flushed && bytesWritten == qint64(data.size());
+ if (!flushed || bytesWritten != qint64(data.size()))
+ status = QTextStream::WriteFailed;
}
QString QTextStreamPrivate::read(int maxlen)
@@ -908,7 +918,7 @@ inline void QTextStreamPrivate::restoreToSavedConverterState()
/*! \internal
*/
-inline bool QTextStreamPrivate::write(const QString &data)
+inline void QTextStreamPrivate::write(const QString &data)
{
if (string) {
// ### What about seek()??
@@ -916,9 +926,8 @@ inline bool QTextStreamPrivate::write(const QString &data)
} else {
writeBuffer += data;
if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE)
- return flushWriteBuffer();
+ flushWriteBuffer();
}
- return true;
}
/*! \internal
@@ -959,7 +968,7 @@ inline void QTextStreamPrivate::ungetChar(const QChar &ch)
/*! \internal
*/
-inline bool QTextStreamPrivate::putString(const QString &s, bool number)
+inline void QTextStreamPrivate::putString(const QString &s, bool number)
{
QString tmp = s;
@@ -993,7 +1002,7 @@ inline bool QTextStreamPrivate::putString(const QString &s, bool number)
qt_prettyDebug(a.constData(), a.size(), qMax(16, a.size())).constData(),
qt_prettyDebug(b.constData(), b.size(), qMax(16, b.size())).constData());
#endif
- return write(tmp);
+ write(tmp);
}
/*!
@@ -1255,6 +1264,7 @@ qint64 QTextStream::pos() const
return qint64(-1);
}
thatd->readBufferOffset = oldReadBufferOffset;
+ thatd->readConverterSavedStateOffset = 0;
// Return the device position.
return d->device->pos();
@@ -1593,6 +1603,9 @@ void QTextStream::resetStatus()
Sets the status of the text stream to the \a status given.
+ Subsequent calls to setStatus() are ignored until resetStatus()
+ is called.
+
\sa Status status() resetStatus()
*/
void QTextStream::setStatus(Status status)
@@ -2267,7 +2280,7 @@ QTextStream &QTextStream::operator>>(char *c)
/*! \internal
*/
-bool QTextStreamPrivate::putNumber(qulonglong number, bool negative)
+void QTextStreamPrivate::putNumber(qulonglong number, bool negative)
{
QString result;
@@ -2307,7 +2320,7 @@ bool QTextStreamPrivate::putNumber(qulonglong number, bool negative)
result.prepend(QLatin1Char('0'));
}
}
- return putString(result, true);
+ putString(result, true);
}
/*!
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index ab8b1e1..fc2fee6 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -89,7 +89,8 @@ public:
enum Status {
Ok,
ReadPastEnd,
- ReadCorruptData
+ ReadCorruptData,
+ WriteFailed
};
enum NumberFlag {
ShowBase = 0x1,
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 6e55f93..efd3f45 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -965,14 +965,14 @@ static void QT_FASTCALL _fragment(const char **ptr, QUrlParseData *parseData)
}
struct NameprepCaseFoldingEntry {
- int uc;
+ uint uc;
ushort mapping[4];
};
-inline bool operator<(int one, const NameprepCaseFoldingEntry &other)
+inline bool operator<(uint one, const NameprepCaseFoldingEntry &other)
{ return one < other.uc; }
-inline bool operator<(const NameprepCaseFoldingEntry &one, int other)
+inline bool operator<(const NameprepCaseFoldingEntry &one, uint other)
{ return one.uc < other; }
static const NameprepCaseFoldingEntry NameprepCaseFolding[] = {
@@ -1861,45 +1861,44 @@ static const NameprepCaseFoldingEntry NameprepCaseFolding[] = {
{ 0xFF38, { 0xFF58, 0x0000, 0x0000, 0x0000 } },
{ 0xFF39, { 0xFF59, 0x0000, 0x0000, 0x0000 } },
{ 0xFF3A, { 0xFF5A, 0x0000, 0x0000, 0x0000 } },
- // #####
-/* { 0x10400, { 0x10428, 0x0000, 0x0000, 0x0000 } },
- { 0x10401, { 0x10429, 0x0000, 0x0000, 0x0000 } },
- { 0x10402, { 0x1042A, 0x0000, 0x0000, 0x0000 } },
- { 0x10403, { 0x1042B, 0x0000, 0x0000, 0x0000 } },
- { 0x10404, { 0x1042C, 0x0000, 0x0000, 0x0000 } },
- { 0x10405, { 0x1042D, 0x0000, 0x0000, 0x0000 } },
- { 0x10406, { 0x1042E, 0x0000, 0x0000, 0x0000 } },
- { 0x10407, { 0x1042F, 0x0000, 0x0000, 0x0000 } },
- { 0x10408, { 0x10430, 0x0000, 0x0000, 0x0000 } },
- { 0x10409, { 0x10431, 0x0000, 0x0000, 0x0000 } },
- { 0x1040A, { 0x10432, 0x0000, 0x0000, 0x0000 } },
- { 0x1040B, { 0x10433, 0x0000, 0x0000, 0x0000 } },
- { 0x1040C, { 0x10434, 0x0000, 0x0000, 0x0000 } },
- { 0x1040D, { 0x10435, 0x0000, 0x0000, 0x0000 } },
- { 0x1040E, { 0x10436, 0x0000, 0x0000, 0x0000 } },
- { 0x1040F, { 0x10437, 0x0000, 0x0000, 0x0000 } },
- { 0x10410, { 0x10438, 0x0000, 0x0000, 0x0000 } },
- { 0x10411, { 0x10439, 0x0000, 0x0000, 0x0000 } },
- { 0x10412, { 0x1043A, 0x0000, 0x0000, 0x0000 } },
- { 0x10413, { 0x1043B, 0x0000, 0x0000, 0x0000 } },
- { 0x10414, { 0x1043C, 0x0000, 0x0000, 0x0000 } },
- { 0x10415, { 0x1043D, 0x0000, 0x0000, 0x0000 } },
- { 0x10416, { 0x1043E, 0x0000, 0x0000, 0x0000 } },
- { 0x10417, { 0x1043F, 0x0000, 0x0000, 0x0000 } },
- { 0x10418, { 0x10440, 0x0000, 0x0000, 0x0000 } },
- { 0x10419, { 0x10441, 0x0000, 0x0000, 0x0000 } },
- { 0x1041A, { 0x10442, 0x0000, 0x0000, 0x0000 } },
- { 0x1041B, { 0x10443, 0x0000, 0x0000, 0x0000 } },
- { 0x1041C, { 0x10444, 0x0000, 0x0000, 0x0000 } },
- { 0x1041D, { 0x10445, 0x0000, 0x0000, 0x0000 } },
- { 0x1041E, { 0x10446, 0x0000, 0x0000, 0x0000 } },
- { 0x1041F, { 0x10447, 0x0000, 0x0000, 0x0000 } },
- { 0x10420, { 0x10448, 0x0000, 0x0000, 0x0000 } },
- { 0x10421, { 0x10449, 0x0000, 0x0000, 0x0000 } },
- { 0x10422, { 0x1044A, 0x0000, 0x0000, 0x0000 } },
- { 0x10423, { 0x1044B, 0x0000, 0x0000, 0x0000 } },
- { 0x10424, { 0x1044C, 0x0000, 0x0000, 0x0000 } },
- { 0x10425, { 0x1044D, 0x0000, 0x0000, 0x0000 } },*/
+ { 0x10400, { 0xd801, 0xdc28, 0x0000, 0x0000 } },
+ { 0x10401, { 0xd801, 0xdc29, 0x0000, 0x0000 } },
+ { 0x10402, { 0xd801, 0xdc2A, 0x0000, 0x0000 } },
+ { 0x10403, { 0xd801, 0xdc2B, 0x0000, 0x0000 } },
+ { 0x10404, { 0xd801, 0xdc2C, 0x0000, 0x0000 } },
+ { 0x10405, { 0xd801, 0xdc2D, 0x0000, 0x0000 } },
+ { 0x10406, { 0xd801, 0xdc2E, 0x0000, 0x0000 } },
+ { 0x10407, { 0xd801, 0xdc2F, 0x0000, 0x0000 } },
+ { 0x10408, { 0xd801, 0xdc30, 0x0000, 0x0000 } },
+ { 0x10409, { 0xd801, 0xdc31, 0x0000, 0x0000 } },
+ { 0x1040A, { 0xd801, 0xdc32, 0x0000, 0x0000 } },
+ { 0x1040B, { 0xd801, 0xdc33, 0x0000, 0x0000 } },
+ { 0x1040C, { 0xd801, 0xdc34, 0x0000, 0x0000 } },
+ { 0x1040D, { 0xd801, 0xdc35, 0x0000, 0x0000 } },
+ { 0x1040E, { 0xd801, 0xdc36, 0x0000, 0x0000 } },
+ { 0x1040F, { 0xd801, 0xdc37, 0x0000, 0x0000 } },
+ { 0x10410, { 0xd801, 0xdc38, 0x0000, 0x0000 } },
+ { 0x10411, { 0xd801, 0xdc39, 0x0000, 0x0000 } },
+ { 0x10412, { 0xd801, 0xdc3A, 0x0000, 0x0000 } },
+ { 0x10413, { 0xd801, 0xdc3B, 0x0000, 0x0000 } },
+ { 0x10414, { 0xd801, 0xdc3C, 0x0000, 0x0000 } },
+ { 0x10415, { 0xd801, 0xdc3D, 0x0000, 0x0000 } },
+ { 0x10416, { 0xd801, 0xdc3E, 0x0000, 0x0000 } },
+ { 0x10417, { 0xd801, 0xdc3F, 0x0000, 0x0000 } },
+ { 0x10418, { 0xd801, 0xdc40, 0x0000, 0x0000 } },
+ { 0x10419, { 0xd801, 0xdc41, 0x0000, 0x0000 } },
+ { 0x1041A, { 0xd801, 0xdc42, 0x0000, 0x0000 } },
+ { 0x1041B, { 0xd801, 0xdc43, 0x0000, 0x0000 } },
+ { 0x1041C, { 0xd801, 0xdc44, 0x0000, 0x0000 } },
+ { 0x1041D, { 0xd801, 0xdc45, 0x0000, 0x0000 } },
+ { 0x1041E, { 0xd801, 0xdc46, 0x0000, 0x0000 } },
+ { 0x1041F, { 0xd801, 0xdc47, 0x0000, 0x0000 } },
+ { 0x10420, { 0xd801, 0xdc48, 0x0000, 0x0000 } },
+ { 0x10421, { 0xd801, 0xdc49, 0x0000, 0x0000 } },
+ { 0x10422, { 0xd801, 0xdc4A, 0x0000, 0x0000 } },
+ { 0x10423, { 0xd801, 0xdc4B, 0x0000, 0x0000 } },
+ { 0x10424, { 0xd801, 0xdc4C, 0x0000, 0x0000 } },
+ { 0x10425, { 0xd801, 0xdc4D, 0x0000, 0x0000 } },
{ 0x1D400, { 0x0061, 0x0000, 0x0000, 0x0000 } },
{ 0x1D401, { 0x0062, 0x0000, 0x0000, 0x0000 } },
{ 0x1D402, { 0x0063, 0x0000, 0x0000, 0x0000 } },
@@ -2354,17 +2353,23 @@ static void mapToLowerCase(QString *str, int from)
{
int N = sizeof(NameprepCaseFolding) / sizeof(NameprepCaseFolding[0]);
- QChar *d = 0;
+ ushort *d = 0;
for (int i = from; i < str->size(); ++i) {
- int uc = str->at(i).unicode();
+ uint uc = str->at(i).unicode();
if (uc < 0x80) {
if (uc <= 'Z' && uc >= 'A') {
- uc |= 0x20;
if (!d)
- d = str->data();
- d[i] = QChar(uc);
+ d = reinterpret_cast<ushort *>(str->data());
+ d[i] = (uc | 0x20);
}
} else {
+ if (QChar(uc).isHighSurrogate() && i < str->size() - 1) {
+ ushort low = str->at(i + 1).unicode();
+ if (QChar(low).isLowSurrogate()) {
+ uc = QChar::surrogateToUcs4(uc, low);
+ ++i;
+ }
+ }
const NameprepCaseFoldingEntry *entry = qBinaryFind(NameprepCaseFolding,
NameprepCaseFolding + N,
uc);
@@ -2373,23 +2378,26 @@ static void mapToLowerCase(QString *str, int from)
while (l < 4 && entry->mapping[l])
++l;
if (l > 1) {
- str->replace(i, 1, (const QChar *)&entry->mapping[0], l);
+ if (uc <= 0xffff)
+ str->replace(i, 1, reinterpret_cast<const QChar *>(&entry->mapping[0]), l);
+ else
+ str->replace(i-1, 2, reinterpret_cast<const QChar *>(&entry->mapping[0]), l);
d = 0;
} else {
if (!d)
- d = str->data();
- d[i] = QChar(entry->mapping[0]);
+ d = reinterpret_cast<ushort *>(str->data());
+ d[i] = entry->mapping[0];
}
}
}
}
}
-static bool isMappedToNothing(const QChar &ch)
+static bool isMappedToNothing(uint uc)
{
- if (ch.unicode() < 0xad)
+ if (uc < 0xad)
return false;
- switch (ch.unicode()) {
+ switch (uc) {
case 0x00AD: case 0x034F: case 0x1806: case 0x180B: case 0x180C: case 0x180D:
case 0x200B: case 0x200C: case 0x200D: case 0x2060: case 0xFE00: case 0xFE01:
case 0xFE02: case 0xFE03: case 0xFE04: case 0xFE05: case 0xFE06: case 0xFE07:
@@ -2408,66 +2416,72 @@ static void stripProhibitedOutput(QString *str, int from)
const ushort *in = out;
const ushort *end = (ushort *)str->data() + str->size();
while (in < end) {
- ushort uc = *in;
- if (uc < 0x80 ||
- !(uc <= 0x009F
- || uc == 0x00A0
- || uc == 0x0340
- || uc == 0x0341
- || uc == 0x06DD
- || uc == 0x070F
- || uc == 0x1680
- || uc == 0x180E
- || (uc >= 0x2000 && uc <= 0x200B)
- || uc == 0x200C
- || uc == 0x200D
- || uc == 0x200E
- || uc == 0x200F
- || (uc >= 0x2028 && uc <= 0x202F)
- || uc == 0x205F
- || (uc >= 0x2060 && uc <= 0x2063)
- || uc == 0x206A
- || (uc >= 0x206A && uc <= 0x206F)
- || (uc >= 0x2FF0 && uc <= 0x2FFB)
- || uc == 0x3000
- || (uc >= 0xD800 && uc <= 0xDFFF)
- || (uc >= 0xE000 && uc <= 0xF8FF)
- || (uc >= 0xFDD0 && uc <= 0xFDEF)
- || uc == 0xFEFF
- || (uc >= 0xFFF9 && uc <= 0xFFFC)
- || (uc >= 0xFFFA && (uc <= 0xFFFE || uc == 0xFFFF))
- /* ### Add NAMEPREP support for surrogates
- || uc == 0xE0001
- || (uc >= 0x2FFFE && uc <= 0x2FFFF)
- || (uc >= 0x1D173 && uc <= 0x1D17A)
- || (uc >= 0x1FFFE && uc <= 0x1FFFF)
- || (uc >= 0x3FFFE && uc <= 0x3FFFF)
- || (uc >= 0x4FFFE && uc <= 0x4FFFF)
- || (uc >= 0x5FFFE && uc <= 0x5FFFF)
- || (uc >= 0x6FFFE && uc <= 0x6FFFF)
- || (uc >= 0x7FFFE && uc <= 0x7FFFF)
- || (uc >= 0x8FFFE && uc <= 0x8FFFF)
- || (uc >= 0x9FFFE && uc <= 0x9FFFF)
- || (uc >= 0xAFFFE && uc <= 0xAFFFF)
- || (uc >= 0xBFFFE && uc <= 0xBFFFF)
- || (uc >= 0xCFFFE && uc <= 0xCFFFF)
- || (uc >= 0xDFFFE && uc <= 0xDFFFF)
- || (uc >= 0xE0020 && uc <= 0xE007F)
- || (uc >= 0xEFFFE && uc <= 0xEFFFF)
- || (uc >= 0xF0000 && uc <= 0xFFFFD)
- || (uc >= 0xFFFFE && uc <= 0xFFFFF)
- || (uc >= 0x100000 && uc <= 0x10FFFD)
- || (uc >= 0x10FFFE && uc <= 0x10FFFF)*/))
- *out++ = *in;
+ uint uc = *in;
+ if (QChar(uc).isHighSurrogate() && in < end - 1) {
+ ushort low = *(in + 1);
+ if (QChar(low).isLowSurrogate()) {
+ ++in;
+ uc = QChar::surrogateToUcs4(uc, low);
+ }
+ }
+ if (uc <= 0xFFFF) {
+ if (uc < 0x80 ||
+ !(uc <= 0x009F
+ || uc == 0x00A0
+ || uc == 0x0340
+ || uc == 0x0341
+ || uc == 0x06DD
+ || uc == 0x070F
+ || uc == 0x1680
+ || uc == 0x180E
+ || (uc >= 0x2000 && uc <= 0x200F)
+ || (uc >= 0x2028 && uc <= 0x202F)
+ || uc == 0x205F
+ || (uc >= 0x2060 && uc <= 0x2063)
+ || (uc >= 0x206A && uc <= 0x206F)
+ || (uc >= 0x2FF0 && uc <= 0x2FFB)
+ || uc == 0x3000
+ || (uc >= 0xD800 && uc <= 0xDFFF)
+ || (uc >= 0xE000 && uc <= 0xF8FF)
+ || (uc >= 0xFDD0 && uc <= 0xFDEF)
+ || uc == 0xFEFF
+ || (uc >= 0xFFF9 && uc <= 0xFFFF))) {
+ *out++ = *in;
+ }
+ } else {
+ if (!((uc >= 0x1D173 && uc <= 0x1D17A)
+ || (uc >= 0x1FFFE && uc <= 0x1FFFF)
+ || (uc >= 0x2FFFE && uc <= 0x2FFFF)
+ || (uc >= 0x3FFFE && uc <= 0x3FFFF)
+ || (uc >= 0x4FFFE && uc <= 0x4FFFF)
+ || (uc >= 0x5FFFE && uc <= 0x5FFFF)
+ || (uc >= 0x6FFFE && uc <= 0x6FFFF)
+ || (uc >= 0x7FFFE && uc <= 0x7FFFF)
+ || (uc >= 0x8FFFE && uc <= 0x8FFFF)
+ || (uc >= 0x9FFFE && uc <= 0x9FFFF)
+ || (uc >= 0xAFFFE && uc <= 0xAFFFF)
+ || (uc >= 0xBFFFE && uc <= 0xBFFFF)
+ || (uc >= 0xCFFFE && uc <= 0xCFFFF)
+ || (uc >= 0xDFFFE && uc <= 0xDFFFF)
+ || uc == 0xE0001
+ || (uc >= 0xE0020 && uc <= 0xE007F)
+ || (uc >= 0xEFFFE && uc <= 0xEFFFF)
+ || (uc >= 0xF0000 && uc <= 0xFFFFD)
+ || (uc >= 0xFFFFE && uc <= 0xFFFFF)
+ || (uc >= 0x100000 && uc <= 0x10FFFD)
+ || (uc >= 0x10FFFE && uc <= 0x10FFFF))) {
+ *out++ = QChar::highSurrogate(uc);
+ *out++ = QChar::lowSurrogate(uc);
+ }
+ }
++in;
}
if (in != out)
str->truncate(out - str->utf16());
}
-static bool isBidirectionalRorAL(const QChar &c)
+static bool isBidirectionalRorAL(uint uc)
{
- ushort uc = c.unicode();
if (uc < 0x5b0)
return false;
return uc == 0x05BE
@@ -2506,9 +2520,8 @@ static bool isBidirectionalRorAL(const QChar &c)
|| (uc >= 0xFE76 && uc <= 0xFEFC);
}
-static bool isBidirectionalL(const QChar &ch)
+static bool isBidirectionalL(uint uc)
{
- ushort uc = ch.unicode();
if (uc < 0xaa)
return (uc >= 0x0041 && uc <= 0x005A)
|| (uc >= 0x0061 && uc <= 0x007A);
@@ -2873,8 +2886,7 @@ static bool isBidirectionalL(const QChar &ch)
return true;
}
- /* ### Add NAMEPREP support for surrogates
- || (uc >= 0x10300 && uc <= 0x1031E)
+ if ((uc >= 0x10300 && uc <= 0x1031E)
|| (uc >= 0x10320 && uc <= 0x10323)
|| (uc >= 0x10330 && uc <= 0x1034A)
|| (uc >= 0x10400 && uc <= 0x10425)
@@ -2910,7 +2922,9 @@ static bool isBidirectionalL(const QChar &ch)
|| (uc >= 0x20000 && uc <= 0x2A6D6)
|| (uc >= 0x2F800 && uc <= 0x2FA1D)
|| (uc >= 0xF0000 && uc <= 0xFFFFD)
- || (uc >= 0x100000 && uc <= 0x10FFFD)*/
+ || (uc >= 0x100000 && uc <= 0x10FFFD)) {
+ return true;
+ }
return false;
}
@@ -2943,13 +2957,37 @@ void qt_nameprep(QString *source, int from)
return; // everything was mapped easily (lowercased, actually)
int firstNonAscii = out - src;
+ // Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme
+ // but allowed in "query" scheme
+ // (Table A.1)
+ const bool isUnassignedAllowed = false; // ###
// Characters commonly mapped to nothing are simply removed
// (Table B.1)
const QChar *in = out;
- while (in < e) {
- if (!isMappedToNothing(*in))
- *out++ = *in;
- ++in;
+ for ( ; in < e; ++in) {
+ uint uc = in->unicode();
+ if (QChar(uc).isHighSurrogate() && in < e - 1) {
+ ushort low = in[1].unicode();
+ if (QChar(low).isLowSurrogate()) {
+ ++in;
+ uc = QChar::surrogateToUcs4(uc, low);
+ }
+ }
+ if (!isUnassignedAllowed) {
+ QChar::UnicodeVersion version = QChar::unicodeVersion(uc);
+ if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) {
+ source->resize(from); // not allowed, clear the label
+ return;
+ }
+ }
+ if (!isMappedToNothing(uc)) {
+ if (uc <= 0xFFFF) {
+ *out++ = *in;
+ } else {
+ *out++ = QChar::highSurrogate(uc);
+ *out++ = QChar::lowSurrogate(uc);
+ }
+ }
}
if (out != in)
source->truncate(out - src);
@@ -2960,7 +2998,8 @@ void qt_nameprep(QString *source, int from)
// Normalize to Unicode 3.2 form KC
extern void qt_string_normalize(QString *data, QString::NormalizationForm mode,
QChar::UnicodeVersion version, int from);
- qt_string_normalize(source, QString::NormalizationForm_KC, QChar::Unicode_3_2, firstNonAscii);
+ qt_string_normalize(source, QString::NormalizationForm_KC, QChar::Unicode_3_2,
+ firstNonAscii > from ? firstNonAscii - 1 : from);
// Strip prohibited output
stripProhibitedOutput(source, firstNonAscii);
@@ -2971,14 +3010,22 @@ void qt_nameprep(QString *source, int from)
src = source->data();
e = src + source->size();
for (in = src + from; in < e && (!containsLCat || !containsRandALCat); ++in) {
- if (isBidirectionalL(*in))
+ uint uc = in->unicode();
+ if (QChar(uc).isHighSurrogate() && in < e - 1) {
+ ushort low = in[1].unicode();
+ if (QChar(low).isLowSurrogate()) {
+ ++in;
+ uc = QChar::surrogateToUcs4(uc, low);
+ }
+ }
+ if (isBidirectionalL(uc))
containsLCat = true;
- else if (isBidirectionalRorAL(*in))
+ else if (isBidirectionalRorAL(uc))
containsRandALCat = true;
}
if (containsRandALCat) {
- if (containsLCat || (!isBidirectionalRorAL(src[from])
- || !isBidirectionalRorAL(e[-1])))
+ if (containsLCat || (!isBidirectionalRorAL(src[from].unicode())
+ || !isBidirectionalRorAL(e[-1].unicode())))
source->resize(from); // not allowed, clear the label
}
}
@@ -6002,6 +6049,14 @@ QUrl &QUrl::operator =(const QString &url)
return *this;
}
+/*!
+ \fn void QUrl::swap(QUrl &other)
+ \since 4.8
+
+ Swaps URL \a other with this URL. This operation is very
+ fast and never fails.
+*/
+
/*! \internal
Forces a detach.
@@ -6024,19 +6079,22 @@ bool QUrl::isDetached() const
/*!
- Returns a QUrl representation of \a localFile, interpreted as a
- local file.
+ Returns a QUrl representation of \a localFile, interpreted as a local
+ file. This function accepts paths separated by slashes as well as the
+ native separator for this platform.
+
+ This function also accepts paths with a doubled leading slash (or
+ backslash) to indicate a remote file, as in
+ "//servername/path/to/file.txt". Note that only certain platforms can
+ actually open this file using QFile::open().
- \sa toLocalFile()
+ \sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators
*/
QUrl QUrl::fromLocalFile(const QString &localFile)
{
QUrl url;
url.setScheme(QLatin1String("file"));
- QString deslashified = localFile;
- deslashified.replace(QLatin1Char('\\'), QLatin1Char('/'));
-
-
+ QString deslashified = QDir::fromNativeSeparators(localFile);
// magic for drives on windows
if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) {
@@ -6055,35 +6113,61 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
}
/*!
- Returns the path of this URL formatted as a local file path.
+ Returns the path of this URL formatted as a local file path. The path
+ returned will use forward slashes, even if it was originally created
+ from one with backslashes.
+
+ If this URL contains a non-empty hostname, it will be encoded in the
+ returned value in the form found on SMB networks (for example,
+ "//servername/path/to/file.txt").
- \sa fromLocalFile()
+ \sa fromLocalFile(), isLocalFile()
*/
QString QUrl::toLocalFile() const
{
- if (!d) return QString();
- if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
+ // the call to isLocalFile() also ensures that we're parsed
+ if (!isLocalFile())
+ return QString();
QString tmp;
QString ourPath = path();
- if (d->scheme.isEmpty() || QString::compare(d->scheme, QLatin1String("file"), Qt::CaseInsensitive) == 0) {
- // magic for shared drive on windows
- if (!d->host.isEmpty()) {
- tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
- ? QLatin1Char('/') + ourPath : ourPath);
- } else {
- tmp = ourPath;
- // magic for drives on windows
- if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':'))
- tmp.remove(0, 1);
- }
+ // magic for shared drive on windows
+ if (!d->host.isEmpty()) {
+ tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
+ ? QLatin1Char('/') + ourPath : ourPath);
+ } else {
+ tmp = ourPath;
+ // magic for drives on windows
+ if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':'))
+ tmp.remove(0, 1);
}
return tmp;
}
/*!
+ \since 4.7
+ Returns true if this URL is pointing to a local file path. A URL is a
+ local file path if the scheme is "file".
+
+ Note that this function considers URLs with hostnames to be local file
+ paths, even if the eventual file path cannot be opened with
+ QFile::open().
+
+ \sa fromLocalFile(), toLocalFile()
+*/
+bool QUrl::isLocalFile() const
+{
+ if (!d) return false;
+ if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
+
+ if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0)
+ return false; // not file
+ return true;
+}
+
+/*!
Returns true if this URL is a parent of \a childUrl. \a childUrl is a child
of this URL if the two URLs share the same scheme and authority,
and this URL's path is a parent of the path of \a childUrl.
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 58d4e9e..7534b8d 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -94,8 +94,14 @@ public:
#ifndef QT_NO_URL_CAST_FROM_STRING
QUrl &operator =(const QString &url);
#endif
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QUrl &operator=(QUrl &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
~QUrl();
+ inline void swap(QUrl &other) { qSwap(d, other.d); }
+
void setUrl(const QString &url);
void setUrl(const QString &url, ParsingMode mode);
// ### Qt 5: merge the two setUrl() functions, with mode = TolerantMode
@@ -183,6 +189,7 @@ public:
static QUrl fromLocalFile(const QString &localfile);
QString toLocalFile() const;
+ bool isLocalFile() const;
QString toString(FormattingOptions options = None) const;
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 1851e04..a3628b1 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -1,102 +1,111 @@
# Qt core object module
HEADERS += \
- kernel/qabstracteventdispatcher.h \
+ kernel/qabstracteventdispatcher.h \
kernel/qabstractitemmodel.h \
kernel/qabstractitemmodel_p.h \
- kernel/qbasictimer.h \
- kernel/qeventloop.h\
- kernel/qpointer.h \
+ kernel/qbasictimer.h \
+ kernel/qeventloop.h\
+ kernel/qpointer.h \
kernel/qcorecmdlineargs_p.h \
- kernel/qcoreapplication.h \
- kernel/qcoreevent.h \
- kernel/qmetaobject.h \
- kernel/qmetatype.h \
- kernel/qmimedata.h \
- kernel/qobject.h \
- kernel/qobjectdefs.h \
- kernel/qsignalmapper.h \
- kernel/qsocketnotifier.h \
- kernel/qtimer.h \
- kernel/qtranslator.h \
+ kernel/qcoreapplication.h \
+ kernel/qcoreevent.h \
+ kernel/qmetaobject.h \
+ kernel/qmetatype.h \
+ kernel/qmimedata.h \
+ kernel/qobject.h \
+ kernel/qobjectdefs.h \
+ kernel/qsignalmapper.h \
+ kernel/qsocketnotifier.h \
+ kernel/qtimer.h \
+ kernel/qtranslator.h \
kernel/qtranslator_p.h \
kernel/qvariant.h \
- kernel/qabstracteventdispatcher_p.h \
- kernel/qcoreapplication_p.h \
- kernel/qobjectcleanuphandler.h \
+ kernel/qabstracteventdispatcher_p.h \
+ kernel/qcoreapplication_p.h \
+ kernel/qobjectcleanuphandler.h \
kernel/qvariant_p.h \
kernel/qmetaobject_p.h \
kernel/qobject_p.h \
- kernel/qcoreglobaldata_p.h \
- kernel/qsharedmemory.h \
+ kernel/qcoreglobaldata_p.h \
+ kernel/qsharedmemory.h \
kernel/qsharedmemory_p.h \
kernel/qsystemsemaphore.h \
kernel/qsystemsemaphore_p.h \
kernel/qfunctions_p.h \
- kernel/qmath.h
+ kernel/qmath.h \
+ kernel/qsystemerror_p.h
SOURCES += \
- kernel/qabstracteventdispatcher.cpp \
+ kernel/qabstracteventdispatcher.cpp \
kernel/qabstractitemmodel.cpp \
- kernel/qbasictimer.cpp \
- kernel/qeventloop.cpp \
- kernel/qcoreapplication.cpp \
- kernel/qcoreevent.cpp \
- kernel/qmetaobject.cpp \
- kernel/qmetatype.cpp \
- kernel/qmimedata.cpp \
- kernel/qobject.cpp \
- kernel/qobjectcleanuphandler.cpp \
- kernel/qsignalmapper.cpp \
- kernel/qsocketnotifier.cpp \
- kernel/qtimer.cpp \
- kernel/qtranslator.cpp \
- kernel/qvariant.cpp \
+ kernel/qbasictimer.cpp \
+ kernel/qeventloop.cpp \
+ kernel/qcoreapplication.cpp \
+ kernel/qcoreevent.cpp \
+ kernel/qmetaobject.cpp \
+ kernel/qmetatype.cpp \
+ kernel/qmimedata.cpp \
+ kernel/qobject.cpp \
+ kernel/qobjectcleanuphandler.cpp \
+ kernel/qsignalmapper.cpp \
+ kernel/qsocketnotifier.cpp \
+ kernel/qtimer.cpp \
+ kernel/qtranslator.cpp \
+ kernel/qvariant.cpp \
kernel/qcoreglobaldata.cpp \
kernel/qsharedmemory.cpp \
kernel/qsystemsemaphore.cpp \
kernel/qpointer.cpp \
- kernel/qmath.cpp
+ kernel/qmath.cpp \
+ kernel/qsystemerror.cpp
win32 {
- SOURCES += \
- kernel/qeventdispatcher_win.cpp \
- kernel/qcoreapplication_win.cpp \
- kernel/qwineventnotifier_p.cpp \
+ SOURCES += \
+ kernel/qeventdispatcher_win.cpp \
+ kernel/qcoreapplication_win.cpp \
+ kernel/qwineventnotifier_p.cpp \
kernel/qsharedmemory_win.cpp \
kernel/qsystemsemaphore_win.cpp
- HEADERS += \
- kernel/qeventdispatcher_win_p.h \
- kernel/qwineventnotifier_p.h
+ HEADERS += \
+ kernel/qeventdispatcher_win_p.h \
+ kernel/qwineventnotifier_p.h
}
wince*: {
- SOURCES += \
- kernel/qfunctions_wince.cpp
- HEADERS += \
- kernel/qfunctions_wince.h
+ SOURCES += \
+ kernel/qfunctions_wince.cpp
+ HEADERS += \
+ kernel/qfunctions_wince.h
}
-mac:!embedded {
+mac:!embedded:!qpa{
SOURCES += \
kernel/qcoreapplication_mac.cpp
}
-mac {
+mac:!nacl {
SOURCES += \
- kernel/qcore_mac.cpp
+ kernel/qcore_mac.cpp
+}
+
+nacl {
+ SOURCES += \
+ kernel/qfunctions_nacl.cpp
+ HEADERS += \
+ kernel/qfunctions_nacl.h
}
unix:!symbian {
- SOURCES += \
+ SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
kernel/qsharedmemory_unix.cpp \
kernel/qsystemsemaphore_unix.cpp
- HEADERS += \
+ HEADERS += \
kernel/qcore_unix_p.h \
- kernel/qcrashhandler_p.h
+ kernel/qcrashhandler_p.h
contains(QT_CONFIG, glib) {
SOURCES += \
@@ -115,7 +124,7 @@ unix:!symbian {
}
symbian {
- SOURCES += \
+ SOURCES += \
kernel/qcore_unix.cpp \
kernel/qcrashhandler.cpp \
kernel/qeventdispatcher_symbian.cpp \
@@ -123,7 +132,7 @@ symbian {
kernel/qsharedmemory_symbian.cpp \
kernel/qsystemsemaphore_symbian.cpp
- HEADERS += \
+ HEADERS += \
kernel/qcore_unix_p.h \
kernel/qcrashhandler_p.h \
kernel/qeventdispatcher_symbian_p.h \
@@ -131,9 +140,25 @@ symbian {
}
vxworks {
- SOURCES += \
- kernel/qfunctions_vxworks.cpp
- HEADERS += \
- kernel/qfunctions_vxworks.h
+ SOURCES += \
+ kernel/qfunctions_vxworks.cpp
+ HEADERS += \
+ 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/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 8fd010a..9dd22dc 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -532,7 +532,7 @@ bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVaria
case 1: //floating point
return v1.toReal() < v2.toReal();
default:
- return v1.toString() < v2.toString();
+ return v1.toString().localeAwareCompare(v2.toString()) < 0;
}
}
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 40b8967..f7f6bfe 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -68,7 +68,15 @@
# undef qDebug
#endif
+#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED)
#include <ApplicationServices/ApplicationServices.h>
+#else
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+#ifndef QT_NO_CORESERVICES
+#include <CoreServices/CoreServices.h>
+#endif
#undef DEBUG
#ifdef OLD_DEBUG
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index a7c5197..801d63f 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -61,7 +61,8 @@ Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
#else
TPtrC16 ptr(qt_QString2TPtrC(aString));
#endif
- buffer = q_check_ptr(HBufC::New(ptr.Length()));
+ buffer = HBufC::New(ptr.Length());
+ Q_CHECK_PTR(buffer);
buffer->Des().Copy(ptr);
return buffer;
}
@@ -81,8 +82,9 @@ QHBufC::QHBufC()
}
QHBufC::QHBufC(const QHBufC &src)
- : m_hBufC(q_check_ptr(src.m_hBufC->Alloc()))
+ : m_hBufC(src.m_hBufC->Alloc())
{
+ Q_CHECK_PTR(m_hBufC);
}
/*!
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/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 54972ec..834f05b 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -42,7 +42,8 @@
#include "qcore_unix_p.h"
#include "qelapsedtimer.h"
-#ifndef Q_OS_VXWORKS
+#ifdef Q_OS_NACL
+#elif !defined (Q_OS_VXWORKS)
# if !defined(Q_OS_HPUX) || defined(__ia64)
# include <sys/select.h>
# endif
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 7d88b10..be86c58 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -71,6 +71,7 @@
# include <e32ldr.h>
# include "qeventdispatcher_symbian_p.h"
# include "private/qcore_symbian_p.h"
+# include "private/qfilesystemengine_p.h"
# include <apacmdln.h>
#elif defined(Q_OS_UNIX)
# if !defined(QT_NO_GLIB)
@@ -174,6 +175,11 @@ CApaCommandLine* QCoreApplicationPrivate::symbianCommandLine()
extern QString qAppFileName();
#endif
+int QCoreApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0
+#if defined(QT3_SUPPORT)
+bool QCoreApplicationPrivate::useQt3Support = true;
+#endif
+
#if !defined(Q_OS_WIN)
#ifdef Q_OS_MAC
QString QCoreApplicationPrivate::macMenuBarName()
@@ -315,10 +321,14 @@ struct QCoreApplicationData {
Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata)
-QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv)
+QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags)
: QObjectPrivate(), argc(aargc), argv(aargv), application_type(0), eventFilter(0),
in_exec(false), aboutToQuitEmitted(false)
{
+ app_compile_version = flags & 0xffffff;
+#if defined(QT3_SUPPORT)
+ useQt3Support = !(flags & 0x01000000);
+#endif
static const char *const empty = "";
if (argc == 0 || argv == 0) {
argc = 0;
@@ -566,7 +576,7 @@ void QCoreApplication::flush()
one valid character string.
*/
QCoreApplication::QCoreApplication(int &argc, char **argv)
- : QObject(*new QCoreApplicationPrivate(argc, argv))
+ : QObject(*new QCoreApplicationPrivate(argc, argv, 0x040000))
{
init();
QCoreApplicationPrivate::eventDispatcher->startingUp();
@@ -582,6 +592,25 @@ QCoreApplication::QCoreApplication(int &argc, char **argv)
#endif
}
+QCoreApplication::QCoreApplication(int &argc, char **argv, int _internal)
+: QObject(*new QCoreApplicationPrivate(argc, argv, _internal))
+{
+ init();
+ QCoreApplicationPrivate::eventDispatcher->startingUp();
+#if defined(Q_OS_SYMBIAN)
+#ifndef QT_NO_LIBRARY
+ // Refresh factoryloader, as text codecs are requested during lib path
+ // resolving process and won't be therefore properly loaded.
+ // Unknown if this is symbian specific issue.
+ QFactoryLoader::refreshAll();
+#endif
+#ifndef QT_NO_SYSTEMLOCALE
+ d_func()->symbianInit();
+#endif
+#endif //Q_OS_SYMBIAN
+}
+
+
// ### move to QCoreApplicationPrivate constructor?
void QCoreApplication::init()
{
@@ -595,6 +624,12 @@ void QCoreApplication::init()
Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
QCoreApplication::self = this;
+#ifdef Q_OS_SYMBIAN
+ //ensure temp and working directories exist
+ QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::tempPath()), true);
+ QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::currentPath()), true);
+#endif
+
#ifndef QT_NO_THREAD
QThread::initialize();
#endif
@@ -860,11 +895,6 @@ bool QCoreApplication::notify(QObject *receiver, QEvent *event)
d->checkReceiverThread(receiver);
#endif
-#ifdef QT3_SUPPORT
- if (event->type() == QEvent::ChildRemoved && !receiver->d_func()->pendingChildInsertedEvents.isEmpty())
- receiver->d_func()->removePendingChildInsertedEvents(static_cast<QChildEvent *>(event)->child());
-#endif // QT3_SUPPORT
-
return receiver->isWidgetType() ? false : d->notify_helper(receiver, event);
}
@@ -1074,6 +1104,7 @@ int QCoreApplication::exec()
return returnCode;
}
+
/*!
Tells the application to exit with a return code.
@@ -1530,7 +1561,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
--pe.receiver->d_func()->postedEvents;
#ifdef QT3_SUPPORT
if (pe.event->type() == QEvent::ChildInsertedRequest)
- pe.receiver->d_func()->removePendingChildInsertedEvents(0);
+ pe.receiver->d_func()->pendingChildInsertedEvents.clear();
#endif
pe.event->posted = false;
events.append(pe.event);
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 6383809..3957158 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -78,7 +78,23 @@ class Q_CORE_EXPORT QCoreApplication : public QObject
Q_DECLARE_PRIVATE(QCoreApplication)
public:
- QCoreApplication(int &argc, char **argv);
+ enum { ApplicationFlags = QT_VERSION
+#if !defined(QT3_SUPPORT)
+ | 0x01000000
+#endif
+ };
+
+#if defined(QT_BUILD_CORE_LIB) || defined(qdoc)
+ QCoreApplication(int &argc, char **argv); // ### Qt5 remove
+#endif
+#if !defined(qdoc)
+ QCoreApplication(int &argc, char **argv, int
+#if !defined(QT_BUILD_CORE_LIB)
+ = ApplicationFlags
+#endif
+ );
+#endif
+
~QCoreApplication();
#ifdef QT_DEPRECATED
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 703c825..add2a35 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -78,7 +78,7 @@ class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QCoreApplication)
public:
- QCoreApplicationPrivate(int &aargc, char **aargv);
+ QCoreApplicationPrivate(int &aargc, char **aargv, uint flags);
~QCoreApplicationPrivate();
bool sendThroughApplicationEventFilters(QObject *, QEvent *);
@@ -135,6 +135,10 @@ public:
static uint attribs;
static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
+ static int app_compile_version;
+#if defined(QT3_SUPPORT)
+ static bool useQt3Support;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index a8cf5f1..fbb08fa 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -231,6 +231,8 @@ QT_BEGIN_NAMESPACE
\value WinIdChange The window system identifer for this native widget has changed
\value Gesture A gesture was triggered (QGestureEvent)
\value GestureOverride A gesture override was triggered (QGestureEvent)
+ \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent)
+ \value Scroll The object needs to scroll to the supplied position (QScrollEvent)
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 329c0a2..c9d311a 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -288,6 +288,9 @@ public:
Gesture = 198,
GestureOverride = 202,
#endif
+ ScrollPrepare = 204,
+ Scroll = 205,
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
@@ -328,6 +331,7 @@ private:
friend class QETWidget;
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
+ friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
#ifndef QT_NO_GESTURES
friend class QGestureManager;
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_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index ec70ff7..4e19414 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -180,6 +180,8 @@ static gboolean timerSourceCheck(GSource *source)
static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer)
{
GTimerSource *timerSource = reinterpret_cast<GTimerSource *>(source);
+ if (timerSource->processEventsFlags & QEventLoop::X11ExcludeTimers)
+ return true;
timerSource->runWithIdlePriority = true;
(void) timerSource->timerList.activateTimers();
return true; // ??? don't remove, right again?
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 47dd558..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) {
@@ -1028,7 +1029,8 @@ bool QEventDispatcherSymbian::hasPendingEvents()
void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
{
- QSocketActiveObject *socketAO = q_check_ptr(new QSocketActiveObject(this, notifier));
+ QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
+ Q_CHECK_PTR(socketAO);
m_notifiers.insert(notifier, socketAO);
selectThread().requestSocketEvents(notifier, &socketAO->iStatus);
}
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 050805f..dceb51d 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -112,9 +112,11 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
bool pipefail = false;
// initialize the common parts of the event loop
-#if defined(Q_OS_INTEGRITY)
+#if defined(Q_OS_NACL)
+ // 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 {
@@ -157,7 +159,9 @@ QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate()
{
-#if defined(Q_OS_VXWORKS)
+#if defined(Q_OS_NACL)
+ // do nothing.
+#elif defined(Q_OS_VXWORKS)
close(thread_pipe[0]);
char name[20];
@@ -312,7 +316,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
QTimerInfoList::QTimerInfoList()
{
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_NACL)
if (!QElapsedTimer::isMonotonic()) {
// not using monotonic timers, initialize the timeChanged() machinery
previousTime = qt_gettime();
@@ -339,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)
@@ -364,6 +368,10 @@ timeval qAbs(const timeval &t)
*/
bool QTimerInfoList::timeChanged(timeval *delta)
{
+#ifdef Q_OS_NACL
+ Q_UNUSED(delta)
+ return false; // Calling "times" crashes.
+#endif
struct tms unused;
clock_t currentTicks = times(&unused);
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index 8055425..96a3e4a 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -64,7 +64,7 @@
# include <sys/times.h>
#else
# include <sys/time.h>
-# if !defined(Q_OS_HPUX) || defined(__ia64)
+# if (!defined(Q_OS_HPUX) || defined(__ia64)) && !defined(Q_OS_NACL)
# include <sys/select.h>
# endif
#endif
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 6d90a51..6badb6a 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -78,6 +78,8 @@ extern uint qGlobalPostedEventsCount();
#ifndef QT_NO_GESTURES
#ifndef WM_GESTURE
# define WM_GESTURE 0x0119
+#endif
+#ifndef WM_GESTURENOTIFY
# define WM_GESTURENOTIFY 0x011A
#endif
#endif // QT_NO_GESTURES
@@ -490,7 +492,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
// we also use a Windows timer to send posted events when the message queue is full
|| (message == WM_TIMER
&& d->sendPostedEventsWindowsTimerId != 0
- && wp == d->sendPostedEventsWindowsTimerId)) {
+ && wp == (uint)d->sendPostedEventsWindowsTimerId)) {
int localSerialNumber = d->serialNumber;
if (localSerialNumber != d->lastSerialNumber) {
d->lastSerialNumber = localSerialNumber;
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/qfunctions_nacl.cpp b/src/corelib/kernel/qfunctions_nacl.cpp
new file mode 100644
index 0000000..f3d85ef
--- /dev/null
+++ b/src/corelib/kernel/qfunctions_nacl.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** 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 "qfunctions_nacl.h"
+#include <pthread.h>
+#include <qglobal.h>
+
+/*
+ The purpose of this file is to stub out certain functions
+ that are not provided by the Native Client SDK. This is
+ done as an alterative to sprinkling the Qt sources with
+ NACL ifdefs.
+
+ There are two main classes of functions:
+
+ - Functions that are called but can have no effect:
+ For these we simply give an empty implementation
+
+ - Functions that are referenced in the source code, but
+ is not/must not be called at run-time:
+ These we either leave undefined or implement with a
+ qFatal.
+
+ This is a work in progress.
+*/
+
+extern "C" {
+
+void pthread_cleanup_push(void (*)(void *), void *)
+{
+
+}
+
+void pthread_cleanup_pop(int)
+{
+
+}
+
+int pthread_setcancelstate(int, int *)
+{
+ return 0;
+}
+
+int pthread_setcanceltype(int, int *)
+{
+ return 0;
+}
+
+void pthread_testcancel(void)
+{
+
+}
+
+
+int pthread_cancel(pthread_t)
+{
+ return 0;
+}
+
+int pthread_attr_setinheritsched(pthread_attr_t *,int)
+{
+ return 0;
+}
+
+
+int pthread_attr_getinheritsched(const pthread_attr_t *, int *)
+{
+ return 0;
+}
+
+// event dispatcher, select
+//struct fd_set;
+//struct timeval;
+
+int fcntl(int, int, ...)
+{
+ return 0;
+}
+
+int sigaction(int, const struct sigaction *, struct sigaction *)
+{
+ return 0;
+}
+
+int open(const char *, int, ...)
+{
+ return 0;
+}
+
+int open64(const char *, int, ...)
+{
+ return 0;
+}
+
+int access(const char *, int)
+{
+ return 0;
+}
+
+typedef long off64_t;
+off64_t ftello64(void *)
+{
+ qFatal("ftello64 called");
+ return 0;
+}
+
+off64_t lseek64(int, off_t, int)
+{
+ qFatal("lseek64 called");
+ return 0;
+}
+
+} // Extern C
+
+int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
+{
+ return 0;
+}
diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h
new file mode 100644
index 0000000..db36ad5
--- /dev/null
+++ b/src/corelib/kernel/qfunctions_nacl.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** 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 QNACLUNIMPLEMENTED_H
+#define QNACLUNIMPLEMENTED_H
+
+#ifdef Q_OS_NACL
+
+#include <sys/types.h>
+
+// pthread
+#include <pthread.h>
+#define PTHREAD_CANCEL_DISABLE 1
+#define PTHREAD_CANCEL_ENABLE 2
+#define PTHREAD_INHERIT_SCHED 3
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+extern "C" {
+
+void pthread_cleanup_push(void (*handler)(void *), void *arg);
+void pthread_cleanup_pop(int execute);
+
+int pthread_setcancelstate(int state, int *oldstate);
+int pthread_setcanceltype(int type, int *oldtype);
+void pthread_testcancel(void);
+int pthread_cancel(pthread_t thread);
+
+int pthread_attr_setinheritsched(pthread_attr_t *attr,
+ int inheritsched);
+int pthread_attr_getinheritsched(const pthread_attr_t *attr,
+ int *inheritsched);
+
+// event dispatcher, select
+//struct fd_set;
+//struct timeval;
+int fcntl(int fildes, int cmd, ...);
+int sigaction(int sig, const struct sigaction * act, struct sigaction * oact);
+
+typedef long off64_t;
+off64_t ftello64(void *stream);
+off64_t lseek64(int fildes, off_t offset, int whence);
+int open64(const char *path, int oflag, ...);
+
+}
+
+int select(int nfds, fd_set * readfds, fd_set * writefds, fd_set * errorfds, struct timeval * timeout);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //Q_OS_NACL
+
+#endif //QNACLUNIMPLEMENTED_H
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 3d41c0c..d27fec3 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -59,6 +59,8 @@
# include "QtCore/qfunctions_wince.h"
#elif defined(Q_OS_VXWORKS)
# include "QtCore/qfunctions_vxworks.h"
+#elif defined(Q_OS_NACL)
+# include "QtCore/qfunctions_nacl.h"
#endif
#ifdef Q_CC_RVCT
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index d07b7cb..c5775f6 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -266,7 +266,25 @@ QObject *QMetaObject::cast(QObject *obj) const
const QMetaObject *m = obj->metaObject();
do {
if (m == this)
- return const_cast<QObject*>(obj);
+ return obj;
+ } while ((m = m->d.superdata));
+ }
+ return 0;
+}
+
+/*!
+ \internal
+
+ Returns \a obj if object \a obj inherits from this
+ meta-object; otherwise returns 0.
+*/
+const QObject *QMetaObject::cast(const QObject *obj) const
+{
+ if (obj) {
+ const QMetaObject *m = obj->metaObject();
+ do {
+ if (m == this)
+ return obj;
} while ((m = m->d.superdata));
}
return 0;
@@ -1577,6 +1595,12 @@ bool QMetaMethod::invoke(QObject *object,
: Qt::QueuedConnection;
}
+#ifdef QT_NO_THREAD
+ if (connectionType == Qt::BlockingQueuedConnection) {
+ connectionType = Qt::DirectConnection;
+ }
+#endif
+
// invoke!
void *param[] = {
returnValue.data(),
@@ -1595,7 +1619,7 @@ bool QMetaMethod::invoke(QObject *object,
int methodIndex = ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset();
if (connectionType == Qt::DirectConnection) {
return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, methodIndex, param) < 0;
- } else {
+ } else if (connectionType == Qt::QueuedConnection) {
if (returnValue.data()) {
qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in "
"queued connections");
@@ -1628,40 +1652,21 @@ bool QMetaMethod::invoke(QObject *object,
}
}
- if (connectionType == Qt::QueuedConnection) {
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
- 0,
- -1,
- nargs,
- types,
- args));
- } else {
- if (currentThread == objectThread) {
- qWarning("QMetaMethod::invoke: Dead lock detected in "
- "BlockingQueuedConnection: Receiver is %s(%p)",
- mobj->className(), object);
- }
+ QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ 0, -1, nargs, types, args));
+ } else { // blocking queued connection
+#ifndef QT_NO_THREAD
+ if (currentThread == objectThread) {
+ qWarning("QMetaMethod::invoke: Dead lock detected in "
+ "BlockingQueuedConnection: Receiver is %s(%p)",
+ mobj->className(), object);
+ }
- // blocking queued connection
-#ifdef QT_NO_THREAD
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
- 0,
- -1,
- nargs,
- types,
- args));
-#else
- QSemaphore semaphore;
- QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
- 0,
- -1,
- nargs,
- types,
- args,
- &semaphore));
- semaphore.acquire();
+ QSemaphore semaphore;
+ QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex,
+ 0, -1, 0, 0, param, &semaphore));
+ semaphore.acquire();
#endif // QT_NO_THREAD
- }
}
return true;
}
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 7b2e938..e9bba45 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -139,6 +139,8 @@ private:
const QMetaObject *mobj;
uint handle;
friend struct QMetaObject;
+ friend struct QMetaObjectPrivate;
+ friend class QObject;
};
Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE);
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 1d97cb7..210b32c 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -133,6 +133,8 @@ struct QMetaObjectPrivate
#ifndef QT_NO_QOBJECT
//defined in qobject.cpp
enum DisconnectType { DisconnectAll, DisconnectOne };
+ static void memberIndexes(const QObject *obj, const QMetaMethod &member,
+ int *signalIndex, int *methodIndex);
static bool connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index,
int type = 0, int *types = 0);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 3296d1f..bdc96c6 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -311,6 +311,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong),
QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong),
QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char),
+ QT_ADD_STATIC_METATYPE("signed char", QMetaType::Char),
QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar),
QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short),
QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort),
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 8eeee30..a2bb7d1 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -353,6 +353,7 @@ Q_DECLARE_BUILTIN_METATYPE(QChar, QChar)
Q_DECLARE_BUILTIN_METATYPE(long, Long)
Q_DECLARE_BUILTIN_METATYPE(short, Short)
Q_DECLARE_BUILTIN_METATYPE(char, Char)
+Q_DECLARE_BUILTIN_METATYPE(signed char, Char)
Q_DECLARE_BUILTIN_METATYPE(ulong, ULong)
Q_DECLARE_BUILTIN_METATYPE(ushort, UShort)
Q_DECLARE_BUILTIN_METATYPE(uchar, UChar)
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4a5b63f..c6153cb 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -150,18 +150,33 @@ QObjectPrivate::QObjectPrivate(int version)
postedEvents = 0;
extraData = 0;
connectedSignals[0] = connectedSignals[1] = 0;
- inEventHandler = false;
inThreadChangeEvent = false;
+#ifdef QT_JAMBI_BUILD
+ inEventHandler = false;
deleteWatch = 0;
+#endif
metaObject = 0;
hasGuards = false;
}
QObjectPrivate::~QObjectPrivate()
{
+ if (pendTimer) {
+ // unregister pending timers
+ if (threadData->eventDispatcher)
+ threadData->eventDispatcher->unregisterTimers(q_ptr);
+ }
+
+ if (postedEvents)
+ QCoreApplication::removePostedEvents(q_ptr, 0);
+
+ threadData->deref();
+
delete static_cast<QAbstractDynamicMetaObject*>(metaObject);
+#ifdef QT_JAMBI_BUILD
if (deleteWatch)
*deleteWatch = 1;
+#endif
#ifndef QT_NO_USERDATA
if (extraData)
qDeleteAll(extraData->userData);
@@ -170,6 +185,7 @@ QObjectPrivate::~QObjectPrivate()
}
+#ifdef QT_JAMBI_BUILD
int *QObjectPrivate::setDeleteWatch(QObjectPrivate *d, int *w) {
int *old = d->deleteWatch;
d->deleteWatch = w;
@@ -184,18 +200,15 @@ void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int dele
if (oldWatch)
*oldWatch = deleteWatch;
}
-
-
-
-
+#endif
#ifdef QT3_SUPPORT
void QObjectPrivate::sendPendingChildInsertedEvents()
{
Q_Q(QObject);
for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) {
- QObject *c = pendingChildInsertedEvents.at(i);
- if (!c)
+ QObject *c = pendingChildInsertedEvents.at(i).data();
+ if (!c || c->parent() != q)
continue;
QChildEvent childEvent(QEvent::ChildInserted, c);
QCoreApplication::sendEvent(q, &childEvent);
@@ -203,26 +216,6 @@ void QObjectPrivate::sendPendingChildInsertedEvents()
pendingChildInsertedEvents.clear();
}
-void QObjectPrivate::removePendingChildInsertedEvents(QObject *child)
-{
- if (!child) {
- pendingChildInsertedEvents.clear();
- return;
- }
-
- // the QObject destructor calls QObject::removeChild, which calls
- // QCoreApplication::sendEvent() directly. this can happen while the event
- // loop is in the middle of posting events, and when we get here, we may
- // not have any more posted events for this object.
-
- // if this is a child remove event and the child insert hasn't
- // been dispatched yet, kill that insert
- for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) {
- QObject *&c = pendingChildInsertedEvents[i];
- if (c == child)
- c = 0;
- }
-}
#endif
@@ -426,6 +419,8 @@ void QMetaObject::removeGuard(QObject **ptr)
if (!hash || hash->isEmpty())
return;
QMutexLocker locker(guardHashLock());
+ if (!*ptr) //check again, under the lock
+ return;
GuardHash::iterator it = hash->find(*ptr);
const GuardHash::iterator end = hash->end();
bool more = false; //if the QObject has more pointer attached to it.
@@ -477,11 +472,6 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o)
*/
void QObjectPrivate::clearGuards(QObject *object)
{
- QObjectPrivate *priv = QObjectPrivate::get(object);
-
- if (!priv->hasGuards)
- return;
-
GuardHash *hash = 0;
QMutex *mutex = 0;
QT_TRY {
@@ -516,12 +506,14 @@ QMetaCallEvent::QMetaCallEvent(int id, const QObject *sender, int signalId,
*/
QMetaCallEvent::~QMetaCallEvent()
{
- for (int i = 0; i < nargs_; ++i) {
- if (types_[i] && args_[i])
- QMetaType::destroy(types_[i], args_[i]);
+ if (types_) {
+ for (int i = 0; i < nargs_; ++i) {
+ if (types_[i] && args_[i])
+ QMetaType::destroy(types_[i], args_[i]);
+ }
+ qFree(types_);
+ qFree(args_);
}
- if (types_) qFree(types_);
- if (args_) qFree(args_);
#ifndef QT_NO_THREAD
if (semaphore_)
semaphore_->release();
@@ -731,13 +723,15 @@ QObject::QObject(QObject *parent)
d_ptr->q_ptr = this;
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
- QT_TRY {
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- setParent(parent);
- } QT_CATCH(...) {
- d->threadData->deref();
- QT_RETHROW;
+ if (parent) {
+ QT_TRY {
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
+ parent = 0;
+ setParent(parent);
+ } QT_CATCH(...) {
+ d->threadData->deref();
+ QT_RETHROW;
+ }
}
qt_addObject(this);
}
@@ -756,9 +750,11 @@ QObject::QObject(QObject *parent, const char *name)
qt_addObject(d_ptr->q_ptr = this);
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- setParent(parent);
+ if (parent) {
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
+ parent = 0;
+ setParent(parent);
+ }
setObjectName(QString::fromAscii(name));
}
#endif
@@ -772,21 +768,23 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
d_ptr->q_ptr = this;
d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref();
- QT_TRY {
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- if (d->isWidget) {
- if (parent) {
- d->parent = parent;
- d->parent->d_func()->children.append(this);
+ if (parent) {
+ QT_TRY {
+ if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
+ parent = 0;
+ if (d->isWidget) {
+ if (parent) {
+ d->parent = parent;
+ d->parent->d_func()->children.append(this);
+ }
+ // no events sent here, this is done at the end of the QWidget constructor
+ } else {
+ setParent(parent);
}
- // no events sent here, this is done at the end of the QWidget constructor
- } else {
- setParent(parent);
+ } QT_CATCH(...) {
+ d->threadData->deref();
+ QT_RETHROW;
}
- } QT_CATCH(...) {
- d->threadData->deref();
- QT_RETHROW;
}
qt_addObject(this);
}
@@ -821,7 +819,7 @@ QObject::~QObject()
d->wasDeleted = true;
d->blockSig = 0; // unblock signals so we always emit destroyed()
- if (!d->isWidget) {
+ if (d->hasGuards && !d->isWidget) {
// set all QPointers for this object to zero - note that
// ~QWidget() does this for us, so we don't have to do it twice
QObjectPrivate::clearGuards(this);
@@ -839,22 +837,16 @@ QObject::~QObject()
delete d->sharedRefcount;
}
- QT_TRY {
- emit destroyed(this);
- } QT_CATCH(...) {
- // all the signal/slots connections are still in place - if we don't
- // quit now, we will crash pretty soon.
- qWarning("Detected an unexpected exception in ~QObject while emitting destroyed().");
-#if defined(Q_BUILD_INTERNAL) && !defined(QT_NO_EXCEPTIONS)
- struct AutotestException : public std::exception
- {
- const char *what() const throw() { return "autotest swallow"; }
- } autotestException;
- // throw autotestException;
-#else
- QT_RETHROW;
-#endif
+ if (d->isSignalConnected(0)) {
+ QT_TRY {
+ emit destroyed(this);
+ } QT_CATCH(...) {
+ // all the signal/slots connections are still in place - if we don't
+ // quit now, we will crash pretty soon.
+ qWarning("Detected an unexpected exception in ~QObject while emitting destroyed().");
+ QT_RETHROW;
+ }
}
if (d->declarativeData)
@@ -892,7 +884,7 @@ QObject::~QObject()
if (c->next) c->next->prev = c->prev;
}
if (needToUnlock)
- m->unlock();
+ m->unlockInline();
connectionList.first = c->nextConnectionList;
delete c;
@@ -916,7 +908,7 @@ QObject::~QObject()
bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
//the node has maybe been removed while the mutex was unlocked in relock?
if (!node || node->sender != sender) {
- m->unlock();
+ m->unlockInline();
continue;
}
node->receiver = 0;
@@ -926,35 +918,18 @@ QObject::~QObject()
node = node->next;
if (needToUnlock)
- m->unlock();
+ m->unlockInline();
}
}
- if (d->pendTimer) {
- // unregister pending timers
- if (d->threadData->eventDispatcher)
- d->threadData->eventDispatcher->unregisterTimers(this);
- }
-
-#ifdef QT3_SUPPORT
- d->pendingChildInsertedEvents.clear();
-#endif
-
- d->eventFilters.clear();
-
if (!d->children.isEmpty())
d->deleteChildren();
qt_removeObject(this);
- if (d->postedEvents)
- QCoreApplication::removePostedEvents(this, 0);
-
if (d->parent) // remove it from parent object
d->setParent_helper(0);
- d->threadData->deref();
-
#ifdef QT_JAMBI_BUILD
if (d->inEventHandler) {
qWarning("QObject: Do not delete object, '%s', during its event handler!",
@@ -1202,7 +1177,9 @@ bool QObject::event(QEvent *e)
case QEvent::MetaCall:
{
+#ifdef QT_JAMBI_BUILD
d_func()->inEventHandler = false;
+#endif
QMetaCallEvent *mce = static_cast<QMetaCallEvent*>(e);
QObjectPrivate::Sender currentSender;
currentSender.sender = const_cast<QObject*>(mce->sender());
@@ -1520,11 +1497,14 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
currentSender->ref = 0;
currentSender = 0;
+#ifdef QT_JAMBI_BUILD
// the current event thread also shouldn't restore the delete watch
inEventHandler = false;
+
if (deleteWatch)
*deleteWatch = 1;
deleteWatch = 0;
+#endif
// set new thread data
targetData->ref();
@@ -1774,11 +1754,7 @@ QObjectList QObject::queryList(const char *inheritsClass,
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11
- \warning This function is not available with MSVC 6. Use
- qFindChild() instead if you need to support that version of the
- compiler.
-
- \sa findChildren(), qFindChild()
+ \sa findChildren()
*/
/*!
@@ -1798,11 +1774,7 @@ QObjectList QObject::queryList(const char *inheritsClass,
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13
- \warning This function is not available with MSVC 6. Use
- qFindChildren() instead if you need to support that version of the
- compiler.
-
- \sa findChild(), qFindChildren()
+ \sa findChild()
*/
/*!
@@ -1813,20 +1785,19 @@ QObjectList QObject::queryList(const char *inheritsClass,
and that have names matching the regular expression \a regExp,
or an empty list if there are no such objects.
The search is performed recursively.
-
- \warning This function is not available with MSVC 6. Use
- qFindChildren() instead if you need to support that version of the
- compiler.
*/
/*!
\fn T qFindChild(const QObject *obj, const QString &name)
\relates QObject
+ \obsolete
This function is equivalent to
- \a{obj}->\l{QObject::findChild()}{findChild}<T>(\a name). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \a{obj}->\l{QObject::findChild()}{findChild}<T>(\a name).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QObject::findChild()
*/
@@ -1834,11 +1805,14 @@ QObjectList QObject::queryList(const char *inheritsClass,
/*!
\fn QList<T> qFindChildren(const QObject *obj, const QString &name)
\relates QObject
+ \obsolete
This function is equivalent to
- \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a name). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a name).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QObject::findChildren()
*/
@@ -1849,9 +1823,13 @@ QObjectList QObject::queryList(const char *inheritsClass,
\overload qFindChildren()
This function is equivalent to
- \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a regExp). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a regExp).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
+
+ \sa QObject::findChildren()
*/
/*!
@@ -1861,9 +1839,11 @@ QObjectList QObject::queryList(const char *inheritsClass,
\overload qFindChildren()
This function is equivalent to
- \a{obj}->\l{QObject::findChild()}{findChild}<T>(\a name). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \a{obj}->\l{QObject::findChild()}{findChild}<T>(\a name).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QObject::findChild()
*/
@@ -1875,9 +1855,11 @@ QObjectList QObject::queryList(const char *inheritsClass,
\overload qFindChildren()
This function is equivalent to
- \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a name). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a name).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QObject::findChildren()
*/
@@ -1997,12 +1979,14 @@ void QObjectPrivate::setParent_helper(QObject *o)
QChildEvent e(QEvent::ChildAdded, q);
QCoreApplication::sendEvent(parent, &e);
#ifdef QT3_SUPPORT
- if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
- QCoreApplication::postEvent(parent,
- new QEvent(QEvent::ChildInsertedRequest),
- Qt::HighEventPriority);
+ if (QCoreApplicationPrivate::useQt3Support) {
+ if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
+ QCoreApplication::postEvent(parent,
+ new QEvent(QEvent::ChildInsertedRequest),
+ Qt::HighEventPriority);
+ }
+ parent->d_func()->pendingChildInsertedEvents.append(q);
}
- parent->d_func()->pendingChildInsertedEvents.append(q);
#endif
}
}
@@ -2311,7 +2295,7 @@ static void err_info_about_objects(const char * func,
a thread different from this object's thread. Do not use this
function in this type of scenario.
- \sa QSignalMapper
+ \sa senderSignalIndex(), QSignalMapper
*/
QObject *QObject::sender() const
@@ -2322,13 +2306,53 @@ QObject *QObject::sender() const
if (!d->currentSender)
return 0;
- // Return 0 if d->currentSender isn't in d->senders
- bool found = false;
- for (QObjectPrivate::Connection *c = d->senders; c && !found; c = c->next)
- found = (c->sender == d->currentSender->sender);
- if (!found)
- return 0;
- return d->currentSender->sender;
+ for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) {
+ if (c->sender == d->currentSender->sender)
+ return d->currentSender->sender;
+ }
+
+ return 0;
+}
+
+/*!
+ \since 4.8
+
+ Returns the meta-method index of the signal that called the currently
+ executing slot, which is a member of the class returned by sender().
+ If called outside of a slot activated by a signal, -1 is returned.
+
+ For signals with default parameters, this function will always return
+ the index with all parameters, regardless of which was used with
+ connect(). For example, the signal \c {destroyed(QObject *obj = 0)}
+ will have two different indexes (with and without the parameter), but
+ this function will always return the index with a parameter. This does
+ not apply when overloading signals with different parameters.
+
+ \warning This function violates the object-oriented principle of
+ modularity. However, getting access to the signal index might be useful
+ when many signals are connected to a single slot.
+
+ \warning The return value of this function is not valid when the slot
+ is called via a Qt::DirectConnection from a thread different from this
+ object's thread. Do not use this function in this type of scenario.
+
+ \sa sender(), QMetaObject::indexOfSignal(), QMetaObject::method()
+*/
+
+int QObject::senderSignalIndex() const
+{
+ Q_D(const QObject);
+
+ QMutexLocker locker(signalSlotLock(this));
+ if (!d->currentSender)
+ return -1;
+
+ for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) {
+ if (c->sender == d->currentSender->sender)
+ return d->currentSender->signal;
+ }
+
+ return -1;
}
/*!
@@ -2390,6 +2414,71 @@ int QObject::receivers(const char *signal) const
}
/*!
+ \internal
+
+ This helper function calculates signal and method index for the given
+ member in the specified class.
+
+ \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1.
+
+ \li If specified member is not a member of obj instance class (or one of
+ its parent classes) then both signalIndex and methodIndex are set to -1.
+
+ This function is used by QObject::connect and QObject::disconnect which
+ are working with QMetaMethod.
+
+ \param[out] signalIndex is set to the signal index of member. If the member
+ specified is not signal this variable is set to -1.
+
+ \param[out] methodIndex is set to the method index of the member. If the
+ member is not a method of the object specified by obj param this variable
+ is set to -1.
+*/
+void QMetaObjectPrivate::memberIndexes(const QObject *obj,
+ const QMetaMethod &member,
+ int *signalIndex, int *methodIndex)
+{
+ *signalIndex = -1;
+ *methodIndex = -1;
+ if (!obj || !member.mobj)
+ return;
+ const QMetaObject *m = obj->metaObject();
+ // Check that member is member of obj class
+ while (m != 0 && m != member.mobj)
+ m = m->d.superdata;
+ if (!m)
+ return;
+ *signalIndex = *methodIndex = (member.handle - get(member.mobj)->methodData)/5;
+
+ int signalOffset;
+ int methodOffset;
+ computeOffsets(m, &signalOffset, &methodOffset);
+
+ *methodIndex += methodOffset;
+ if (member.methodType() == QMetaMethod::Signal) {
+ *signalIndex = originalClone(m, *signalIndex);
+ *signalIndex += signalOffset;
+ } else {
+ *signalIndex = -1;
+ }
+}
+
+static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaMethod &signal,
+ const QMetaObject *receiver, const QMetaMethod &method)
+{
+ if (signal.attributes() & QMetaMethod::Compatibility) {
+ if (!(method.attributes() & QMetaMethod::Compatibility))
+ qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)",
+ sender->className(), signal.signature());
+ } else if ((method.attributes() & QMetaMethod::Compatibility) &&
+ method.methodType() == QMetaMethod::Signal) {
+ qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
+ sender->className(), signal.signature(),
+ receiver->className(), method.signature());
+ }
+}
+
+/*!
\threadsafe
Creates a connection of the given \a type from the \a signal in
@@ -2566,7 +2655,7 @@ bool QObject::connect(const QObject *sender, const char *signal,
}
int *types = 0;
- if ((type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
+ if ((type == Qt::QueuedConnection)
&& !(types = queuedConnectionTypes(smeta->method(signal_absolute_index).parameterTypes())))
return false;
@@ -2574,15 +2663,8 @@ bool QObject::connect(const QObject *sender, const char *signal,
{
QMetaMethod smethod = smeta->method(signal_absolute_index);
QMetaMethod rmethod = rmeta->method(method_index);
- if (warnCompat) {
- if(smethod.attributes() & QMetaMethod::Compatibility) {
- if (!(rmethod.attributes() & QMetaMethod::Compatibility))
- qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)", smeta->className(), signal);
- } else if(rmethod.attributes() & QMetaMethod::Compatibility && membcode != QSIGNAL_CODE) {
- qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
- smeta->className(), signal, rmeta->className(), method);
- }
- }
+ if (warnCompat)
+ check_and_warn_compat(smeta, smethod, rmeta, rmethod);
}
#endif
if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types))
@@ -2591,6 +2673,111 @@ bool QObject::connect(const QObject *sender, const char *signal,
return true;
}
+/*!
+ \since 4.8
+
+ Creates a connection of the given \a type from the \a signal in
+ the \a sender object to the \a method in the \a receiver object.
+ Returns true if the connection succeeds; otherwise returns false.
+
+ This function works in the same way as
+ connect(const QObject *sender, const char *signal,
+ const QObject *receiver, const char *method,
+ Qt::ConnectionType type)
+ but it uses QMetaMethod to specify signal and method.
+
+ \see connect(const QObject *sender, const char *signal,
+ const QObject *receiver, const char *method,
+ Qt::ConnectionType type)
+ */
+bool QObject::connect(const QObject *sender, const QMetaMethod &signal,
+ const QObject *receiver, const QMetaMethod &method,
+ Qt::ConnectionType type)
+{
+#ifndef QT_NO_DEBUG
+ bool warnCompat = true;
+#endif
+ if (type == Qt::AutoCompatConnection) {
+ type = Qt::AutoConnection;
+#ifndef QT_NO_DEBUG
+ warnCompat = false;
+#endif
+ }
+
+ if (sender == 0
+ || receiver == 0
+ || signal.methodType() != QMetaMethod::Signal
+ || method.methodType() == QMetaMethod::Constructor) {
+ qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
+ sender ? sender->metaObject()->className() : "(null)",
+ signal.signature(),
+ receiver ? receiver->metaObject()->className() : "(null)",
+ method.signature() );
+ return false;
+ }
+
+ // Reconstructing SIGNAL() macro result for signal.signature() string
+ QByteArray signalSignature;
+ signalSignature.reserve(qstrlen(signal.signature())+1);
+ signalSignature.append((char)(QSIGNAL_CODE + '0'));
+ signalSignature.append(signal.signature());
+
+ {
+ QByteArray methodSignature;
+ methodSignature.reserve(qstrlen(method.signature())+1);
+ methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE
+ : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0'));
+ methodSignature.append(method.signature());
+ const void *cbdata[] = { sender, signalSignature.constData(), receiver, methodSignature.constData(), &type };
+ if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata))
+ return true;
+ }
+
+
+ int signal_index;
+ int method_index;
+ {
+ int dummy;
+ QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
+ QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
+ }
+
+ const QMetaObject *smeta = sender->metaObject();
+ const QMetaObject *rmeta = receiver->metaObject();
+ if (signal_index == -1) {
+ qWarning("QObject::connect: Can't find signal %s on instance of class %s",
+ signal.signature(), smeta->className());
+ return false;
+ }
+ if (method_index == -1) {
+ qWarning("QObject::connect: Can't find method %s on instance of class %s",
+ method.signature(), rmeta->className());
+ return false;
+ }
+
+ if (!QMetaObject::checkConnectArgs(signal.signature(), method.signature())) {
+ qWarning("QObject::connect: Incompatible sender/receiver arguments"
+ "\n %s::%s --> %s::%s",
+ smeta->className(), signal.signature(),
+ rmeta->className(), method.signature());
+ return false;
+ }
+
+ int *types = 0;
+ if ((type == Qt::QueuedConnection)
+ && !(types = queuedConnectionTypes(signal.parameterTypes())))
+ return false;
+
+#ifndef QT_NO_DEBUG
+ if (warnCompat)
+ check_and_warn_compat(smeta, signal, rmeta, method);
+#endif
+ if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types))
+ return false;
+
+ const_cast<QObject*>(sender)->connectNotify(signalSignature.constData());
+ return true;
+}
/*!
\fn bool QObject::connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
@@ -2770,6 +2957,107 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
return res;
}
+/*!
+ \since 4.8
+
+ Disconnects \a signal in object \a sender from \a method in object
+ \a receiver. Returns true if the connection is successfully broken;
+ otherwise returns false.
+
+ This function provides the same posibilities like
+ disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
+ but uses QMetaMethod to represent the signal and the method to be disconnected.
+
+ Additionally this function returnsfalse and no signals and slots disconnected
+ if:
+ \list 1
+
+ \i \a signal is not a member of sender class or one of its parent classes.
+
+ \i \a method is not a member of receiver class or one of its parent classes.
+
+ \i \a signal instance represents not a signal.
+
+ \endlist
+
+ QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object".
+ In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case
+ method shoud also be QMetaMethod(). \a sender parameter should be never 0.
+
+ \see disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
+ */
+bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
+ const QObject *receiver, const QMetaMethod &method)
+{
+ if (sender == 0 || (receiver == 0 && method.mobj != 0)) {
+ qWarning("Object::disconnect: Unexpected null parameter");
+ return false;
+ }
+ if (signal.mobj) {
+ if(signal.methodType() != QMetaMethod::Signal) {
+ qWarning("Object::%s: Attempt to %s non-signal %s::%s",
+ "disconnect","unbind",
+ sender->metaObject()->className(), signal.signature());
+ return false;
+ }
+ }
+ if (method.mobj) {
+ if(method.methodType() == QMetaMethod::Constructor) {
+ qWarning("QObject::disconect: cannot use constructor as argument %s::%s",
+ receiver->metaObject()->className(), method.signature());
+ return false;
+ }
+ }
+
+ // Reconstructing SIGNAL() macro result for signal.signature() string
+ QByteArray signalSignature;
+ if (signal.mobj) {
+ signalSignature.reserve(qstrlen(signal.signature())+1);
+ signalSignature.append((char)(QSIGNAL_CODE + '0'));
+ signalSignature.append(signal.signature());
+ }
+
+ {
+ QByteArray methodSignature;
+ if (method.mobj) {
+ methodSignature.reserve(qstrlen(method.signature())+1);
+ methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE
+ : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0'));
+ methodSignature.append(method.signature());
+ }
+ const void *cbdata[] = { sender, signal.mobj ? signalSignature.constData() : 0,
+ receiver, method.mobj ? methodSignature.constData() : 0 };
+ if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata))
+ return true;
+ }
+
+ int signal_index;
+ int method_index;
+ {
+ int dummy;
+ QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
+ QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
+ }
+ // If we are here sender is not null. If signal is not null while signal_index
+ // is -1 then this signal is not a member of sender.
+ if (signal.mobj && signal_index == -1) {
+ qWarning("QObject::disconect: signal %s not found on class %s",
+ signal.signature(), sender->metaObject()->className());
+ return false;
+ }
+ // If this condition is true then method is not a member of receeiver.
+ if (receiver && method.mobj && method_index == -1) {
+ qWarning("QObject::disconect: method %s not found on class %s",
+ method.signature(), receiver->metaObject()->className());
+ return false;
+ }
+
+ if (!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index))
+ return false;
+
+ const_cast<QObject*>(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : 0);
+ return true;
+}
/*!
\threadsafe
@@ -2987,7 +3275,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c,
}
if (needToUnlock)
- receiverMutex->unlock();
+ receiverMutex->unlockInline();
c->receiver = 0;
@@ -3074,7 +3362,7 @@ void QMetaObject::connectSlotsByName(QObject *o)
return;
const QMetaObject *mo = o->metaObject();
Q_ASSERT(mo);
- const QObjectList list = qFindChildren<QObject *>(o, QString());
+ const QObjectList list = o->findChildren<QObject *>(QString());
for (int i = 0; i < mo->methodCount(); ++i) {
const char *slot = mo->method(i).signature();
Q_ASSERT(slot);
@@ -3121,8 +3409,7 @@ void QMetaObject::connectSlotsByName(QObject *o)
}
}
-static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c,
- void **argv, QSemaphore *semaphore = 0)
+static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv)
{
if (!c->argumentTypes && c->argumentTypes != &DIRECT_CONNECTION_ONLY) {
QMetaMethod m = sender->metaObject()->method(signal);
@@ -3152,30 +3439,9 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
signal,
nargs,
types,
- args,
- semaphore));
+ args));
}
-static void blocking_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv)
-{
- if (QThread::currentThread() == c->receiver->thread()) {
- qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
- "Sender is %s(%p), receiver is %s(%p)",
- sender->metaObject()->className(), sender,
- c->receiver->metaObject()->className(), c->receiver);
- }
-
-#ifdef QT_NO_THREAD
- queued_activate(sender, signal, c, argv);
-#else
- QSemaphore semaphore;
- queued_activate(sender, signal, c, argv, &semaphore);
- QMutex *mutex = signalSlotLock(sender);
- mutex->unlock();
- semaphore.acquire();
- mutex->lock();
-#endif
-}
/*!\internal
\obsolete.
@@ -3239,23 +3505,36 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
continue;
QObject * const receiver = c->receiver;
+ const int method = c->method;
+ const bool receiverInSameThread = currentThreadData == receiver->d_func()->threadData;
// determine if this connection should be sent immediately or
// put into the event queue
- if ((c->connectionType == Qt::AutoConnection
- && (currentThreadData != sender->d_func()->threadData
- || receiver->d_func()->threadData != sender->d_func()->threadData))
+ if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv);
continue;
+#ifndef QT_NO_THREAD
} else if (c->connectionType == Qt::BlockingQueuedConnection) {
- blocking_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv);
+ locker.unlock();
+ if (receiverInSameThread) {
+ qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
+ "Sender is %s(%p), receiver is %s(%p)",
+ sender->metaObject()->className(), sender,
+ receiver->metaObject()->className(), receiver);
+ }
+ QSemaphore semaphore;
+ QCoreApplication::postEvent(receiver, new QMetaCallEvent(method,
+ sender, signal_absolute_index,
+ 0, 0,
+ argv ? argv : empty_argv,
+ &semaphore));
+ semaphore.acquire();
+ locker.relock();
continue;
+#endif
}
-
- const int method = c->method;
QObjectPrivate::Sender currentSender;
- const bool receiverInSameThread = currentThreadData == receiver->d_func()->threadData;
QObjectPrivate::Sender *previousSender = 0;
if (receiverInSameThread) {
currentSender.sender = sender;
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 2c9c106..0ad73f5 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -77,19 +77,9 @@ class QObjectUserData;
typedef QList<QObject*> QObjectList;
-#if defined Q_CC_MSVC && _MSC_VER < 1300
-template<typename T> inline T qFindChild(const QObject *o, const QString &name = QString(), T = 0);
-template<typename T> inline QList<T> qFindChildren(const QObject *o, const QString &name = QString(), T = 0);
-# ifndef QT_NO_REGEXP
-template<typename T> inline QList<T> qFindChildren(const QObject *o, const QRegExp &re, T = 0);
-# endif
-#else
-template<typename T> inline T qFindChild(const QObject *, const QString & = QString());
-template<typename T> inline QList<T> qFindChildren(const QObject *, const QString & = QString());
-# ifndef QT_NO_REGEXP
-template<typename T> inline QList<T> qFindChildren(const QObject *, const QRegExp &);
-# endif
-#endif
+Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re,
+ const QMetaObject &mo, QList<void *> *list);
+Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo);
class
#if defined(__INTEL_COMPILER) && defined(Q_OS_WIN)
@@ -109,7 +99,7 @@ public:
uint ownObjectName : 1;
uint sendChildEvents : 1;
uint receiveChildEvents : 1;
- uint inEventHandler : 1;
+ uint inEventHandler : 1; //only used if QT_JAMBI_BUILD
uint inThreadChangeEvent : 1;
uint hasGuards : 1; //true iff there is one or more QPointer attached to this object
uint unused : 22;
@@ -164,20 +154,36 @@ public:
int startTimer(int interval);
void killTimer(int id);
-#ifndef QT_NO_MEMBER_TEMPLATES
template<typename T>
inline T findChild(const QString &aName = QString()) const
- { return qFindChild<T>(this, aName); }
+ { return static_cast<T>(qt_qFindChild_helper(this, aName, reinterpret_cast<T>(0)->staticMetaObject)); }
template<typename T>
inline QList<T> findChildren(const QString &aName = QString()) const
- { return qFindChildren<T>(this, aName); }
+ {
+ QList<T> list;
+ union {
+ QList<T> *typedList;
+ QList<void *> *voidList;
+ } u;
+ u.typedList = &list;
+ qt_qFindChildren_helper(this, aName, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
+ return list;
+ }
#ifndef QT_NO_REGEXP
template<typename T>
inline QList<T> findChildren(const QRegExp &re) const
- { return qFindChildren<T>(this, re); }
-#endif
+ {
+ QList<T> list;
+ union {
+ QList<T> *typedList;
+ QList<void *> *voidList;
+ } u;
+ u.typedList = &list;
+ qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
+ return list;
+ }
#endif
#ifdef QT3_SUPPORT
@@ -207,6 +213,21 @@ public:
#endif
#endif
);
+
+ static bool connect(const QObject *sender, const QMetaMethod &signal,
+ const QObject *receiver, const QMetaMethod &method,
+ Qt::ConnectionType type =
+#ifdef qdoc
+ Qt::AutoConnection
+#else
+#ifdef QT3_SUPPORT
+ Qt::AutoCompatConnection
+#else
+ Qt::AutoConnection
+#endif
+#endif
+ );
+
inline bool connect(const QObject *sender, const char *signal,
const char *member, Qt::ConnectionType type =
#ifdef qdoc
@@ -222,6 +243,8 @@ public:
static bool disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member);
+ static bool disconnect(const QObject *sender, const QMetaMethod &signal,
+ const QObject *receiver, const QMetaMethod &member);
inline bool disconnect(const char *signal = 0,
const QObject *receiver = 0, const char *member = 0)
{ return disconnect(this, signal, receiver, member); }
@@ -257,6 +280,7 @@ public Q_SLOTS:
protected:
QObject *sender() const;
+ int senderSignalIndex() const;
int receivers(const char* signal) const;
virtual void timerEvent(QTimerEvent *);
@@ -321,62 +345,43 @@ public:
};
#endif
-Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re,
- const QMetaObject &mo, QList<void *> *list);
-Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo);
-
+#ifdef QT_DEPRECATED
template<typename T>
-inline T qFindChild(const QObject *o, const QString &name)
-{ return static_cast<T>(qt_qFindChild_helper(o, name, reinterpret_cast<T>(0)->staticMetaObject)); }
+inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString())
+{ return o->findChild<T>(name); }
template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QString &name)
+inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QString &name = QString())
{
- QList<T> list;
- union {
- QList<T> *typedList;
- QList<void *> *voidList;
- } u;
- u.typedList = &list;
- qt_qFindChildren_helper(o, name, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
- return list;
+ return o->findChildren<T>(name);
}
#ifndef QT_NO_REGEXP
template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QRegExp &re)
+inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
{
- QList<T> list;
- union {
- QList<T> *typedList;
- QList<void *> *voidList;
- } u;
- u.typedList = &list;
- qt_qFindChildren_helper(o, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
- return list;
+ return o->findChildren<T>(re);
}
#endif
+#endif //QT_DEPRECATED
+
template <class T>
inline T qobject_cast(QObject *object)
{
-#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
+#if !defined(QT_NO_QOBJECT_CHECK)
+ 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)
{
- // this will cause a compilation error if T is not const
- register T ptr = static_cast<T>(object);
- Q_UNUSED(ptr);
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
+#if !defined(QT_NO_QOBJECT_CHECK)
+ reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
#endif
- return static_cast<T>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject *>(object))));
+ return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 4fcaef3..c7555be 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -55,6 +55,7 @@
#include "QtCore/qobject.h"
#include "QtCore/qpointer.h"
+#include "QtCore/qsharedpointer.h"
#include "QtCore/qcoreevent.h"
#include "QtCore/qlist.h"
#include "QtCore/qvector.h"
@@ -154,7 +155,6 @@ public:
#ifdef QT3_SUPPORT
void sendPendingChildInsertedEvents();
- void removePendingChildInsertedEvents(QObject *child);
#endif
static inline Sender *setCurrentSender(QObject *receiver,
@@ -162,8 +162,10 @@ public:
static inline void resetCurrentSender(QObject *receiver,
Sender *currentSender,
Sender *previousSender);
+#ifdef QT_JAMBI_BUILD
static int *setDeleteWatch(QObjectPrivate *d, int *newWatch);
static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch);
+#endif
static void clearGuards(QObject *);
static QObjectPrivate *get(QObject *o) {
@@ -185,7 +187,7 @@ public:
mutable quint32 connectedSignals[2];
#ifdef QT3_SUPPORT
- QList<QObject *> pendingChildInsertedEvents;
+ QVector< QWeakPointer<QObject> > pendingChildInsertedEvents;
#else
// preserve binary compatibility with code compiled without Qt 3 support
// keeping the binary layout stable helps the Qt Creator debugger
@@ -201,7 +203,9 @@ public:
// these objects are all used to indicate that a QObject was deleted
// plus QPointer, which keeps a separate list
QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
+#ifdef QT_JAMBI_BUILD
int *deleteWatch;
+#endif
};
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index b727187..54b5ab2 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -118,7 +118,7 @@ class QString;
# define QT_TR_FUNCTIONS
#endif
-#if defined(QT_NO_MEMBER_TEMPLATES) || defined(QT_NO_QOBJECT_CHECK)
+#if defined(QT_NO_QOBJECT_CHECK)
/* tmake ignore Q_OBJECT */
#define Q_OBJECT_CHECK
#else
@@ -145,7 +145,7 @@ inline int qYouForgotTheQ_OBJECT_Macro(T, T) { return 0; }
template <typename T1, typename T2>
inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
-#endif // QT_NO_MEMBER_TEMPLATES
+#endif // QT_NO_QOBJECT_CHECK
#ifdef Q_NO_DATA_RELOCATION
#define Q_OBJECT_GETSTATICMETAOBJECT static const QMetaObject &getStaticMetaObject();
@@ -217,11 +217,15 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method);
#define QTOSTRING(s) QTOSTRING_HELPER(s)
#ifndef QT_NO_DEBUG
# define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__)
-# define METHOD(a) qFlagLocation("0"#a QLOCATION)
+# ifndef QT_NO_KEYWORDS
+# define METHOD(a) qFlagLocation("0"#a QLOCATION)
+# endif
# define SLOT(a) qFlagLocation("1"#a QLOCATION)
# define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
#else
-# define METHOD(a) "0"#a
+# ifndef QT_NO_KEYWORDS
+# define METHOD(a) "0"#a
+# endif
# define SLOT(a) "1"#a
# define SIGNAL(a) "2"#a
#endif
@@ -300,6 +304,7 @@ struct Q_CORE_EXPORT QMetaObject
const QMetaObject *superClass() const;
QObject *cast(QObject *obj) const;
+ const QObject *cast(const QObject *obj) const;
#ifndef QT_NO_TRANSLATION
// ### Qt 4: Merge overloads
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 85b37d0..78715a1 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -73,14 +73,13 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
QString part1 = key;
part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
result.append(part1);
-#ifdef Q_OS_SYMBIAN
- return result.left(KMaxKernelName);
-#endif
QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex();
result.append(QLatin1String(hex));
#ifdef Q_OS_WIN
return result;
+#elif defined(Q_OS_SYMBIAN)
+ return result.left(KMaxKernelName);
#else
return QDir::tempPath() + QLatin1Char('/') + result;
#endif
@@ -142,9 +141,12 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
remain. Do not mix using QtSharedMemory and QSharedMemory. Port
everything to QSharedMemory.
- \warning QSharedMemory changes the key in a Qt-specific way.
- It is therefore currently not possible to use the shared memory of
- non-Qt applications with QSharedMemory.
+ \warning QSharedMemory changes the key in a Qt-specific way, unless otherwise
+ specified. Interoperation with non-Qt applications is achieved by first creating
+ a default shared memory with QSharedMemory() and then setting a native key with
+ setNativeKey(). When using native keys, shared memory is not protected against
+ multiple accesses on it (e.g. unable to lock()) and a user-defined mechanism
+ should be used to achieve a such protection.
*/
/*!
@@ -153,8 +155,8 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
Constructs a shared memory object with the given \a parent. The
shared memory object's key is not set by the constructor, so the
shared memory object does not have an underlying shared memory
- segment attached. The key must be set with setKey() before create()
- or attach() can be used.
+ segment attached. The key must be set with setKey() or setNativeKey()
+ before create() or attach() can be used.
\sa setKey()
*/
@@ -191,24 +193,62 @@ QSharedMemory::~QSharedMemory()
}
/*!
- Sets a new \a key for this shared memory object. If \a key and the
- current key are the same, the function returns without doing
- anything. If the shared memory object is attached to an underlying
- shared memory segment, it will \l {detach()} {detach} from it before
- setting the new key. This function does not do an attach().
+ Sets the platform independent \a key for this shared memory object. If \a key
+ is the same as the current key, the function returns without doing anything.
- \sa key() isAttached()
- */
+ You can call key() to retrieve the platform independent key. Internally,
+ QSharedMemory converts this key into a platform specific key. If you instead
+ call nativeKey(), you will get the platform specific, converted key.
+
+ If the shared memory object is attached to an underlying shared memory
+ segment, it will \l {detach()} {detach} from it before setting the new key.
+ This function does not do an attach().
+
+ \sa key() nativeKey() isAttached()
+*/
void QSharedMemory::setKey(const QString &key)
{
Q_D(QSharedMemory);
- if (key == d->key)
+ if (key == d->key && d->makePlatformSafeKey(key) == d->nativeKey)
return;
if (isAttached())
detach();
d->cleanHandle();
d->key = key;
+ d->nativeKey = d->makePlatformSafeKey(key);
+}
+
+/*!
+ \since 4.8
+
+ Sets the native, platform specific, \a key for this shared memory object. If
+ \a key is the same as the current native key, the function returns without
+ doing anything. If all you want is to assign a key to a segment, you should
+ call setKey() instead.
+
+ You can call nativeKey() to retrieve the native key. If a native key has been
+ assigned, calling key() will return a null string.
+
+ If the shared memory object is attached to an underlying shared memory
+ segment, it will \l {detach()} {detach} from it before setting the new key.
+ This function does not do an attach().
+
+ The application will not be portable if you set a native key.
+
+ \sa nativeKey() key() isAttached()
+*/
+void QSharedMemory::setNativeKey(const QString &key)
+{
+ Q_D(QSharedMemory);
+ if (key == d->nativeKey && d->key.isNull())
+ return;
+
+ if (isAttached())
+ detach();
+ d->cleanHandle();
+ d->key = QString();
+ d->nativeKey = key;
}
bool QSharedMemoryPrivate::initKey()
@@ -251,13 +291,15 @@ bool QSharedMemoryPrivate::initKey()
}
/*!
- Returns the key assigned to this shared memory. The key is the
- identifier used by the operating system to identify the shared
- memory segment. When QSharedMemory is used for interprocess
- communication, the key is how each process attaches to the shared
- memory segment through which the IPC occurs.
+ Returns the key assigned with setKey() to this shared memory, or a null key
+ if no key has been assigned, or if the segment is using a nativeKey(). The
+ key is the identifier used by Qt applications to identify the shared memory
+ segment.
- \sa setKey()
+ You can find the native, platform specific, key used by the operating system
+ by calling nativeKey().
+
+ \sa setKey() setNativeKey()
*/
QString QSharedMemory::key() const
{
@@ -266,13 +308,30 @@ QString QSharedMemory::key() const
}
/*!
- Creates a shared memory segment of \a size bytes with the key passed
- to the constructor or set with setKey(), attaches to the new shared
- memory segment with the given access \a mode, and returns \tt true.
- If a shared memory segment identified by the key already exists, the
- attach operation is not performed, and \tt false is returned. When
- the return value is \tt false, call error() to determine which error
- occurred.
+ \since 4.8
+
+ Returns the native, platform specific, key for this shared memory object. The
+ native key is the identifier used by the operating system to identify the
+ shared memory segment.
+
+ You can use the native key to access shared memory segments that have not
+ been created by Qt, or to grant shared memory access to non-Qt applications.
+
+ \sa setKey() setNativeKey()
+*/
+QString QSharedMemory::nativeKey() const
+{
+ Q_D(const QSharedMemory);
+ return d->nativeKey;
+}
+
+/*!
+ Creates a shared memory segment of \a size bytes with the key passed to the
+ constructor, set with setKey() or set with setNativeKey(), then attaches to
+ the new shared memory segment with the given access \a mode and returns
+ \tt true. If a shared memory segment identified by the key already exists,
+ the attach operation is not performed and \tt false is returned. When the
+ return value is \tt false, call error() to determine which error occurred.
\sa error()
*/
@@ -294,7 +353,7 @@ bool QSharedMemory::create(int size, AccessMode mode)
QString function = QLatin1String("QSharedMemory::create");
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
- if (!d->tryLocker(&lock, function))
+ if (!d->key.isNull() && !d->tryLocker(&lock, function))
return false;
#endif
@@ -338,7 +397,7 @@ int QSharedMemory::size() const
/*!
Attempts to attach the process to the shared memory segment
identified by the key that was passed to the constructor or to a
- call to setKey(). The access \a mode is \l {QSharedMemory::}
+ call to setKey() or setNativeKey(). The access \a mode is \l {QSharedMemory::}
{ReadWrite} by default. It can also be \l {QSharedMemory::}
{ReadOnly}. Returns true if the attach operation is successful. If
false is returned, call error() to determine which error occurred.
@@ -355,7 +414,7 @@ bool QSharedMemory::attach(AccessMode mode)
return false;
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
- if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::attach")))
+ if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::attach")))
return false;
#endif
@@ -395,7 +454,7 @@ bool QSharedMemory::detach()
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
- if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::detach")))
+ if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::detach")))
return false;
#endif
@@ -447,9 +506,9 @@ const void *QSharedMemory::data() const
by this process and returns true. If another process has locked the
segment, this function blocks until the lock is released. Then it
acquires the lock and returns true. If this function returns false,
- it means either that you have ignored a false return from create()
- or attach(), or that QSystemSemaphore::acquire() failed due to an
- unknown system error.
+ it means that you have ignored a false return from create() or attach(),
+ that you have set the key with setNativeKey() or that
+ QSystemSemaphore::acquire() failed due to an unknown system error.
\sa unlock(), data(), QSystemSemaphore::acquire()
*/
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index f6f3623..4a61003 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -85,6 +85,8 @@ public:
void setKey(const QString &key);
QString key() const;
+ void setNativeKey(const QString &key);
+ QString nativeKey() const;
bool create(int size, AccessMode mode = ReadWrite);
int size() const;
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index d40fd38..72eda37 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -122,6 +122,7 @@ public:
void *memory;
int size;
QString key;
+ QString nativeKey;
QSharedMemory::SharedMemoryError error;
QString errorString;
#ifndef QT_NO_SYSTEMSEMAPHORE
diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp
index dbcebc0..3565e26 100644
--- a/src/corelib/kernel/qsharedmemory_symbian.cpp
+++ b/src/corelib/kernel/qsharedmemory_symbian.cpp
@@ -107,16 +107,14 @@ bool QSharedMemoryPrivate::cleanHandle()
bool QSharedMemoryPrivate::create(int size)
{
- // Get a windows acceptable key
- QString safeKey = makePlatformSafeKey(key);
QString function = QLatin1String("QSharedMemory::create");
- if (safeKey.isEmpty()) {
+ if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: key error").arg(function);
return false;
}
- TPtrC ptr(qt_QString2TPtrC(safeKey));
+ TPtrC ptr(qt_QString2TPtrC(nativeKey));
TInt err = chunk.CreateGlobal(ptr, size, size);
@@ -136,14 +134,13 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */)
// Grab a pointer to the memory block
if (!chunk.Handle()) {
QString function = QLatin1String("QSharedMemory::handle");
- QString safeKey = makePlatformSafeKey(key);
- if (safeKey.isEmpty()) {
+ if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
return false;
}
- TPtrC ptr(qt_QString2TPtrC(safeKey));
+ TPtrC ptr(qt_QString2TPtrC(nativeKey));
TInt err = KErrNoMemory;
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index ddb0e34..b30117f 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -116,21 +116,20 @@ key_t QSharedMemoryPrivate::handle()
return unix_key;
// don't allow making handles on empty keys
- if (key.isEmpty()) {
+ if (nativeKey.isEmpty()) {
errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:"));
error = QSharedMemory::KeyError;
return 0;
}
// ftok requires that an actual file exists somewhere
- QString fileName = makePlatformSafeKey(key);
- if (!QFile::exists(fileName)) {
+ if (!QFile::exists(nativeKey)) {
errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:"));
error = QSharedMemory::NotFound;
return 0;
}
- unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q');
+ unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q');
if (-1 == unix_key) {
errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:"));
error = QSharedMemory::KeyError;
@@ -181,7 +180,7 @@ bool QSharedMemoryPrivate::create(int size)
{
// build file if needed
bool createdFile = false;
- int built = createUnixKeyFile(makePlatformSafeKey(key));
+ int built = createUnixKeyFile(nativeKey);
if (built == -1) {
errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:"));
error = QSharedMemory::KeyError;
@@ -194,7 +193,7 @@ bool QSharedMemoryPrivate::create(int size)
// get handle
if (!handle()) {
if (createdFile)
- QFile::remove(makePlatformSafeKey(key));
+ QFile::remove(nativeKey);
return false;
}
@@ -210,7 +209,7 @@ bool QSharedMemoryPrivate::create(int size)
setErrorString(function);
}
if (createdFile && error != QSharedMemory::AlreadyExists)
- QFile::remove(makePlatformSafeKey(key));
+ QFile::remove(nativeKey);
return false;
}
@@ -291,7 +290,7 @@ bool QSharedMemoryPrivate::detach()
}
// remove file
- if (!QFile::remove(makePlatformSafeKey(key)))
+ if (!QFile::remove(nativeKey))
return false;
}
return true;
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index ac9c86a..bc13e33 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -99,18 +99,17 @@ HANDLE QSharedMemoryPrivate::handle()
{
if (!hand) {
QString function = QLatin1String("QSharedMemory::handle");
- QString safeKey = makePlatformSafeKey(key);
- if (safeKey.isEmpty()) {
+ if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
return false;
}
#ifndef Q_OS_WINCE
- hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)safeKey.utf16());
+ hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16());
#else
// This works for opening a mapping too, but always opens it with read/write access in
// attach as it seems.
- hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)safeKey.utf16());
+ hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16());
#endif
if (!hand) {
setErrorString(function);
@@ -133,17 +132,15 @@ bool QSharedMemoryPrivate::cleanHandle()
bool QSharedMemoryPrivate::create(int size)
{
- // Get a windows acceptable key
- QString safeKey = makePlatformSafeKey(key);
QString function = QLatin1String("QSharedMemory::create");
- if (safeKey.isEmpty()) {
+ if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: key error").arg(function);
return false;
}
// Create the file mapping.
- hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)safeKey.utf16());
+ hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16());
setErrorString(function);
// hand is valid when it already exists unlike unix so explicitly check
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
new file mode 100644
index 0000000..3381afa
--- /dev/null
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** 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 <qglobal.h>
+#include "qsystemerror_p.h"
+#if !defined(Q_OS_WINCE)
+# include <errno.h>
+# if defined(Q_CC_MSVC)
+# include <crtdbg.h>
+# endif
+#endif
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
+ defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
+namespace {
+ // There are two incompatible versions of strerror_r:
+ // a) the XSI/POSIX.1 version, which returns an int,
+ // indicating success or not
+ // b) the GNU version, which returns a char*, which may or may not
+ // be the beginning of the buffer we used
+ // The GNU libc manpage for strerror_r says you should use the the XSI
+ // version in portable code. However, it's impossible to do that if
+ // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
+ // depending on the return type
+ static inline QString fromstrerror_helper(int, const QByteArray &buf)
+ {
+ return QString::fromLocal8Bit(buf);
+ }
+ static inline QString fromstrerror_helper(const char *str, const QByteArray &)
+ {
+ return QString::fromLocal8Bit(str);
+ }
+}
+#endif
+
+static QString standardLibraryErrorString(int errorCode)
+{
+ const char *s = 0;
+ QString ret;
+ switch (errorCode) {
+ case 0:
+ break;
+ case EACCES:
+ s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied");
+ break;
+ case EMFILE:
+ s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files");
+ break;
+ case ENOENT:
+ s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory");
+ break;
+ case ENOSPC:
+ s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
+ break;
+ default: {
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ QByteArray buf(1024, '\0');
+ ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
+ #else
+ ret = QString::fromLocal8Bit(strerror(errorCode));
+ #endif
+ break; }
+ }
+ if (s) {
+ // ######## this breaks moc build currently
+ // ret = QCoreApplication::translate("QIODevice", s);
+ ret = QString::fromLatin1(s);
+ }
+ return ret.trimmed();
+}
+
+#ifdef Q_OS_WIN
+static QString windowsErrorString(int errorCode)
+{
+ QString ret;
+ wchar_t *string = 0;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPWSTR)&string,
+ 0,
+ NULL);
+ ret = QString::fromWCharArray(string);
+ LocalFree((HLOCAL)string);
+
+ if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
+ ret = QString::fromLatin1("The specified module could not be found.");
+ return ret;
+}
+#endif
+
+#ifdef Q_OS_SYMBIAN
+static QString symbianErrorString(int errorCode)
+{
+ switch (errorCode) {
+ case KErrNotFound:
+ return QLatin1String("not found");
+ case KErrCancel:
+ return QLatin1String("cancelled");
+ case KErrNoMemory:
+ return QLatin1String("out of memory");
+ case KErrNotSupported:
+ return QLatin1String("not supported");
+ case KErrBadHandle:
+ return QLatin1String("bad handle"); //KERN-EXEC 0 panic is more likely
+ case KErrAlreadyExists:
+ return QLatin1String("already exists");
+ case KErrPathNotFound:
+ return QLatin1String("path not found");
+ case KErrInUse:
+ return QLatin1String("in use");
+ case KErrNotReady:
+ return QLatin1String("not ready (e.g. FS dismounted, no memory card)");
+ case KErrCorrupt:
+ return QLatin1String("corrupt");
+ case KErrAccessDenied:
+ return QLatin1String("access denied");
+ case KErrLocked:
+ return QLatin1String("locked");
+ case KErrWrite:
+ return QLatin1String("incomplete write error");
+ case KErrDisMounted:
+ return QLatin1String("file system dismounted during operation"); //i.e. a forcible dismount was done while we had files open
+ case KErrEof:
+ return QLatin1String("end of file");
+ case KErrDiskFull:
+ return QLatin1String("no space in file system");
+ case KErrBadName:
+ return QLatin1String("invalid filename");
+ case KErrTimedOut:
+ return QLatin1String("timed out");
+ case KErrBadDescriptor:
+ return QLatin1String("bad descriptor (passed address on stack to async call?)");
+ case KErrAbort:
+ return QLatin1String("aborted");
+ case KErrTooBig:
+ return QLatin1String("too big"); //e.g. trying to open a >2GB file with 32 bit API
+ case KErrBadPower:
+ return QLatin1String("insufficient power");
+ case KErrDirFull:
+ return QLatin1String("no space in directory table");
+ case KErrHardwareNotAvailable:
+ return QLatin1String("hardware not available");
+ case KErrSessionClosed:
+ return QLatin1String("session closed");
+ case KErrPermissionDenied:
+ return QLatin1String("permission denied");
+ default:
+ return QString(QLatin1String("symbian error %d")).arg(errorCode);
+ }
+}
+#endif
+
+QString QSystemError::toString()
+{
+ switch(errorScope) {
+ case NativeError:
+#if defined (Q_OS_WIN)
+ return windowsErrorString(errorCode);
+#elif defined (Q_OS_SYMBIAN)
+ return symbianErrorString(errorCode);
+#else
+ //unix: fall through as native and standard library are the same
+#endif
+ case StandardLibraryError:
+ return standardLibraryErrorString(errorCode);
+ default:
+ qWarning("invalid error scope");
+ //fall through
+ case NoError:
+ return QLatin1String("No error");
+ }
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
new file mode 100644
index 0000000..e96e85a
--- /dev/null
+++ b/src/corelib/kernel/qsystemerror_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 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 QSYSTEMERROR_P_H
+#define QSYSTEMERROR_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 <qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QSystemError
+{
+public:
+ enum ErrorScope
+ {
+ NoError,
+ StandardLibraryError,
+ NativeError
+ };
+
+ inline QSystemError(int error, ErrorScope scope);
+ inline QSystemError();
+
+ QString toString();
+ inline ErrorScope scope();
+ inline int error();
+
+ //data members
+ int errorCode;
+ ErrorScope errorScope;
+};
+
+QSystemError::QSystemError(int error, QSystemError::ErrorScope scope)
+: errorCode(error), errorScope(scope)
+{
+
+}
+
+QSystemError::QSystemError()
+: errorCode(0), errorScope(NoError)
+{
+
+}
+
+QSystemError::ErrorScope QSystemError::scope()
+{
+ return errorScope;
+}
+
+int QSystemError::error()
+{
+ return errorCode;
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QSYSTEMERROR_P_H
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index 9a58d32..a68abd3 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -50,11 +50,11 @@
#include <sys/types.h>
#include <sys/ipc.h>
+#include <sys/sem.h>
#include <fcntl.h>
#include <errno.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
+#include "private/qcore_unix_p.h"
// OpenBSD 4.2 doesn't define EIDRM, see BUGS section:
// http://www.openbsd.org/cgi-bin/man.cgi?query=semop&manpath=OpenBSD+4.2
@@ -218,7 +218,10 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
operation.sem_num = 0;
operation.sem_op = count;
operation.sem_flg = SEM_UNDO;
- if (-1 == semop(semaphore, &operation, 1)) {
+
+ register int res;
+ EINTR_LOOP(res, semop(semaphore, &operation, 1));
+ if (-1 == res) {
// If the semaphore was removed be nice and create it and then modifySemaphore again
if (errno == EINVAL || errno == EIDRM) {
semaphore = -1;
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 73a32c4..3570564 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/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 3741ae1..f065238 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -947,11 +947,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
-#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- *f = (double)(qlonglong)qMetaTypeUNumber(d);
-#else
*f = double(qMetaTypeUNumber(d));
-#endif
break;
default:
*f = 0.0;
@@ -986,11 +982,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
-#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- *f = (float)(qlonglong)qMetaTypeUNumber(d);
-#else
*f = float(qMetaTypeUNumber(d));
-#endif
break;
default:
*f = 0.0f;
@@ -1084,7 +1076,7 @@ static void streamDebug(QDebug dbg, const QVariant &v)
dbg.nospace() << v.toFloat();
break;
case QMetaType::QObjectStar:
- dbg.nospace() << qVariantValue<QObject *>(v);
+ dbg.nospace() << qvariant_cast<QObject *>(v);
break;
case QVariant::Double:
dbg.nospace() << v.toDouble();
@@ -1245,7 +1237,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
conversion functions to data types defined in QtGui, such as
QColor, QImage, and QPixmap. In other words, there is no \c
toColor() function. Instead, you can use the QVariant::value() or
- the qVariantValue() template function. For example:
+ the qvariant_cast() template function. For example:
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 2
@@ -1360,12 +1352,12 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
Note that you have to pass the address of the variable you want stored.
- Usually, you never have to use this constructor, use qVariantFromValue()
+ Usually, you never have to use this constructor, use QVariant::fromValue()
instead to construct variants from the pointer types represented by
\c QMetaType::VoidStar, \c QMetaType::QObjectStar and
\c QMetaType::QWidgetStar.
- \sa qVariantFromValue(), Type
+ \sa QVariant::fromValue(), Type
*/
/*!
@@ -1816,6 +1808,14 @@ QVariant& QVariant::operator=(const QVariant &variant)
}
/*!
+ \fn void QVariant::swap(QVariant &other)
+ \since 4.8
+
+ Swaps variant \a other with this variant. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn void QVariant::detach()
\internal
@@ -3074,10 +3074,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 4
- \warning This function is not available with MSVC 6. Use
- qVariantSetValue() instead if you need to support that version of
- the compiler.
-
\sa value(), fromValue(), canConvert()
*/
@@ -3095,10 +3091,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 5
- \warning This function is not available with MSVC 6. Use
- qVariantValue() or qvariant_cast() instead if you need to support
- that version of the compiler.
-
\sa setValue(), fromValue(), canConvert()
*/
@@ -3111,10 +3103,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 6
- \warning This function is not available with MSVC 6. Use
- qVariantCanConvert() instead if you need to support that version
- of the compiler.
-
\sa convert()
*/
@@ -3130,23 +3118,22 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\note If you are working with custom types, you should use
the Q_DECLARE_METATYPE() macro to register your custom type.
- \warning This function is not available with MSVC 6. Use
- qVariantFromValue() instead if you need to support that version
- of the compiler.
-
\sa setValue(), value()
*/
/*!
\fn QVariant qVariantFromValue(const T &value)
\relates QVariant
+ \obsolete
Returns a variant containing a copy of the given \a value
with template type \c{T}.
- This function is equivalent to QVariant::fromValue(\a value). It
- is provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ This function is equivalent to QVariant::fromValue(\a value).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
For example, a QObject pointer can be stored in a variant with the
following code:
@@ -3158,13 +3145,16 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
/*! \fn void qVariantSetValue(QVariant &variant, const T &value)
\relates QVariant
+ \obsolete
Sets the contents of the given \a variant to a copy of the
\a value with the specified template type \c{T}.
- This function is equivalent to QVariant::setValue(\a value). It
- is provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ This function is equivalent to QVariant::setValue(\a value).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QVariant::setValue()
*/
@@ -3175,33 +3165,39 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
Returns the given \a value converted to the template type \c{T}.
- This function is equivalent to qVariantValue().
+ This function is equivalent to QVariant::value().
- \sa qVariantValue(), QVariant::value()
+ \sa QVariant::value()
*/
/*! \fn T qVariantValue(const QVariant &value)
\relates QVariant
+ \obsolete
Returns the given \a value converted to the template type \c{T}.
This function is equivalent to
- \l{QVariant::value()}{QVariant::value}<T>(\a value). It is
- provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ \l{QVariant::value()}{QVariant::value}<T>(\a value).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QVariant::value(), qvariant_cast()
*/
/*! \fn bool qVariantCanConvert(const QVariant &value)
\relates QVariant
+ \obsolete
Returns true if the given \a value can be converted to the
template type specified; otherwise returns false.
- This function is equivalent to QVariant::canConvert(\a value). It
- is provided as a work-around for MSVC 6, which doesn't support
- member template functions.
+ This function is equivalent to QVariant::canConvert(\a value).
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QVariant::canConvert()
*/
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index d9bc49a..1b8cb7f 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -83,19 +83,11 @@ class QUrl;
class QVariant;
class QVariantComparisonHelper;
-#ifndef QT_NO_MEMBER_TEMPLATES
template <typename T>
inline QVariant qVariantFromValue(const T &);
-template <typename T>
-inline void qVariantSetValue(QVariant &, const T &);
-
template<typename T>
-inline T qVariantValue(const QVariant &);
-
-template<typename T>
-inline bool qVariantCanConvert(const QVariant &);
-#endif
+inline T qvariant_cast(const QVariant &);
class Q_CORE_EXPORT QVariant
{
@@ -227,6 +219,12 @@ class Q_CORE_EXPORT QVariant
QVariant(Qt::GlobalColor color);
QVariant& operator=(const QVariant &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QVariant &operator=(QVariant &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+
+ inline void swap(QVariant &other) { qSwap(d, other.d); }
Type type() const;
int userType() const;
@@ -327,13 +325,12 @@ class Q_CORE_EXPORT QVariant
const void *constData() const;
inline const void *data() const { return constData(); }
-#ifndef QT_NO_MEMBER_TEMPLATES
template<typename T>
inline void setValue(const T &value);
template<typename T>
inline T value() const
- { return qVariantValue<T>(*this); }
+ { return qvariant_cast<T>(*this); }
template<typename T>
static inline QVariant fromValue(const T &value)
@@ -341,8 +338,7 @@ class Q_CORE_EXPORT QVariant
template<typename T>
bool canConvert() const
- { return qVariantCanConvert<T>(*this); }
-#endif
+ { return canConvert(Type(qMetaTypeId<T>())); }
public:
#ifndef qdoc
@@ -527,11 +523,9 @@ inline QSize &QVariant::asSize()
{ return *reinterpret_cast<QSize *>(castOrDetach(Size)); }
#endif //QT3_SUPPORT
-#ifndef QT_NO_MEMBER_TEMPLATES
template<typename T>
inline void QVariant::setValue(const T &avalue)
{ qVariantSetValue(*this, avalue); }
-#endif
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant& p);
@@ -594,16 +588,16 @@ template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
return v;
}
+#ifdef QT_DEPRECATED
template<typename T>
-inline T qVariantValue(const QVariant &variant)
+inline QT_DEPRECATED T qVariantValue(const QVariant &variant)
{ return qvariant_cast<T>(variant); }
template<typename T>
-inline bool qVariantCanConvert(const QVariant &variant)
-{
- return variant.canConvert(static_cast<QVariant::Type>(
- qMetaTypeId<T>(static_cast<T *>(0))));
-}
+inline QT_DEPRECATED bool qVariantCanConvert(const QVariant &variant)
+{ return variant.template canConvert<T>(); }
+#endif
+
#endif
Q_DECLARE_SHARED(QVariant)
Q_DECLARE_TYPEINFO(QVariant, Q_MOVABLE_TYPE);
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index ba86353..eb7a7f7 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -8,13 +8,15 @@ HEADERS += \
plugin/qplugin.h \
plugin/quuid.h \
plugin/qfactoryloader_p.h \
- plugin/qsystemlibrary_p.h
+ plugin/qsystemlibrary_p.h \
+ plugin/qelfparser_p.h
SOURCES += \
plugin/qpluginloader.cpp \
plugin/qfactoryloader.cpp \
plugin/quuid.cpp \
- plugin/qlibrary.cpp
+ plugin/qlibrary.cpp \
+ plugin/qelfparser_p.cpp
win32 {
SOURCES += \
@@ -26,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/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
new file mode 100644
index 0000000..198c6d7
--- /dev/null
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** 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 "qelfparser_p.h"
+
+#ifndef QT_NO_LIBRARY
+#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
+
+#include "qlibrary_p.h"
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+// #define QELFPARSER_DEBUG 1
+
+const char *QElfParser::parseSectionHeader(const char *data, ElfSectionHeader *sh)
+{
+ sh->name = read<qelfword_t>(data);
+ data += sizeof(qelfword_t); // sh_name
+ sh->type = read<qelfword_t>(data);
+ data += sizeof(qelfword_t) // sh_type
+ + sizeof(qelfaddr_t) // sh_flags
+ + sizeof(qelfaddr_t); // sh_addr
+ sh->offset = read<qelfoff_t>(data);
+ data += sizeof(qelfoff_t); // sh_offset
+ sh->size = read<qelfword_t>(data);
+ data += sizeof(qelfword_t); // sh_size
+ return data;
+}
+
+int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library, QLibraryPrivate *lib, long *pos, ulong *sectionlen)
+{
+#if defined(QELFPARSER_DEBUG)
+ qDebug() << "QElfParser::parse " << library;
+#endif
+
+ if (fdlen < 64){
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is not an ELF object (%2)").arg(library).arg(QLatin1String("file too small"));
+ return NotElf;
+ }
+ const char *data = dataStart;
+ if (qstrncmp(data, "\177ELF", 4) != 0) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is not an ELF object").arg(library);
+ return NotElf;
+ }
+ // 32 or 64 bit
+ if (data[4] != 1 && data[4] != 2) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library).arg(QLatin1String("odd cpu architecture"));
+ return Corrupt;
+ }
+ m_bits = (data[4] << 5);
+
+ /* If you remove this check, to read ELF objects of a different arch, please make sure you modify the typedefs
+ to match the _plugin_ architecture.
+ */
+ if ((sizeof(void*) == 4 && m_bits != 32) || (sizeof(void*) == 8 && m_bits != 64)) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library).arg(QLatin1String("wrong cpu architecture"));
+ return Corrupt;
+ }
+ // endian
+ if (data[5] == 0) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library).arg(QLatin1String("odd endianess"));
+ return Corrupt;
+ }
+ m_endian = (data[5] == 1 ? ElfLittleEndian : ElfBigEndian);
+
+ data += 16 // e_ident
+ + sizeof(qelfhalf_t) // e_type
+ + sizeof(qelfhalf_t) // e_machine
+ + sizeof(qelfword_t) // e_version
+ + sizeof(qelfaddr_t) // e_entry
+ + sizeof(qelfoff_t); // e_phoff
+
+ qelfoff_t e_shoff = read<qelfoff_t> (data);
+ data += sizeof(qelfoff_t) // e_shoff
+ + sizeof(qelfword_t); // e_flags
+
+ qelfhalf_t e_shsize = read<qelfhalf_t> (data);
+
+ if (e_shsize > fdlen) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library).arg(QLatin1String("unexpected e_shsize"));
+ return Corrupt;
+ }
+
+ data += sizeof(qelfhalf_t) // e_ehsize
+ + sizeof(qelfhalf_t) // e_phentsize
+ + sizeof(qelfhalf_t); // e_phnum
+
+ qelfhalf_t e_shentsize = read<qelfhalf_t> (data);
+
+ if (e_shentsize % 4){
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library).arg(QLatin1String("unexpected e_shentsize"));
+ return Corrupt;
+ }
+ data += sizeof(qelfhalf_t); // e_shentsize
+ qelfhalf_t e_shnum = read<qelfhalf_t> (data);
+ data += sizeof(qelfhalf_t); // e_shnum
+ qelfhalf_t e_shtrndx = read<qelfhalf_t> (data);
+ data += sizeof(qelfhalf_t); // e_shtrndx
+
+ if ((quint32)(e_shnum * e_shentsize) > fdlen) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("announced %2 sections, each %3 bytes, exceed file size"))
+ .arg(e_shnum).arg(e_shentsize);
+ return Corrupt;
+ }
+
+#if defined(QELFPARSER_DEBUG)
+ qDebug() << e_shnum << "sections starting at " << ("0x" + QByteArray::number(e_shoff, 16)).data() << "each" << e_shentsize << "bytes";
+#endif
+
+ ElfSectionHeader strtab;
+ qulonglong soff = e_shoff + e_shentsize * (e_shtrndx);
+
+ if ((soff + e_shentsize) > fdlen || soff % 4 || soff == 0) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("shstrtab section header seems to be at %1"))
+ .arg(QString::number(soff, 16));
+ return Corrupt;
+ }
+
+ parseSectionHeader(dataStart + soff, &strtab);
+ m_stringTableFileOffset = strtab.offset;
+
+ if ((quint32)(m_stringTableFileOffset + e_shentsize) >= fdlen || m_stringTableFileOffset == 0) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("string table seems to be at %1"))
+ .arg(QString::number(soff, 16));
+ return Corrupt;
+ }
+
+#if defined(QELFPARSER_DEBUG)
+ qDebug(".shstrtab at 0x%s", QByteArray::number(m_stringTableFileOffset, 16).data());
+#endif
+
+ const char *s = dataStart + e_shoff;
+ for (int i = 0; i < e_shnum; ++i) {
+ ElfSectionHeader sh;
+ parseSectionHeader(s, &sh);
+ if (sh.name == 0) {
+ s += e_shentsize;
+ continue;
+ }
+ const char *shnam = dataStart + m_stringTableFileOffset + sh.name;
+
+ if (m_stringTableFileOffset + sh.name > fdlen) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("section name %2 of %3 behind end of file"))
+ .arg(i).arg(e_shnum);
+ return Corrupt;
+ }
+
+#if defined(QELFPARSER_DEBUG)
+ qDebug() << "++++" << i << shnam;
+#endif
+
+ if (qstrcmp(shnam, ".qtplugin") == 0 || qstrcmp(shnam, ".rodata") == 0) {
+ if (!(sh.type & 0x1)) {
+ if (shnam[1] == 'r') {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("empty .rodata. not a library."));
+ return Corrupt;
+ }
+#if defined(QELFPARSER_DEBUG)
+ qDebug()<<"section is not program data. skipped.";
+#endif
+ s += e_shentsize;
+ continue;
+ }
+
+ if (sh.offset == 0 || (sh.offset + sh.size) > fdlen) {
+ if (lib)
+ lib->errorString = QLibrary::tr("'%1' is an invalid ELF object (%2)").arg(library)
+ .arg(QLatin1String("missing section data. This is not a library."));
+ return Corrupt;
+ }
+ *pos = sh.offset;
+ *sectionlen = sh.size - 1;
+ if (shnam[1] == 'q')
+ return Ok;
+ }
+ s += e_shentsize;
+ }
+ return NoQtSection;
+}
+
+QT_END_NAMESPACE
+
+#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // QT_NO_LIBRARY
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
new file mode 100644
index 0000000..3ccce10
--- /dev/null
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** 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 QELFPARSER_P_H
+#define QELFPARSER_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 <qendian.h>
+#include <qglobal.h>
+
+#ifndef QT_NO_LIBRARY
+#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
+
+QT_BEGIN_NAMESPACE
+
+class QString;
+class QLibraryPrivate;
+
+typedef quint16 qelfhalf_t;
+typedef quint32 qelfword_t;
+typedef quintptr qelfoff_t;
+typedef quintptr qelfaddr_t;
+
+class QElfParser
+{
+public:
+ enum {Ok = 0, NotElf = 1, NoQtSection = 2, Corrupt = 3};
+ enum {ElfLittleEndian = 0, ElfBigEndian = 1};
+
+ struct ElfSectionHeader
+ {
+ qelfword_t name;
+ qelfword_t type;
+ qelfoff_t offset;
+ qelfword_t size;
+ };
+
+ int m_endian;
+ int m_bits;
+ int m_stringTableFileOffset;
+
+ template <typename T>
+ T read(const char *s)
+ {
+ if (m_endian == ElfBigEndian)
+ return qFromBigEndian<T>(reinterpret_cast<const uchar *>(s));
+ else
+ return qFromLittleEndian<T>(reinterpret_cast<const uchar *>(s));
+ }
+
+ const char *parseSectionHeader(const char* s, ElfSectionHeader *sh);
+ int parse(const char *m_s, ulong fdlen, const QString &library, QLibraryPrivate *lib, long *pos, ulong *sectionlen);
+};
+
+QT_END_NAMESPACE
+
+#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // QT_NO_LIBRARY
+
+#endif // QELFPARSER_P_H
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/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index c6ed78a..80e927b 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -1,3 +1,4 @@
+
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
@@ -38,7 +39,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "qplatformdefs.h"
#include "qlibrary.h"
@@ -61,11 +61,10 @@
#include <qdebug.h>
#include <qvector.h>
#include <qdir.h>
+#include "qelfparser_p.h"
QT_BEGIN_NAMESPACE
-//#define QT_DEBUG_COMPONENT
-
#ifdef QT_NO_DEBUG
# define QLIBRARY_AS_DEBUG false
#else
@@ -365,11 +364,35 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB
fdlen = data.size();
}
- // verify that the pattern is present in the plugin
+ /*
+ ELF binaries on GNU, have .qplugin sections.
+ */
+ long pos = 0;
const char pattern[] = "pattern=QT_PLUGIN_VERIFICATION_DATA";
const ulong plen = qstrlen(pattern);
- long pos = qt_find_pattern(filedata, fdlen, pattern, plen);
-
+#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
+ int r = QElfParser().parse(filedata, fdlen, library, lib, &pos, &fdlen);
+ if (r == QElfParser::NoQtSection) {
+ if (pos > 0) {
+ // find inside .rodata
+ long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
+ if (rel < 0) {
+ pos = -1;
+ } else {
+ pos += rel;
+ }
+ } else {
+ pos = qt_find_pattern(filedata, fdlen, pattern, plen);
+ }
+ } else if (r != QElfParser::Ok) {
+ if (lib && qt_debug_component()) {
+ qWarning("QElfParser: %s",qPrintable(lib->errorString));
+ }
+ return false;
+ }
+#else
+ pos = qt_find_pattern(filedata, fdlen, pattern, plen);
+#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
bool ret = false;
if (pos >= 0)
ret = qt_parse_pattern(filedata + pos, version, debug, key);
@@ -392,6 +415,7 @@ struct LibraryData {
QSettings *settings;
LibraryMap libraryMap;
+ QSet<QLibraryPrivate*> loadedLibs;
};
Q_GLOBAL_STATIC(LibraryData, libraryData)
@@ -443,7 +467,18 @@ bool QLibraryPrivate::load()
return true;
if (fileName.isEmpty())
return false;
- return load_sys();
+
+ bool ret = load_sys();
+ if (ret) {
+ //when loading a library we add a reference to it so that the QLibraryPrivate won't get deleted
+ //this allows to unload the library at a later time
+ if (LibraryData *lib = libraryData()) {
+ lib->loadedLibs += this;
+ libraryRefCount.ref();
+ }
+ }
+
+ return ret;
}
bool QLibraryPrivate::unload()
@@ -451,10 +486,16 @@ bool QLibraryPrivate::unload()
if (!pHnd)
return false;
if (!libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to
- if (instance)
- delete instance();
+ delete inst.data();
if (unload_sys()) {
- instance = 0;
+ if (qt_debug_component())
+ qWarning() << "QLibraryPrivate::unload succeeded on" << fileName;
+ //when the library is unloaded, we release the reference on it so that 'this'
+ //can get deleted
+ if (LibraryData *lib = libraryData()) {
+ if (lib->loadedLibs.remove(this))
+ libraryRefCount.deref();
+ }
pHnd = 0;
}
}
@@ -475,6 +516,8 @@ bool QLibraryPrivate::loadPlugin()
libraryUnloadCount.ref();
return true;
}
+ if (pluginState == IsNotAPlugin)
+ return false;
if (load()) {
instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance");
#if defined(Q_OS_SYMBIAN)
@@ -487,6 +530,9 @@ bool QLibraryPrivate::loadPlugin()
#endif
return instance;
}
+ if (qt_debug_component())
+ qWarning() << "QLibraryPrivate::loadPlugin failed on" << fileName << ":" << errorString;
+ pluginState = IsNotAPlugin;
return false;
}
@@ -496,7 +542,7 @@ bool QLibraryPrivate::loadPlugin()
\table
\header \i Platform \i Valid suffixes
- \row \i Windows \i \c .dll
+ \row \i Windows \i \c .dll, \c .DLL
\row \i Unix/Linux \i \c .so
\row \i AIX \i \c .a
\row \i HP-UX \i \c .sl, \c .so (HP-UXi)
@@ -509,7 +555,7 @@ bool QLibraryPrivate::loadPlugin()
bool QLibrary::isLibrary(const QString &fileName)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return fileName.endsWith(QLatin1String(".dll"));
+ return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive);
#elif defined(Q_OS_SYMBIAN)
// Plugin stubs are also considered libraries in Symbian.
return (fileName.endsWith(QLatin1String(".dll")) ||
@@ -571,6 +617,46 @@ bool QLibrary::isLibrary(const QString &fileName)
}
+#if defined (Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_CC_INTEL)
+#define QT_USE_MS_STD_EXCEPTION 1
+const char* qt_try_versioninfo(void *pfn, bool *exceptionThrown)
+{
+ *exceptionThrown = false;
+ const char *szData = 0;
+ typedef const char * (*VerificationFunction)();
+ VerificationFunction func = reinterpret_cast<VerificationFunction>(pfn);
+ __try {
+ if(func)
+ szData = func();
+ } __except(EXCEPTION_EXECUTE_HANDLER) {
+ *exceptionThrown = true;
+ }
+ return szData;
+}
+#endif
+
+#ifdef Q_CC_BOR
+typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)();
+#else
+typedef const char * (*QtPluginQueryVerificationDataFunction)();
+#endif
+
+bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown)
+{
+ *exceptionThrown = false;
+ const char *szData = 0;
+ if (!pfn)
+ return false;
+#ifdef QT_USE_MS_STD_EXCEPTION
+ szData = qt_try_versioninfo((void *)pfn, exceptionThrown);
+ if (*exceptionThrown)
+ return false;
+#else
+ szData = pfn();
+#endif
+ return qt_parse_pattern(szData, qt_version, debug, key);
+}
+
bool QLibraryPrivate::isPlugin(QSettings *settings)
{
errorString.clear();
@@ -606,7 +692,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
.arg((QT_VERSION & 0xff00) >> 8)
.arg(QLIBRARY_AS_DEBUG ? QLatin1String("debug") : QLatin1String("false"))
.arg(fileName);
-#ifdef Q_WS_MAC
+#ifdef Q_WS_MAC
// On Mac, add the application arch to the reg key in order to
// cache plugin information separately for each arch. This prevents
// Qt from wrongly caching plugin load failures when the archs
@@ -621,7 +707,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
regkey += QLatin1String("-ppc");
#endif
#endif // Q_WS_MAC
-
+
QStringList reg;
#ifndef QT_NO_SETTINGS
if (!settings) {
@@ -646,70 +732,82 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
} else
#endif
{
- bool temporary_load = false;
+ bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases)
+ do {
+ bool temporary_load = false;
#ifdef Q_OS_WIN
- HMODULE hTempModule = 0;
+ HMODULE hTempModule = 0;
#endif
- if (!pHnd) {
+ if (!pHnd) {
#ifdef Q_OS_WIN
- //avoid 'Bad Image' message box
- UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
- hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES);
- SetErrorMode(oldmode);
+ DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES;
+ //avoid 'Bad Image' message box
+ UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
+ hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags);
+ SetErrorMode(oldmode);
#else
# if defined(Q_OS_SYMBIAN)
- //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
- if (fileinfo.exists())
+ //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
+ if (fileinfo.exists())
# endif
- temporary_load = load_sys();
+ temporary_load = load_sys();
#endif
- }
-# ifdef Q_CC_BOR
- typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)();
-# else
- typedef const char * (*QtPluginQueryVerificationDataFunction)();
-# endif
+ }
#ifdef Q_OS_WIN
- QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule
- ? (QtPluginQueryVerificationDataFunction)
+ QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction)
#ifdef Q_OS_WINCE
- ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data")
+ ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data")
#else
- ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data")
+ ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data")
#endif
: (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
#else
- QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL;
+ QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL;
# if defined(Q_OS_SYMBIAN)
- if (temporary_load) {
- qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
- // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal
- if (!qtPluginQueryVerificationDataFunction)
- qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1");
- }
+ if (temporary_load) {
+ qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
+ // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal
+ if (!qtPluginQueryVerificationDataFunction)
+ qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1");
+ }
# else
- qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
+ qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
# endif
#endif
-
- if (!qtPluginQueryVerificationDataFunction
- || !qt_parse_pattern(qtPluginQueryVerificationDataFunction(), &qt_version, &debug, &key)) {
- qt_version = 0;
- key = "unknown";
- if (temporary_load)
- unload_sys();
- } else {
- success = true;
- }
-#ifdef Q_OS_WIN
- if (hTempModule) {
- BOOL ok = ::FreeLibrary(hTempModule);
- if (ok) {
- hTempModule = 0;
+ bool exceptionThrown = false;
+ bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction,
+ &qt_version, &debug, &key, &exceptionThrown);
+ if (!exceptionThrown) {
+ if (!ret) {
+ qt_version = 0;
+ key = "unknown";
+ if (temporary_load)
+ unload_sys();
+ } else {
+ success = true;
+ }
+ retryLoadLibrary = false;
+ }
+#ifdef QT_USE_MS_STD_EXCEPTION
+ else {
+ // An exception was thrown when calling qt_plugin_query_verification_data().
+ // This usually happens when plugin is compiled with the /clr compiler flag,
+ // & will only work if the dependencies are loaded & DLLMain() is called.
+ // LoadLibrary() will do this, try once with this & if it fails dont load.
+ retryLoadLibrary = !retryLoadLibrary;
}
+#endif
+#ifdef Q_OS_WIN
+ if (hTempModule) {
+ BOOL ok = ::FreeLibrary(hTempModule);
+ if (ok) {
+ hTempModule = 0;
+ }
- }
+ }
#endif
+ } while(retryLoadLibrary); // Will be 'false' in all cases other than when an
+ // exception is thrown(will happen only when using a MS compiler)
}
// Qt 4.5 compatibility: stl doesn't affect binary compatibility
@@ -759,6 +857,9 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
#ifdef QT_BUILD_KEY_COMPAT2
&& key != QT_BUILD_KEY_COMPAT2
#endif
+#ifdef QT_BUILD_KEY_COMPAT3
+ && key != QT_BUILD_KEY_COMPAT3
+#endif
) {
if (qt_debug_component()) {
qWarning("In %s:\n"
@@ -1039,7 +1140,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
*/
void *QLibrary::resolve(const char *symbol)
{
- if (!load())
+ if (!isLoaded() && !load())
return 0;
return d->resolve(symbol);
}
@@ -1182,15 +1283,11 @@ QLibrary::LoadHints QLibrary::loadHints() const
/* Internal, for debugging */
bool qt_debug_component()
{
-#if defined(QT_DEBUG_COMPONENT)
- return true; //compatibility?
-#else
static int debug_env = -1;
if (debug_env == -1)
debug_env = QT_PREPEND_NAMESPACE(qgetenv)("QT_DEBUG_PLUGINS").toInt();
return debug_env != 0;
-#endif
}
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index 2650ffe..e2e16d9 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -60,6 +60,7 @@
#include "QtCore/qpointer.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qplugin.h"
+#include "QtCore/qsharedpointer.h"
#ifndef QT_NO_LIBRARY
@@ -90,6 +91,7 @@ public:
static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString());
+ QWeakPointer<QObject> inst;
QtPluginInstanceFunction instance;
uint qt_version;
QString lastModified;
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 9dad7e6..e32729a 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -56,9 +56,13 @@
#include <string.h>
#endif
+#if defined(Q_OS_VXWORKS) || defined (Q_OS_NACL)
+#define QT_NO_DYNAMIC_LIBRARY
+#endif
+
QT_BEGIN_NAMESPACE
-#if !defined(QT_HPUX_LD) && !defined(Q_OS_VXWORKS)
+#if !defined(QT_HPUX_LD) && !defined(QT_NO_DYNAMIC_LIBRARY)
QT_BEGIN_INCLUDE_NAMESPACE
#include <dlfcn.h>
QT_END_INCLUDE_NAMESPACE
@@ -66,8 +70,8 @@ QT_END_INCLUDE_NAMESPACE
static QString qdlerror()
{
-#if defined(Q_OS_VXWORKS)
- const char *err = "VxWorks does not support dynamic libraries.";
+#if defined(QT_NO_DYNAMIC_LIBRARY)
+ const char *err = "This platform does not support dynamic libraries.";
#elif !defined(QT_HPUX_LD)
const char *err = dlerror();
#else
@@ -79,7 +83,7 @@ static QString qdlerror()
bool QLibraryPrivate::load_sys()
{
QString attempt;
-#if !defined(Q_OS_VXWORKS)
+#if !defined(QT_NO_DYNAMIC_LIBRARY)
QFileInfo fi(fileName);
#if defined(Q_OS_SYMBIAN)
@@ -223,15 +227,19 @@ bool QLibraryPrivate::load_sys()
#ifdef Q_OS_MAC
if (!pHnd) {
- if (CFBundleRef bundle = CFBundleGetBundleWithIdentifier(QCFString(fileName))) {
+ QByteArray utf8Bundle = fileName.toUtf8();
+ QCFType<CFURLRef> bundleUrl = CFURLCreateFromFileSystemRepresentation(NULL, reinterpret_cast<const UInt8*>(utf8Bundle.data()), utf8Bundle.length(), true);
+ QCFType<CFBundleRef> bundle = CFBundleCreate(NULL, bundleUrl);
+ if(bundle) {
QCFType<CFURLRef> url = CFBundleCopyExecutableURL(bundle);
- QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
- pHnd = dlopen(QFile::encodeName(str), dlFlags);
- attempt = str;
+ char executableFile[FILENAME_MAX];
+ CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(executableFile), FILENAME_MAX);
+ attempt = QString::fromUtf8(executableFile);
+ pHnd = dlopen(QFile::encodeName(attempt), dlFlags);
}
}
#endif
-#endif // Q_OS_VXWORKS
+#endif // QT_NO_DYNAMIC_LIBRARY
if (!pHnd) {
errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qdlerror());
}
@@ -244,7 +252,7 @@ bool QLibraryPrivate::load_sys()
bool QLibraryPrivate::unload_sys()
{
-#if !defined(Q_OS_VXWORKS)
+#if !defined(QT_NO_DYNAMIC_LIBRARY)
# if defined(QT_HPUX_LD)
if (shl_unload((shl_t)pHnd)) {
# else
@@ -278,7 +286,7 @@ void* QLibraryPrivate::resolve_sys(const char* symbol)
void* address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
-#elif defined(Q_OS_VXWORKS)
+#elif defined (QT_NO_DYNAMIC_LIBRARY)
void *address = 0;
#else
void* address = dlsym(pHnd, symbol);
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index d8e4bf3..2fe67ae 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -101,13 +101,17 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio
// NOTE: if you change pattern, you MUST change the pattern in
// qlibrary.cpp as well. changing the pattern will break all
// backwards compatibility as well (no old plugins will be loaded).
+// QT5: should probably remove the entire pattern thing and do the section
+// trick for all platforms. for now, keep it and fallback to scan for it.
# ifdef QPLUGIN_DEBUG_STR
# undef QPLUGIN_DEBUG_STR
# endif
# ifdef QT_NO_DEBUG
# define QPLUGIN_DEBUG_STR "false"
+# define QPLUGIN_SECTION_DEBUG_STR ""
# else
# define QPLUGIN_DEBUG_STR "true"
+# define QPLUGIN_SECTION_DEBUG_STR ".debug"
# endif
# define Q_PLUGIN_VERIFICATION_DATA \
static const char qt_plugin_verification_data[] = \
@@ -116,6 +120,13 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio
"debug="QPLUGIN_DEBUG_STR"\n" \
"buildkey="QT_BUILD_KEY;
+# if defined (Q_OF_ELF) && defined (Q_CC_GNU)
+# define Q_PLUGIN_VERIFICATION_SECTION \
+ __attribute__ ((section (".qtplugin"))) __attribute__((used))
+# else
+# define Q_PLUGIN_VERIFICATION_SECTION
+# endif
+
# if defined (Q_OS_WIN32) && defined(Q_CC_BOR)
# define Q_STANDARD_CALL __stdcall
# else
@@ -123,7 +134,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginInstanceFunction(QtPluginInstanceFunctio
# endif
# define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS) \
- Q_PLUGIN_VERIFICATION_DATA \
+ Q_PLUGIN_VERIFICATION_SECTION Q_PLUGIN_VERIFICATION_DATA \
Q_EXTERN_C Q_DECL_EXPORT \
const char * Q_STANDARD_CALL qt_plugin_query_verification_data() \
{ return qt_plugin_verification_data; } \
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 399eb8d..2997293 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -198,11 +198,11 @@ QPluginLoader::~QPluginLoader()
*/
QObject *QPluginLoader::instance()
{
- if (!load())
+ if (!isLoaded() && !load())
return 0;
- if (d->instance)
- return d->instance();
- return 0;
+ if (!d->inst && d->instance)
+ d->inst = d->instance();
+ return d->inst.data();
}
/*!
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index e52d73e..b2af5ca 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -793,7 +793,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
}
// We require that at least one animation is valid.
// ### generalize
- QList<QVariantAnimation*> variantAnims = qFindChildren<QVariantAnimation*>(anim);
+ QList<QVariantAnimation*> variantAnims = anim->findChildren<QVariantAnimation*>();
if (QVariantAnimation *va = qobject_cast<QVariantAnimation*>(anim))
variantAnims.append(va);
@@ -1178,7 +1178,7 @@ void QStateMachinePrivate::removeStartState()
void QStateMachinePrivate::clearHistory()
{
Q_Q(QStateMachine);
- QList<QHistoryState*> historyStates = qFindChildren<QHistoryState*>(q);
+ QList<QHistoryState*> historyStates = q->findChildren<QHistoryState*>();
for (int i = 0; i < historyStates.size(); ++i) {
QHistoryState *h = historyStates.at(i);
QHistoryStatePrivate::get(h)->configuration.clear();
@@ -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;
@@ -1389,7 +1392,7 @@ void QStateMachinePrivate::cancelAllDelayedEvents()
delayedEvents.clear();
}
-namespace {
+namespace _QStateMachine_Internal{
class GoToStateTransition : public QAbstractTransition
{
@@ -1403,7 +1406,9 @@ protected:
};
} // namespace
-
+// mingw compiler tries to export QObject::findChild<GoToStateTransition>(),
+// which doesn't work if its in an anonymous namespace.
+using namespace _QStateMachine_Internal;
/*!
\internal
@@ -1440,7 +1445,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState)
Q_ASSERT(sourceState != 0);
// Reuse previous GoToStateTransition in case of several calls to
// goToState() in a row.
- GoToStateTransition *trans = qFindChild<GoToStateTransition*>(sourceState);
+ GoToStateTransition *trans = sourceState->findChild<GoToStateTransition*>();
if (!trans) {
trans = new GoToStateTransition(targetState);
sourceState->addTransition(trans);
@@ -1562,7 +1567,7 @@ void QStateMachinePrivate::unregisterAllTransitions()
{
Q_Q(QStateMachine);
{
- QList<QSignalTransition*> transitions = qFindChildren<QSignalTransition*>(rootState());
+ QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>();
for (int i = 0; i < transitions.size(); ++i) {
QSignalTransition *t = transitions.at(i);
if (t->machine() == q)
@@ -1570,7 +1575,7 @@ void QStateMachinePrivate::unregisterAllTransitions()
}
}
{
- QList<QEventTransition*> transitions = qFindChildren<QEventTransition*>(rootState());
+ QList<QEventTransition*> transitions = rootState()->findChildren<QEventTransition*>();
for (int i = 0; i < transitions.size(); ++i) {
QEventTransition *t = transitions.at(i);
if (t->machine() == q)
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index cafcfef..001506c 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -45,6 +45,7 @@
#ifndef QT_NO_THREAD
#include "qatomic.h"
+#include "qelapsedtimer.h"
#include "qthread.h"
#include "qmutex_p.h"
@@ -130,7 +131,7 @@ QMutex::QMutex(RecursionMode mode)
\warning Destroying a locked mutex may result in undefined behavior.
*/
QMutex::~QMutex()
-{ delete d; }
+{ delete static_cast<QMutexPrivate *>(d); }
/*!
Locks the mutex. If another thread has locked the mutex then this
@@ -146,6 +147,7 @@ QMutex::~QMutex()
*/
void QMutex::lock()
{
+ QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
Qt::HANDLE self;
if (d->recursive) {
@@ -156,20 +158,12 @@ void QMutex::lock()
return;
}
- bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
+ bool isLocked = d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
-#ifndef QT_NO_DEBUG
- if (d->owner == self)
- qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner;
-#endif
-
// didn't get the lock, wait for it
isLocked = d->wait();
Q_ASSERT_X(isLocked, "QMutex::lock",
"Internal error, infinite wait has timed out.");
-
- // don't need to wait for the lock anymore
- d->contenders.deref();
}
d->owner = self;
@@ -178,54 +172,10 @@ void QMutex::lock()
return;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
-
- bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
+ bool isLocked = d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
- int spinCount = 0;
- int lastSpinCount = d->lastSpinCount;
-
- enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 };
- const int maximumSpinCount = lastSpinCount + AdditionalSpins;
-
- do {
- if (spinCount++ > maximumSpinCount) {
- // puts("spinning useless, sleeping");
- isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- if (!isLocked) {
-#ifndef QT_NO_DEBUG
- if (d->owner == self)
- qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner;
-#endif
-
- // didn't get the lock, wait for it
- isLocked = d->wait();
- Q_ASSERT_X(isLocked, "QMutex::lock",
- "Internal error, infinite wait has timed out.");
-
- // don't need to wait for the lock anymore
- d->contenders.deref();
- }
- // decrease the lastSpinCount since we didn't actually get the lock by spinning
- spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor;
- break;
- }
-
- isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- } while (!isLocked);
-
- // adjust the last spin lock count
- lastSpinCount = d->lastSpinCount;
- d->lastSpinCount = spinCount >= 0
- ? qMax(lastSpinCount, spinCount)
- : lastSpinCount + spinCount;
+ lockInternal();
}
-
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
}
/*!
@@ -247,6 +197,7 @@ void QMutex::lock()
*/
bool QMutex::tryLock()
{
+ QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
Qt::HANDLE self;
if (d->recursive) {
@@ -257,7 +208,7 @@ bool QMutex::tryLock()
return true;
}
- bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
+ bool isLocked = d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
// some other thread has the mutex locked, or we tried to
// recursively lock an non-recursive mutex
@@ -270,19 +221,7 @@ bool QMutex::tryLock()
return isLocked;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
- bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
- if (!isLocked) {
- // some other thread has the mutex locked, or we tried to
- // recursively lock an non-recursive mutex
- return isLocked;
- }
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
- return isLocked;
+ return d->contenders.testAndSetAcquire(0, 1);
}
/*! \overload
@@ -310,6 +249,7 @@ bool QMutex::tryLock()
*/
bool QMutex::tryLock(int timeout)
{
+ QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
Qt::HANDLE self;
if (d->recursive) {
@@ -320,13 +260,10 @@ bool QMutex::tryLock(int timeout)
return true;
}
- bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
+ bool isLocked = d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
// didn't get the lock, wait for it
isLocked = d->wait(timeout);
-
- // don't need to wait for the lock anymore
- d->contenders.deref();
if (!isLocked)
return false;
}
@@ -337,23 +274,9 @@ bool QMutex::tryLock(int timeout)
return true;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
- bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
- if (!isLocked) {
- // didn't get the lock, wait for it
- isLocked = d->wait(timeout);
-
- // don't need to wait for the lock anymore
- d->contenders.deref();
- if (!isLocked)
- return false;
- }
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
- return true;
+ return (d->contenders.testAndSetAcquire(0, 1)
+ // didn't get the lock, wait for it
+ || d->wait(timeout));
}
@@ -366,9 +289,7 @@ bool QMutex::tryLock(int timeout)
*/
void QMutex::unlock()
{
- Q_ASSERT_X(d->owner == QThread::currentThreadId(), "QMutex::unlock()",
- "A mutex must be unlocked in the same thread that locked it.");
-
+ QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
if (d->recursive) {
if (!--d->count) {
d->owner = 0;
@@ -376,9 +297,6 @@ void QMutex::unlock()
d->wakeUp();
}
} else {
-#ifndef QT_NO_DEBUG
- d->owner = 0;
-#endif
if (!d->contenders.testAndSetRelease(1, 0))
d->wakeUp();
}
@@ -506,6 +424,92 @@ void QMutex::unlock()
Use the constructor that takes a RecursionMode parameter instead.
*/
+/*!
+ \internal helper for lockInline()
+ */
+void QMutex::lockInternal()
+{
+ QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
+
+ if (QThread::idealThreadCount() == 1) {
+ // don't spin on single cpu machines
+ bool isLocked = d->wait();
+ Q_ASSERT_X(isLocked, "QMutex::lock",
+ "Internal error, infinite wait has timed out.");
+ Q_UNUSED(isLocked);
+ return;
+ }
+
+ QElapsedTimer elapsedTimer;
+ elapsedTimer.start();
+ do {
+ qint64 spinTime = elapsedTimer.nsecsElapsed();
+ if (spinTime > d->maximumSpinTime) {
+ // didn't get the lock, wait for it, since we're not going to gain anything by spinning more
+ elapsedTimer.start();
+ bool isLocked = d->wait();
+ Q_ASSERT_X(isLocked, "QMutex::lock",
+ "Internal error, infinite wait has timed out.");
+ Q_UNUSED(isLocked);
+
+ qint64 maximumSpinTime = d->maximumSpinTime;
+ qint64 averageWaitTime = d->averageWaitTime;
+ qint64 actualWaitTime = elapsedTimer.nsecsElapsed();
+ if (actualWaitTime < (QMutexPrivate::MaximumSpinTimeThreshold * 3 / 2)) {
+ // measure the wait times
+ averageWaitTime = d->averageWaitTime = qMin((averageWaitTime + actualWaitTime) / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
+ }
+
+ // adjust the spin count when spinning does not benefit contention performance
+ if ((spinTime + actualWaitTime) - qint64(QMutexPrivate::MaximumSpinTimeThreshold) >= qint64(QMutexPrivate::MaximumSpinTimeThreshold)) {
+ // long waits, stop spinning
+ d->maximumSpinTime = 0;
+ } else {
+ // allow spinning if wait times decrease, but never spin more than the average wait time (otherwise we may perform worse)
+ d->maximumSpinTime = qBound(qint64(averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
+ }
+ return;
+ }
+ // be a good citizen... yielding lets something else run if there is something to run, but may also relieve memory pressure if not
+ QThread::yieldCurrentThread();
+ } while (d->contenders != 0 || !d->contenders.testAndSetAcquire(0, 1));
+
+ // spinning is working, do not change the spin time (unless we are using much less time than allowed to spin)
+ qint64 maximumSpinTime = d->maximumSpinTime;
+ qint64 spinTime = elapsedTimer.nsecsElapsed();
+ if (spinTime < maximumSpinTime / 2) {
+ // we are using much less time than we need, adjust the limit
+ d->maximumSpinTime = qBound(qint64(d->averageWaitTime * 3 / 2), maximumSpinTime / 2, qint64(QMutexPrivate::MaximumSpinTimeThreshold));
+ }
+}
+
+/*!
+ \internal
+*/
+void QMutex::unlockInternal()
+{
+ static_cast<QMutexPrivate *>(d)->wakeUp();
+}
+
+/*!
+ \fn QMutex::lockInline()
+ \internal
+ inline version of QMutex::lock()
+*/
+
+/*!
+ \fn QMutex::unlockInline()
+ \internal
+ inline version of QMutex::unlock()
+*/
+
+/*!
+ \fn QMutex::tryLockInline()
+ \internal
+ inline version of QMutex::tryLock()
+*/
+
+
QT_END_NAMESPACE
#endif // QT_NO_THREAD
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 52a0fc3..5f75195 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -43,6 +43,7 @@
#define QMUTEX_H
#include <QtCore/qglobal.h>
+#include <QtCore/qatomic.h>
#include <new>
QT_BEGIN_HEADER
@@ -53,7 +54,8 @@ QT_MODULE(Core)
#ifndef QT_NO_THREAD
-class QMutexPrivate;
+class QAtomicInt;
+class QMutexData;
class Q_CORE_EXPORT QMutex
{
@@ -66,10 +68,13 @@ public:
explicit QMutex(RecursionMode mode = NonRecursive);
~QMutex();
- void lock();
- bool tryLock();
+ void lock(); //### Qt5: make inline;
+ inline void lockInline();
+ bool tryLock(); //### Qt5: make inline;
bool tryLock(int timeout);
- void unlock();
+ inline bool tryLockInline();
+ void unlock(); //### Qt5: make inline;
+ inline void unlockInline();
#if defined(QT3_SUPPORT)
inline QT3_SUPPORT bool locked()
@@ -86,9 +91,11 @@ public:
#endif
private:
+ void lockInternal();
+ void unlockInternal();
Q_DISABLE_COPY(QMutex)
- QMutexPrivate *d;
+ QMutexData *d;
};
class Q_CORE_EXPORT QMutexLocker
@@ -99,7 +106,7 @@ public:
Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
"QMutexLocker", "QMutex pointer is misaligned");
if (m) {
- m->lock();
+ m->lockInline();
val = reinterpret_cast<quintptr>(m) | quintptr(1u);
} else {
val = 0;
@@ -111,7 +118,7 @@ public:
{
if ((val & quintptr(1u)) == quintptr(1u)) {
val &= ~quintptr(1u);
- mutex()->unlock();
+ mutex()->unlockInline();
}
}
@@ -119,7 +126,7 @@ public:
{
if (val) {
if ((val & quintptr(1u)) == quintptr(0u)) {
- mutex()->lock();
+ mutex()->lockInline();
val |= quintptr(1u);
}
}
@@ -145,6 +152,53 @@ private:
quintptr val;
};
+class QMutexData
+{
+ public:
+ QAtomicInt contenders;
+ const uint recursive : 1;
+ uint reserved : 31;
+ protected:
+ QMutexData(QMutex::RecursionMode mode);
+ ~QMutexData();
+};
+
+#ifdef QT_NO_DEBUG
+inline void QMutex::unlockInline()
+{
+ if (d->recursive) {
+ unlock();
+ } else if (!d->contenders.testAndSetRelease(1, 0)) {
+ unlockInternal();
+ }
+}
+
+inline bool QMutex::tryLockInline()
+{
+ if (d->recursive) {
+ return tryLock();
+ } else {
+ return d->contenders.testAndSetAcquire(0, 1);
+ }
+}
+
+inline void QMutex::lockInline()
+{
+ if (d->recursive) {
+ lock();
+ } else if(!tryLockInline()) {
+ 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
@@ -157,9 +211,11 @@ public:
inline ~QMutex() {}
static inline void lock() {}
- static inline bool tryLock() { return true; }
- static inline bool tryLock(int timeout) { Q_UNUSED(timeout); return true; }
- static void unlock() {}
+ static inline void lockInline() {}
+ static inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; }
+ static inline bool tryLockInline() { return true; }
+ static inline void unlock() {}
+ static inline void unlockInline() {}
#if defined(QT3_SUPPORT)
static inline QT3_SUPPORT bool locked() { return false; }
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 0373b3f..1a31c87 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -56,25 +56,32 @@
#include <QtCore/qglobal.h>
#include <QtCore/qnamespace.h>
+#include <QtCore/qmutex.h>
+
+#if defined(Q_OS_MAC)
+# include <mach/semaphore.h>
+#endif
QT_BEGIN_NAMESPACE
-class QMutexPrivate {
+class QMutexPrivate : public QMutexData {
public:
QMutexPrivate(QMutex::RecursionMode mode);
~QMutexPrivate();
- ulong self();
bool wait(int timeout = -1);
void wakeUp();
- const bool recursive;
- QAtomicInt contenders;
- volatile int lastSpinCount;
+ // 1ms = 1000000ns
+ enum { MaximumSpinTimeThreshold = 1000000 };
+ volatile qint64 maximumSpinTime;
+ volatile qint64 averageWaitTime;
Qt::HANDLE owner;
uint count;
-#if defined(Q_OS_UNIX)
+#if defined(Q_OS_MAC)
+ semaphore_t mach_semaphore;
+#elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
volatile bool wakeup;
pthread_mutex_t mutex;
pthread_cond_t cond;
@@ -83,6 +90,12 @@ public:
#endif
};
+inline QMutexData::QMutexData(QMutex::RecursionMode mode)
+ : recursive(mode == QMutex::Recursive)
+{}
+
+inline QMutexData::~QMutexData() {}
+
QT_END_NAMESPACE
#endif // QMUTEX_P_H
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index dd7e5d1..11e2060 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -53,30 +53,116 @@
#undef wakeup
#endif
+#if defined(Q_OS_MAC)
+# include <mach/mach.h>
+# include <mach/task.h>
+#elif defined(Q_OS_LINUX)
+# include <linux/futex.h>
+# include <sys/syscall.h>
+# include <unistd.h>
+#endif
+
QT_BEGIN_NAMESPACE
+#if !defined(Q_OS_MAC) && !defined(Q_OS_LINUX)
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
qWarning("%s: %s failure: %s", where, what, qPrintable(qt_error_string(code)));
}
+#endif
QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
- : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0), wakeup(false)
+ : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
{
+#if defined(Q_OS_MAC)
+ kern_return_t r = semaphore_create(mach_task_self(), &mach_semaphore, SYNC_POLICY_FIFO, 0);
+ if (r != KERN_SUCCESS)
+ qWarning("QMutex: failed to create semaphore, error %d", r);
+#elif !defined(Q_OS_LINUX)
+ wakeup = false;
report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
+#endif
}
QMutexPrivate::~QMutexPrivate()
{
+#if defined(Q_OS_MAC)
+ kern_return_t r = semaphore_destroy(mach_task_self(), mach_semaphore);
+ if (r != KERN_SUCCESS)
+ qWarning("QMutex: failed to destroy semaphore, error %d", r);
+#elif !defined(Q_OS_LINUX)
report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
+#endif
+}
+
+#if defined(Q_OS_MAC)
+
+bool QMutexPrivate::wait(int timeout)
+{
+ if (contenders.fetchAndAddAcquire(1) == 0) {
+ // lock acquired without waiting
+ return true;
+ }
+ bool returnValue;
+ if (timeout < 0) {
+ returnValue = semaphore_wait(mach_semaphore) == KERN_SUCCESS;
+ } else {
+ mach_timespec_t ts;
+ ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
+ ts.tv_sec = (timeout / 1000);
+ kern_return_t r = semaphore_timedwait(mach_semaphore, ts);
+ returnValue = r == KERN_SUCCESS;
+ }
+ contenders.deref();
+ return returnValue;
+}
+
+void QMutexPrivate::wakeUp()
+{
+ semaphore_signal(mach_semaphore);
+}
+
+#elif defined(Q_OS_LINUX)
+
+static inline int _q_futex(volatile int *addr, int op, int val, const struct timespec *timeout, int *addr2, int val2)
+{
+ return syscall(SYS_futex, addr, op, val, timeout, addr2, val2);
}
bool QMutexPrivate::wait(int timeout)
{
+ while (contenders.fetchAndStoreAcquire(2) > 0) {
+ struct timespec ts, *pts = 0;
+ if (timeout >= 0) {
+ ts.tv_nsec = ((timeout % 1000) * 1000) * 1000;
+ ts.tv_sec = (timeout / 1000);
+ pts = &ts;
+ }
+ int r = _q_futex(&contenders._q_value, FUTEX_WAIT, 2, pts, 0, 0);
+ if (r != 0 && errno == ETIMEDOUT)
+ return false;
+ }
+ return true;
+}
+
+void QMutexPrivate::wakeUp()
+{
+ (void) contenders.fetchAndStoreRelease(0);
+ (void) _q_futex(&contenders._q_value, FUTEX_WAKE, 1, 0, 0, 0);
+}
+
+#else // !Q_OS_MAC && !Q_OS_LINUX
+
+bool QMutexPrivate::wait(int timeout)
+{
+ if (contenders.fetchAndAddAcquire(1) == 0) {
+ // lock acquired without waiting
+ return true;
+ }
report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
int errorCode = 0;
while (!wakeup) {
@@ -104,6 +190,7 @@ bool QMutexPrivate::wait(int timeout)
}
wakeup = false;
report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
+ contenders.deref();
return errorCode == 0;
}
@@ -115,6 +202,8 @@ void QMutexPrivate::wakeUp()
report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
}
+#endif // !Q_OS_MAC && !Q_OS_LINUX
+
QT_END_NAMESPACE
#endif // QT_NO_THREAD
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index e2f1227..3a535c1 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
- : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0)
+ : QMutexData(mode), maximumSpinTime(MaximumSpinTimeThreshold), averageWaitTime(0), owner(0), count(0)
{
event = CreateEvent(0, FALSE, FALSE, 0);
if (!event)
@@ -60,7 +60,13 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
- return WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0;
+ if (contenders.fetchAndAddAcquire(1) == 0) {
+ // lock acquired without waiting
+ return true;
+ }
+ bool returnValue = (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
+ contenders.deref();
+ return returnValue;
}
void QMutexPrivate::wakeUp()
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index 5e9c5a8..ddabfb7 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -55,7 +55,7 @@
QT_BEGIN_NAMESPACE
-class QMutex;
+#include <QtCore/qmutex.h>
/*
Locks 2 mutexes in a defined order, avoiding a recursive lock if
@@ -79,8 +79,8 @@ public:
void relock()
{
if (!locked) {
- if (mtx1) mtx1->lock();
- if (mtx2) mtx2->lock();
+ if (mtx1) mtx1->lockInline();
+ if (mtx2) mtx2->lockInline();
locked = true;
}
}
@@ -88,8 +88,8 @@ public:
void unlock()
{
if (locked) {
- if (mtx1) mtx1->unlock();
- if (mtx2) mtx2->unlock();
+ if (mtx1) mtx1->unlockInline();
+ if (mtx2) mtx2->unlockInline();
locked = false;
}
}
@@ -100,10 +100,10 @@ public:
if (mtx1 == mtx2)
return false;
if (mtx1 < mtx2) {
- mtx2->lock();
+ mtx2->lockInline();
return true;
}
- if (!mtx2->tryLock()) {
+ if (!mtx2->tryLockInline()) {
mtx1->unlock();
mtx2->lock();
mtx1->lock();
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index 721d41f..ba6fa6e 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -223,8 +223,9 @@ bool QSemaphore::tryAcquire(int n, int timeout)
QElapsedTimer timer;
timer.start();
while (n > d->avail) {
- if (timer.hasExpired(timeout)
- || !d->cond.wait(locker.mutex(), timeout - timer.elapsed()))
+ const qint64 elapsed = timer.elapsed();
+ if (timeout - elapsed <= 0
+ || !d->cond.wait(locker.mutex(), timeout - elapsed))
return false;
}
}
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 8223cff..326f494 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -173,7 +173,8 @@ void QAdoptedThread::run()
*/
QThreadPrivate::QThreadPrivate(QThreadData *d)
- : QObjectPrivate(), running(false), finished(false), terminated(false), exited(false), returnCode(-1),
+ : QObjectPrivate(), running(false), finished(false), terminated(false),
+ isInFinish(false), exited(false), returnCode(-1),
stackSize(0), priority(QThread::InheritPriority), data(d)
{
#if defined (Q_OS_UNIX)
@@ -403,6 +404,11 @@ QThread::~QThread()
Q_D(QThread);
{
QMutexLocker locker(&d->mutex);
+ if (d->isInFinish) {
+ locker.unlock();
+ wait();
+ locker.relock();
+ }
if (d->running && !d->finished)
qWarning("QThread: Destroyed while thread is still running");
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index e8f7ef5..36e07c0 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -126,6 +126,7 @@ public:
bool running;
bool finished;
bool terminated;
+ bool isInFinish; //when in QThreadPrivate::finish
bool exited;
int returnCode;
@@ -208,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 c2bc895..811a193 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -94,7 +94,9 @@
# define old_qDebug qDebug
# undef qDebug
# endif
+#ifndef QT_NO_CORESERVICES
# include <CoreServices/CoreServices.h>
+#endif //QT_NO_CORESERVICES
# ifdef old_qDebug
# undef qDebug
@@ -119,6 +121,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;
@@ -154,6 +167,7 @@ static void create_current_thread_data_key()
static void destroy_current_thread_data_key()
{
+ pthread_once(&current_thread_data_once, create_current_thread_data_key);
pthread_key_delete(current_thread_data_key);
}
Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
@@ -165,7 +179,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);
@@ -175,7 +191,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);
@@ -184,7 +202,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);
@@ -318,7 +338,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);
@@ -347,39 +370,45 @@ void QThreadPrivate::finish(void *arg)
{
QThread *thr = reinterpret_cast<QThread *>(arg);
QThreadPrivate *d = thr->d_func();
+
#ifdef Q_OS_SYMBIAN
- if (lockAnyway)
+ QMutexLocker locker(lockAnyway ? &d->mutex : 0);
+#else
+ QMutexLocker locker(&d->mutex);
#endif
- d->mutex.lock();
+ d->isInFinish = true;
d->priority = QThread::InheritPriority;
- d->running = false;
- d->finished = true;
- if (d->terminated)
+ bool terminated = d->terminated;
+ void *data = &d->data->tls;
+ locker.unlock();
+ if (terminated)
emit thr->terminated();
- d->terminated = false;
emit thr->finished();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QThreadStorageData::finish((void **)data);
+ locker.relock();
+ d->terminated = false;
- if (d->data->eventDispatcher) {
- d->data->eventDispatcher->closingDown();
- QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
+ QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
+ if (eventDispatcher) {
d->data->eventDispatcher = 0;
+ locker.unlock();
+ eventDispatcher->closingDown();
delete eventDispatcher;
+ locker.relock();
}
- void *data = &d->data->tls;
- QThreadStorageData::finish((void **)data);
-
d->thread_id = 0;
#ifdef Q_OS_SYMBIAN
if (closeNativeHandle)
d->data->symbian_thread_handle.Close();
#endif
+ d->running = false;
+ d->finished = true;
+
+ d->isInFinish = false;
d->thread_done.wakeAll();
-#ifdef Q_OS_SYMBIAN
- if (lockAnyway)
-#endif
- d->mutex.unlock();
}
@@ -404,7 +433,7 @@ int QThread::idealThreadCount()
{
int cores = -1;
-#if defined(Q_OS_MAC)
+#if defined(Q_OS_MAC) && !defined(Q_WS_QPA)
// Mac OS X
cores = MPProcessorsScheduled();
#elif defined(Q_OS_HPUX)
@@ -568,6 +597,10 @@ void QThread::start(Priority priority)
{
Q_D(QThread);
QMutexLocker locker(&d->mutex);
+
+ if (d->isInFinish)
+ d->thread_done.wait(locker.mutex());
+
if (d->running)
return;
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 66161d7..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);
@@ -323,24 +326,33 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway)
QThread *thr = reinterpret_cast<QThread *>(arg);
QThreadPrivate *d = thr->d_func();
- if (lockAnyway)
- d->mutex.lock();
+ QMutexLocker locker(lockAnyway ? &d->mutex : 0);
+ d->isInFinish = true;
d->priority = QThread::InheritPriority;
- d->running = false;
- d->finished = true;
- if (d->terminated)
+ bool terminated = d->terminated;
+ void **tls_data = reinterpret_cast<void **>(&d->data->tls);
+ locker.unlock();
+ if (terminated)
emit thr->terminated();
- d->terminated = false;
emit thr->finished();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QThreadStorageData::finish(tls_data);
+ locker.relock();
- if (d->data->eventDispatcher) {
- d->data->eventDispatcher->closingDown();
- QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
+ d->terminated = false;
+
+ QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
+ if (eventDispatcher) {
d->data->eventDispatcher = 0;
+ locker.unlock();
+ eventDispatcher->closingDown();
delete eventDispatcher;
+ locker.relock();
}
- QThreadStorageData::finish(reinterpret_cast<void **>(&d->data->tls));
+ d->running = false;
+ d->finished = true;
+ d->isInFinish = false;
if (!d->waiters) {
CloseHandle(d->handle);
@@ -349,8 +361,6 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway)
d->id = 0;
- if (lockAnyway)
- d->mutex.unlock();
}
/**************************************************************************
@@ -399,6 +409,12 @@ void QThread::start(Priority priority)
Q_D(QThread);
QMutexLocker locker(&d->mutex);
+ if (d->isInFinish) {
+ locker.unlock();
+ wait();
+ locker.relock();
+ }
+
if (d->running)
return;
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index ebf79af..2b35333 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -178,11 +178,12 @@ void QThreadStorageData::finish(void **p)
return; // nothing to do
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
-
- for(int i = tls->size() - 1; i >= 0; i--) {
- void *&value = (*tls)[i];
+ while (!tls->isEmpty()) {
+ void *&value = tls->last();
void *q = value;
value = 0;
+ int i = tls->size() - 1;
+ tls->resize(i);
if (!q) {
// data already deleted
@@ -200,6 +201,11 @@ void QThreadStorageData::finish(void **p)
continue;
}
destructor(q); //crash here might mean the thread exited after qthreadstorage was destroyed
+
+ if (tls->size() > i) {
+ //re reset the tls in case it has been recreated by its own destructor.
+ (*tls)[i] = 0;
+ }
}
tls->clear();
}
@@ -215,19 +221,18 @@ void QThreadStorageData::finish(void **p)
QThreadStorage is a template class that provides per-thread data
storage.
- \e{Note that due to compiler limitations, QThreadStorage can only
- store pointers.}
-
The setLocalData() function stores a single thread-specific value
for the calling thread. The data can be accessed later using
- localData(). QThreadStorage takes ownership of the data (which
- must be created on the heap with \c new) and deletes it when the
- thread exits, either normally or via termination.
+ localData().
The hasLocalData() function allows the programmer to determine if
data has previously been set using the setLocalData() function.
This is also useful for lazy initializiation.
+ If T is a pointer type, QThreadStorage takes ownership of the data
+ (which must be created on the heap with \c new) and deletes it when
+ the thread exits, either normally or via termination.
+
For example, the following code uses QThreadStorage to store a
single cache for each thread that calls the cacheObject() and
removeFromCache() functions. The cache is automatically
@@ -241,9 +246,6 @@ void QThreadStorageData::finish(void **p)
\list
- \o As noted above, QThreadStorage can only store pointers due to
- compiler limitations.
-
\o The QThreadStorage destructor does not delete per-thread data.
QThreadStorage only deletes per-thread data when the thread exits
or when setLocalData() is called multiple times.
@@ -279,8 +281,11 @@ void QThreadStorageData::finish(void **p)
/*!
\fn bool QThreadStorage::hasLocalData() const
- Returns true if the calling thread has non-zero data available;
- otherwise returns false.
+ If T is a pointer type, returns true if the calling thread has
+ non-zero data available.
+
+ If T is a value type, returns whether the data has already been
+ constructed by calling setLocalData or localData.
\sa localData()
*/
@@ -291,10 +296,8 @@ void QThreadStorageData::finish(void **p)
Returns a reference to the data that was set by the calling
thread.
- Note: QThreadStorage can only store pointers. This function
- returns a reference to the pointer that was set by the calling
- thread. The value of this reference is 0 if no data was set by
- the calling thread,
+ If no data has been set, this will create a default constructed
+ instance of type T.
\sa hasLocalData()
*/
@@ -305,10 +308,6 @@ void QThreadStorageData::finish(void **p)
Returns a copy of the data that was set by the calling thread.
- Note: QThreadStorage can only store pointers. This function
- returns a pointer to the data that was set by the calling thread.
- If no data was set by the calling thread, this function returns 0.
-
\sa hasLocalData()
*/
@@ -318,19 +317,9 @@ void QThreadStorageData::finish(void **p)
Sets the local data for the calling thread to \a data. It can be
accessed later using the localData() functions.
- If \a data is 0, this function deletes the previous data (if
- any) and returns immediately.
-
- If \a data is non-zero, QThreadStorage takes ownership of the \a
- data and deletes it automatically either when the thread exits
- (either normally or via termination) or when setLocalData() is
- called again.
-
- Note: QThreadStorage can only store pointers. The \a data
- argument must be either a pointer to an object created on the heap
- (i.e. using \c new) or 0. You should not delete \a data
- yourself; QThreadStorage takes ownership and will delete the \a
- data itself.
+ If T is a pointer type, QThreadStorage takes ownership of the data
+ and deletes it automatically either when the thread exits (either
+ normally or via termination) or when setLocalData() is called again.
\sa localData(), hasLocalData()
*/
diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h
index 3fa0971..e1cafb6 100644
--- a/src/corelib/thread/qthreadstorage.h
+++ b/src/corelib/thread/qthreadstorage.h
@@ -91,7 +91,10 @@ inline
void qThreadStorage_setLocalData(QThreadStorageData &d, T **t)
{ (void) d.set(*t); }
-#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
+template <typename T>
+inline
+void qThreadStorage_deleteData(void *d, T **)
+{ delete static_cast<T *>(d); }
// value-based specialization
template <typename T>
@@ -116,7 +119,11 @@ inline
void qThreadStorage_setLocalData(QThreadStorageData &d, T *t)
{ (void) d.set(new T(*t)); }
-#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
+template <typename T>
+inline
+void qThreadStorage_deleteData(void *d, T *)
+{ delete static_cast<T *>(d); }
+
// MOC_SKIP_END
#endif
@@ -130,7 +137,7 @@ private:
Q_DISABLE_COPY(QThreadStorage)
static inline void deleteData(void *x)
- { delete static_cast<T>(x); }
+ { qThreadStorage_deleteData(x, reinterpret_cast<T*>(0)); }
public:
inline QThreadStorage() : d(deleteData) { }
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/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index a3cd7ad..6181c82 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -418,6 +418,13 @@ void QBitArray::fill(bool value, int begin, int end)
this bit array.
*/
+/*! \fn void QBitArray::swap(QBitArray &other)
+ \since 4.8
+
+ Swaps bit array \a other with this bit array. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QBitArray::operator==(const QBitArray &other) const
Returns true if \a other is equal to this bit array; otherwise
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index d2f9bf3..cec338c 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -63,6 +63,12 @@ public:
explicit QBitArray(int size, bool val = false);
QBitArray(const QBitArray &other) : d(other.d) {}
inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; }
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QBitArray &operator=(QBitArray &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+
+ inline void swap(QBitArray &other) { qSwap(d, other.d); }
inline int size() const { return (d.size() << 3) - *d.constData(); }
inline int count() const { return (d.size() << 3) - *d.constData(); }
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 641f8d5..1c9b654 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -541,12 +541,19 @@ QByteArray qUncompress(const uchar* data, int nbytes)
forever {
ulong alloc = len;
- d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + alloc))));
- if (!d) {
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc));
+ if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
return QByteArray();
}
+ d.take(); // realloc was successful
+ d.reset(p);
int res = ::uncompress((uchar*)d->array, &len,
(uchar*)data+4, nbytes-4);
@@ -554,12 +561,19 @@ QByteArray qUncompress(const uchar* data, int nbytes)
switch (res) {
case Z_OK:
if (len != alloc) {
- d.reset(q_check_ptr(static_cast<QByteArray::Data *>(qRealloc(d.take(), sizeof(QByteArray::Data) + len))));
- if (!d) {
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len));
+ if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
return QByteArray();
}
+ d.take(); // realloc was successful
+ d.reset(p);
}
d->ref = 1;
d->alloc = d->size = len;
@@ -673,12 +687,12 @@ QByteArray::Data QByteArray::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
values. To set all the bytes to a particular value, call fill().
To obtain a pointer to the actual character data, call data() or
- constData(). These functions return a pointer to the beginning of
- the data. The pointer is guaranteed to remain valid until a
- non-const function is called on the QByteArray. It is also
- guaranteed that the data ends with a '\\0' byte. This '\\0' byte
- is automatically provided by QByteArray and is not counted in
- size().
+ constData(). These functions return a pointer to the beginning of the data.
+ The pointer is guaranteed to remain valid until a non-const function is
+ called on the QByteArray. It is also guaranteed that the data ends with a
+ '\\0' byte unless the QByteArray was created from a \l{fromRawData()}{raw
+ data}. This '\\0' byte is automatically provided by QByteArray and is not
+ counted in size().
QByteArray provides the following basic functions for modifying
the byte data: append(), prepend(), insert(), replace(), and
@@ -900,15 +914,24 @@ QByteArray &QByteArray::operator=(const char *str)
return *this;
}
+/*! \fn void QByteArray::swap(QByteArray &other)
+ \since 4.8
+
+ Swaps byte array \a other with this byte array. This operation is very
+ fast and never fails.
+*/
+
/*! \fn int QByteArray::size() const
Returns the number of bytes in this byte array.
- The last byte in the byte array is at position size() - 1. In
- addition, QByteArray ensures that the byte at position size() is
- always '\\0', so that you can use the return value of data() and
- constData() as arguments to functions that expect '\\0'-terminated
- strings.
+ The last byte in the byte array is at position size() - 1. In addition,
+ QByteArray ensures that the byte at position size() is always '\\0', so
+ that you can use the return value of data() and constData() as arguments to
+ functions that expect '\\0'-terminated strings. If the QByteArray object
+ was created from a \l{fromRawData()}{raw data} that didn't include the
+ trailing null-termination character then QByteArray doesn't add it
+ automaticall unless the \l{deep copy} is created.
Example:
\snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 6
@@ -1039,10 +1062,11 @@ QByteArray &QByteArray::operator=(const char *str)
/*! \fn const char *QByteArray::constData() const
- Returns a pointer to the data stored in the byte array. The
- pointer can be used to access the bytes that compose the array.
- The data is '\\0'-terminated. The pointer remains valid as long
- as the byte array isn't reallocated or destroyed.
+ Returns a pointer to the data stored in the byte array. The pointer can be
+ used to access the bytes that compose the array. The data is
+ '\\0'-terminated unless the QByteArray object was created from raw data.
+ The pointer remains valid as long as the byte array isn't reallocated or
+ destroyed.
This function is mostly useful to pass a byte array to a function
that accepts a \c{const char *}.
@@ -1051,7 +1075,7 @@ QByteArray &QByteArray::operator=(const char *str)
but most functions that take \c{char *} arguments assume that the
data ends at the first '\\0' they encounter.
- \sa data(), operator[]()
+ \sa data(), operator[](), fromRawData()
*/
/*! \fn void QByteArray::detach()
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 58decb8..70d865a 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -144,6 +144,12 @@ public:
QByteArray &operator=(const QByteArray &);
QByteArray &operator=(const char *str);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QByteArray &operator=(QByteArray &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+
+ inline void swap(QByteArray &other) { qSwap(d, other.d); }
inline int size() const;
bool isEmpty() const;
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 27a87d3..7f6b869 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -61,7 +61,7 @@ class QCache
};
Node *f, *l;
QHash<Key, Node> hash;
- void *unused;
+ void *unused; // ### Qt5: remove
int mx, total;
inline void unlink(Node &n) {
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index 7cdc256..a903007 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -48,11 +48,11 @@
# undef QT_NO_CAST_TO_ASCII
#endif
#include "qchar.h"
+
#include "qdatastream.h"
#include "qtextcodec.h"
#include "qunicodetables_p.h"
-
#include "qunicodetables.cpp"
QT_BEGIN_NAMESPACE
@@ -677,7 +677,7 @@ bool QChar::isSymbol() const
\since 4.7
Returns true if the UCS-4-encoded character specified by \a ucs4
- is the high part of a utf16 surrogate
+ is the low part of a utf16 surrogate
(ie. if its code point is between 0xdc00 and 0xdfff, inclusive).
*/
@@ -686,7 +686,7 @@ bool QChar::isSymbol() const
\since 4.7
Returns true if the UCS-4-encoded character specified by \a ucs4
- can be splited to the high and low parts of a utf16 surrogate
+ can be split into the high and low parts of a utf16 surrogate
(ie. if its code point is greater than or equals to 0x10000).
*/
@@ -1069,6 +1069,15 @@ QChar::UnicodeVersion QChar::unicodeVersion(ushort ucs2)
return (QChar::UnicodeVersion) qGetProp(ucs2)->unicodeVersion;
}
+/*!
+ \since 4.8
+
+ Returns the most recent supported Unicode version.
+*/
+QChar::UnicodeVersion QChar::currentUnicodeVersion()
+{
+ return UNICODE_DATA_VERSION;
+}
/*!
Returns the lowercase equivalent if the character is uppercase or titlecase;
@@ -1489,6 +1498,16 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
}
+struct UCS2Pair {
+ ushort u1;
+ ushort u2;
+};
+
+inline bool operator<(ushort u1, const UCS2Pair &ligature)
+{ return u1 < ligature.u1; }
+inline bool operator<(const UCS2Pair &ligature, ushort u1)
+{ return ligature.u1 < u1; }
+
static ushort ligatureHelper(ushort u1, ushort u2)
{
// hangul L-V pair
@@ -1511,12 +1530,14 @@ static ushort ligatureHelper(ushort u1, ushort u2)
if (index == 0xffff)
return 0;
const unsigned short *ligatures = uc_ligature_map+index;
- ushort length = *ligatures;
- ++ligatures;
- // ### use bsearch
- for (uint i = 0; i < length; ++i)
- if (ligatures[2*i] == u1)
- return ligatures[2*i+1];
+ ushort length = *ligatures++;
+ {
+ const UCS2Pair *data = reinterpret_cast<const UCS2Pair *>(ligatures);
+ const UCS2Pair *r = qBinaryFind(data, data + length, u1);
+ if (r != data + length)
+ return r->u2;
+ }
+
return 0;
}
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 441c89f..5080536 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -105,7 +105,7 @@ public:
enum Category
{
- NoCategory,
+ NoCategory, // ### Qt 5: replace with Other_NotAssigned
Mark_NonSpacing, // Mn
Mark_SpacingCombining, // Mc
@@ -144,7 +144,7 @@ public:
Symbol_Modifier, // Sk
Symbol_Other, // So
- Punctuation_Dask = Punctuation_Dash // oops
+ Punctuation_Dask = Punctuation_Dash // ### Qt 5: remove
};
enum Direction
@@ -210,7 +210,7 @@ public:
};
enum UnicodeVersion {
- Unicode_Unassigned,
+ Unicode_Unassigned, // ### Qt 5: assign with some constantly big value
Unicode_1_1,
Unicode_2_0,
Unicode_2_1_2,
@@ -334,6 +334,8 @@ public:
static UnicodeVersion QT_FASTCALL unicodeVersion(uint ucs4);
static UnicodeVersion QT_FASTCALL unicodeVersion(ushort ucs2);
+ static UnicodeVersion QT_FASTCALL currentUnicodeVersion();
+
static QString QT_FASTCALL decomposition(uint ucs4);
#ifdef QT3_SUPPORT
diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp
index 6197d90..8e1c4c4 100644
--- a/src/corelib/tools/qcontiguouscache.cpp
+++ b/src/corelib/tools/qcontiguouscache.cpp
@@ -194,6 +194,13 @@ MyRecord record(int row) const
Assigns \a other to this cache and returns a reference to this cache.
*/
+/*! \fn void QContiguousCache::swap(QContiguousCache<T> &other)
+ \since 4.8
+
+ Swaps cache \a other with this cache. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QContiguousCache::operator==(const QContiguousCache<T> &other) const
Returns true if \a other is equal to this cache; otherwise returns false.
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index 1d6fdf4..7880c2e 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -110,6 +110,11 @@ public:
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
QContiguousCache<T> &operator=(const QContiguousCache<T> &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QContiguousCache<T> &operator=(QContiguousCache<T> &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QContiguousCache<T> &other) { qSwap(d, other.d); }
bool operator==(const QContiguousCache<T> &other) const;
inline bool operator!=(const QContiguousCache<T> &other) const { return !(*this == other); }
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index c167ee3..a3a8884 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -3426,8 +3426,9 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
QString tz = parts.at(5);
if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive))
return QDateTime();
- int tzoffset = 0;
+ QDateTime dt(date, time, Qt::UTC);
if (tz.length() > 3) {
+ int tzoffset = 0;
QChar sign = tz.at(3);
if ((sign != QLatin1Char('+'))
&& (sign != QLatin1Char('-'))) {
@@ -3442,8 +3443,9 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f)
tzoffset = (tzhour*60 + tzminute) * 60;
if (sign == QLatin1Char('-'))
tzoffset = -tzoffset;
+ dt.setUtcOffset(tzoffset);
}
- return QDateTime(date, time, Qt::UTC).addSecs(-tzoffset).toLocalTime();
+ return dt.toLocalTime();
}
#endif //QT_NO_TEXTDATE
}
@@ -5838,6 +5840,41 @@ bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::S
return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);
}
+#ifdef Q_OS_SYMBIAN
+const static TTime UnixEpochOffset(I64LIT(0xdcddb30f2f8000));
+const static TInt64 MinimumMillisecondTime(KMinTInt64 / 1000);
+const static TInt64 MaximumMillisecondTime(KMaxTInt64 / 1000);
+QDateTime qt_symbian_TTime_To_QDateTime(const TTime& time)
+{
+ TTimeIntervalMicroSeconds absolute = time.MicroSecondsFrom(UnixEpochOffset);
+
+ return QDateTime::fromMSecsSinceEpoch(absolute.Int64() / 1000);
+}
+
+TTime qt_symbian_QDateTime_To_TTime(const QDateTime& datetime)
+{
+ qint64 absolute = datetime.toMSecsSinceEpoch();
+ if(absolute > MaximumMillisecondTime)
+ return TTime(KMaxTInt64);
+ if(absolute < MinimumMillisecondTime)
+ return TTime(KMinTInt64);
+ return TTime(absolute * 1000);
+}
+
+time_t qt_symbian_TTime_To_time_t(const TTime& time)
+{
+ TTimeIntervalSeconds interval;
+ TInt err = time.SecondsFrom(UnixEpochOffset, interval);
+ if (err || interval.Int() < 0)
+ return (time_t) 0;
+ return (time_t) interval.Int();
+}
+
+TTime qt_symbian_time_t_To_TTime(time_t time)
+{
+ return UnixEpochOffset + TTimeIntervalSeconds(time);
+}
+#endif //Q_OS_SYMBIAN
#endif // QT_BOOTSTRAPPED
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index ec21f98..ad4055d 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -275,6 +275,12 @@ Q_CORE_EXPORT bool operator==(const QDateTimeParser::SectionNode &s1, const QDat
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::Sections)
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::FieldInfo)
+#ifdef Q_OS_SYMBIAN
+QDateTime qt_symbian_TTime_To_QDateTime(const TTime& time);
+TTime qt_symbian_QDateTime_To_TTime(const QDateTime& datetime);
+time_t qt_symbian_TTime_To_time_t(const TTime& time);
+TTime qt_symbian_time_t_To_TTime(time_t time);
+#endif //Q_OS_SYMBIAN
#endif // QT_BOOTSTRAPPED
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/tools/qelapsedtimer.cpp
index da64359..0b4b63c 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/tools/qelapsedtimer.cpp
@@ -136,10 +136,11 @@ QT_BEGIN_NAMESPACE
implementations, to guarantee that the same reference clock is being
used.
- \value SystemTime The human-readable system time. This clock is not monotonic.
- \value MonotonicClock The system's monotonic clock, usually found in Unix systems. This clock is monotonic and does not overflow.
- \value TickCounter The system's tick counter, used on Windows and Symbian systems. This clock may overflow.
- \value MachAbsoluteTime The Mach kernel's absolute time (Mac OS X). This clock is monotonic and does not overflow.
+ \value SystemTime The human-readable system time. This clock is not monotonic.
+ \value MonotonicClock The system's monotonic clock, usually found in Unix systems. This clock is monotonic and does not overflow.
+ \value TickCounter The system's tick counter, used on Windows and Symbian systems. This clock may overflow.
+ \value MachAbsoluteTime The Mach kernel's absolute time (Mac OS X). This clock is monotonic and does not overflow.
+ \value PerformanceCounter The high-resolution performance counter provided by Windows. This clock is monotonic and does not overflow.
\section2 SystemTime
@@ -163,7 +164,9 @@ QT_BEGIN_NAMESPACE
The tick counter clock type is based on the system's or the processor's
tick counter, multiplied by the duration of a tick. This clock type is
- used on Windows and Symbian platforms.
+ used on Windows and Symbian platforms. If the high-precision performance
+ counter is available on Windows, the \tt{PerformanceCounter} clock type
+ is used instead.
The TickCounter clock type is the only clock type that may overflow.
Windows Vista and Windows Server 2008 support the extended 64-bit tick
@@ -191,6 +194,16 @@ QT_BEGIN_NAMESPACE
This clock is monotonic and does not overflow.
+ \section2 PerformanceCounter
+
+ This clock uses the Windows functions \tt{QueryPerformanceCounter} and
+ \tt{QueryPerformanceFrequency} to access the system's high-precision
+ performance counter. Since this counter may not be available on all
+ systems, QElapsedTimer will fall back to the \tt{TickCounter} clock
+ automatically, if this clock cannot be used.
+
+ This clock is monotonic and does not overflow.
+
\sa clockType(), isMonotonic()
*/
diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/tools/qelapsedtimer.h
index 27344f5..3cf4a70 100644
--- a/src/corelib/tools/qelapsedtimer.h
+++ b/src/corelib/tools/qelapsedtimer.h
@@ -57,7 +57,8 @@ public:
SystemTime,
MonotonicClock,
TickCounter,
- MachAbsoluteTime
+ MachAbsoluteTime,
+ PerformanceCounter
};
static ClockType clockType();
static bool isMonotonic();
@@ -67,6 +68,7 @@ public:
void invalidate();
bool isValid() const;
+ qint64 nsecsElapsed() const;
qint64 elapsed() const;
bool hasExpired(qint64 timeout) const;
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index 78aef50..508c94f 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -103,6 +103,22 @@ qint64 QElapsedTimer::restart()
return t1 - old;
}
+/*! \since 4.8
+
+ Returns the number of nanoseconds since this QElapsedTimer was last
+ started. Calling this function in a QElapsedTimer that was invalidated
+ will result in undefined results.
+
+ On platforms that do not provide nanosecond resolution, the value returned
+ will be the best estimate available.
+
+ \sa start(), restart(), hasExpired(), invalidate()
+*/
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ return elapsed() * 1000000;
+}
+
/*!
Returns the number of milliseconds since this QElapsedTimer was last
started. Calling this function in a QElapsedTimer that was invalidated
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/tools/qelapsedtimer_mac.cpp
index 42342dd..110549a 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/tools/qelapsedtimer_mac.cpp
@@ -97,6 +97,12 @@ qint64 QElapsedTimer::restart()
return absoluteToMSecs(t1 - old);
}
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ uint64_t cpu_time = mach_absolute_time();
+ return absoluteToNSecs(cpu_time - t1);
+}
+
qint64 QElapsedTimer::elapsed() const
{
uint64_t cpu_time = mach_absolute_time();
diff --git a/src/corelib/tools/qelapsedtimer_symbian.cpp b/src/corelib/tools/qelapsedtimer_symbian.cpp
index 80b7ca1..b831e03 100644
--- a/src/corelib/tools/qelapsedtimer_symbian.cpp
+++ b/src/corelib/tools/qelapsedtimer_symbian.cpp
@@ -64,11 +64,6 @@ static quint64 getMicrosecondFromTick()
return nanokernel_tick_period * (val | (quint64(highdword) << 32));
}
-static quint64 getMillisecondFromTick()
-{
- return getMicrosecondFromTick() / 1000;
-}
-
timeval qt_gettime()
{
timeval tv;
@@ -91,36 +86,41 @@ bool QElapsedTimer::isMonotonic()
void QElapsedTimer::start()
{
- t1 = getMillisecondFromTick();
+ t1 = getMicrosecondFromTick();
t2 = 0;
}
qint64 QElapsedTimer::restart()
{
qint64 oldt1 = t1;
- t1 = getMillisecondFromTick();
+ t1 = getMicrosecondFromTick();
t2 = 0;
return t1 - oldt1;
}
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ return (getMicrosecondFromTick() - t1) * 1000;
+}
+
qint64 QElapsedTimer::elapsed() const
{
- return getMillisecondFromTick() - t1;
+ return (getMicrosecondFromTick() - t1) / 1000;
}
qint64 QElapsedTimer::msecsSinceReference() const
{
- return t1;
+ return t1 / 1000;
}
qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
{
- return other.t1 - t1;
+ return (other.t1 - t1) / 1000;
}
qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
{
- return msecsTo(other) / 1000;
+ return msecsTo(other) / 1000000;
}
bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2)
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp
index e26f566..f24c6fb 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/tools/qelapsedtimer_unix.cpp
@@ -167,6 +167,17 @@ qint64 QElapsedTimer::restart()
return elapsedAndRestart(t1, t2, &t1, &t2);
}
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ qint64 sec, frac;
+ do_gettime(&sec, &frac);
+ sec = sec - t1;
+ frac = frac - t2;
+ if (!monotonicClockAvailable)
+ frac *= 1000;
+ return sec * Q_INT64_C(1000000000) + frac;
+}
+
qint64 QElapsedTimer::elapsed() const
{
qint64 sec, frac;
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index aa5abaf..b3210f1 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -42,6 +42,9 @@
#include "qelapsedtimer.h"
#include <windows.h>
+// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
+static quint64 counterFrequency = 0;
+
typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
static PtrGetTickCount64 ptrGetTickCount64 = 0;
@@ -65,12 +68,44 @@ static void resolveLibs()
ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
#endif
+ // Retrieve the number of high-resolution performance counter ticks per second
+ LARGE_INTEGER frequency;
+ if (!QueryPerformanceFrequency(&frequency)) {
+ counterFrequency = 0;
+ } else {
+ counterFrequency = frequency.QuadPart;
+ }
+
done = true;
}
+static inline qint64 ticksToNanoseconds(qint64 ticks)
+{
+ if (counterFrequency > 0) {
+ // QueryPerformanceCounter uses an arbitrary frequency
+ return ticks * 1000000000 / counterFrequency;
+ } else {
+ // GetTickCount(64) return milliseconds
+ return ticks * 1000000;
+ }
+}
+
static quint64 getTickCount()
{
resolveLibs();
+
+ // This avoids a division by zero and disables the high performance counter if it's not available
+ if (counterFrequency > 0) {
+ LARGE_INTEGER counter;
+
+ if (QueryPerformanceCounter(&counter)) {
+ return counter.QuadPart;
+ } else {
+ qWarning("QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
+ return 0;
+ }
+ }
+
if (ptrGetTickCount64)
return ptrGetTickCount64();
@@ -85,7 +120,12 @@ static quint64 getTickCount()
QElapsedTimer::ClockType QElapsedTimer::clockType()
{
- return TickCounter;
+ resolveLibs();
+
+ if (counterFrequency > 0)
+ return PerformanceCounter;
+ else
+ return TickCounter;
}
bool QElapsedTimer::isMonotonic()
@@ -104,22 +144,30 @@ qint64 QElapsedTimer::restart()
qint64 oldt1 = t1;
t1 = getTickCount();
t2 = 0;
- return t1 - oldt1;
+ return ticksToNanoseconds(t1 - oldt1) / 1000000;
+}
+
+qint64 QElapsedTimer::nsecsElapsed() const
+{
+ qint64 elapsed = getTickCount() - t1;
+ return ticksToNanoseconds(elapsed);
}
qint64 QElapsedTimer::elapsed() const
{
- return getTickCount() - t1;
+ qint64 elapsed = getTickCount() - t1;
+ return ticksToNanoseconds(elapsed) / 1000000;
}
qint64 QElapsedTimer::msecsSinceReference() const
{
- return t1;
+ return ticksToNanoseconds(t1) / 1000000;
}
qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
{
- return other.t1 - t1;
+ qint64 difference = other.t1 - t1;
+ return ticksToNanoseconds(difference) / 1000000;
}
qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 32463e0..b6ba8b2 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -54,6 +54,10 @@
QT_BEGIN_NAMESPACE
+
+// ### Qt 5: see tests/benchmarks/corelib/tools/qhash/qhash_string.cpp
+// Hashing of the whole string is a waste of cycles.
+
/*
These functions are based on Peter J. Weinberger's hash function
(from the Dragon Book). The constant 24 in the original function
@@ -730,6 +734,20 @@ void QHashData::checkSanity()
Assigns \a other to this hash and returns a reference to this hash.
*/
+/*! \fn void QHash::swap(QHash<Key, T> &other)
+ \since 4.8
+
+ Swaps hash \a other with this hash. This operation is very
+ fast and never fails.
+*/
+
+/*! \fn void QMultiHash::swap(QMultiHash<Key, T> &other)
+ \since 4.8
+
+ Swaps hash \a other with this hash. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QHash::operator==(const QHash<Key, T> &other) const
Returns true if \a other is equal to this hash; otherwise returns
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 06984bf..4982144 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -225,7 +225,7 @@ struct QHashNode
inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; }
};
-#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
+
#define Q_HASH_DECLARE_INT_NODES(key_type) \
template <class T> \
struct QHashDummyNode<key_type, T> { \
@@ -253,7 +253,6 @@ Q_HASH_DECLARE_INT_NODES(ushort);
Q_HASH_DECLARE_INT_NODES(int);
Q_HASH_DECLARE_INT_NODES(uint);
#undef Q_HASH_DECLARE_INT_NODES
-#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
template <class Key, class T>
class QHash
@@ -284,6 +283,11 @@ public:
inline ~QHash() { if (!d->ref.deref()) freeData(d); }
QHash<Key, T> &operator=(const QHash<Key, T> &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QHash<Key, T> &operator=(QHash<Key, T> &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QHash<Key, T> &other) { qSwap(d, other.d); }
bool operator==(const QHash<Key, T> &other) const;
inline bool operator!=(const QHash<Key, T> &other) const { return !(*this == other); }
@@ -513,8 +517,6 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode2(QHashData::Node *node)
{
#ifdef Q_CC_BOR
concrete(node)->~QHashNode<Key, T>();
-#elif defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION)
- concrete(node)->~QHashNode();
#else
concrete(node)->~Node();
#endif
@@ -924,6 +926,7 @@ class QMultiHash : public QHash<Key, T>
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
+ inline void swap(QMultiHash<Key, T> &other) { QHash<Key, T>::swap(other); } // prevent QMultiHash<->QHash swaps
inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value)
{ return QHash<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index ec46cc5..724cace 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -147,6 +147,13 @@ QLinkedListData QLinkedListData::shared_null = {
list.
*/
+/*! \fn void QLinkedList::swap(QLinkedList<T> &other)
+ \since 4.8
+
+ Swaps list \a other with this list. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QLinkedList::operator==(const QLinkedList<T> &other) const
Returns true if \a other is equal to this list; otherwise returns
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 0737a73..b01dcc4 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -85,6 +85,11 @@ public:
inline QLinkedList(const QLinkedList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); }
~QLinkedList();
QLinkedList<T> &operator=(const QLinkedList<T> &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QLinkedList<T> &operator=(QLinkedList<T> &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QLinkedList<T> &other) { qSwap(d, other.d); }
bool operator==(const QLinkedList<T> &l) const;
inline bool operator!=(const QLinkedList<T> &l) const { return !(*this == l); }
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 88b9245..7bbdc16 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -602,6 +602,13 @@ void **QListData::erase(void **xi)
list.
*/
+/*! \fn void QList::swap(QList<T> &other)
+ \since 4.8
+
+ Swaps list \a other with this list. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QList::operator==(const QList<T> &other) const
Returns true if \a other is equal to this list; otherwise returns
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index b353148..da70b80 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -50,6 +50,10 @@
#include <iterator>
#include <list>
#endif
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+#include <iterator>
+#include <initializer_list>
+#endif
#include <new>
#include <limits.h>
@@ -118,6 +122,15 @@ public:
inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
~QList();
QList<T> &operator=(const QList<T> &l);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QList &operator=(QList &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QList<T> &other) { qSwap(d, other.d); }
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ inline QList(std::initializer_list<T> args) : d(&QListData::shared_null)
+ { d->ref.ref(); qCopy(args.begin(), args.end(), std::back_inserter(*this)); }
+#endif
bool operator==(const QList<T> &l) const;
inline bool operator!=(const QList<T> &l) const { return !(*this == l); }
@@ -713,7 +726,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper()
template <typename T>
Q_OUTOFLINE_TEMPLATE QList<T>::~QList()
{
- if (d && !d->ref.deref())
+ if (!d->ref.deref())
free(d);
}
@@ -741,8 +754,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::free(QListData::Data *data)
{
node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
reinterpret_cast<Node *>(data->array + data->end));
- if (data->ref == 0)
- qFree(data);
+ qFree(data);
}
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 2c028af..9e13fcc 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -404,6 +404,20 @@ void QMapData::dump()
Assigns \a other to this map and returns a reference to this map.
*/
+/*! \fn void QMap::swap(QMap<Key, T> &other)
+ \since 4.8
+
+ Swaps map \a other with this map. This operation is very
+ fast and never fails.
+*/
+
+/*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other)
+ \since 4.8
+
+ Swaps map \a other with this map. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QMap::operator==(const QMap<Key, T> &other) const
Returns true if \a other is equal to this map; otherwise returns
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index a302cf8..6ac30dd 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -107,7 +107,6 @@ template <class Key> inline bool qMapLessThanKey(const Key &key1, const Key &key
return key1 < key2;
}
-#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
template <class Ptr> inline bool qMapLessThanKey(Ptr *key1, Ptr *key2)
{
Q_ASSERT(sizeof(quintptr) == sizeof(Ptr *));
@@ -119,7 +118,6 @@ template <class Ptr> inline bool qMapLessThanKey(const Ptr *key1, const Ptr *key
Q_ASSERT(sizeof(quintptr) == sizeof(const Ptr *));
return quintptr(key1) < quintptr(key2);
}
-#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION
template <class Key, class T>
struct QMapNode {
@@ -187,6 +185,11 @@ public:
inline ~QMap() { if (!d) return; if (!d->ref.deref()) freeData(d); }
QMap<Key, T> &operator=(const QMap<Key, T> &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QMap<Key, T> &operator=(QMap<Key, T> &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QMap<Key, T> &other) { qSwap(d, other.d); }
#ifndef QT_NO_STL
explicit QMap(const typename std::map<Key, T> &other);
std::map<Key, T> toStdMap() const;
@@ -640,13 +643,13 @@ Q_OUTOFLINE_TEMPLATE void QMap<Key, T>::freeData(QMapData *x)
while (next != x) {
cur = next;
next = cur->forward[0];
-#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#if defined(_MSC_VER)
#pragma warning(disable:4189)
#endif
Node *concreteNode = concrete(reinterpret_cast<QMapData::Node *>(cur));
concreteNode->key.~Key();
concreteNode->value.~T();
-#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#if defined(_MSC_VER)
#pragma warning(default:4189)
#endif
}
@@ -971,6 +974,7 @@ class QMultiMap : public QMap<Key, T>
public:
QMultiMap() {}
QMultiMap(const QMap<Key, T> &other) : QMap<Key, T>(other) {}
+ inline void swap(QMultiMap<Key, T> &other) { QMap<Key, T>::swap(other); }
inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value)
{ return QMap<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index 63fc498..2a13fc4 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -187,7 +187,19 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QPoint &QPoint::operator*=(qreal factor)
+ \fn QPoint &QPoint::operator*=(float factor)
+
+ Multiplies this point's coordinates by the given \a factor, and
+ returns a reference to this point.
+
+ Note that the result is rounded to the nearest integer as points are held as
+ integers. Use QPointF for floating point accuracy.
+
+ \sa operator/=()
+*/
+
+/*!
+ \fn QPoint &QPoint::operator*=(double factor)
Multiplies this point's coordinates by the given \a factor, and
returns a reference to this point. For example:
@@ -200,6 +212,14 @@ QT_BEGIN_NAMESPACE
\sa operator/=()
*/
+/*!
+ \fn QPoint &QPoint::operator*=(int factor)
+
+ Multiplies this point's coordinates by the given \a factor, and
+ returns a reference to this point.
+
+ \sa operator/=()
+*/
/*!
\fn bool operator==(const QPoint &p1, const QPoint &p2)
@@ -237,7 +257,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn const QPoint operator*(const QPoint &point, qreal factor)
+ \fn const QPoint operator*(const QPoint &point, float factor)
\relates QPoint
Returns a copy of the given \a point multiplied by the given \a factor.
@@ -249,7 +269,44 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn const QPoint operator*(qreal factor, const QPoint &point)
+ \fn const QPoint operator*(const QPoint &point, double factor)
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+
+ Note that the result is rounded to the nearest integer as points
+ are held as integers. Use QPointF for floating point accuracy.
+
+ \sa QPoint::operator*=()
+*/
+
+/*!
+ \fn const QPoint operator*(const QPoint &point, int factor)
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+
+ \sa QPoint::operator*=()
+*/
+
+/*!
+ \fn const QPoint operator*(float factor, const QPoint &point)
+ \overload
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+*/
+
+/*!
+ \fn const QPoint operator*(double factor, const QPoint &point)
+ \overload
+ \relates QPoint
+
+ Returns a copy of the given \a point multiplied by the given \a factor.
+*/
+
+/*!
+ \fn const QPoint operator*(int factor, const QPoint &point)
\overload
\relates QPoint
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 719c239..4496127 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -70,15 +70,23 @@ public:
QPoint &operator+=(const QPoint &p);
QPoint &operator-=(const QPoint &p);
- QPoint &operator*=(qreal c);
+
+ QPoint &operator*=(float c);
+ QPoint &operator*=(double c);
+ QPoint &operator*=(int c);
+
QPoint &operator/=(qreal c);
friend inline bool operator==(const QPoint &, const QPoint &);
friend inline bool operator!=(const QPoint &, const QPoint &);
friend inline const QPoint operator+(const QPoint &, const QPoint &);
friend inline const QPoint operator-(const QPoint &, const QPoint &);
- friend inline const QPoint operator*(const QPoint &, qreal);
- friend inline const QPoint operator*(qreal, const QPoint &);
+ friend inline const QPoint operator*(const QPoint &, float);
+ friend inline const QPoint operator*(float, const QPoint &);
+ friend inline const QPoint operator*(const QPoint &, double);
+ friend inline const QPoint operator*(double, const QPoint &);
+ friend inline const QPoint operator*(const QPoint &, int);
+ friend inline const QPoint operator*(int, const QPoint &);
friend inline const QPoint operator-(const QPoint &);
friend inline const QPoint operator/(const QPoint &, qreal);
@@ -141,9 +149,15 @@ inline QPoint &QPoint::operator+=(const QPoint &p)
inline QPoint &QPoint::operator-=(const QPoint &p)
{ xp-=p.xp; yp-=p.yp; return *this; }
-inline QPoint &QPoint::operator*=(qreal c)
+inline QPoint &QPoint::operator*=(float c)
+{ xp = qRound(xp*c); yp = qRound(yp*c); return *this; }
+
+inline QPoint &QPoint::operator*=(double c)
{ xp = qRound(xp*c); yp = qRound(yp*c); return *this; }
+inline QPoint &QPoint::operator*=(int c)
+{ xp = xp*c; yp = yp*c; return *this; }
+
inline bool operator==(const QPoint &p1, const QPoint &p2)
{ return p1.xp == p2.xp && p1.yp == p2.yp; }
@@ -156,12 +170,24 @@ inline const QPoint operator+(const QPoint &p1, const QPoint &p2)
inline const QPoint operator-(const QPoint &p1, const QPoint &p2)
{ return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); }
-inline const QPoint operator*(const QPoint &p, qreal c)
+inline const QPoint operator*(const QPoint &p, float c)
{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }
-inline const QPoint operator*(qreal c, const QPoint &p)
+inline const QPoint operator*(const QPoint &p, double c)
{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }
+inline const QPoint operator*(const QPoint &p, int c)
+{ return QPoint(p.xp*c, p.yp*c); }
+
+inline const QPoint operator*(float c, const QPoint &p)
+{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }
+
+inline const QPoint operator*(double c, const QPoint &p)
+{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); }
+
+inline const QPoint operator*(int c, const QPoint &p)
+{ return QPoint(p.xp*c, p.yp*c); }
+
inline const QPoint operator-(const QPoint &p)
{ return QPoint(-p.xp, -p.yp); }
diff --git a/src/corelib/tools/qqueue.cpp b/src/corelib/tools/qqueue.cpp
index 922aee7..a256b03 100644
--- a/src/corelib/tools/qqueue.cpp
+++ b/src/corelib/tools/qqueue.cpp
@@ -91,6 +91,14 @@
*/
/*!
+ \fn void QQueue::swap(QQueue<T> &other)
+ \since 4.8
+
+ Swaps queue \a other with this queue. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn void QQueue::enqueue(const T& t)
Adds value \a t to the tail of the queue.
diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h
index 1916cd3..c0d5ce8 100644
--- a/src/corelib/tools/qqueue.h
+++ b/src/corelib/tools/qqueue.h
@@ -56,6 +56,7 @@ class QQueue : public QList<T>
public:
inline QQueue() {}
inline ~QQueue() {}
+ inline void swap(QQueue<T> &other) { QList<T>::swap(other); } // prevent QList<->QQueue swaps
inline void enqueue(const T &t) { QList<T>::append(t); }
inline T dequeue() { return QList<T>::takeFirst(); }
inline T &head() { return QList<T>::first(); }
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index c46d170..486a5df 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -3858,6 +3858,14 @@ QRegExp &QRegExp::operator=(const QRegExp &rx)
}
/*!
+ \fn void QRegExp::swap(QRegExp &other)
+ \since 4.8
+
+ Swaps regular expression \a other with this regular
+ expression. This operation is very fast and never fails.
+*/
+
+/*!
Returns true if this regular expression is equal to \a rx;
otherwise returns false.
@@ -4168,6 +4176,8 @@ int QRegExp::matchedLength() const
}
#ifndef QT_NO_REGEXP_CAPTURE
+
+#ifndef QT_NO_DEPRECATED
/*!
\obsolete
Returns the number of captures contained in the regular expression.
@@ -4178,6 +4188,7 @@ int QRegExp::numCaptures() const
{
return captureCount();
}
+#endif
/*!
\since 4.6
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 1cf8522..98d82f9 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -76,6 +76,11 @@ public:
QRegExp(const QRegExp &rx);
~QRegExp();
QRegExp &operator=(const QRegExp &rx);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QRegExp &operator=(QRegExp &&other)
+ { qSwap(priv,other.priv); return *this; }
+#endif
+ inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
bool operator==(const QRegExp &rx) const;
inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index f8a3613..92bccf5 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -54,7 +54,7 @@ struct QScopedPointerDeleter
static inline void cleanup(T *pointer)
{
// Enforce a complete type.
- // If you get a compile error here, read the secion on forward declared
+ // If you get a compile error here, read the section on forward declared
// classes in the QScopedPointer documentation.
typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
(void) sizeof(IsIncompleteType);
@@ -69,7 +69,7 @@ struct QScopedPointerArrayDeleter
static inline void cleanup(T *pointer)
{
// Enforce a complete type.
- // If you get a compile error here, read the secion on forward declared
+ // If you get a compile error here, read the section on forward declared
// classes in the QScopedPointer documentation.
typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ];
(void) sizeof(IsIncompleteType);
@@ -186,11 +186,30 @@ template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T, class Cleanup>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p1, QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
+
+
+namespace QtPrivate {
+ template <typename X, typename Y> struct QScopedArrayEnsureSameType;
+ template <typename X> struct QScopedArrayEnsureSameType<X,X> { typedef X* Type; };
+ template <typename X> struct QScopedArrayEnsureSameType<const X, X> { typedef X* Type; };
+}
+
template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
{
public:
- explicit inline QScopedArrayPointer(T *p = 0)
+ template <typename D>
+ explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = 0)
: QScopedPointer<T, Cleanup>(p)
{
}
@@ -206,6 +225,17 @@ public:
}
private:
+ explicit inline QScopedArrayPointer(void *) {
+ // Enforce the same type.
+
+ // If you get a compile error here, make sure you declare
+ // QScopedArrayPointer with the same template type as you pass to the
+ // constructor. See also the QScopedPointer documentation.
+
+ // Storing a scalar array as a pointer to a different type is not
+ // allowed and results in undefined behavior.
+ }
+
Q_DISABLE_COPY(QScopedArrayPointer)
};
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 1074f99..a2a8052 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -61,6 +61,11 @@ public:
inline QSet<T> &operator=(const QSet<T> &other)
{ q_hash = other.q_hash; return *this; }
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QSet<T> &operator=(QSet<T> &&other)
+ { qSwap(q_hash, other.q_hash); return *this; }
+#endif
+ inline void swap(QSet<T> &other) { q_hash.swap(other.q_hash); }
inline bool operator==(const QSet<T> &other) const
{ return q_hash == other.q_hash; }
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index 5249182..8748fd9 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -123,6 +123,13 @@
*/
/*!
+ \fn void QSet::swap(QSet<T> &other)
+
+ Swaps set \a other with this set. This operation is very fast and
+ never fails.
+*/
+
+/*!
\fn bool QSet::operator==(const QSet<T> &other) const
Returns true if the \a other set is equal to this set; otherwise
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 0b36c60..1494373 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -113,6 +113,11 @@ 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
inline bool operator!() const { return !d; }
@@ -163,14 +168,12 @@ public:
explicit QExplicitlySharedDataPointer(T *data);
inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<T> &o) : d(o.d) { if (d) d->ref.ref(); }
-#ifndef QT_NO_MEMBER_TEMPLATES
template<class X>
inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<X> &o) : d(static_cast<T *>(o.data()))
{
if(d)
d->ref.ref();
}
-#endif
inline QExplicitlySharedDataPointer<T> & operator=(const QExplicitlySharedDataPointer<T> &o) {
if (o.d != d) {
@@ -194,6 +197,11 @@ public:
}
return *this;
}
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) : d(o.d) { o.d = 0; }
+ inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
inline bool operator!() const { return !d; }
@@ -257,6 +265,20 @@ template <class T>
Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2)
{ p1.swap(p2); }
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p2)
+ { p1.swap(p2); }
+
+ template <class T>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 36131b1..b1f77b4 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1275,8 +1275,6 @@ QT_END_NAMESPACE
-#if !defined(QT_NO_MEMBER_TEMPLATES)
-
//# define QT_SHARED_POINTER_BACKTRACE_SUPPORT
# ifdef QT_SHARED_POINTER_BACKTRACE_SUPPORT
# if defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__) && !defined(QT_LINUXBASE)
@@ -1501,5 +1499,3 @@ void QtSharedPointer::internalSafetyCheckCleanCheck()
}
QT_END_NAMESPACE
-
-#endif
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 899bd1a..a57abb3 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -47,10 +47,7 @@
#include <QtCore/qshareddata.h>
#ifndef Q_QDOC
-# if !defined(QT_NO_MEMBER_TEMPLATES)
-// QSharedPointer requires member template support
# include <QtCore/qsharedpointer_impl.h>
-# endif
#else
QT_BEGIN_HEADER
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 0337c1f..b29e5b6 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -119,7 +119,6 @@ namespace QtSharedPointer {
template <class T> inline void normalDeleter(T *t) { delete t; }
// this uses partial template specialization
- // the only compilers that didn't support this were MSVC 6.0 and 2002
template <class T> struct RemovePointer;
template <class T> struct RemovePointer<T *> { typedef T Type; };
template <class T> struct RemovePointer<QSharedPointer<T> > { typedef T Type; };
@@ -333,7 +332,6 @@ namespace QtSharedPointer {
protected:
typedef ExternalRefCountData Data;
- inline void ref() const { d->weakref.ref(); d->strongref.ref(); }
inline void deref()
{ deref(d, this->value); }
static inline void deref(Data *d, T *value)
@@ -405,7 +403,13 @@ namespace QtSharedPointer {
template <class X>
inline void internalCopy(const ExternalRefCount<X> &other)
{
- internalSet(other.d, other.data());
+ Data *o = other.d;
+ T *actual = other.value;
+ if (o)
+ other.ref();
+ qSwap(d, o);
+ qSwap(this->value, actual);
+ deref(o, actual);
}
inline void internalSwap(ExternalRefCount &other)
@@ -421,6 +425,7 @@ namespace QtSharedPointer {
template <class X> friend class QT_PREPEND_NAMESPACE(QWeakPointer);
template <class X, class Y> friend QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &src);
#endif
+ inline void ref() const { d->weakref.ref(); d->strongref.ref(); }
inline void internalSet(Data *o, T *actual)
{
@@ -478,6 +483,13 @@ public:
BaseClass::internalCopy(other);
return *this;
}
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QSharedPointer<T> &operator=(QSharedPointer<T> &&other)
+ {
+ QSharedPointer<T>::internalSwap(other);
+ return *this;
+ }
+#endif
template <class X>
inline QSharedPointer(const QSharedPointer<X> &other) : BaseClass(other)
@@ -782,6 +794,16 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2)
p1.swap(p2);
}
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T>
+ inline void swap(QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
namespace QtSharedPointer {
// helper functions:
template <class X, class T>
@@ -862,9 +884,13 @@ qobject_cast(const QWeakPointer<T> &src)
{
return qSharedPointerObjectCast<typename QtSharedPointer::RemovePointer<X>::Type, T>(src);
}
-
#endif
+
+template<typename T> Q_DECLARE_TYPEINFO_BODY(QWeakPointer<T>, Q_MOVABLE_TYPE);
+template<typename T> Q_DECLARE_TYPEINFO_BODY(QSharedPointer<T>, Q_MOVABLE_TYPE);
+
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 0aea58c..f96703d 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -72,7 +72,12 @@
QT_BEGIN_NAMESPACE
-#if defined (Q_OS_WINCE)
+#if defined (Q_OS_NACL)
+static inline uint detectProcessorFeatures()
+{
+ return 0;
+}
+#elif defined (Q_OS_WINCE)
static inline uint detectProcessorFeatures()
{
uint features = 0;
diff --git a/src/corelib/tools/qstack.cpp b/src/corelib/tools/qstack.cpp
index 94595ec..f967b63 100644
--- a/src/corelib/tools/qstack.cpp
+++ b/src/corelib/tools/qstack.cpp
@@ -91,6 +91,14 @@
*/
/*!
+ \fn void QStack::swap(QStack<T> &other)
+ \since 4.8
+
+ Swaps stack \a other with this stack. This operation is very fast and
+ never fails.
+*/
+
+/*!
\fn void QStack::push(const T& t)
Adds element \a t to the top of the stack.
diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h
index 72a2c49..6e10103 100644
--- a/src/corelib/tools/qstack.h
+++ b/src/corelib/tools/qstack.h
@@ -56,6 +56,7 @@ class QStack : public QVector<T>
public:
inline QStack() {}
inline ~QStack() {}
+ inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
inline void push(const T &t) { QVector<T>::append(t); }
T pop();
T &top();
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index d01899d..b7272ec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -111,7 +111,23 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int from,
const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
-
+static inline int qt_last_index_of(const QChar *haystack, int haystackLen, const QChar &needle,
+ int from, Qt::CaseSensitivity cs);
+static inline int qt_string_count(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen,
+ Qt::CaseSensitivity cs);
+static inline int qt_string_count(const QChar *haystack, int haystackLen,
+ const QChar &needle, Qt::CaseSensitivity cs);
+static inline int qt_find_latin1_string(const QChar *hay, int size, const QLatin1String &needle,
+ int from, Qt::CaseSensitivity cs);
+static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
+static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
+ const QLatin1String &needle, Qt::CaseSensitivity cs);
+static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen, Qt::CaseSensitivity cs);
+static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
+ const QLatin1String &needle, Qt::CaseSensitivity cs);
// Unicode case-insensitive comparison
static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be)
@@ -350,11 +366,7 @@ inline char qToLower(char ch)
return ch;
}
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
-const QString::Null QString::null;
-#else
const QString::Null QString::null = { };
-#endif
/*!
\macro QT_NO_CAST_FROM_ASCII
@@ -703,7 +715,7 @@ const QString::Null QString::null = { };
formats, the \e precision represents the maximum number of
significant digits (trailing zeroes are omitted).
- \section1 More Efficient String Construction
+ \section1 More Efficient String Construction
Using the QString \c{'+'} operator, it is easy to construct a
complex string from multiple substrings. You will often write code
@@ -913,7 +925,7 @@ int QString::grow(int size)
/*!
\since 4.2
- Returns a copy of the \a string, where the encoding of \a string depends on
+ Returns a copy of the \a string, where the encoding of \a string depends on
the size of wchar. If wchar is 4 bytes, the \a string is interpreted as ucs-4,
if wchar is 2 bytes it is interpreted as ucs-2.
@@ -946,6 +958,24 @@ QString QString::fromWCharArray(const wchar_t *string, int size)
\sa utf16(), toAscii(), toLatin1(), toUtf8(), toLocal8Bit()
*/
+template<typename T> int toUcs4_helper(const unsigned short *uc, int length, T *out)
+{
+ int i = 0;
+ for (; i < length; ++i) {
+ uint u = uc[i];
+ if (QChar::isHighSurrogate(u) && i < length-1) {
+ ushort low = uc[i+1];
+ if (QChar::isLowSurrogate(low)) {
+ ++i;
+ u = QChar::surrogateToUcs4(u, low);
+ }
+ }
+ *out = T(u);
+ ++out;
+ }
+ return i;
+}
+
/*!
\since 4.2
@@ -970,21 +1000,7 @@ int QString::toWCharArray(wchar_t *array) const
memcpy(array, utf16(), sizeof(wchar_t)*length());
return length();
} else {
- wchar_t *a = array;
- const unsigned short *uc = utf16();
- for (int i = 0; i < length(); ++i) {
- uint u = uc[i];
- if (QChar::isHighSurrogate(u) && i + 1 < length()) {
- ushort low = uc[i+1];
- if (QChar::isLowSurrogate(low)) {
- u = QChar::surrogateToUcs4(u, low);
- ++i;
- }
- }
- *a = wchar_t(u);
- ++a;
- }
- return a - array;
+ return toUcs4_helper<wchar_t>(utf16(), length(), array);
}
}
@@ -1159,6 +1175,13 @@ QString::QString(QChar ch)
*/
+/*! \fn void QString::swap(QString &other)
+ \since 4.8
+
+ Swaps string \a other with this string. This operation is very fast and
+ never fails.
+*/
+
/*! \fn void QString::detach()
\internal
@@ -1317,7 +1340,9 @@ void QString::realloc(int alloc)
asciiCache->remove(d);
}
#endif
- d = static_cast<Data *>(q_check_ptr(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar))));
+ Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
+ Q_CHECK_PTR(p);
+ d = p;
d->alloc = alloc;
d->data = d->array;
}
@@ -2481,14 +2506,10 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
\sa lastIndexOf(), contains(), count()
*/
+
int QString::indexOf(const QLatin1String &str, int from, Qt::CaseSensitivity cs) const
{
- int len = qstrlen(str.latin1());
- QVarLengthArray<ushort> s(len);
- for (int i = 0; i < len; ++i)
- s[i] = str.latin1()[i];
-
- return qFindString(unicode(), length(), from, (const QChar *)s.data(), len, cs);
+ return qt_find_latin1_string(unicode(), size(), str, from, cs);
}
int qFindString(
@@ -2578,6 +2599,23 @@ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
return findChar(unicode(), length(), ch, from, cs);
}
+/*!
+ \since 4.8
+
+ \overload indexOf()
+
+ Returns the index position of the first occurrence of the string
+ reference \a str in this string, searching forward from index
+ position \a from. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+*/
+int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
+{
+ return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);
+}
+
static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs)
{
/*
@@ -2657,12 +2695,13 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
if (from > delta)
from = delta;
-
return lastIndexOfHelper(d->data, from, str.d->data, str.d->size, cs);
}
/*!
\since 4.5
+ \overload lastIndexOf()
+
Returns the index position of the last occurrence of the string \a
str in this string, searching backward from index position \a
from. If \a from is -1 (default), the search starts at the last
@@ -2710,26 +2749,43 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity
*/
int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
{
- ushort c = ch.unicode();
- if (from < 0)
- from += d->size;
- if (from < 0 || from >= d->size)
- return -1;
- if (from >= 0) {
- const ushort *n = d->data + from;
- const ushort *b = d->data;
- if (cs == Qt::CaseSensitive) {
- for (; n >= b; --n)
- if (*n == c)
- return n - b;
- } else {
- c = foldCase(c);
- for (; n >= b; --n)
- if (foldCase(*n) == c)
- return n - b;
- }
+ return qt_last_index_of(unicode(), size(), ch, from, cs);
}
+
+/*!
+ \since 4.8
+ \overload lastIndexOf()
+
+ Returns the index position of the last occurrence of the string
+ reference \a str in this string, searching backward from index
+ position \a from. If \a from is -1 (default), the search starts at
+ the last character; if \a from is -2, at the next to last character
+ and so on. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa indexOf(), contains(), count()
+*/
+int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
+{
+ const int sl = str.size();
+ if (sl == 1)
+ return lastIndexOf(str.at(0), from, cs);
+
+ const int l = d->size;
+ if (from < 0)
+ from += l;
+ int delta = l - sl;
+ if (from == l && sl == 0)
+ return from;
+ if (from < 0 || from >= l || delta < 0)
return -1;
+ if (from > delta)
+ from = delta;
+
+ return lastIndexOfHelper(d->data, from, reinterpret_cast<const ushort*>(str.unicode()),
+ str.size(), cs);
}
#ifndef QT_NO_REGEXP
@@ -2904,19 +2960,10 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
\sa contains(), indexOf()
*/
+
int QString::count(const QString &str, Qt::CaseSensitivity cs) const
{
- int num = 0;
- int i = -1;
- if (d->size > 500 && str.d->size > 5) {
- QStringMatcher matcher(str, cs);
- while ((i = matcher.indexIn(*this, i + 1)) != -1)
- ++num;
- } else {
- while ((i = indexOf(str, i + 1, cs)) != -1)
- ++num;
- }
- return num;
+ return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
}
/*!
@@ -2924,25 +2971,29 @@ int QString::count(const QString &str, Qt::CaseSensitivity cs) const
Returns the number of occurrences of character \a ch in the string.
*/
+
int QString::count(QChar ch, Qt::CaseSensitivity cs) const
{
- ushort c = ch.unicode();
- int num = 0;
- const ushort *i = d->data + d->size;
- const ushort *b = d->data;
- if (cs == Qt::CaseSensitive) {
- while (i != b)
- if (*--i == c)
- ++num;
- } else {
- c = foldCase(c);
- while (i != b)
- if (foldCase(*(--i)) == c)
- ++num;
+ return qt_string_count(unicode(), size(), ch, cs);
}
- return num;
+
+/*!
+ \since 4.8
+ \overload count()
+ Returns the number of (potentially overlapping) occurrences of the
+ string reference \a str in this string.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa contains(), indexOf()
+*/
+int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const
+{
+ return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
}
+
/*! \fn bool QString::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
Returns true if this string contains an occurrence of the string
@@ -2965,6 +3016,18 @@ int QString::count(QChar ch, Qt::CaseSensitivity cs) const
character \a ch; otherwise returns false.
*/
+/*! \fn bool QString::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \since 4.8
+
+ Returns true if this string contains an occurrence of the string
+ reference \a str; otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa indexOf(), count()
+*/
+
/*! \fn bool QString::contains(const QRegExp &rx) const
\overload contains()
@@ -3366,22 +3429,8 @@ QString QString::mid(int position, int n) const
*/
bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const
{
- if (d == &shared_null)
- return (s.d == &shared_null);
- if (d->size == 0)
- return s.d->size == 0;
- if (s.d->size > d->size)
- return false;
- if (cs == Qt::CaseSensitive) {
- return qMemEquals(d->data, s.d->data, s.d->size);
- } else {
- uint last = 0;
- uint olast = 0;
- for (int i = 0; i < s.d->size; ++i)
- if (foldCase(d->data[i], last) != foldCase(s.d->data[i], olast))
- return false;
- }
- return true;
+ return qt_starts_with(isNull() ? 0 : unicode(), size(),
+ s.isNull() ? 0 : s.unicode(), s.size(), cs);
}
/*!
@@ -3389,24 +3438,7 @@ bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const
*/
bool QString::startsWith(const QLatin1String& s, Qt::CaseSensitivity cs) const
{
- if (d == &shared_null)
- return (s.latin1() == 0);
- if (d->size == 0)
- return !s.latin1() || *s.latin1() == 0;
- int slen = qstrlen(s.latin1());
- if (slen > d->size)
- return false;
- const uchar *latin = (const uchar *)s.latin1();
- if (cs == Qt::CaseSensitive) {
- for (int i = 0; i < slen; ++i)
- if (d->data[i] != latin[i])
- return false;
- } else {
- for (int i = 0; i < slen; ++i)
- if (foldCase(d->data[i]) != foldCase((ushort)latin[i]))
- return false;
- }
- return true;
+ return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs);
}
/*!
@@ -3424,6 +3456,23 @@ bool QString::startsWith(const QChar &c, Qt::CaseSensitivity cs) const
}
/*!
+ \since 4.8
+ \overload
+ Returns true if the string starts with the string reference \a s;
+ otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa endsWith()
+*/
+bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const
+{
+ return qt_starts_with(isNull() ? 0 : unicode(), size(),
+ s.isNull() ? 0 : s.unicode(), s.size(), cs);
+}
+
+/*!
Returns true if the string ends with \a s; otherwise returns
false.
@@ -3436,49 +3485,34 @@ bool QString::startsWith(const QChar &c, Qt::CaseSensitivity cs) const
*/
bool QString::endsWith(const QString& s, Qt::CaseSensitivity cs) const
{
- if (d == &shared_null)
- return (s.d == &shared_null);
- if (d->size == 0)
- return s.d->size == 0;
- int pos = d->size - s.d->size;
- if (pos < 0)
- return false;
- if (cs == Qt::CaseSensitive) {
- return qMemEquals(d->data + pos, s.d->data, s.d->size);
- } else {
- uint last = 0;
- uint olast = 0;
- for (int i = 0; i < s.length(); i++)
- if (foldCase(d->data[pos+i], last) != foldCase(s.d->data[i], olast))
- return false;
+ return qt_ends_with(isNull() ? 0 : unicode(), size(),
+ s.isNull() ? 0 : s.unicode(), s.size(), cs);
}
- return true;
+
+/*!
+ \since 4.8
+ \overload endsWith()
+ Returns true if the string ends with the string reference \a s;
+ otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa startsWith()
+*/
+bool QString::endsWith(const QStringRef &s, Qt::CaseSensitivity cs) const
+{
+ return qt_ends_with(isNull() ? 0 : unicode(), size(),
+ s.isNull() ? 0 : s.unicode(), s.size(), cs);
}
+
/*!
\overload endsWith()
*/
bool QString::endsWith(const QLatin1String& s, Qt::CaseSensitivity cs) const
{
- if (d == &shared_null)
- return (s.latin1() == 0);
- if (d->size == 0)
- return !s.latin1() || *s.latin1() == 0;
- int slen = qstrlen(s.latin1());
- int pos = d->size - slen;
- const uchar *latin = (const uchar *)s.latin1();
- if (pos < 0)
- return false;
- if (cs == Qt::CaseSensitive) {
- for (int i = 0; i < slen; i++)
- if (d->data[pos+i] != latin[i])
- return false;
- } else {
- for (int i = 0; i < slen; i++)
- if (foldCase(d->data[pos+i]) != foldCase((ushort)latin[i]))
- return false;
- }
- return true;
+ return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs);
}
/*!
@@ -3717,20 +3751,8 @@ QVector<uint> QString::toUcs4() const
{
QVector<uint> v(length());
uint *a = v.data();
- const unsigned short *uc = utf16();
- for (int i = 0; i < length(); ++i) {
- uint u = uc[i];
- if (QChar(u).isHighSurrogate() && i < length()-1) {
- ushort low = uc[i+1];
- if (QChar(low).isLowSurrogate()) {
- ++i;
- u = QChar::surrogateToUcs4(u, low);
- }
- }
- *a = u;
- ++a;
- }
- v.resize(a - v.data());
+ int len = toUcs4_helper<uint>(utf16(), length(), a);
+ v.resize(len);
return v;
}
@@ -6239,28 +6261,32 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
if (version == QChar::Unicode_Unassigned) {
version = UNICODE_DATA_VERSION;
} else if (version != UNICODE_DATA_VERSION) {
- QString &s = *data;
+ const QString &s = *data;
+ QChar *d = 0;
for (int i = 0; i < NumNormalizationCorrections; ++i) {
const NormalizationCorrection &n = uc_normalization_corrections[i];
if (n.version > version) {
int pos = from;
- if (n.ucs4 > 0xffff) {
+ if (QChar::requiresSurrogates(n.ucs4)) {
ushort ucs4High = QChar::highSurrogate(n.ucs4);
ushort ucs4Low = QChar::lowSurrogate(n.ucs4);
ushort oldHigh = QChar::highSurrogate(n.old_mapping);
ushort oldLow = QChar::lowSurrogate(n.old_mapping);
while (pos < s.length() - 1) {
if (s.at(pos).unicode() == ucs4High && s.at(pos + 1).unicode() == ucs4Low) {
- s[pos] = oldHigh;
- s[pos + 1] = oldLow;
- ++pos;
+ if (!d)
+ d = data->data();
+ d[pos] = QChar(oldHigh);
+ d[++pos] = QChar(oldLow);
}
++pos;
}
} else {
while (pos < s.length()) {
if (s.at(pos).unicode() == n.ucs4) {
- s[pos] = n.old_mapping;
+ if (!d)
+ d = data->data();
+ d[pos] = QChar(n.old_mapping);
}
++pos;
}
@@ -7445,31 +7471,17 @@ QDataStream &operator<<(QDataStream &out, const QString &str)
out << str.toLatin1();
} else {
if (!str.isNull() || out.version() < 3) {
- int byteOrder = out.byteOrder();
- const QChar* ub = str.unicode();
- static const uint auto_size = 1024;
- char t[auto_size];
- char *b;
- if (str.length()*sizeof(QChar) > auto_size) {
- b = new char[str.length()*sizeof(QChar)];
+ if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
+ out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length());
} else {
- b = t;
- }
- int l = str.length();
- char *c=b;
- while (l--) {
- if (byteOrder == QDataStream::BigEndian) {
- *c++ = (char)ub->row();
- *c++ = (char)ub->cell();
- } else {
- *c++ = (char)ub->cell();
- *c++ = (char)ub->row();
+ QVarLengthArray<ushort> buffer(str.length());
+ const ushort *data = reinterpret_cast<const ushort *>(str.constData());
+ for (int i = 0; i < str.length(); i++) {
+ buffer[i] = qbswap(*data);
+ ++data;
}
- ub++;
+ out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size());
}
- out.writeBytes(b, sizeof(QChar)*str.length());
- if (str.length()*sizeof(QChar) > auto_size)
- delete [] b;
} else {
// write null marker
out << (quint32)0xffffffff;
@@ -7662,6 +7674,7 @@ QDataStream &operator>>(QDataStream &in, QString &str)
Use the startsWith(QString, Qt::CaseSensitive) overload instead.
*/
+
/*!
\fn bool QString::endsWith(const QString &s, bool cs) const
@@ -8367,4 +8380,717 @@ QStringRef QString::midRef(int position, int n) const
return QStringRef(this, position, n);
}
+/*!
+ \since 4.8
+
+ Returns the index position of the first occurrence of the string \a
+ str in this string reference, searching forward from index position
+ \a from. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ If \a from is -1, the search starts at the last character; if it is
+ -2, at the next to last character and so on.
+
+ \sa QString::indexOf(), lastIndexOf(), contains(), count()
+*/
+int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
+{
+ return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload indexOf()
+
+ Returns the index position of the first occurrence of the
+ character \a ch in the string reference, searching forward from
+ index position \a from. Returns -1 if \a ch could not be found.
+
+ \sa QString::indexOf(), lastIndexOf(), contains(), count()
+*/
+int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
+{
+ return findChar(unicode(), length(), ch, from, cs);
+}
+
+/*!
+ \since 4.8
+
+ Returns the index position of the first occurrence of the string \a
+ str in this string reference, searching forward from index position
+ \a from. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ If \a from is -1, the search starts at the last character; if it is
+ -2, at the next to last character and so on.
+
+ \sa QString::indexOf(), lastIndexOf(), contains(), count()
+*/
+int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const
+{
+ return qt_find_latin1_string(unicode(), size(), str, from, cs);
+}
+
+/*!
+ \since 4.8
+
+ \overload indexOf()
+
+ Returns the index position of the first occurrence of the string
+ reference \a str in this string reference, searching forward from
+ index position \a from. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::indexOf(), lastIndexOf(), contains(), count()
+*/
+int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
+{
+ return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+
+ Returns the index position of the last occurrence of the string \a
+ str in this string reference, searching backward from index position
+ \a from. If \a from is -1 (default), the search starts at the last
+ character; if \a from is -2, at the next to last character and so
+ on. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::lastIndexOf(), indexOf(), contains(), count()
+*/
+int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
+{
+ const int sl = str.size();
+ if (sl == 1)
+ return lastIndexOf(str.at(0), from, cs);
+
+ const int l = size();;
+ if (from < 0)
+ from += l;
+ int delta = l - sl;
+ if (from == l && sl == 0)
+ return from;
+ if (from < 0 || from >= l || delta < 0)
+ return -1;
+ if (from > delta)
+ from = delta;
+
+ return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from,
+ reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload lastIndexOf()
+
+ Returns the index position of the last occurrence of the character
+ \a ch, searching backward from position \a from.
+
+ \sa QString::lastIndexOf(), indexOf(), contains(), count()
+*/
+int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
+{
+ return qt_last_index_of(unicode(), size(), ch, from, cs);
+}
+
+/*!
+ \since 4.8
+ \overload lastIndexOf()
+
+ Returns the index position of the last occurrence of the string \a
+ str in this string reference, searching backward from index position
+ \a from. If \a from is -1 (default), the search starts at the last
+ character; if \a from is -2, at the next to last character and so
+ on. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::lastIndexOf(), indexOf(), contains(), count()
+*/
+int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const
+{
+ const int sl = qstrlen(str.latin1());
+ if (sl == 1)
+ return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
+
+ const int l = size();
+ if (from < 0)
+ from += l;
+ int delta = l - sl;
+ if (from == l && sl == 0)
+ return from;
+ if (from < 0 || from >= l || delta < 0)
+ return -1;
+ if (from > delta)
+ from = delta;
+
+ QVarLengthArray<ushort> s(sl);
+ for (int i = 0; i < sl; ++i)
+ s[i] = str.latin1()[i];
+
+ return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from, s.data(), sl, cs);
+}
+
+/*!
+ \since 4.8
+ \overload lastIndexOf()
+
+ Returns the index position of the last occurrence of the string
+ reference \a str in this string reference, searching backward from
+ index position \a from. If \a from is -1 (default), the search
+ starts at the last character; if \a from is -2, at the next to last
+ character and so on. Returns -1 if \a str is not found.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::lastIndexOf(), indexOf(), contains(), count()
+*/
+int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
+{
+ const int sl = str.size();
+ if (sl == 1)
+ return lastIndexOf(str.at(0), from, cs);
+
+ const int l = size();
+ if (from < 0)
+ from += l;
+ int delta = l - sl;
+ if (from == l && sl == 0)
+ return from;
+ if (from < 0 || from >= l || delta < 0)
+ return -1;
+ if (from > delta)
+ from = delta;
+
+ return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from,
+ reinterpret_cast<const ushort*>(str.unicode()),
+ str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ Returns the number of (potentially overlapping) occurrences of
+ the string \a str in this string reference.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa QString::count(), contains(), indexOf()
+*/
+int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const
+{
+ return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload count()
+
+ Returns the number of occurrences of the character \a ch in the
+ string reference.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa QString::count(), contains(), indexOf()
+*/
+int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const
+{
+ return qt_string_count(unicode(), size(), ch, cs);
+}
+
+/*!
+ \since 4.8
+ \overload count()
+
+ Returns the number of (potentially overlapping) occurrences of the
+ string reference \a str in this string reference.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa QString::count(), contains(), indexOf()
+*/
+int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const
+{
+ return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+
+ Returns true if the string reference starts with \a str; otherwise
+ returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa QString::startsWith(), endsWith()
+*/
+bool QStringRef::startsWith(const QString &str, Qt::CaseSensitivity cs) const
+{
+ return qt_starts_with(isNull() ? 0 : unicode(), size(),
+ str.isNull() ? 0 : str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload startsWith()
+ \sa QString::startsWith(), endsWith()
+*/
+bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs) const
+{
+ return qt_starts_with(isNull() ? 0 : unicode(), size(), str, cs);
+}
+
+/*!
+ \since 4.8
+ \overload startsWith()
+ \sa QString::startsWith(), endsWith()
+*/
+bool QStringRef::startsWith(const QStringRef &str, Qt::CaseSensitivity cs) const
+{
+ return qt_starts_with(isNull() ? 0 : unicode(), size(),
+ str.isNull() ? 0 : str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload startsWith()
+
+ Returns true if the string reference starts with \a ch; otherwise
+ returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::startsWith(), endsWith()
+*/
+bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs) const
+{
+ if (!isEmpty()) {
+ const ushort *data = reinterpret_cast<const ushort*>(unicode());
+ return (cs == Qt::CaseSensitive
+ ? data[0] == ch
+ : foldCase(data[0]) == foldCase(ch.unicode()));
+ } else {
+ return false;
+ }
+}
+
+/*!
+ \since 4.8
+ Returns true if the string reference ends with \a str; otherwise
+ returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::endsWith(), startsWith()
+*/
+bool QStringRef::endsWith(const QString &str, Qt::CaseSensitivity cs) const
+{
+ return qt_ends_with(isNull() ? 0 : unicode(), size(),
+ str.isNull() ? 0 : str.unicode(), str.size(), cs);
+}
+
+/*!
+ \since 4.8
+ \overload endsWith()
+
+ Returns true if the string reference ends with \a ch; otherwise
+ returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is case
+ sensitive; otherwise the search is case insensitive.
+
+ \sa QString::endsWith(), endsWith()
+*/
+bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs) const
+{
+ if (!isEmpty()) {
+ const ushort *data = reinterpret_cast<const ushort*>(unicode());
+ const int size = length();
+ return (cs == Qt::CaseSensitive
+ ? data[size - 1] == ch
+ : foldCase(data[size - 1]) == foldCase(ch.unicode()));
+ } else {
+ return false;
+ }
+}
+
+/*!
+ \since 4.8
+ \overload endsWith()
+ \sa QString::endsWith(), endsWith()
+*/
+bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs) const
+{
+ return qt_ends_with(isNull() ? 0 : unicode(), size(), str, cs);
+}
+
+/*!
+ \since 4.8
+ \overload endsWith()
+ \sa QString::endsWith(), endsWith()
+*/
+bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const
+{
+ return qt_ends_with(isNull() ? 0 : unicode(), size(),
+ str.isNull() ? 0 : str.unicode(), str.size(), cs);
+}
+
+
+/*! \fn bool QStringRef::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+
+ \since 4.8
+ Returns true if this string reference contains an occurrence of
+ the string \a str; otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa indexOf(), count()
+*/
+
+/*! \fn bool QStringRef::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+
+ \overload contains()
+ \since 4.8
+
+ Returns true if this string contains an occurrence of the
+ character \a ch; otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+*/
+
+/*! \fn bool QStringRef::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \overload contains()
+ \since 4.8
+
+ Returns true if this string reference contains an occurrence of
+ the string reference \a str; otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa indexOf(), count()
+*/
+
+/*! \fn bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs) const
+ \since 4,8
+ \overload contains()
+
+ Returns true if this string reference contains an occurrence of
+ the string \a str; otherwise returns false.
+
+ If \a cs is Qt::CaseSensitive (default), the search is
+ case sensitive; otherwise the search is case insensitive.
+
+ \sa indexOf(), count()
+*/
+
+static inline int qt_last_index_of(const QChar *haystack, int haystackLen, const QChar &needle,
+ int from, Qt::CaseSensitivity cs)
+{
+ ushort c = needle.unicode();
+ if (from < 0)
+ from += haystackLen;
+ if (from < 0 || from >= haystackLen)
+ return -1;
+ if (from >= 0) {
+ const ushort *b = reinterpret_cast<const ushort*>(haystack);
+ const ushort *n = b + from;
+ if (cs == Qt::CaseSensitive) {
+ for (; n >= b; --n)
+ if (*n == c)
+ return n - b;
+ } else {
+ c = foldCase(c);
+ for (; n >= b; --n)
+ if (foldCase(*n) == c)
+ return n - b;
+ }
+ }
+ return -1;
+
+
+}
+
+static inline int qt_string_count(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen,
+ Qt::CaseSensitivity cs)
+{
+ int num = 0;
+ int i = -1;
+ if (haystackLen > 500 && needleLen > 5) {
+ QStringMatcher matcher(needle, needleLen, cs);
+ while ((i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1)
+ ++num;
+ } else {
+ while ((i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1)
+ ++num;
+ }
+ return num;
+}
+
+static inline int qt_string_count(const QChar *unicode, int size, const QChar &ch,
+ Qt::CaseSensitivity cs)
+{
+ ushort c = ch.unicode();
+ int num = 0;
+ const ushort *b = reinterpret_cast<const ushort*>(unicode);
+ const ushort *i = b + size;
+ if (cs == Qt::CaseSensitive) {
+ while (i != b)
+ if (*--i == c)
+ ++num;
+ } else {
+ c = foldCase(c);
+ while (i != b)
+ if (foldCase(*(--i)) == c)
+ ++num;
+ }
+ return num;
+}
+
+static inline int qt_find_latin1_string(const QChar *haystack, int size,
+ const QLatin1String &needle,
+ int from, Qt::CaseSensitivity cs)
+{
+ const char *latin1 = needle.latin1();
+ int len = qstrlen(latin1);
+ QVarLengthArray<ushort> s(len);
+ for (int i = 0; i < len; ++i)
+ s[i] = latin1[i];
+
+ return qFindString(haystack, size, from,
+ reinterpret_cast<const QChar*>(s.constData()), len, cs);
+}
+
+static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
+{
+ if (!haystack)
+ return !needle;
+ if (haystackLen == 0)
+ return needleLen == 0;
+ if (needleLen > haystackLen)
+ return false;
+
+ const ushort *h = reinterpret_cast<const ushort*>(haystack);
+ const ushort *n = reinterpret_cast<const ushort*>(needle);
+
+ if (cs == Qt::CaseSensitive) {
+ return qMemEquals(h, n, needleLen);
+ } else {
+ uint last = 0;
+ uint olast = 0;
+ for (int i = 0; i < needleLen; ++i)
+ if (foldCase(h[i], last) != foldCase(n[i], olast))
+ return false;
+ }
+ return true;
+}
+
+static inline bool qt_starts_with(const QChar *haystack, int haystackLen,
+ const QLatin1String &needle, Qt::CaseSensitivity cs)
+{
+ if (!haystack)
+ return !needle.latin1();
+ if (haystackLen == 0)
+ return !needle.latin1() || *needle.latin1() == 0;
+ const int slen = qstrlen(needle.latin1());
+ if (slen > haystackLen)
+ return false;
+ const ushort *data = reinterpret_cast<const ushort*>(haystack);
+ const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1());
+ if (cs == Qt::CaseSensitive) {
+ for (int i = 0; i < slen; ++i)
+ if (data[i] != latin[i])
+ return false;
+ } else {
+ for (int i = 0; i < slen; ++i)
+ if (foldCase(data[i]) != foldCase((ushort)latin[i]))
+ return false;
+ }
+ return true;
+}
+
+static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
+ const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
+{
+ if (!haystack)
+ return !needle;
+ if (haystackLen == 0)
+ return needleLen == 0;
+ const int pos = haystackLen - needleLen;
+ if (pos < 0)
+ return false;
+
+ const ushort *h = reinterpret_cast<const ushort*>(haystack);
+ const ushort *n = reinterpret_cast<const ushort*>(needle);
+
+ if (cs == Qt::CaseSensitive) {
+ return qMemEquals(h + pos, n, needleLen);
+ } else {
+ uint last = 0;
+ uint olast = 0;
+ for (int i = 0; i < needleLen; i++)
+ if (foldCase(h[pos+i], last) != foldCase(n[i], olast))
+ return false;
+ }
+ return true;
+}
+
+
+static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
+ const QLatin1String &needle, Qt::CaseSensitivity cs)
+{
+ if (!haystack)
+ return !needle.latin1();
+ if (haystackLen == 0)
+ return !needle.latin1() || *needle.latin1() == 0;
+ const int slen = qstrlen(needle.latin1());
+ int pos = haystackLen - slen;
+ if (pos < 0)
+ return false;
+ const uchar *latin = reinterpret_cast<const uchar*>(needle.latin1());
+ const ushort *data = reinterpret_cast<const ushort*>(haystack);
+ if (cs == Qt::CaseSensitive) {
+ for (int i = 0; i < slen; i++)
+ if (data[pos+i] != latin[i])
+ return false;
+ } else {
+ for (int i = 0; i < slen; i++)
+ if (foldCase(data[pos+i]) != foldCase((ushort)latin[i]))
+ return false;
+ }
+ return true;
+}
+
+/*!
+ \since 4.8
+
+ Returns a Latin-1 representation of the string as a QByteArray.
+
+ The returned byte array is undefined if the string contains non-Latin1
+ characters. Those characters may be suppressed or replaced with a
+ question mark.
+
+ \sa toAscii(), toUtf8(), toLocal8Bit(), QTextCodec
+*/
+QByteArray QStringRef::toLatin1() const
+{
+ return toLatin1_helper(unicode(), length());
+}
+
+/*!
+ \since 4.8
+
+ Returns an 8-bit representation of the string as a QByteArray.
+
+ If a codec has been set using QTextCodec::setCodecForCStrings(),
+ it is used to convert Unicode to 8-bit char; otherwise this
+ function does the same as toLatin1().
+
+ Note that, despite the name, this function does not necessarily return an US-ASCII
+ (ANSI X3.4-1986) string and its result may not be US-ASCII compatible.
+
+ \sa toLatin1(), toUtf8(), toLocal8Bit(), QTextCodec
+*/
+QByteArray QStringRef::toAscii() const
+{
+#ifndef QT_NO_TEXTCODEC
+ if (QString::codecForCStrings)
+ return QString::codecForCStrings->fromUnicode(unicode(), length());
+#endif // QT_NO_TEXTCODEC
+ return toLatin1();
+}
+
+/*!
+ \since 4.8
+
+ Returns the local 8-bit representation of the string as a
+ QByteArray. The returned byte array is undefined if the string
+ contains characters not supported by the local 8-bit encoding.
+
+ QTextCodec::codecForLocale() is used to perform the conversion from
+ Unicode. If the locale encoding could not be determined, this function
+ does the same as toLatin1().
+
+ If this string contains any characters that cannot be encoded in the
+ locale, the returned byte array is undefined. Those characters may be
+ suppressed or replaced by another.
+
+ \sa toAscii(), toLatin1(), toUtf8(), QTextCodec
+*/
+QByteArray QStringRef::toLocal8Bit() const
+{
+#ifndef QT_NO_TEXTCODEC
+ if (QTextCodec::codecForLocale())
+ return QTextCodec::codecForLocale()->fromUnicode(unicode(), length());
+#endif // QT_NO_TEXTCODEC
+ return toLatin1();
+}
+
+/*!
+ \since 4.8
+
+ Returns a UTF-8 representation of the string as a QByteArray.
+
+ UTF-8 is a Unicode codec and can represent all characters in a Unicode
+ string like QString.
+
+ However, in the Unicode range, there are certain codepoints that are not
+ considered characters. The Unicode standard reserves the last two
+ codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
+ U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF,
+ inclusive, as non-characters. If any of those appear in the string, they
+ may be discarded and will not appear in the UTF-8 representation, or they
+ may be replaced by one or more replacement characters.
+
+ \sa toAscii(), toLatin1(), toLocal8Bit(), QTextCodec
+*/
+QByteArray QStringRef::toUtf8() const
+{
+ if (isNull())
+ return QByteArray();
+
+ return QUtf8::convertFromUnicode(constData(), length(), 0);
+}
+
+/*!
+ \since 4.8
+
+ Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.
+
+ UCS-4 is a Unicode codec and is lossless. All characters from this string
+ can be encoded in UCS-4.
+
+ \sa fromUtf8(), toAscii(), toLatin1(), toLocal8Bit(), QTextCodec, fromUcs4(), toWCharArray()
+*/
+QVector<uint> QStringRef::toUcs4() const
+{
+ QVector<uint> v(length());
+ uint *a = v.data();
+ int len = toUcs4_helper<uint>(reinterpret_cast<const unsigned short *>(unicode()), length(), a);
+ v.resize(len);
+ return v;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 36503fd..b54258f 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -51,14 +51,7 @@
#endif
#ifndef QT_NO_STL
-# if defined (Q_CC_MSVC_NET) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450
-# pragma warning (push)
-# pragma warning (disable : 4189)
-# include <string>
-# pragma warning (pop)
-# else
-# include <string>
-# endif
+# include <string>
# ifndef QT_NO_STL_WCHAR
// workaround for some headers not typedef'ing std::wstring
@@ -111,7 +104,11 @@ public:
QString &operator=(QChar c);
QString &operator=(const QString &);
inline QString &operator=(const QLatin1String &);
-
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QString &operator=(QString &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QString &other) { qSwap(d, other.d); }
inline int size() const { return d->size; }
inline int count() const { return d->size; }
inline int length() const;
@@ -198,14 +195,18 @@ public:
int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int indexOf(const QLatin1String &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int indexOf(const QStringRef &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int lastIndexOf(const QLatin1String &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int lastIndexOf(const QStringRef &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline QBool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline QBool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ inline QBool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#ifndef QT_NO_REGEXP
int indexOf(const QRegExp &, int from = 0) const;
@@ -241,9 +242,11 @@ public:
QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT;
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool endsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -902,6 +905,8 @@ inline QString::const_iterator QString::constEnd() const
{ return reinterpret_cast<const QChar*>(d->data + d->size); }
inline QBool QString::contains(const QString &s, Qt::CaseSensitivity cs) const
{ return QBool(indexOf(s, 0, cs) != -1); }
+inline QBool QString::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
+{ return QBool(indexOf(s, 0, cs) != -1); }
inline QBool QString::contains(QChar c, Qt::CaseSensitivity cs) const
{ return QBool(indexOf(c, 0, cs) != -1); }
@@ -1123,6 +1128,34 @@ public:
m_size = other.m_size; return *this;
}
+ int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+
+ inline QBool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ inline QBool contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ inline QBool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ inline QBool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+
+ int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+
+ bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool startsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+
+ bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool endsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+
inline QStringRef &operator=(const QString *string);
inline const QChar *unicode() const {
@@ -1133,6 +1166,12 @@ public:
inline const QChar *data() const { return unicode(); }
inline const QChar *constData() const { return unicode(); }
+ QByteArray toAscii() const Q_REQUIRED_RESULT;
+ QByteArray toLatin1() const Q_REQUIRED_RESULT;
+ QByteArray toUtf8() const Q_REQUIRED_RESULT;
+ QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
+ QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
+
inline void clear() { m_string = 0; m_position = m_size = 0; }
QString toString() const;
inline bool isEmpty() const { return m_size == 0; }
@@ -1241,6 +1280,16 @@ inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QString &s
inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef &s2)
{ return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
+inline QBool QStringRef::contains(const QString &s, Qt::CaseSensitivity cs) const
+{ return QBool(indexOf(s, 0, cs) != -1); }
+inline QBool QStringRef::contains(QLatin1String s, Qt::CaseSensitivity cs) const
+{ return QBool(indexOf(s, 0, cs) != -1); }
+inline QBool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
+{ return QBool(indexOf(c, 0, cs) != -1); }
+inline QBool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
+{ return QBool(indexOf(s, 0, cs) != -1); }
+
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 53368eb..7d75de7 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -150,8 +150,8 @@ QT_BEGIN_NAMESPACE
void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
{
#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) {
- QString tmp = QString::fromAscii(a);
+ if (QString::codecForCStrings && len) {
+ QString tmp = QString::fromAscii(a, len > 0 ? len - 1 : -1);
memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
out += tmp.length();
return;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 8d9537c..d230d67 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -270,10 +270,11 @@ template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
{
typedef QByteArray type;
enum { ExactSize = false };
- static int size(const QByteArray &ba) { return qstrnlen(ba.constData(), ba.size()); }
+ static int size(const QByteArray &ba) { return ba.size(); }
static inline void appendTo(const QByteArray &ba, QChar *&out)
{
- QAbstractConcatenable::convertFromAscii(ba.constData(), -1, out);
+ // adding 1 because convertFromAscii expects the size including the null-termination
+ QAbstractConcatenable::convertFromAscii(ba.constData(), ba.size() + 1, out);
}
};
#endif
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index b1b5bd8..6a98755 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -44,7 +44,10 @@
#include <QtCore/qcontainerfwd.h>
#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
+
#include <new>
+#include <string.h>
QT_BEGIN_HEADER
@@ -123,6 +126,18 @@ public:
}
}
void append(const T *buf, int size);
+ inline QVarLengthArray<T, Prealloc> &operator<<(const T &t)
+ { append(t); return *this; }
+ inline QVarLengthArray<T, Prealloc> &operator+=(const T &t)
+ { append(t); return *this; }
+
+ void prepend(const T &t);
+ void insert(int i, const T &t);
+ void insert(int i, int n, const T &t);
+ void replace(int i, const T &t);
+ void remove(int i);
+ void remove(int i, int n);
+
inline T *data() { return ptr; }
inline const T *data() const { return ptr; }
@@ -135,6 +150,21 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
+
+ typedef T* iterator;
+ typedef const T* const_iterator;
+
+ inline iterator begin() { return ptr; }
+ inline const_iterator begin() const { return ptr; }
+ inline const_iterator constBegin() const { return ptr; }
+ inline iterator end() { return ptr + s; }
+ inline const_iterator end() const { return ptr + s; }
+ inline const_iterator constEnd() const { return ptr + s; }
+ iterator insert(iterator before, int n, const T &x);
+ inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
+ iterator erase(iterator begin, iterator end);
+ inline iterator erase(iterator pos) { return erase(pos, pos+1); }
+
private:
friend class QPodList<T, Prealloc>;
void realloc(int size, int alloc);
@@ -272,6 +302,100 @@ Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i, const T &defau
return (i < 0 || i >= size()) ? defaultValue : at(i);
}
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::insert(int i, const T &t)
+{ Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
+ insert(begin() + i, 1, t); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::insert(int i, int n, const T &t)
+{ Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
+ insert(begin() + i, n, t); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::remove(int i, int n)
+{ Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= s, "QVarLengthArray::remove", "index out of range");
+ erase(begin() + i, begin() + i + n); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::remove(int i)
+{ Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::remove", "index out of range");
+ erase(begin() + i, begin() + i + 1); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::prepend(const T &t)
+{ insert(begin(), 1, t); }
+
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::replace(int i, const T &t)
+{
+ Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::replace", "index out of range");
+ const T copy(t);
+ data()[i] = copy;
+}
+
+
+template <class T, int Prealloc>
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(iterator before, size_type n, const T &t)
+{
+ int offset = int(before - ptr);
+ if (n != 0) {
+ resize(s + n);
+ const T copy(t);
+ if (QTypeInfo<T>::isStatic) {
+ T *b = ptr + offset;
+ T *j = ptr + s;
+ T *i = j - n;
+ while (i != b)
+ *--j = *--i;
+ i = b + n;
+ while (i != b)
+ *--i = copy;
+ } else {
+ T *b = ptr + offset;
+ T *i = b + n;
+ memmove(i, b, (s - offset - n) * sizeof(T));
+ while (i != b)
+ new (--i) T(copy);
+ }
+ }
+ return ptr + offset;
+}
+
+template <class T, int Prealloc>
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(iterator abegin, iterator aend)
+{
+ int f = int(abegin - ptr);
+ int l = int(aend - ptr);
+ int n = l - f;
+ if (QTypeInfo<T>::isComplex) {
+ qCopy(ptr + l, ptr + s, ptr + f);
+ T *i = ptr + s;
+ T *b = ptr + s - n;
+ while (i != b) {
+ --i;
+ i->~T();
+ }
+ } else {
+ memmove(ptr + f, ptr + l, (s - l) * sizeof(T));
+ }
+ s -= n;
+ return ptr + f;
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r)
+{
+ if (l.size() != r.size())
+ return false;
+ for (int i = 0; i < l.size(); i++) {
+ if (l.at(i) != r.at(i))
+ return false;
+ }
+ return true;
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+bool operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r)
+{
+ return !(l == r);
+}
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index 996ca7f..3c80c1c 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -337,3 +337,211 @@
Typedef for const T &. Provided for STL compatibility.
*/
+/*! \fn void QVarLengthArray::prepend(const T &value)
+
+ \since 4.8
+ Inserts \a value at the beginning of the array.
+
+
+ This is the same as vector.insert(0, \a value).
+
+ For large arrays, this operation can be slow (\l{linear time}),
+ because it requires moving all the items in the vector by one
+ position further in memory. If you want a container class that
+ provides a fast prepend() function, use QList or QLinkedList
+ instead.
+
+ \sa append(), insert()
+*/
+
+/*! \fn void QVarLengthArray::replace(int i, const T &value)
+
+ \since 4.8
+ Replaces the item at index position \a i with \a value.
+
+ \a i must be a valid index position in the array (i.e., 0 <= \a
+ i < size()).
+
+ \sa operator[](), remove()
+*/
+
+/*! \fn void QVarLengthArray::remove(int i)
+
+ \overload
+ \since 4.8
+
+ Removes the element at index position \a i.
+
+ \sa insert(), replace()
+*/
+
+/*! \fn void QVarLengthArray::remove(int i, int count)
+
+ \overload
+ \since 4.8
+
+ Removes \a count elements from the middle of the array, starting at
+ index position \a i.
+
+ \sa insert(), replace()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::begin()
+ \since 4.8
+
+ Returns an \l{STL-style iterator} pointing to the first item in
+ the array.
+
+ \sa constBegin(), end()
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::begin() const
+ \since 4.8
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const
+ \since 4.8
+
+ Returns a const \l{STL-style iterator} pointing to the first item
+ in the array.
+
+ \sa begin(), constEnd()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::end()
+ \since 4.8
+
+ Returns an \l{STL-style iterator} pointing to the imaginary item
+ after the last item in the array.
+
+ \sa begin(), constEnd()
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::end() const
+ \since 4.8
+
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const
+ \since 4.8
+
+ Returns a const \l{STL-style iterator} pointing to the imaginary
+ item after the last item in the array.
+
+ \sa constBegin(), end()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator pos)
+ \since 4.8
+
+ Removes the item pointed to by the iterator \a pos from the
+ vector, and returns an iterator to the next item in the vector
+ (which may be end()).
+
+ \sa insert(), remove()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator begin, iterator end)
+
+ \overload
+ \since 4.8
+
+ Removes all the items from \a begin up to (but not including) \a
+ end. Returns an iterator to the same item that \a end referred to
+ before the call.
+*/
+
+/*! \fn void QVarLengthArray::insert(int i, const T &value)
+ \since 4.8
+
+ Inserts \a value at index position \a i in the array. If \a i is
+ 0, the value is prepended to the vector. If \a i is size(), the
+ value is appended to the vector.
+
+ For large arrays, this operation can be slow (\l{linear time}),
+ because it requires moving all the items at indexes \a i and
+ above by one position further in memory. If you want a container
+ class that provides a fast insert() function, use QLinkedList
+ instead.
+
+ \sa remove()
+*/
+
+/*! \fn void QVarLengthArray::insert(int i, int count, const T &value)
+
+ \overload
+ \since 4.8
+
+ Inserts \a count copies of \a value at index position \a i in the
+ vector.
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, const T &value)
+
+ \overload
+ \since 4.8
+
+ Inserts \a value in front of the item pointed to by the iterator
+ \a before. Returns an iterator pointing at the inserted item.
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, int count, const T &value)
+
+ \since 4.8
+ Inserts \a count copies of \a value in front of the item pointed to
+ by the iterator \a before. Returns an iterator pointing at the
+ first of the inserted items.
+*/
+
+
+
+/*! \fn bool operator==(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+
+ \relates QVarLengthArray
+ \since 4.8
+ Returns true if the two array are equal;
+
+ Two arrays are considered equal if they contain the same values
+ in the same order.
+
+ This function requires the value type to have an implementation
+ of \c operator==().
+
+ \sa operator!=()
+*/
+
+/*! \fn bool operator!=(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+
+ \relates QVarLengthArray
+ \since 4.8
+ Returns true if the two array are different;
+
+ Two arrays are considered equal if they contain the same values
+ in the same order.
+
+ This function requires the value type to have an implementation
+ of \c operator==().
+
+ \sa operator==()
+*/
+
+/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value)
+
+ \since 4.8
+ Appends \a value to the array and returns a reference to this
+ vector.
+
+ \sa append(), operator+=()
+*/
+
+/*! \fn QVarLengthArray &QVarLengthArray::operator+=(const T &value)
+
+ \since 4.8
+ Appends \a value to the array and returns a reference to this
+ vector.
+
+ \sa append(), operator<<()
+*/
+
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index d428d9f..e2e366d 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -285,6 +285,13 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive
vector.
*/
+/*! \fn void QVector::swap(QVector<T> &other)
+ \since 4.8
+
+ Swaps vector \a other with this vector. This operation is very fast and
+ never fails.
+*/
+
/*! \fn bool QVector::operator==(const QVector<T> &other) const
Returns true if \a other is equal to this vector; otherwise
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 551dbca..9418642 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -53,6 +53,9 @@
#endif
#include <stdlib.h>
#include <string.h>
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+#include <initializer_list>
+#endif
QT_BEGIN_HEADER
@@ -112,12 +115,22 @@ class QVector
};
public:
+ // ### Qt 5: Consider making QVector non-shared to get at least one
+ // "really fast" container. See tests/benchmarks/corelib/tools/qvector/
inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); }
explicit QVector(int size);
QVector(int size, const T &t);
inline QVector(const QVector<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
inline ~QVector() { if (!d) return; if (!d->ref.deref()) free(p); }
QVector<T> &operator=(const QVector<T> &v);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QVector<T> operator=(QVector<T> &&other)
+ { qSwap(p, other.p); return *this; }
+#endif
+ inline void swap(QVector<T> &other) { qSwap(d, other.d); }
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ inline QVector(std::initializer_list<T> args);
+#endif
bool operator==(const QVector<T> &v) const;
inline bool operator!=(const QVector<T> &v) const { return !(*this == v); }
@@ -293,11 +306,10 @@ public:
#ifndef QT_NO_STL
static inline QVector<T> fromStdVector(const std::vector<T> &vector)
- { QVector<T> tmp; tmp.reserve(vector.size()); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
+ { QVector<T> tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
{ std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
-
private:
friend class QRegion; // Optimization for QRegion::rects()
@@ -426,6 +438,22 @@ QVector<T>::QVector(int asize, const T &t)
new (--i) T(t);
}
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+template <typename T>
+QVector<T>::QVector(std::initializer_list<T> args)
+{
+ d = malloc(int(args.size()));
+ d->ref = 1;
+ d->alloc = d->size = int(args.size());
+ d->sharable = true;
+ d->capacity = false;
+ T* i = p->array + d->size;
+ auto it = args.end();
+ while (i != p->array)
+ new (--i) T(*(--it));
+}
+#endif
+
template <typename T>
void QVector<T>::free(Data *x)
{
@@ -790,11 +818,8 @@ QT_END_INCLUDE_NAMESPACE
#else
#define Q_TEMPLATE_EXTERN extern
#endif
-# pragma warning(push) /* MSVC 6.0 doesn't care about the disabling in qglobal.h (why?), so do it here */
-# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QPointF>;
Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QPoint>;
-# pragma warning(pop)
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index d81ab04..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 += \
@@ -83,10 +84,11 @@ SOURCES += \
symbian:SOURCES+=tools/qlocale_symbian.cpp
-mac:SOURCES += tools/qelapsedtimer_mac.cpp
+!nacl:mac:SOURCES += tools/qelapsedtimer_mac.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/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 18b4118..2ef0386 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -2941,6 +2941,9 @@ QStringRef QXmlStreamReader::documentEncoding() const
By default, QXmlStreamWriter encodes XML in UTF-8. Different
encodings can be enforced using setCodec().
+ If an error occurs while writing to the underlying device, hasError()
+ starts returning true and subsequent writes are ignored.
+
The \l{QXmlStream Bookmarks Example} illustrates how to use a
stream writer to write an XML bookmark file (XBEL) that
was previously read in by a QXmlStreamReader.
@@ -2965,7 +2968,8 @@ public:
void write(const QStringRef &);
void write(const QString &);
void writeEscaped(const QString &, bool escapeWhitespace = false);
- void write(const char *s);
+ void write(const char *s, int len);
+ template <int N> void write(const char (&s)[N]) { write(s, N - 1); }
bool finishStartElement(bool contents = true);
void writeStartElement(const QString &namespaceUri, const QString &name);
QIODevice *device;
@@ -2975,6 +2979,7 @@ public:
uint inEmptyElement :1;
uint lastWasStartElement :1;
uint wroteSomething :1;
+ uint hasError :1;
uint autoFormatting :1;
QByteArray autoFormattingIndent;
NamespaceDeclaration emptyNamespace;
@@ -3007,6 +3012,7 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q)
#endif
inStartElement = inEmptyElement = false;
wroteSomething = false;
+ hasError = false;
lastWasStartElement = false;
lastNamespaceDeclaration = 1;
autoFormatting = false;
@@ -3016,11 +3022,15 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q)
void QXmlStreamWriterPrivate::write(const QStringRef &s)
{
if (device) {
+ if (hasError)
+ return;
#ifdef QT_NO_TEXTCODEC
- device->write(s.toString().toLatin1(), s.size());
+ QByteArray bytes = s.toLatin1();
#else
- device->write(encoder->fromUnicode(s.constData(), s.size()));
+ QByteArray bytes = encoder->fromUnicode(s.constData(), s.size());
#endif
+ if (device->write(bytes) != bytes.size())
+ hasError = true;
}
else if (stringDevice)
s.appendTo(stringDevice);
@@ -3031,11 +3041,15 @@ void QXmlStreamWriterPrivate::write(const QStringRef &s)
void QXmlStreamWriterPrivate::write(const QString &s)
{
if (device) {
+ if (hasError)
+ return;
#ifdef QT_NO_TEXTCODEC
- device->write(s.toLatin1(), s.size());
+ QByteArray bytes = s.toLatin1();
#else
- device->write(encoder->fromUnicode(s));
+ QByteArray bytes = encoder->fromUnicode(s);
#endif
+ if (device->write(bytes) != bytes.size())
+ hasError = true;
}
else if (stringDevice)
stringDevice->append(s);
@@ -3070,31 +3084,19 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa
escaped += QChar(c);
}
}
- if (device) {
-#ifdef QT_NO_TEXTCODEC
- device->write(escaped.toLatin1(), escaped.size());
-#else
- device->write(encoder->fromUnicode(escaped));
-#endif
- }
- else if (stringDevice)
- stringDevice->append(escaped);
- else
- qWarning("QXmlStreamWriter: No device");
+ write(escaped);
}
-
-void QXmlStreamWriterPrivate::write(const char *s)
+// ASCII only!
+void QXmlStreamWriterPrivate::write(const char *s, int len)
{
if (device) {
-#ifndef QT_NO_TEXTCODEC
- if (codec->mibEnum() != 106)
- device->write(encoder->fromUnicode(QLatin1String(s)));
- else
-#endif
- device->write(s, strlen(s));
+ if (hasError)
+ return;
+ if (device->write(s, len) != len)
+ hasError = true;
} else if (stringDevice) {
- stringDevice->append(QLatin1String(s));
+ stringDevice->append(QString::fromLatin1(s, len));
} else
qWarning("QXmlStreamWriter: No device");
}
@@ -3172,7 +3174,7 @@ void QXmlStreamWriterPrivate::indent(int level)
{
write("\n");
for (int i = level; i > 0; --i)
- write(autoFormattingIndent.constData());
+ write(autoFormattingIndent.constData(), autoFormattingIndent.length());
}
@@ -3373,6 +3375,17 @@ int QXmlStreamWriter::autoFormattingIndent() const
return d->autoFormattingIndent.count(' ') - d->autoFormattingIndent.count('\t');
}
+/*!
+ Returns \c true if the stream failed to write to the underlying device.
+
+ The error status is never reset. Writes happening after the error
+ occurred are ignored, even if the error condition is cleared.
+ */
+bool QXmlStreamWriter::hasError() const
+{
+ Q_D(const QXmlStreamWriter);
+ return d->hasError;
+}
/*!
\overload
@@ -3759,7 +3772,7 @@ void QXmlStreamWriter::writeStartDocument(const QString &version)
#ifdef QT_NO_TEXTCODEC
d->write("iso-8859-1");
#else
- d->write(d->codec->name().constData());
+ d->write(d->codec->name().constData(), d->codec->name().length());
#endif
}
d->write("\"?>");
@@ -3782,12 +3795,13 @@ void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalon
#ifdef QT_NO_TEXTCODEC
d->write("iso-8859-1");
#else
- d->write(d->codec->name().constData());
+ d->write(d->codec->name().constData(), d->codec->name().length());
#endif
}
- d->write("\" standalone=\"");
- d->write(standalone ? "yes" : "no");
- d->write("\"?>");
+ if (standalone)
+ d->write("\" standalone=\"yes\"?>");
+ else
+ d->write("\" standalone=\"no\"?>");
}
diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h
index 1a91326..e5cb61e 100644
--- a/src/corelib/xml/qxmlstream.h
+++ b/src/corelib/xml/qxmlstream.h
@@ -169,6 +169,7 @@ Q_DECLARE_TYPEINFO(QXmlStreamAttribute, Q_MOVABLE_TYPE);
class Q_XMLSTREAM_EXPORT QXmlStreamAttributes : public QVector<QXmlStreamAttribute>
{
public:
+ inline QXmlStreamAttributes() {}
QStringRef value(const QString &namespaceUri, const QString &name) const;
QStringRef value(const QString &namespaceUri, const QLatin1String &name) const;
QStringRef value(const QLatin1String &namespaceUri, const QLatin1String &name) const;
@@ -473,6 +474,8 @@ public:
void writeCurrentToken(const QXmlStreamReader &reader);
#endif
+ bool hasError() const;
+
private:
Q_DISABLE_COPY(QXmlStreamWriter)
Q_DECLARE_PRIVATE(QXmlStreamWriter)
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index 46a723a..52ed217 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -12,7 +12,7 @@ contains(QT_CONFIG, dbus-linked) {
}
# INCLUDEPATH += .
-unix {
+unix|win32-g++* {
QMAKE_PKGCONFIG_DESCRIPTION = Qt \
DBus \
module
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp
index 39debdc..e48e1c0 100644
--- a/src/dbus/qdbusabstractinterface.cpp
+++ b/src/dbus/qdbusabstractinterface.cpp
@@ -208,7 +208,7 @@ bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const Q
QLatin1String(DBUS_INTERFACE_PROPERTIES),
QLatin1String("Set"));
QDBusMessagePrivate::setParametersValidated(msg, true);
- msg << interface << QString::fromUtf8(mp.name()) << qVariantFromValue(QDBusVariant(value));
+ msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value));
QDBusMessage reply = connection.call(msg, QDBus::Block);
if (reply.type() != QDBusMessage::ReplyMessage) {
diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp
index 00f49ba..09f0e82 100644
--- a/src/dbus/qdbusargument.cpp
+++ b/src/dbus/qdbusargument.cpp
@@ -72,7 +72,7 @@ QByteArray QDBusArgumentPrivate::createSignature(int id)
return "";
QByteArray signature;
- QDBusMarshaller *marshaller = new QDBusMarshaller;
+ QDBusMarshaller *marshaller = new QDBusMarshaller(0);
marshaller->ba = &signature;
// run it
@@ -114,7 +114,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d)
return false;
if (d->message && d->ref != 1) {
- QDBusMarshaller *dd = new QDBusMarshaller;
+ QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities);
dd->message = q_dbus_message_copy(d->message);
q_dbus_message_iter_init_append(dd->message, &dd->iterator);
@@ -157,7 +157,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d)
if (d->ref == 1)
return true; // no need to detach
- QDBusDemarshaller *dd = new QDBusDemarshaller;
+ QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities);
dd->message = q_dbus_message_ref(d->message);
dd->iterator = static_cast<QDBusDemarshaller*>(d)->iterator;
@@ -295,7 +295,7 @@ QDBusArgument::QDBusArgument()
return;
}
- QDBusMarshaller *dd = new QDBusMarshaller;
+ QDBusMarshaller *dd = new QDBusMarshaller(0);
d = dd;
// create a new message with any type, we won't sent it anyways
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/qdbusargument_p.h b/src/dbus/qdbusargument_p.h
index fe3a9cd..89a383f 100644
--- a/src/dbus/qdbusargument_p.h
+++ b/src/dbus/qdbusargument_p.h
@@ -65,8 +65,8 @@ class QDBusDemarshaller;
class QDBusArgumentPrivate
{
public:
- inline QDBusArgumentPrivate()
- : message(0), ref(1)
+ inline QDBusArgumentPrivate(int flags = 0)
+ : message(0), ref(1), capabilities(flags)
{ }
~QDBusArgumentPrivate();
@@ -89,6 +89,7 @@ public:
public:
DBusMessage *message;
QAtomicInt ref;
+ int capabilities;
enum Direction {
Marshalling,
Demarshalling
@@ -98,7 +99,7 @@ public:
class QDBusMarshaller: public QDBusArgumentPrivate
{
public:
- QDBusMarshaller() : parent(0), ba(0), closeCode(0), ok(true)
+ QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true)
{ direction = Marshalling; }
~QDBusMarshaller();
@@ -153,7 +154,8 @@ private:
class QDBusDemarshaller: public QDBusArgumentPrivate
{
public:
- inline QDBusDemarshaller() : parent(0) { direction = Demarshalling; }
+ inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0)
+ { direction = Demarshalling; }
~QDBusDemarshaller();
QString currentSignature();
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index 3fb63eb..4883a4d 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -42,6 +42,7 @@
#include <qdebug.h>
#include <qcoreapplication.h>
#include <qstringlist.h>
+#include <qthread.h>
#include "qdbusconnection.h"
#include "qdbusconnectioninterface.h"
@@ -247,6 +248,17 @@ void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionP
*/
/*!
+ \since 4.8
+ \enum QDBusConnection::ConnectionCapabilities
+ The available capabilities for a D-Bus connection.
+
+ \value UnixFileDescriptorPassing passing of Unix file descriptors to other processes
+ (see QDBusUnixFileDescriptor)
+
+ \sa connectionCapabilities()
+*/
+
+/*!
Creates a QDBusConnection object attached to the connection with name \a name.
This does not open the connection. You have to call connectToBus() to open it.
@@ -873,6 +885,21 @@ QDBusConnectionInterface *QDBusConnection::interface() const
}
/*!
+ \internal
+ \since 4.8
+
+ Returns the internal, implementation-defined pointer for this
+ connection. Currently, this returns a DBusConnection* pointer,
+ without changing the reference count. It is the responsibility of
+ the caller to call dbus_connection_ref if it wants to store the
+ pointer.
+*/
+void *QDBusConnection::internalPointer() const
+{
+ return d ? d->connection : 0;
+}
+
+/*!
Returns true if this QDBusConnection object is connected.
*/
bool QDBusConnection::isConnected() const
@@ -932,6 +959,18 @@ QString QDBusConnection::name() const
}
/*!
+ \since 4.8
+
+ Returns the capabilities of this connection as negotiated with the bus
+ server or peer. If this QDBusConnection is not connected, this function
+ returns no capabilities.
+*/
+QDBusConnection::ConnectionCapabilities QDBusConnection::connectionCapabilities() const
+{
+ return d ? d->capabilities : ConnectionCapabilities(0);
+}
+
+/*!
Attempts to register the \a serviceName on the D-Bus server and
returns true if the registration succeeded. The registration will
fail if the name is already registered by another application.
@@ -972,7 +1011,16 @@ class QDBusDefaultConnection: public QDBusConnection
public:
inline QDBusDefaultConnection(BusType type, const char *name)
: QDBusConnection(connectToBus(type, QString::fromLatin1(name))), ownName(name)
- { }
+ {
+ // make sure this connection is running on the main thread
+ QCoreApplication *instance = QCoreApplication::instance();
+ if (!instance) {
+ qWarning("QDBusConnection: %s D-Bus connection created before QCoreApplication. Application may misbehave.",
+ type == SessionBus ? "session" : type == SystemBus ? "system" : "generic");
+ } else {
+ QDBusConnectionPrivate::d(*this)->moveToThread(instance->thread());
+ }
+ }
inline ~QDBusDefaultConnection()
{ disconnectFromBus(QString::fromLatin1(ownName)); }
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index ec59434..6ab0ea2 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -111,9 +111,13 @@ public:
UnregisterNode,
UnregisterTree
};
-
Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)
+ enum ConnectionCapability {
+ UnixFileDescriptorPassing = 0x0001
+ };
+ Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)
+
QDBusConnection(const QString &name);
QDBusConnection(const QDBusConnection &other);
~QDBusConnection();
@@ -124,6 +128,7 @@ public:
QString baseService() const;
QDBusError lastError() const;
QString name() const;
+ ConnectionCapabilities connectionCapabilities() const;
bool send(const QDBusMessage &message) const;
bool callWithCallback(const QDBusMessage &message, QObject *receiver,
@@ -163,6 +168,8 @@ public:
QDBusConnectionInterface *interface() const;
+ void *internalPointer() const;
+
static QDBusConnection connectToBus(BusType type, const QString &name);
static QDBusConnection connectToBus(const QString &address, const QString &name);
static void disconnectFromBus(const QString &name);
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index 85308c1..36f7c53 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -262,6 +262,7 @@ signals:
public:
QAtomicInt ref;
+ QDBusConnection::ConnectionCapabilities capabilities;
QString name; // this connection's name
QString baseService; // this connection's base service
diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp
index ac3b5fa..111122e 100644
--- a/src/dbus/qdbusdemarshaller.cpp
+++ b/src/dbus/qdbusdemarshaller.cpp
@@ -128,7 +128,7 @@ inline QDBusSignature QDBusDemarshaller::toSignature()
inline QDBusVariant QDBusDemarshaller::toVariant()
{
- QDBusDemarshaller sub;
+ QDBusDemarshaller sub(capabilities);
sub.message = q_dbus_message_ref(message);
q_dbus_message_iter_recurse(&iterator, &sub.iterator);
q_dbus_message_iter_next(&iterator);
@@ -188,11 +188,11 @@ QVariant QDBusDemarshaller::toVariantInternal()
{
switch (q_dbus_message_iter_get_arg_type(&iterator)) {
case DBUS_TYPE_BYTE:
- return qVariantFromValue(toByte());
+ return QVariant::fromValue(toByte());
case DBUS_TYPE_INT16:
- return qVariantFromValue(toShort());
+ return QVariant::fromValue(toShort());
case DBUS_TYPE_UINT16:
- return qVariantFromValue(toUShort());
+ return QVariant::fromValue(toUShort());
case DBUS_TYPE_INT32:
return toInt();
case DBUS_TYPE_UINT32:
@@ -208,11 +208,11 @@ QVariant QDBusDemarshaller::toVariantInternal()
case DBUS_TYPE_STRING:
return toString();
case DBUS_TYPE_OBJECT_PATH:
- return qVariantFromValue(toObjectPath());
+ return QVariant::fromValue(toObjectPath());
case DBUS_TYPE_SIGNATURE:
- return qVariantFromValue(toSignature());
+ return QVariant::fromValue(toSignature());
case DBUS_TYPE_VARIANT:
- return qVariantFromValue(toVariant());
+ return QVariant::fromValue(toVariant());
case DBUS_TYPE_ARRAY:
switch (q_dbus_message_iter_get_element_type(&iterator)) {
@@ -222,14 +222,14 @@ QVariant QDBusDemarshaller::toVariantInternal()
case DBUS_TYPE_STRING:
return toStringList();
case DBUS_TYPE_DICT_ENTRY:
- return qVariantFromValue(duplicate());
+ return QVariant::fromValue(duplicate());
default:
- return qVariantFromValue(duplicate());
+ return QVariant::fromValue(duplicate());
}
case DBUS_TYPE_STRUCT:
- return qVariantFromValue(duplicate());
+ return QVariant::fromValue(duplicate());
default:
// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",
@@ -249,7 +249,7 @@ QStringList QDBusDemarshaller::toStringList()
{
QStringList list;
- QDBusDemarshaller sub;
+ QDBusDemarshaller sub(capabilities);
q_dbus_message_iter_recurse(&iterator, &sub.iterator);
q_dbus_message_iter_next(&iterator);
while (!sub.atEnd())
@@ -297,7 +297,7 @@ inline QDBusDemarshaller *QDBusDemarshaller::beginMapEntry()
QDBusDemarshaller *QDBusDemarshaller::beginCommon()
{
- QDBusDemarshaller *d = new QDBusDemarshaller;
+ QDBusDemarshaller *d = new QDBusDemarshaller(capabilities);
d->parent = this;
d->message = q_dbus_message_ref(message);
@@ -336,7 +336,7 @@ QDBusDemarshaller *QDBusDemarshaller::endCommon()
QDBusArgument QDBusDemarshaller::duplicate()
{
- QDBusDemarshaller *d = new QDBusDemarshaller;
+ QDBusDemarshaller *d = new QDBusDemarshaller(capabilities);
d->iterator = iterator;
d->message = q_dbus_message_ref(message);
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index bc03896..ee917a5 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -535,7 +535,7 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data)
if (d->mode == QDBusConnectionPrivate::InvalidMode)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message);
+ QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message, d->capabilities);
qDBusDebug() << d << "got message (signal):" << amsg;
return d->handleMessage(amsg) ?
@@ -832,14 +832,14 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu
slotData.slotIdx = -1;
slotData.metaTypes.clear();
slotCache.hash.insert(cacheKey, slotData);
- object->setProperty(cachePropertyName, qVariantFromValue(slotCache));
+ object->setProperty(cachePropertyName, QVariant::fromValue(slotCache));
return false;
}
}
// save to the cache
slotCache.hash.insert(cacheKey, slotData);
- object->setProperty(cachePropertyName, qVariantFromValue(slotCache));
+ object->setProperty(cachePropertyName, QVariant::fromValue(slotCache));
// found the slot to be called
deliverCall(object, flags, msg, slotData.metaTypes, slotData.slotIdx);
@@ -967,7 +967,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
extern bool qDBusInitThreads();
QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
- : QObject(p), ref(1), mode(InvalidMode), connection(0), server(0), busService(0),
+ : QObject(p), ref(1), capabilities(0), mode(InvalidMode), connection(0), server(0), busService(0),
watchAndTimeoutLock(QMutex::Recursive),
rootNode(QString(QLatin1Char('/')))
{
@@ -1204,7 +1204,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
QDBusMessagePrivate::setParametersValidated(message, true);
message.setArguments(args);
QDBusError error;
- DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
+ DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);
if (!msg) {
qWarning("QDBusConnection: Could not emit signal %s.%s: %s", qPrintable(interface), memberName.constData(),
qPrintable(error.message()));
@@ -1754,7 +1754,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call)
if (call->pending) {
// decode the message
DBusMessage *reply = q_dbus_pending_call_steal_reply(call->pending);
- msg = QDBusMessagePrivate::fromDBusMessage(reply);
+ msg = QDBusMessagePrivate::fromDBusMessage(reply, connection->capabilities);
q_dbus_message_unref(reply);
}
qDBusDebug() << connection << "got message reply (async):" << msg;
@@ -1805,7 +1805,7 @@ int QDBusConnectionPrivate::send(const QDBusMessage& message)
// through the d_ptr->localReply link
QDBusError error;
- DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
+ DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);
if (!msg) {
if (message.type() == QDBusMessage::MethodCallMessage)
qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
@@ -1851,7 +1851,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
if (!QCoreApplication::instance() || sendMode == QDBus::Block) {
QDBusError err;
- DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &err);
+ DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &err);
if (!msg) {
qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
qPrintable(message.service()), qPrintable(message.path()),
@@ -1872,7 +1872,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
return QDBusMessage::createError(err);
}
- QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(reply);
+ QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(reply, capabilities);
q_dbus_message_unref(reply);
qDBusDebug() << this << "got message reply (blocking):" << amsg;
@@ -1948,7 +1948,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
pcall->ref = 0;
QDBusError error;
- DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
+ DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);
if (!msg) {
qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
qPrintable(message.service()), qPrintable(message.path()),
diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp
index 35e8b8d..357fa2b 100644
--- a/src/dbus/qdbusinternalfilters.cpp
+++ b/src/dbus/qdbusinternalfilters.cpp
@@ -264,7 +264,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
return propertyNotFoundError(msg, interface_name, property_name);
}
- return msg.createReply(qVariantFromValue(QDBusVariant(value)));
+ return msg.createReply(QVariant::fromValue(QDBusVariant(value)));
}
enum PropertyWriteResult {
@@ -334,7 +334,7 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant
// we have to demarshall before writing
void *null = 0;
QVariant other(id, null);
- if (!QDBusMetaType::demarshall(qVariantValue<QDBusArgument>(value), id, other.data())) {
+ if (!QDBusMetaType::demarshall(qvariant_cast<QDBusArgument>(value), id, other.data())) {
qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. "
"Use qDBusRegisterMetaType to register it",
mp.typeName(), id);
@@ -495,7 +495,7 @@ QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &n
return interfaceNotFoundError(msg, interface_name);
}
- return msg.createReply(qVariantFromValue(result));
+ return msg.createReply(QVariant::fromValue(result));
}
QT_END_NAMESPACE
diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp
index 15e56e7..76d76cc 100644
--- a/src/dbus/qdbusmarshaller.cpp
+++ b/src/dbus/qdbusmarshaller.cpp
@@ -188,7 +188,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
return false;
}
- QDBusMarshaller sub;
+ QDBusMarshaller sub(capabilities);
open(sub, DBUS_TYPE_VARIANT, signature);
bool isOk = sub.appendVariantInternal(value);
// don't call sub.close(): it auto-closes
@@ -203,7 +203,7 @@ inline void QDBusMarshaller::append(const QStringList &arg)
return;
}
- QDBusMarshaller sub;
+ QDBusMarshaller sub(capabilities);
open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING);
QStringList::ConstIterator it = arg.constBegin();
QStringList::ConstIterator end = arg.constEnd();
@@ -280,6 +280,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature
sub.parent = this;
sub.ba = ba;
sub.ok = true;
+ sub.capabilities = capabilities;
if (ba)
switch (code) {
@@ -303,7 +304,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature
QDBusMarshaller *QDBusMarshaller::beginCommon(int code, const char *signature)
{
- QDBusMarshaller *d = new QDBusMarshaller;
+ QDBusMarshaller *d = new QDBusMarshaller(capabilities);
open(*d, code, signature);
return d;
}
@@ -362,7 +363,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
if (!d->message)
return false; // can't append this one...
- QDBusDemarshaller demarshaller;
+ QDBusDemarshaller demarshaller(capabilities);
demarshaller.message = q_dbus_message_ref(d->message);
if (d->direction == Demarshalling) {
@@ -528,7 +529,7 @@ bool QDBusMarshaller::appendCrossMarshalling(QDBusDemarshaller *demarshaller)
// We have to recurse
QDBusDemarshaller *drecursed = demarshaller->beginCommon();
- QDBusMarshaller mrecursed; // create on the stack makes it autoclose
+ QDBusMarshaller mrecursed(capabilities); // create on the stack makes it autoclose
QByteArray subSignature;
const char *sig = 0;
if (code == DBUS_TYPE_VARIANT || code == DBUS_TYPE_ARRAY) {
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index c13d483..bd77c77 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -95,14 +95,15 @@ QString QDBusMessage::errorMessage() const
/*!
\internal
- Constructs a DBusMessage object from this object. The returned value must be de-referenced
- with q_dbus_message_unref.
+ Constructs a DBusMessage object from \a message. The returned value must be de-referenced
+ with q_dbus_message_unref. The \a capabilities flags indicates which capabilities to use.
The \a error object is set to indicate the error if anything went wrong with the
marshalling. Usually, this error message will be placed in the reply, as if the call failed.
The \a error pointer must not be null.
*/
-DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDBusError *error)
+DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDBusConnection::ConnectionCapabilities capabilities,
+ QDBusError *error)
{
if (!qdbus_loadLibDBus()) {
*error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library"));
@@ -177,7 +178,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
// we can record this fact
d_ptr->parametersValidated = true;
- QDBusMarshaller marshaller;
+ QDBusMarshaller marshaller(capabilities);
QVariantList::ConstIterator it = d_ptr->arguments.constBegin();
QVariantList::ConstIterator cend = d_ptr->arguments.constEnd();
q_dbus_message_iter_init_append(msg, &marshaller.iterator);
@@ -222,7 +223,7 @@ DBUS_DISABLE_CHECKS
\internal
Constructs a QDBusMessage by parsing the given DBusMessage object.
*/
-QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg)
+QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnection::ConnectionCapabilities capabilities)
{
QDBusMessage message;
if (!dmsg)
@@ -238,7 +239,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg)
message.d_ptr->signature = QString::fromUtf8(q_dbus_message_get_signature(dmsg));
message.d_ptr->msg = q_dbus_message_ref(dmsg);
- QDBusDemarshaller demarshaller;
+ QDBusDemarshaller demarshaller(capabilities);
demarshaller.message = q_dbus_message_ref(dmsg);
if (q_dbus_message_iter_init(demarshaller.message, &demarshaller.iterator))
while (!demarshaller.atEnd())
@@ -272,7 +273,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
// we must marshall and demarshall again so as to create QDBusArgument
// entries for the complex types
QDBusError error;
- DBusMessage *message = toDBusMessage(asSent, &error);
+ DBusMessage *message = toDBusMessage(asSent, conn.capabilities, &error);
if (!message) {
// failed to marshall, so it's a call error
return QDBusMessage::createError(error);
@@ -280,7 +281,7 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
q_dbus_message_set_sender(message, conn.baseService.toUtf8());
- QDBusMessage retval = fromDBusMessage(message);
+ QDBusMessage retval = fromDBusMessage(message, conn.capabilities);
retval.d_ptr->localMessage = true;
q_dbus_message_unref(message);
if (retval.d_ptr->service.isEmpty())
diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h
index 6747976..52d4d25 100644
--- a/src/dbus/qdbusmessage_p.h
+++ b/src/dbus/qdbusmessage_p.h
@@ -56,6 +56,7 @@
#include <qatomic.h>
#include <qstring.h>
#include <qdbusmessage.h>
+#include <qdbusconnection.h>
struct DBusMessage;
@@ -92,8 +93,9 @@ public:
static void setParametersValidated(QDBusMessage &msg, bool enable)
{ msg.d_ptr->parametersValidated = enable; }
- static DBusMessage *toDBusMessage(const QDBusMessage &message, QDBusError *error);
- static QDBusMessage fromDBusMessage(DBusMessage *dmsg);
+ static DBusMessage *toDBusMessage(const QDBusMessage &message, QDBusConnection::ConnectionCapabilities capabilities,
+ QDBusError *error);
+ static QDBusMessage fromDBusMessage(DBusMessage *dmsg, QDBusConnection::ConnectionCapabilities capabilities);
static bool isLocal(const QDBusMessage &msg);
static QDBusMessage makeLocal(const QDBusConnectionPrivate &conn,
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/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
index bf4aec5..62eb8fe 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -210,7 +210,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb
{
QDeclarativeDebugObjectReference obj;
obj.m_debugId = prop.m_value.toInt();
- prop.m_value = qVariantFromValue(obj);
+ prop.m_value = QVariant::fromValue(obj);
break;
}
case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Unknown:
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
index ea3d9a3..1581675 100644
--- a/src/declarative/debugger/qdeclarativedebugserver.cpp
+++ b/src/declarative/debugger/qdeclarativedebugserver.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h
index ec3e60f..68ea4d8 100644
--- a/src/declarative/debugger/qdeclarativedebugserver_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserver_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
index 631da74..0c2bdb4 100644
--- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
index d2c8dda..d0423f7 100644
--- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h
+++ b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index f3a7db9..b74b18c 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -6,7 +6,7 @@ DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
exists("qdeclarative_enable_gcov") {
QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors
@@ -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
+ }
}
linux-g++-maemo:DEFINES += QDECLARATIVEVIEW_NOBACKGROUND
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 511f789..f42e55a 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1138,71 +1138,50 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject>
}
}
-static inline int children_count_helper(QGraphicsObject *object)
+int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *property)
{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- return d->children.count();
+ QDeclarativeItem *contentItem= static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem;
+ return contentItem->childItems().count() + contentItem->children().count();
}
-static inline QObject *children_at_helper(QGraphicsObject *object, int index)
+QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty<QObject> *property, int index)
{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- if (index >= 0 && index < d->children.count())
- return d->children.at(index)->toGraphicsObject();
- else
+ QDeclarativeItem *contentItem = static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem;
+
+ int childItemCount = contentItem->childItems().count();
+
+ if (index < 0)
return 0;
-}
-static inline void children_clear_helper(QGraphicsObject *object)
-{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object);
- int childCount = d->children.count();
- if (static_cast<QDeclarativeItemPrivate*>(d)->componentComplete) {
- for (int index = 0 ;index < childCount; index++) {
- d->children.at(0)->setParentItem(0);
- }
+ if (index < childItemCount) {
+ return contentItem->childItems().at(index)->toGraphicsObject();
} else {
- for (int index = 0 ;index < childCount; index++) {
- QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
- }
+ return contentItem->children().at(index - childItemCount);
}
+ return 0;
}
-int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty<QObject> *prop)
+void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *property)
{
- return QDeclarativeItemPrivate::resources_count(prop) +
- children_count_helper(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
-}
+ QDeclarativeItem *contentItem = static_cast<QDeclarativeFlickablePrivate*>(property->data)->contentItem;
-QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty<QObject> *prop, int i)
-{
- int resourcesCount = QDeclarativeItemPrivate::resources_count(prop);
- if (i < resourcesCount)
- return QDeclarativeItemPrivate::resources_at(prop, i);
- const int j = i - resourcesCount;
- QGraphicsObject *contentObject = static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem;
- if (j < children_count_helper(contentObject))
- return children_at_helper(contentObject, j);
- return 0;
-}
+ const QList<QGraphicsItem*> graphicsItems = contentItem->childItems();
+ for (int i = 0; i < graphicsItems.count(); i++)
+ contentItem->scene()->removeItem(graphicsItems[i]);
-void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *prop)
-{
- QDeclarativeItemPrivate::resources_clear(prop);
- QGraphicsObject *contentObject =
- static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem;
- children_clear_helper(contentObject);
+ const QList<QObject*> objects = contentItem->children();
+ for (int i = 0; i < objects.count(); i++)
+ objects[i]->setParent(0);
}
QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData()
{
Q_D(QDeclarativeFlickable);
return QDeclarativeListProperty<QObject>(this, (void *)d, QDeclarativeFlickablePrivate::data_append,
- QDeclarativeFlickablePrivate::data_count,
- QDeclarativeFlickablePrivate::data_at,
- QDeclarativeFlickablePrivate::data_clear
- );
+ QDeclarativeFlickablePrivate::data_count,
+ QDeclarativeFlickablePrivate::data_at,
+ QDeclarativeFlickablePrivate::data_clear);
}
QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildren()
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index b890c4f..ce47d88 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2237,6 +2237,7 @@ qreal QDeclarativeGridView::maxXExtent() const
} else {
highlightStart = d->highlightRangeStart;
highlightEnd = d->highlightRangeEnd;
+ lastItemPosition = 0;
if (d->model && d->model->count())
lastItemPosition = d->rowPosAt(d->model->count()-1);
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 6ae1ddc..39bb429 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -2801,7 +2801,7 @@ void QDeclarativeListView::geometryChanged(const QRectF &newGeometry,
Q_D(QDeclarativeListView);
d->maxExtentDirty = true;
d->minExtentDirty = true;
- if (d->isRightToLeft() && d->orient == Qt::Horizontal) {
+ if (d->isRightToLeft() && d->orient == QDeclarativeListView::Horizontal) {
// maintain position relative to the right edge
int dx = newGeometry.width() - oldGeometry.width();
setContentX(contentX() - dx);
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea.cpp b/src/declarative/graphicsitems/qdeclarativepincharea.cpp
index 9bc3d8d..b09cb72 100644
--- a/src/declarative/graphicsitems/qdeclarativepincharea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepincharea.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p.h
index 6d04708..5d06db0 100644
--- a/src/declarative/graphicsitems/qdeclarativepincharea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepincharea_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h
index cd5cf2a..2769987 100644
--- a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 720692c..3ab6417 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -41,7 +41,6 @@
#include "private/qdeclarativetext_p.h"
#include "private/qdeclarativetext_p_p.h"
-#include <private/qtextdocumentlayout_p.h>
#include <qdeclarativestyledtext_p.h>
#include <qdeclarativeinfo.h>
#include <qdeclarativepixmapcache_p.h>
@@ -83,14 +82,6 @@ private:
static QSet<QUrl> errors;
};
-class QDeclarativeTextDocumentLayout : public QTextDocumentLayout
-{
- Q_OBJECT
-public:
- QDeclarativeTextDocumentLayout(QTextDocument *doc);
- void setLineHeight(qreal lineHeight, QDeclarativeText::LineHeightMode mode);
-};
-
DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE);
QString QDeclarativeTextPrivate::elideChar = QString(0x2026);
@@ -184,15 +175,6 @@ void QTextDocumentWithImageResources::setText(const QString &text)
QSet<QUrl> QTextDocumentWithImageResources::errors;
-QDeclarativeTextDocumentLayout::QDeclarativeTextDocumentLayout(QTextDocument *doc)
- : QTextDocumentLayout(doc) {
-}
-
-void QDeclarativeTextDocumentLayout::setLineHeight(qreal lineHeight, QDeclarativeText::LineHeightMode mode = QDeclarativeText::ProportionalHeight)
-{
- QTextDocumentLayout::setLineHeight(lineHeight, QTextDocumentLayout::LineHeightMode(mode));
-}
-
QDeclarativeTextPrivate::~QDeclarativeTextPrivate()
{
}
@@ -238,11 +220,6 @@ void QDeclarativeTextPrivate::updateLayout()
singleline = false;
QDeclarativeStyledText::parse(text, layout);
}
- } else {
- ensureDoc();
- QDeclarativeTextDocumentLayout *layout = new QDeclarativeTextDocumentLayout(doc);
- layout->setLineHeight(lineHeight, lineHeightMode);
- doc->setDocumentLayout(layout);
}
updateSize();
diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h
index 6c18b50..cacc961 100644
--- a/src/declarative/qml/parser/qdeclarativejsengine_p.h
+++ b/src/declarative/qml/parser/qdeclarativejsengine_p.h
@@ -88,12 +88,6 @@ uint qHash(const QDeclarativeJS::NameId &id);
} // end of namespace QDeclarativeJS
-#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
-//this ensures that code outside QDeclarativeJS can use the hash function
-//it also a workaround for some compilers
-inline uint qHash(const QDeclarativeJS::NameId &nameId) { return QDeclarativeJS::qHash(nameId); }
-#endif
-
namespace QDeclarativeJS {
class Lexer;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 0554897..f57f842 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -608,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;
@@ -637,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;
@@ -715,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++;
@@ -799,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);
@@ -1262,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;
@@ -1302,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);
@@ -1615,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) {
@@ -1903,7 +1903,7 @@ 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"));
@@ -1932,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));
@@ -1962,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));
@@ -2017,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));
@@ -2030,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));
@@ -2385,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);
}
@@ -2678,7 +2678,7 @@ static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
QByteArray &data,
- Object *obj,
+ QDeclarativeParser::Object *obj,
const Object::DynamicProperty &prop)
{
if (!prop.defaultValue)
@@ -2701,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;
@@ -2884,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));
}
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index 8dd6824..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) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 824aeab..9fde18c 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1434,7 +1434,7 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn
qsreal x = ctxt->argument(0).toNumber();
qsreal y = ctxt->argument(1).toNumber();
qsreal z = ctxt->argument(2).toNumber();
- return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QVector3D(x, y, z)));
+ return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QVector3D(x, y, z)));
}
/*!
@@ -1464,14 +1464,14 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
QScriptValue formatArg = ctxt->argument(1);
if (formatArg.isString()) {
QString format = formatArg.toString();
- return engine->newVariant(qVariantFromValue(date.toString(format)));
+ return engine->newVariant(QVariant::fromValue(date.toString(format)));
} else if (formatArg.isNumber()) {
enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format"));
}
}
- return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+ return engine->newVariant(QVariant::fromValue(date.toString(enumFormat)));
}
/*!
@@ -1505,14 +1505,14 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
QScriptValue formatArg = ctxt->argument(1);
if (formatArg.isString()) {
QString format = formatArg.toString();
- return engine->newVariant(qVariantFromValue(time.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(qVariantFromValue(time.toString(enumFormat)));
+ return engine->newVariant(QVariant::fromValue(time.toString(enumFormat)));
}
/*!
@@ -1615,14 +1615,14 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
QScriptValue formatArg = ctxt->argument(1);
if (formatArg.isString()) {
QString format = formatArg.toString();
- return engine->newVariant(qVariantFromValue(date.toString(format)));
+ return engine->newVariant(QVariant::fromValue(date.toString(format)));
} else if (formatArg.isNumber()) {
enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
}
}
- return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+ return engine->newVariant(QVariant::fromValue(date.toString(enumFormat)));
}
#endif // QT_NO_DATESTRING
@@ -1651,7 +1651,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine
if (a < 0.0) a=0.0;
if (a > 1.0) a=1.0;
- return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a)));
+ return engine->toScriptValue(QVariant::fromValue(QColor::fromRgbF(r, g, b, a)));
}
/*!
@@ -1679,7 +1679,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
if (a < 0.0) a=0.0;
if (a > 1.0) a=1.0;
- return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a)));
+ return engine->toScriptValue(QVariant::fromValue(QColor::fromHslF(h, s, l, a)));
}
/*!
@@ -1702,7 +1702,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
if (w < 0 || h < 0)
return engine->nullValue();
- return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QRectF(x, y, w, h)));
+ return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
}
/*!
@@ -1715,7 +1715,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin
return ctxt->throwError(QLatin1String("Qt.point(): Invalid arguments"));
qsreal x = ctxt->argument(0).toNumber();
qsreal y = ctxt->argument(1).toNumber();
- return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QPointF(x, y)));
+ return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QPointF(x, y)));
}
/*!
@@ -1728,7 +1728,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine
return ctxt->throwError(QLatin1String("Qt.size(): Invalid arguments"));
qsreal w = ctxt->argument(0).toNumber();
qsreal h = ctxt->argument(1).toNumber();
- return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QSizeF(w, h)));
+ return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QSizeF(w, h)));
}
/*!
@@ -1764,7 +1764,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng
if (ctxt->argumentCount() == 2)
factor = ctxt->argument(1).toNumber();
color = color.lighter(int(qRound(factor*100.)));
- return qScriptValueFromValue(engine, qVariantFromValue(color));
+ return engine->toScriptValue(QVariant::fromValue(color));
}
/*!
@@ -1801,7 +1801,7 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
if (ctxt->argumentCount() == 2)
factor = ctxt->argument(1).toNumber();
color = color.darker(int(qRound(factor*100.)));
- return qScriptValueFromValue(engine, qVariantFromValue(color));
+ return engine->toScriptValue(QVariant::fromValue(color));
}
/*!
@@ -2051,7 +2051,7 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine
a + inv_a * color.alphaF());
}
- return qScriptValueFromValue(engine, qVariantFromValue(finalColor));
+ return engine->toScriptValue(QVariant::fromValue(finalColor));
}
QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &val)
@@ -2081,7 +2081,7 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v
if (objOk) {
return objectClass->newQObject(obj);
} else {
- return qScriptValueFromValue(&scriptEngine, val);
+ return scriptEngine.toScriptValue(val);
}
}
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 7a1234d..e8d593f 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -722,6 +722,7 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
// Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath
+#ifndef QT_NO_SETTINGS
QString installImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
#if defined(Q_OS_SYMBIAN)
@@ -748,6 +749,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
#else
addImportPath(installImportsPath);
#endif
+
+#endif // QT_NO_SETTINGS
+
// env import paths
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
if (!envImportPath.isEmpty()) {
@@ -1014,6 +1018,7 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeImportDatabase::importPlugin: " << uri << " from " << filePath;
+#ifndef QT_NO_LIBRARY
QFileInfo fileInfo(filePath);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
@@ -1065,6 +1070,9 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt
}
return true;
+#else
+ return false;
+#endif
}
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 35bb0f1..d5b9424 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -225,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/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index d9e3ebf..e04cfc5 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;
@@ -200,7 +200,7 @@ const ProcessAST::State ProcessAST::state() const
return _stateStack.back();
}
-Object *ProcessAST::currentObject() const
+QDeclarativeParser::Object *ProcessAST::currentObject() const
{
return state().object;
}
@@ -229,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,
@@ -286,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;
@@ -302,7 +302,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
if (propertyCount) {
Property *prop = currentProperty();
- Value *v = new Value;
+ QDeclarativeParser::Value *v = new QDeclarativeParser::Value;
v->object = obj;
v->location = obj->location;
if (onAssignment)
@@ -319,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) {
@@ -594,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);
@@ -698,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());
@@ -873,7 +873,7 @@ QList<QDeclarativeScriptParser::TypeReference*> QDeclarativeScriptParser::refere
return _refTypes;
}
-Object *QDeclarativeScriptParser::tree() const
+QDeclarativeParser::Object *QDeclarativeScriptParser::tree() const
{
return root;
}
@@ -1196,7 +1196,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 8845b75..4ed2bba 100644
--- a/src/declarative/qml/qdeclarativesqldatabase.cpp
+++ b/src/declarative/qml/qdeclarativesqldatabase.cpp
@@ -244,7 +244,7 @@ static QScriptValue qmlsqldatabase_executeSql(QScriptContext *context, QScriptEn
if (!qmlengine->sqlQueryClass)
qmlengine->sqlQueryClass = new QDeclarativeSqlQueryScriptClass(engine);
QScriptValue rows = engine->newObject(qmlengine->sqlQueryClass);
- rows.setData(engine->newVariant(qVariantFromValue(query)));
+ rows.setData(engine->newVariant(QVariant::fromValue(query)));
rows.setProperty(QLatin1String("item"), engine->newFunction(qmlsqldatabase_item,1), QScriptValue::SkipInEnumeration);
result.setProperty(QLatin1String("rows"),rows);
result.setProperty(QLatin1String("rowsAffected"),query.numRowsAffected());
@@ -282,7 +282,7 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri
QScriptValue instance = engine->newObject();
instance.setProperty(QLatin1String("executeSql"), engine->newFunction(qmlsqldatabase_executeSql,1));
- QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
+ QScriptValue tx = engine->newVariant(instance,QVariant::fromValue(db));
QString foundvers = context->thisObject().property(QLatin1String("version")).toString();
if (from_version!=foundvers) {
@@ -309,8 +309,10 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri
if (ok) {
context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly);
+#ifndef QT_NO_SETTINGS
QSettings ini(qmlsqldatabase_databaseFile(db.connectionName(),engine) + QLatin1String(".ini"), QSettings::IniFormat);
ini.setValue(QLatin1String("Version"), to_version);
+#endif
}
return engine->undefinedValue();
@@ -326,7 +328,7 @@ static QScriptValue qmlsqldatabase_transaction_shared(QScriptContext *context, Q
QScriptValue instance = engine->newObject();
instance.setProperty(QLatin1String("executeSql"),
engine->newFunction(readOnly ? qmlsqldatabase_executeSql_readonly : qmlsqldatabase_executeSql,1));
- QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db));
+ QScriptValue tx = engine->newVariant(instance,QVariant::fromValue(db));
db.transaction();
callback.call(QScriptValue(), QScriptValueList() << tx);
@@ -355,6 +357,7 @@ static QScriptValue qmlsqldatabase_read_transaction(QScriptContext *context, QSc
*/
static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEngine *engine)
{
+#ifndef QT_NO_SETTINGS
qmlsqldatabase_initDatabasesPath(engine);
QSqlDatabase database;
@@ -411,13 +414,16 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng
instance.setProperty(QLatin1String("version"), version, QScriptValue::ReadOnly);
instance.setProperty(QLatin1String("changeVersion"), engine->newFunction(qmlsqldatabase_change_version,3));
- QScriptValue result = engine->newVariant(instance,qVariantFromValue(database));
+ QScriptValue result = engine->newVariant(instance,QVariant::fromValue(database));
if (created && dbcreationCallback.isFunction()) {
dbcreationCallback.call(QScriptValue(), QScriptValueList() << result);
}
return result;
+#else
+ return engine->undefinedValue();
+#endif // QT_NO_SETTINGS
}
void qt_add_qmlsqldatabase(QScriptEngine *engine)
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index f11aa4c..aa1de43 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -92,7 +92,7 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
QSizeF sz = sizeFFromString(s, &ok);
if (ok) return QVariant(sz);
QVector3D v = vector3DFromString(s, &ok);
- if (ok) return qVariantFromValue(v);
+ if (ok) return QVariant::fromValue(v);
return QVariant(s);
}
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
index 0314a7a..a7c0b2c 100644
--- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -152,7 +152,7 @@ QDeclarativeTypeNameScriptClass::property(Object *obj, const Identifier &name)
}
}
-void QDeclarativeTypeNameScriptClass::setProperty(Object *o, const Identifier &n, const QScriptValue &v)
+void QDeclarativeTypeNameScriptClass::setProperty(Object *, const Identifier &n, const QScriptValue &v)
{
Q_ASSERT(object);
Q_ASSERT(!type);
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 1ff0caa..db8a2ae 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -384,7 +384,7 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri
QDeclarativeListModelWorkerAgent *agent = lm->agent();
if (agent) {
QDeclarativeListModelWorkerAgent::VariantRef v(agent);
- return qVariantFromValue(v);
+ return QVariant::fromValue(v);
} else {
return QVariant();
}
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 1fc41c1..aefc896 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -58,6 +58,8 @@
#include <QtCore/qstack.h>
#include <QtCore/qdebug.h>
+#include <QtCore/QStringBuilder>
+
#ifndef QT_NO_XMLSTREAMREADER
// From DOM-Level-3-Core spec
@@ -510,7 +512,7 @@ QScriptValue Node::create(QScriptEngine *engine, NodeImpl *data)
node.d = data;
if (data) A(data);
- return engine->newVariant(instance, qVariantFromValue(node));
+ return engine->newVariant(instance, QVariant::fromValue(node));
}
QScriptValue Element::prototype(QScriptEngine *engine)
@@ -710,7 +712,7 @@ QScriptValue Document::load(QScriptEngine *engine, const QByteArray &data)
instance.setPrototype(Document::prototype(engine));
Node documentNode;
documentNode.d = document;
- return engine->newVariant(instance, qVariantFromValue(documentNode));
+ return engine->newVariant(instance, QVariant::fromValue(documentNode));
}
Node::Node()
@@ -761,7 +763,7 @@ QScriptValue NamedNodeMap::create(QScriptEngine *engine, NodeImpl *data, QList<N
map.list = list;
if (data) A(data);
- instance.setData(engine->newVariant(qVariantFromValue(map)));
+ instance.setData(engine->newVariant(QVariant::fromValue(map)));
if (!QDeclarativeScriptEngine::get(engine)->namedNodeMapClass)
QDeclarativeScriptEngine::get(engine)->namedNodeMapClass= new NamedNodeMapClass(engine);
@@ -818,7 +820,7 @@ QScriptValue NodeList::create(QScriptEngine *engine, NodeImpl *data)
list.d = data;
if (data) A(data);
- instance.setData(engine->newVariant(qVariantFromValue(list)));
+ instance.setData(engine->newVariant(QVariant::fromValue(list)));
if (!QDeclarativeScriptEngine::get(engine)->nodeListClass)
QDeclarativeScriptEngine::get(engine)->nodeListClass= new NodeListClass(engine);
@@ -1090,10 +1092,9 @@ QString QDeclarativeXMLHttpRequest::headers()
foreach (const HeaderPair &header, m_headersList) {
if (ret.length())
- ret.append(QString::fromUtf8("\r\n"));
- ret.append(QString::fromUtf8(header.first));
- ret.append(QString::fromUtf8(": "));
- ret.append(QString::fromUtf8(header.second));
+ ret.append(QLatin1String("\r\n"));
+ ret = ret % QString::fromUtf8(header.first) % QLatin1String(": ")
+ % QString::fromUtf8(header.second);
}
return ret;
}
@@ -1105,9 +1106,9 @@ void QDeclarativeXMLHttpRequest::fillHeadersList()
m_headersList.clear();
foreach (const QByteArray &header, headerList) {
HeaderPair pair (header.toLower(), m_network->rawHeader(header));
- if (pair.first == "set-cookie" ||
- pair.first == "set-cookie2")
- continue;
+ if (pair.first == "set-cookie" ||
+ pair.first == "set-cookie2")
+ continue;
m_headersList << pair;
}
diff --git a/src/declarative/qml/qperformancetimer.cpp b/src/declarative/qml/qperformancetimer.cpp
index 1d7ca80..3b1e09b 100644
--- a/src/declarative/qml/qperformancetimer.cpp
+++ b/src/declarative/qml/qperformancetimer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/qml/qperformancetimer_p.h b/src/declarative/qml/qperformancetimer_p.h
index 14310bf..2787921 100644
--- a/src/declarative/qml/qperformancetimer_p.h
+++ b/src/declarative/qml/qperformancetimer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 6a6dfe1..b3bf84b 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -2941,4 +2941,8 @@ void QDeclarativeAnchorAnimation::transition(QDeclarativeStateActions &actions,
}
}
+QDeclarativeScriptActionPrivate::QDeclarativeScriptActionPrivate()
+ : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index 3c41565..048ecb1 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -248,8 +248,7 @@ class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPriv
{
Q_DECLARE_PUBLIC(QDeclarativeScriptAction)
public:
- QDeclarativeScriptActionPrivate()
- : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {}
+ QDeclarativeScriptActionPrivate();
void init();
diff --git a/src/declarative/util/qdeclarativeapplication.cpp b/src/declarative/util/qdeclarativeapplication.cpp
index e0f6df2..3e66e14 100644
--- a/src/declarative/util/qdeclarativeapplication.cpp
+++ b/src/declarative/util/qdeclarativeapplication.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qdeclarativeapplication_p.h b/src/declarative/util/qdeclarativeapplication_p.h
index caaed18..f59a5fb 100644
--- a/src/declarative/util/qdeclarativeapplication_p.h
+++ b/src/declarative/util/qdeclarativeapplication_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index b2739f0..fb77ec3 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -801,7 +801,7 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray &
{
ModelNode *n = nodes.top();
ModelNode *n2 = new ModelNode(rv->m_nested);
- n->values << qVariantFromValue(n2);
+ n->values << QVariant::fromValue(n2);
nodes.push(n2);
if (processingSet)
n->isArray = true;
@@ -1328,7 +1328,7 @@ bool NestedListModel::insert(int index, const QScriptValue& valuemap)
ModelNode *mn = new ModelNode(this);
mn->listIndex = index;
mn->setObjectValue(valuemap);
- _root->values.insert(index,qVariantFromValue(mn));
+ _root->values.insert(index,QVariant::fromValue(mn));
return true;
}
@@ -1508,7 +1508,7 @@ void ModelNode::setListValue(const QScriptValue& valuelist) {
value->listIndex = i;
value->values << v.toVariant();
}
- values.append(qVariantFromValue(value));
+ values.append(QVariant::fromValue(value));
}
}
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index dcc078d..065b171 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -720,6 +720,23 @@ void QDeclarativeView::paintEvent(QPaintEvent *event)
if (frameRateDebug())
qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time;
+
+#if QT_SHOW_DECLARATIVEVIEW_FPS
+ static QTime timer;
+ static int frames;
+
+ if (frames == 0) {
+ timer.start();
+ } else if (timer.elapsed() > 5000) {
+ qreal avgtime = timer.elapsed() / (qreal) frames;
+ qDebug("Average time per frame: %f ms (%i fps)", avgtime, int(1000 / avgtime));
+ timer.start();
+ frames = 0;
+ }
+ ++frames;
+ scene()->update();
+#endif
+
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 5af53e6..d5c7d1b 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -801,7 +801,7 @@ QScriptValue QDeclarativeXmlListModel::get(int index) const
QScriptValue sv = sengine->newObject();
for (int i=0; i<d->roleObjects.count(); i++)
- sv.setProperty(d->roleObjects[i]->name(), qScriptValueFromValue(sengine, d->data.value(i).value(index)));
+ sv.setProperty(d->roleObjects[i]->name(), sengine->toScriptValue(d->data.value(i).value(index)));
return sv;
}
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index ad2fb4c..31362ff 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -12,7 +12,7 @@ contains(QT_CONFIG, accessibility) {
accessible/qaccessiblewidget.cpp \
accessible/qaccessibleplugin.cpp
- mac:!embedded {
+ mac:!embedded:!qpa {
HEADERS += accessible/qaccessible_mac_p.h
OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \
accessible/qaccessible_mac_cocoa.mm
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 4f0053f..abe68f8 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -409,13 +409,18 @@ static void qAccessibleCleanup()
/*!
\typedef QAccessible::InterfaceFactory
- A function pointer type. Use a function with this prototype to install
- interface factories with installFactory().
+ This is a typedef for a pointer to a function with the following
+ signature:
- The function receives a QObject pointer. If the QObject
- provides a QAccessibleInterface, it sets the second parameter to
- point to the corresponding QAccessibleInterface, and returns true;
- otherwise returns false.
+ \snippet doc/src/snippets/code/src_gui_accessible_qaccessible.cpp 1
+
+ The function receives a QString and a QObject pointer, where the
+ QString is the key identifying the interface. The QObject is used
+ to pass on to the QAccessibleInterface so that it can hold a reference
+ to it.
+
+ If the key and the QObject does not have a corresponding
+ QAccessibleInterface, a null-pointer will be returned.
Installed factories are called by queryAccessibilityInterface() until
one provides an interface.
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm
index cc6ce4b..d01c1c9 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/gui/accessible/qaccessible_mac.mm
@@ -774,7 +774,7 @@ QAInterface QAccessibleHierarchyManager::lookup(const AXUIElementRef &element)
return factory->interface(id);
#else
return QAInterface();
-#endif;
+#endif
}
QAInterface QAccessibleHierarchyManager::lookup(const QAElement &element)
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp
index d6ceabc..1d2d1da 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/gui/accessible/qaccessibleobject.cpp
@@ -276,7 +276,7 @@ QAccessible::Relation QAccessibleApplication::relationTo(int child, const
for (int i = 0; i < tlw.count(); ++i) {
QWidget *w = tlw.at(i);
- QObjectList cl = qFindChildren<QObject *>(w, QString());
+ QObjectList cl = w->findChildren<QObject *>(QString());
if (cl.contains(o))
return Ancestor;
}
diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp
index c31ce44..2b2cec0 100644
--- a/src/gui/accessible/qaccessiblewidget.cpp
+++ b/src/gui/accessible/qaccessiblewidget.cpp
@@ -1015,7 +1015,7 @@ QVariant QAccessibleWidgetEx::invokeMethodEx(Method method, int child, const QVa
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods << ForegroundColor << BackgroundColor;
- return qVariantFromValue(set);
+ return QVariant::fromValue(set);
}
case ForegroundColor:
return widget()->palette().color(widget()->foregroundRole());
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
index 12e3a71..6ba707c 100644
--- a/src/gui/dialogs/dialogs.pri
+++ b/src/gui/dialogs/dialogs.pri
@@ -27,7 +27,7 @@ HEADERS += \
dialogs/qwizard.h \
dialogs/qprintpreviewdialog.h
-!embedded:mac {
+!embedded:!qpa:mac {
OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \
dialogs/qfontdialog_mac.mm \
dialogs/qnspanelproxy_mac.mm \
@@ -61,7 +61,7 @@ win32 {
!win32-borland:!wince*: LIBS += -lshell32 # the filedialog needs this library
}
-!mac:!embedded:!symbian:unix {
+!mac:!embedded:!symbian:unix|qpa {
HEADERS += dialogs/qpagesetupdialog_unix_p.h
SOURCES += dialogs/qprintdialog_unix.cpp \
dialogs/qpagesetupdialog_unix.cpp
diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/gui/dialogs/qcolordialog_mac.mm
index a9c70d3..ee9b19a 100644
--- a/src/gui/dialogs/qcolordialog_mac.mm
+++ b/src/gui/dialogs/qcolordialog_mac.mm
@@ -185,7 +185,7 @@ QT_USE_NAMESPACE
[self relayout];
}
-- (void)colorChanged:(NSNotification *)notification;
+- (void)colorChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
[self updateQtColor];
@@ -439,7 +439,7 @@ void QColorDialogPrivate::openCocoaColorPanel(const QColor &initial,
priv:this];
[colorPanel setDelegate:static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate)];
}
- [delegate setResultSet:false];
+ [static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) setResultSet:NO];
setCocoaPanelColor(initial);
[static_cast<QT_MANGLE_NAMESPACE(QCocoaColorPanelDelegate) *>(delegate) showColorPanel];
}
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index e44c38c..6838d92 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -337,7 +337,7 @@ void QDialogPrivate::setDefault(QPushButton *pushButton)
{
Q_Q(QDialog);
bool hasMain = false;
- QList<QPushButton*> list = qFindChildren<QPushButton*>(q);
+ QList<QPushButton*> list = q->findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
QPushButton *pb = list.at(i);
if (pb->window() == q) {
@@ -372,7 +372,7 @@ void QDialogPrivate::setMainDefault(QPushButton *pushButton)
void QDialogPrivate::hideDefault()
{
Q_Q(QDialog);
- QList<QPushButton*> list = qFindChildren<QPushButton*>(q);
+ QList<QPushButton*> list = q->findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
list.at(i)->setDefault(false);
}
@@ -675,7 +675,7 @@ void QDialog::keyPressEvent(QKeyEvent *e)
switch (e->key()) {
case Qt::Key_Enter:
case Qt::Key_Return: {
- QList<QPushButton*> list = qFindChildren<QPushButton*>(this);
+ QList<QPushButton*> list = findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
QPushButton *pb = list.at(i);
if (pb->isDefault() && pb->isVisible()) {
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 27c58a5..897a916 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -2258,9 +2258,9 @@ void QFileDialogPrivate::createWidgets()
#ifndef QT_NO_FSCOMPLETER
completer = new QFSCompleter(model, q);
qFileDialogUi->fileNameEdit->setCompleter(completer);
+#endif // QT_NO_FSCOMPLETER
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_autoCompleteFileName(QString)));
-#endif // QT_NO_FSCOMPLETER
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_updateOkButton()));
@@ -2996,6 +2996,7 @@ void QFileDialogPrivate::_q_useNameFilter(int index)
const int fileNameExtensionLength = fileNameExtension.count();
fileName.replace(fileName.count() - fileNameExtensionLength,
fileNameExtensionLength, newNameFilterExtension);
+ qFileDialogUi->listView->clearSelection();
lineEdit()->setText(fileName);
}
}
@@ -3311,7 +3312,10 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
if (currentLocation == QDir::separator())
return path.mid(currentLocation.length());
#endif
- return path.mid(currentLocation.length() + 1);
+ if (currentLocation.endsWith(QLatin1Char('/')))
+ return path.mid(currentLocation.length());
+ else
+ return path.mid(currentLocation.length()+1);
}
return index.data(QFileSystemModel::FilePathRole).toString();
}
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index cc53858..832f9bf 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -63,6 +63,7 @@
#include <qdesktopwidget.h>
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
+#import <AppKit/NSSavePanel.h>
#include "ui_qfiledialog.h"
QT_BEGIN_NAMESPACE
@@ -84,7 +85,13 @@ QT_USE_NAMESPACE
@class QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate);
-@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject {
+@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate)
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ : NSObject<NSOpenSavePanelDelegate>
+#else
+ : NSObject
+#endif
+{
@public
NSOpenPanel *mOpenPanel;
NSSavePanel *mSavePanel;
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 9b68adb..114f4be 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -60,7 +60,6 @@
#endif
#ifdef Q_WS_WINCE
-#include <shlobj.h>
#include <commdlg.h>
bool qt_priv_ptr_valid = false;
#else
@@ -603,7 +602,7 @@ QString qt_win_CID_get_existing_directory(const QFileDialogArgs &args)
// Set the FOS_PICKFOLDERS flag
DWORD newOptions;
hr = pfd->GetOptions(&newOptions);
- newOptions |= FOS_PICKFOLDERS;
+ newOptions |= (FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM);
if (SUCCEEDED(hr) && SUCCEEDED((hr = pfd->SetOptions(newOptions)))) {
QWidget *parentWindow = args.parent;
if (parentWindow)
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/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h
index 3fb4d90..db308ef 100644
--- a/src/gui/dialogs/qfileinfogatherer_p.h
+++ b/src/gui/dialogs/qfileinfogatherer_p.h
@@ -84,10 +84,13 @@ public:
&& permissions() == fileInfo.permissions();
}
+#ifndef QT_NO_FSFILEENGINE
bool isCaseSensitive() const {
QFSFileEngine fe(mFileInfo.absoluteFilePath());
return fe.caseSensitive();
}
+#endif
+
QFile::Permissions permissions() const {
return mFileInfo.permissions();
}
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 8bd7fe3..cb8eb6a 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1313,6 +1313,10 @@ QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const
if ((fullPath.length() > 2) && fullPath[0] == QLatin1Char('/') && fullPath[1] == QLatin1Char('/'))
fullPath = fullPath.mid(1);
#endif
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ if (fullPath.length() == 2 && fullPath.endsWith(QLatin1Char(':')))
+ fullPath.append(QLatin1Char('/'));
+#endif
return fullPath;
}
@@ -1454,7 +1458,6 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider)
{
Q_D(QFileSystemModel);
d->fileInfoGatherer.setIconProvider(provider);
- QApplication::processEvents();
d->root.updateIcon(provider, QString());
}
@@ -1631,6 +1634,14 @@ bool QFileSystemModel::event(QEvent *event)
return QAbstractItemModel::event(event);
}
+bool QFileSystemModel::rmdir(const QModelIndex &aindex) const
+{
+ QString path = filePath(aindex);
+ QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
+ d->fileInfoGatherer.removePath(path);
+ return QDir().rmdir(path);
+}
+
/*!
\internal
diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h
index fe8cf4d..8aa9875 100644
--- a/src/gui/dialogs/qfilesystemmodel.h
+++ b/src/gui/dialogs/qfilesystemmodel.h
@@ -139,7 +139,7 @@ public:
QDateTime lastModified(const QModelIndex &index) const;
QModelIndex mkdir(const QModelIndex &parent, const QString &name);
- inline bool rmdir(const QModelIndex &index) const;
+ bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const
inline QString fileName(const QModelIndex &index) const;
inline QIcon fileIcon(const QModelIndex &index) const;
QFile::Permissions permissions(const QModelIndex &index) const;
@@ -163,8 +163,6 @@ private:
friend class QFileDialogPrivate;
};
-inline bool QFileSystemModel::rmdir(const QModelIndex &aindex) const
-{ QDir dir; return dir.rmdir(filePath(aindex)); }
inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
{ return aindex.data(Qt::DisplayRole).toString(); }
inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 87187fc..1552ad6 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -51,6 +51,7 @@
#include <private/qt_mac_p.h>
#include <qabstracteventdispatcher.h>
#include <qdebug.h>
+#include <private/qfontengine_coretext_p.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
@@ -346,7 +347,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
[self relayoutToContentSize:[[mStolenContentView superview] frame].size];
}
-- (void)relayoutToContentSize:(NSSize)frameSize;
+- (void)relayoutToContentSize:(NSSize)frameSize
{
Q_ASSERT(mPanelHackedWithButtons);
@@ -505,7 +506,7 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
QMacCocoaAutoReleasePool pool;
QFontEngine *fe = font.d->engineForScript(QUnicodeTables::Common);
NSFontManager *mgr = [NSFontManager sharedFontManager];
- NSFont *nsFont = 0;
+ const NSFont *nsFont = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (qstrcmp(fe->name(), "CoreText") == 0) {
@@ -531,7 +532,7 @@ void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
size:fontInfo.pointSize()];
}
- [mgr setSelectedFont:nsFont isMultiple:NO];
+ [mgr setSelectedFont:const_cast<NSFont *>(nsFont) isMultiple:NO];
[static_cast<QT_MANGLE_NAMESPACE(QCocoaFontPanelDelegate) *>(delegate) setQtFont:font];
}
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp
index 1947a08..f13b8f5 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/gui/dialogs/qinputdialog.cpp
@@ -1136,6 +1136,8 @@ void QInputDialog::done(int result)
be entered).
\a text is the default text which is placed in the line edit.
\a mode is the echo mode the line edit will use.
+ \a inputMethodHints is the input method hints that will be used in the
+ edit widget if an input method is active.
If \a ok is nonnull \e *\a ok will be set to true if the user pressed
\gui OK and to false if the user pressed \gui Cancel. The dialog's parent
@@ -1158,13 +1160,14 @@ void QInputDialog::done(int result)
QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode mode, const QString &text, bool *ok,
- Qt::WindowFlags flags)
+ Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
{
QInputDialog dialog(parent, flags);
dialog.setWindowTitle(title);
dialog.setLabelText(label);
dialog.setTextValue(text);
dialog.setTextEchoMode(mode);
+ dialog.setInputMethodHints(inputMethodHints);
int ret = dialog.exec();
if (ok)
@@ -1177,6 +1180,17 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
}
/*!
+ \internal
+*/
+// ### Qt 5: Use only the version above.
+QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode mode, const QString &text, bool *ok,
+ Qt::WindowFlags flags)
+{
+ return getText(parent, title, label, mode, text, ok, flags, Qt::ImhNone);
+}
+
+/*!
\since 4.5
Static convenience function to get an integer input from the user.
@@ -1286,6 +1300,8 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
be entered).
\a items is the string list which is inserted into the combobox.
\a current is the number of the item which should be the current item.
+ \a inputMethodHints is the input method hints that will be used if the
+ combobox is editable and an input method is active.
If \a editable is true the user can enter their own text; otherwise the
user may only select one of the existing items.
@@ -1310,7 +1326,7 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label,
const QStringList &items, int current, bool editable, bool *ok,
- Qt::WindowFlags flags)
+ Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
{
QString text(items.value(current));
@@ -1320,6 +1336,7 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
dialog.setComboBoxItems(items);
dialog.setTextValue(text);
dialog.setComboBoxEditable(editable);
+ dialog.setInputMethodHints(inputMethodHints);
int ret = dialog.exec();
if (ok)
@@ -1332,6 +1349,17 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
}
/*!
+ \internal
+*/
+// ### Qt 5: Use only the version above.
+QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current, bool editable, bool *ok,
+ Qt::WindowFlags flags)
+{
+ return getItem(parent, title, label, items, current, editable, ok, flags, Qt::ImhNone);
+}
+
+/*!
\obsolete
Use getInt() instead.
diff --git a/src/gui/dialogs/qinputdialog.h b/src/gui/dialogs/qinputdialog.h
index f3fbda6..b0e6fbb 100644
--- a/src/gui/dialogs/qinputdialog.h
+++ b/src/gui/dialogs/qinputdialog.h
@@ -167,18 +167,37 @@ public:
void setVisible(bool visible);
+#ifdef Q_QDOC
+ static QString getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode echo = QLineEdit::Normal,
+ const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current = 0, bool editable = true,
+ bool *ok = 0, Qt::WindowFlags flags = 0,
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
+#else
static QString getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode echo = QLineEdit::Normal,
const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current = 0, bool editable = true,
+ bool *ok = 0, Qt::WindowFlags flags = 0);
+ static QString getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode echo,
+ const QString &text, bool *ok, Qt::WindowFlags flags,
+ Qt::InputMethodHints inputMethodHints);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current, bool editable,
+ bool *ok, Qt::WindowFlags flags,
+ Qt::InputMethodHints inputMethodHints);
+#endif
static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
int minValue = -2147483647, int maxValue = 2147483647,
int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
double minValue = -2147483647, double maxValue = 2147483647,
int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
- static QString getItem(QWidget *parent, const QString &title, const QString &label,
- const QStringList &items, int current = 0, bool editable = true,
- bool *ok = 0, Qt::WindowFlags flags = 0);
// obsolete
static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 8fd615a..d6dbcf6 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -412,7 +412,7 @@ void QMessageBoxPrivate::updateSize()
void QMessageBoxPrivate::hideSpecial()
{
Q_Q(QMessageBox);
- QList<QPushButton*> list = qFindChildren<QPushButton*>(q);
+ QList<QPushButton*> list = q->findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
QPushButton *pb = list.at(i);
QString text = pb->text();
@@ -1264,7 +1264,7 @@ bool QMessageBox::event(QEvent *e)
(e->type() == QEvent::OkRequest)
? QApplication::translate("QMessageBox", "OK")
: QApplication::translate("QMessageBox", "Help");
- QList<QPushButton*> list = qFindChildren<QPushButton*>(this);
+ QList<QPushButton*> list = findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
QPushButton *pb = list.at(i);
if (pb->text() == bName) {
@@ -1511,7 +1511,7 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
int(defaultButton), 0);
QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&msgBox);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
Q_ASSERT(buttonBox != 0);
uint mask = QMessageBox::FirstButton;
@@ -1945,7 +1945,7 @@ void QMessageBoxPrivate::retranslateStrings()
{
#ifndef QT_NO_TEXTEDIT
if (detailsButton)
- detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
+ detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
#endif
}
diff --git a/src/gui/dialogs/qnspanelproxy_mac.mm b/src/gui/dialogs/qnspanelproxy_mac.mm
index 3078888..5c8ef24 100644
--- a/src/gui/dialogs/qnspanelproxy_mac.mm
+++ b/src/gui/dialogs/qnspanelproxy_mac.mm
@@ -42,6 +42,7 @@
#include <qdialogbuttonbox.h>
#if defined(Q_WS_MAC)
#include <private/qt_mac_p.h>
+#include <private/qcocoaintrospection_p.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
#import <objc/objc-class.h>
@@ -137,46 +138,6 @@ QT_USE_NAMESPACE
QT_BEGIN_NAMESPACE
-void macStartIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class proxyClass)
-{
-#ifndef QT_MAC_USE_COCOA
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
- {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- // The following code replaces the _implementation_ for the selector we want to hack
- // (originalSel) with the implementation found in proxyClass. Then it creates
- // a new 'backup' method inside baseClass containing the old, original,
- // implementation (fakeSel). You can let the proxy implementation of originalSel
- // call fakeSel if needed (similar approach to calling a super class implementation).
- // fakeSel must also be implemented in proxyClass, as the signature is used
- // as template for the method one we add into baseClass.
- // NB: You will typically never create any instances of proxyClass; we use it
- // only for stealing its contents and put it into baseClass.
- Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
- Method newMethod = class_getInstanceMethod(proxyClass, originalSel);
- Method fakeMethod = class_getInstanceMethod(proxyClass, fakeSel);
-
- IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(newMethod));
- class_addMethod(baseClass, fakeSel, originalImp, method_getTypeEncoding(fakeMethod));
-#endif
- }
-}
-
-void macStopIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class /* proxyClass */)
-{
-#ifndef QT_MAC_USE_COCOA
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
- {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
- Method fakeMethodInBaseClass = class_getInstanceMethod(baseClass, fakeSel);
- method_setImplementation(originalMethod, method_getImplementation(fakeMethodInBaseClass));
-#endif
- }
-}
-
/*
Intercept the NSColorPanel constructor if the shared
color panel doesn't exist yet. What's going on here is
@@ -188,12 +149,18 @@ void macStopIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class /* pr
*/
void macStartInterceptNSPanelCtor()
{
- macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
- @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
- [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
- macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
- @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
- [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
+ qt_cocoa_change_implementation(
+ [NSPanel class],
+ @selector(initWithContentRect:styleMask:backing:defer:),
+ [QT_MANGLE_NAMESPACE(QNSPanelProxy) class],
+ @selector(initWithContentRect:styleMask:backing:defer:),
+ @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:));
+ qt_cocoa_change_implementation(
+ [NSPanel class],
+ @selector(initWithContentRect:styleMask:backing:defer:screen:),
+ [QT_MANGLE_NAMESPACE(QNSPanelProxy) class],
+ @selector(initWithContentRect:styleMask:backing:defer:screen:),
+ @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:));
}
/*
@@ -201,12 +168,14 @@ void macStartInterceptNSPanelCtor()
*/
void macStopInterceptNSPanelCtor()
{
- macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:),
- @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:),
- [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
- macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:),
- @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:),
- [NSPanel class], [QT_MANGLE_NAMESPACE(QNSPanelProxy) class]);
+ qt_cocoa_change_back_implementation(
+ [NSPanel class],
+ @selector(initWithContentRect:styleMask:backing:defer:screen:),
+ @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:));
+ qt_cocoa_change_back_implementation(
+ [NSPanel class],
+ @selector(initWithContentRect:styleMask:backing:defer:),
+ @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:));
}
/*
@@ -216,8 +185,12 @@ void macStopInterceptNSPanelCtor()
void macStartInterceptWindowTitle(QWidget *window)
{
currentWindow = window;
- macStartIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
- [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
+ qt_cocoa_change_implementation(
+ [NSWindow class],
+ @selector(setTitle:),
+ [QT_MANGLE_NAMESPACE(QNSWindowProxy) class],
+ @selector(setTitle:),
+ @selector(qt_fakeSetTitle:));
}
/*
@@ -226,8 +199,10 @@ void macStartInterceptWindowTitle(QWidget *window)
void macStopInterceptWindowTitle()
{
currentWindow = 0;
- macStopIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:),
- [NSWindow class], [QT_MANGLE_NAMESPACE(QNSWindowProxy) class]);
+ qt_cocoa_change_back_implementation(
+ [NSWindow class],
+ @selector(setTitle:),
+ @selector(qt_fakeSetTitle:));
}
/*
diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm
index 48a44a0..fa3f473 100644
--- a/src/gui/dialogs/qpagesetupdialog_mac.mm
+++ b/src/gui/dialogs/qpagesetupdialog_mac.mm
@@ -61,7 +61,7 @@ QT_USE_NAMESPACE
@end
@implementation QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate)
-- (id)initWithMacPrintEngine:(QMacPrintEnginePrivate *)printEngine;
+- (id)initWithMacPrintEngine:(QMacPrintEnginePrivate *)printEngine
{
self = [super init];
if (self) {
@@ -312,4 +312,4 @@ int QPageSetupDialog::exec()
QT_END_NAMESPACE
-#endif QT_NO_PRINTDIALOG
+#endif /* QT_NO_PRINTDIALOG */
diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri
index c6c020d..8e8664c 100644
--- a/src/gui/egl/egl.pri
+++ b/src/gui/egl/egl.pri
@@ -6,9 +6,21 @@ contains(QT_CONFIG, egl): {
egl/qeglcontext_p.h \
egl/qeglproperties_p.h
- SOURCES += \
- egl/qegl.cpp \
- egl/qeglproperties.cpp
+ SOURCES += \
+ egl/qegl.cpp \
+ egl/qeglproperties.cpp
+ unix {
+ !isEmpty(QMAKE_INCDIR_EGL){
+ INCLUDEPATH += $$QMAKE_INCDIR_EGL
+ }
+ !isEmpty(QMAKE_LIBDIR_EGL){
+ for(p, QMAKE_LIBDIR_EGL) {
+ exists($$p):LIBS += -L$$p
+ }
+ }
+
+ !isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL
+ }
wince*: SOURCES += egl/qegl_wince.cpp
@@ -16,10 +28,14 @@ contains(QT_CONFIG, egl): {
embedded {
SOURCES += egl/qegl_qws.cpp
} else {
- symbian {
- SOURCES += egl/qegl_symbian.cpp
+ qpa {
+ SOURCES += egl/qegl_qpa.cpp
} else {
- SOURCES += egl/qegl_x11.cpp
+ symbian {
+ SOURCES += egl/qegl_symbian.cpp
+ } else {
+ SOURCES += egl/qegl_x11.cpp
+ }
}
}
}
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index f21765e..fdb6a1e 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -394,7 +394,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
}
}
if (ctx == EGL_NO_CONTEXT) {
- ctx = eglCreateContext(display(), cfg, 0, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, EGL_NO_CONTEXT, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString();
return false;
diff --git a/src/gui/egl/qegl_qpa.cpp b/src/gui/egl/qegl_qpa.cpp
new file mode 100644
index 0000000..10caf46
--- /dev/null
+++ b/src/gui/egl/qegl_qpa.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qpaintdevice.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qwidget.h>
+#include "qeglcontext_p.h"
+
+#if !defined(QT_NO_EGL)
+
+#include <QtGui/private/qgraphicssystem_p.h>
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/qdesktopwidget.h>
+
+QT_BEGIN_NAMESPACE
+
+EGLNativeDisplayType QEgl::nativeDisplay()
+{
+ return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
+}
+
+EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
+{
+ return (EGLNativeWindowType)(widget->winId());
+}
+
+EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap)
+{
+ Q_UNUSED(pixmap);
+ return 0;
+}
+
+//EGLDisplay QEglContext::display()
+//{
+// return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
+//}
+
+static QPlatformScreen *screenForDevice(QPaintDevice *device)
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+
+ QList<QPlatformScreen *> screens = pi->screens();
+
+ int screenNumber;
+ if (device && device->devType() == QInternal::Widget)
+ screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
+ else
+ screenNumber = 0;
+ if (screenNumber < 0 || screenNumber >= screens.size())
+ return 0;
+ return screens[screenNumber];
+}
+
+// Set pixel format and other properties based on a paint device.
+void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
+{
+ if (!dev)
+ return;
+
+ // Find the QGLScreen for this paint device.
+ QPlatformScreen *screen = screenForDevice(dev);
+ if (!screen)
+ return;
+ int devType = dev->devType();
+ if (devType == QInternal::Image)
+ setPixelFormat(static_cast<QImage *>(dev)->format());
+ else
+ setPixelFormat(screen->format());
+}
+
+QT_END_NAMESPACE
+
+#endif // !QT_NO_EGL
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/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h
index e70cf02..017f56d 100644
--- a/src/gui/embedded/qkbd_defaultmap_qws_p.h
+++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h
@@ -642,7 +642,15 @@ const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
{ 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 },
{ 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
{ 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
+ { 113, 0xffff, 0x01000071, 0x00, 0x00, 0x0000 },
+ { 114, 0xffff, 0x01000070, 0x00, 0x00, 0x0000 },
+ { 115, 0xffff, 0x01000072, 0x00, 0x00, 0x0000 },
+ { 116, 0xffff, 0x0100010b, 0x00, 0x00, 0x0000 },
{ 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 },
+ { 138, 0xffff, 0x01000058, 0x00, 0x00, 0x0000 },
+ { 139, 0xffff, 0x01000055, 0x00, 0x00, 0x0000 },
+ { 152, 0xffff, 0x010000ba, 0x00, 0x00, 0x0000 },
+
};
const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = {
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp
index 8fc7bb8..9d2c6e8 100644
--- a/src/gui/embedded/qkbd_qws.cpp
+++ b/src/gui/embedded/qkbd_qws.cpp
@@ -48,8 +48,16 @@
#include <QDataStream>
#include <QStringList>
+#ifdef Q_WS_QWS
#include "qwindowsystem_qws.h"
#include "qscreen_qws.h"
+#endif
+
+#ifdef Q_WS_QPA
+#include <QWindowSystemInterface>
+#include <QKeyEvent>
+#endif
+
#include "qtimer.h"
#include <stdlib.h>
@@ -352,7 +360,15 @@ QWSKeyboardHandler::~QWSKeyboardHandler()
void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
bool isPress, bool autoRepeat)
{
+#if defined(Q_WS_QWS)
qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat);
+#elif defined(Q_WS_QPA)
+ QEvent::Type type = isPress ? QEvent::KeyPress : QEvent::KeyRelease;
+ QString str;
+ if (unicode != 0xffff)
+ str = QString(unicode);
+ QWindowSystemInterface::handleKeyEvent(0, type, keycode, modifiers, str);
+#endif
}
/*!
@@ -375,6 +391,7 @@ void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardM
*/
int QWSKeyboardHandler::transformDirKey(int key)
{
+#ifdef Q_WS_QWS
static int dir_keyrot = -1;
if (dir_keyrot < 0) {
// get the rotation
@@ -387,6 +404,9 @@ int QWSKeyboardHandler::transformDirKey(int key)
}
int xf = qt_screen->transformOrientation() + dir_keyrot;
return (key-Qt::Key_Left+xf)%4+Qt::Key_Left;
+#else
+ return 0;
+#endif
}
/*!
@@ -454,7 +474,7 @@ void QWSKeyboardHandler::endAutoRepeat()
Maps \a keycode according to a keymap and sends that key event to the
\l{Qt for Embedded Linux} server application.
-
+
Please see the \l{Qt for Embedded Linux Character Input} and the \l
{kmap2qmap} documentations for a description on how to create and use
keymap files.
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.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/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp
index cb14fe8..f6eec1d 100644
--- a/src/gui/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp
@@ -600,6 +600,18 @@ void QGraphicsGridLayout::removeAt(int index)
}
/*!
+ Removes the layout item \a item without destroying it.
+ Ownership of the item is transferred to the caller.
+
+ \sa addItem()
+*/
+void QGraphicsGridLayout::removeItem(QGraphicsLayoutItem *item)
+{
+ Q_D(QGraphicsGridLayout);
+ int index = d->engine.indexOf(item);
+ removeAt(index);
+}
+/*!
\reimp
*/
void QGraphicsGridLayout::invalidate()
diff --git a/src/gui/graphicsview/qgraphicsgridlayout.h b/src/gui/graphicsview/qgraphicsgridlayout.h
index 94f90f4..f493eb6 100644
--- a/src/gui/graphicsview/qgraphicsgridlayout.h
+++ b/src/gui/graphicsview/qgraphicsgridlayout.h
@@ -109,11 +109,12 @@ public:
int columnCount() const;
QGraphicsLayoutItem *itemAt(int row, int column) const;
-
+
// inherited from QGraphicsLayout
int count() const;
QGraphicsLayoutItem *itemAt(int index) const;
void removeAt(int index);
+ void removeItem(QGraphicsLayoutItem *item);
void invalidate();
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index a36a276..e342783 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1710,12 +1710,12 @@ void QGraphicsItem::setParentItem(QGraphicsItem *newParent)
return;
const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,
- qVariantFromValue<QGraphicsItem *>(newParent)));
- newParent = qVariantValue<QGraphicsItem *>(newParentVariant);
+ QVariant::fromValue<QGraphicsItem *>(newParent)));
+ newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);
if (newParent == d_ptr->parent)
return;
- const QVariant thisPointerVariant(qVariantFromValue<QGraphicsItem *>(this));
+ const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));
d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);
}
@@ -2139,7 +2139,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip)
*/
QCursor QGraphicsItem::cursor() const
{
- return qVariantValue<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
+ return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
}
/*!
@@ -2159,8 +2159,8 @@ QCursor QGraphicsItem::cursor() const
*/
void QGraphicsItem::setCursor(const QCursor &cursor)
{
- const QVariant cursorVariant(itemChange(ItemCursorChange, qVariantFromValue<QCursor>(cursor)));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qVariantValue<QCursor>(cursorVariant));
+ const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));
d_ptr->hasCursor = 1;
if (d_ptr->scene) {
d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
@@ -2286,7 +2286,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
// Schedule redrawing
if (update) {
- QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
if (c)
c->purge();
if (scene) {
@@ -3728,7 +3728,7 @@ void QGraphicsItem::setPos(const QPointF &pos)
}
// Notify the item that the position is changing.
- const QVariant newPosVariant(itemChange(ItemPositionChange, qVariantFromValue<QPointF>(pos)));
+ const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));
QPointF newPos = newPosVariant.toPointF();
if (newPos == d_ptr->pos)
return;
@@ -4082,7 +4082,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
if (d_ptr->flags & ItemSendsGeometryChanges) {
// Notify the item that the origin point is changing.
const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
- qVariantFromValue<QPointF>(origin)));
+ QVariant::fromValue<QPointF>(origin)));
newOrigin = newOriginVariant.toPointF();
}
@@ -4101,7 +4101,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
// Send post-notification.
if (d_ptr->flags & ItemSendsGeometryChanges)
- itemChange(ItemTransformOriginPointHasChanged, qVariantFromValue<QPointF>(newOrigin));
+ itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
}
/*!
@@ -4363,8 +4363,8 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
}
// Notify the item that the transformation matrix is changing.
- const QVariant newMatrixVariant = qVariantFromValue<QMatrix>(newTransform.toAffine());
- newTransform = QTransform(qVariantValue<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
+ const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());
+ newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
if (d_ptr->transformData->transform == newTransform)
return;
@@ -4372,7 +4372,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
d_ptr->setTransformHelper(newTransform);
// Send post-notification.
- itemChange(ItemTransformHasChanged, qVariantFromValue<QTransform>(newTransform));
+ itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
}
/*!
@@ -4415,8 +4415,8 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
// Notify the item that the transformation matrix is changing.
const QVariant newTransformVariant(itemChange(ItemTransformChange,
- qVariantFromValue<QTransform>(newTransform)));
- newTransform = qVariantValue<QTransform>(newTransformVariant);
+ QVariant::fromValue<QTransform>(newTransform)));
+ newTransform = qvariant_cast<QTransform>(newTransformVariant);
if (d_ptr->transformData->transform == newTransform)
return;
@@ -5269,7 +5269,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
qreal QGraphicsItem::boundingRegionGranularity() const
{
return d_ptr->hasBoundingRegionGranularity
- ? qVariantValue<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
+ ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
: 0;
}
@@ -5305,7 +5305,7 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
}
d_ptr->hasBoundingRegionGranularity = 1;
d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,
- qVariantFromValue<qreal>(granularity));
+ QVariant::fromValue<qreal>(granularity));
}
/*!
@@ -5480,7 +5480,7 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)
*/
QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const
{
- return (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
+ return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
}
/*!
@@ -5488,11 +5488,11 @@ QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const
*/
QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const
{
- QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
if (!c) {
QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
c = new QGraphicsItemCache;
- that->setExtra(ExtraCacheData, qVariantFromValue<void *>(c));
+ that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));
}
return c;
}
@@ -5502,7 +5502,7 @@ QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const
*/
void QGraphicsItemPrivate::removeExtraItemCache()
{
- QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue<void *>(extra(ExtraCacheData));
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
if (c) {
c->purge();
delete c;
@@ -8126,6 +8126,8 @@ QPen QAbstractGraphicsShapeItem::pen() const
void QAbstractGraphicsShapeItem::setPen(const QPen &pen)
{
Q_D(QAbstractGraphicsShapeItem);
+ if (d->pen == pen)
+ return;
prepareGeometryChange();
d->pen = pen;
d->boundingRect = QRectF();
@@ -8156,6 +8158,8 @@ QBrush QAbstractGraphicsShapeItem::brush() const
void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)
{
Q_D(QAbstractGraphicsShapeItem);
+ if (d->brush == brush)
+ return;
d->brush = brush;
update();
}
@@ -9286,6 +9290,8 @@ QPen QGraphicsLineItem::pen() const
void QGraphicsLineItem::setPen(const QPen &pen)
{
Q_D(QGraphicsLineItem);
+ if (d->pen == pen)
+ return;
prepareGeometryChange();
d->pen = pen;
update();
diff --git a/src/gui/graphicsview/qgraphicsitemanimation.cpp b/src/gui/graphicsview/qgraphicsitemanimation.cpp
index ec45d82..7eedc8d 100644
--- a/src/gui/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/gui/graphicsview/qgraphicsitemanimation.cpp
@@ -49,20 +49,20 @@
The QGraphicsItemAnimation class animates a QGraphicsItem. You can
schedule changes to the item's transformation matrix at
- specified steps. The QGraphicsItemAnimation class has a
- current step value. When this value changes the transformations
- scheduled at that step are performed. The current step of the
+ specified steps. The QGraphicsItemAnimation class has a
+ current step value. When this value changes the transformations
+ scheduled at that step are performed. The current step of the
animation is set with the \c setStep() function.
QGraphicsItemAnimation will do a simple linear interpolation
- between the nearest adjacent scheduled changes to calculate the
+ between the nearest adjacent scheduled changes to calculate the
matrix. For instance, if you set the position of an item at values
0.0 and 1.0, the animation will show the item moving in a straight
- line between these positions. The same is true for scaling and
+ line between these positions. The same is true for scaling and
rotation.
It is usual to use the class with a QTimeLine. The timeline's
- \l{QTimeLine::}{valueChanged()} signal is then connected to the
+ \l{QTimeLine::}{valueChanged()} signal is then connected to the
\c setStep() slot. For example, you can set up an item for rotation
by calling \c setRotationAt() for different step values.
The animations timeline is set with the setTimeLine() function.
@@ -286,7 +286,7 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const
QList<QPair<qreal, QPointF> > list;
for (int i = 0; i < d->xPosition.size(); ++i)
list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
-
+
return list;
}
@@ -343,7 +343,7 @@ QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const
QList<QPair<qreal, qreal> > list;
for (int i = 0; i < d->rotation.size(); ++i)
list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
-
+
return list;
}
@@ -395,7 +395,7 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const
QList<QPair<qreal, QPointF> > list;
for (int i = 0; i < d->xTranslation.size(); ++i)
list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
-
+
return list;
}
@@ -447,7 +447,7 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const
QList<QPair<qreal, QPointF> > list;
for (int i = 0; i < d->horizontalScale.size(); ++i)
list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
-
+
return list;
}
@@ -499,7 +499,7 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const
QList<QPair<qreal, QPointF> > list;
for (int i = 0; i < d->horizontalShear.size(); ++i)
list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
-
+
return list;
}
diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp
index ed213f1..904a3de 100644
--- a/src/gui/graphicsview/qgraphicslayout.cpp
+++ b/src/gui/graphicsview/qgraphicslayout.cpp
@@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE
/*!
Contructs a QGraphicsLayout object.
-
+
\a parent is passed to QGraphicsLayoutItem's constructor and the
QGraphicsLayoutItem's isLayout argument is set to \e true.
@@ -259,7 +259,7 @@ void QGraphicsLayout::activate()
return;
d->activateRecursive(this);
-
+
// we don't call activate on a sublayout, but somebody might.
// Therefore, we walk to the parentitem of the toplevel layout.
QGraphicsLayoutItem *parentItem = this;
@@ -270,7 +270,7 @@ void QGraphicsLayout::activate()
Q_ASSERT(!parentItem->isLayout());
setGeometry(parentItem->contentsRect()); // relayout children
-
+
// ### bug, should be parentItem ?
parentLayoutItem()->updateGeometry(); // bubble up; will set activated to false
// ### too many resizes? maybe we should walk up the chain to the
@@ -350,7 +350,7 @@ void QGraphicsLayout::updateGeometry()
widget. QGraphicsLayout uses this event handler to listen for layout
related events such as geometry changes, layout changes or layout
direction changes.
-
+
\a e is a pointer to the event.
You can reimplement this event handler to track similar events for your
diff --git a/src/gui/graphicsview/qgraphicslayout_p.cpp b/src/gui/graphicsview/qgraphicslayout_p.cpp
index c2d4a08..c325602 100644
--- a/src/gui/graphicsview/qgraphicslayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicslayout_p.cpp
@@ -136,13 +136,13 @@ static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem
/*!
\internal
- This function is called from subclasses to add a layout item \a layoutItem
+ This function is called from subclasses to add a layout item \a layoutItem
to a layout.
It takes care of automatically reparenting graphics items, if needed.
If \a layoutItem is a is already in a layout, it will remove it from that layout.
-
+
*/
void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem)
{
@@ -150,14 +150,14 @@ void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem)
if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) {
if (maybeLayout->isLayout())
removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem);
- }
+ }
layoutItem->setParentLayoutItem(q);
if (layoutItem->isLayout()) {
if (QGraphicsItem *parItem = parentItem()) {
static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem);
}
} else {
- if (QGraphicsItem *item = layoutItem->graphicsItem()) {
+ if (QGraphicsItem *item = layoutItem->graphicsItem()) {
QGraphicsItem *newParent = parentItem();
QGraphicsItem *oldParent = item->parentItem();
if (oldParent == newParent || !newParent)
@@ -182,7 +182,7 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item)
QGraphicsLayout *layout = static_cast<QGraphicsLayout *>(item);
if (layout->d_func()->activated)
layout->invalidate();
-
+
for (int i = layout->count() - 1; i >= 0; --i) {
QGraphicsLayoutItem *childItem = layout->itemAt(i);
if (childItem)
@@ -194,5 +194,5 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item)
QT_END_NAMESPACE
-
+
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicslayout_p.h b/src/gui/graphicsview/qgraphicslayout_p.h
index 6e6f385..5358ec3 100644
--- a/src/gui/graphicsview/qgraphicslayout_p.h
+++ b/src/gui/graphicsview/qgraphicslayout_p.h
@@ -84,7 +84,7 @@ class QLayoutStyleInfo
public:
inline QLayoutStyleInfo() { invalidate(); }
inline QLayoutStyleInfo(QStyle *style, QWidget *widget)
- : m_valid(true), m_style(style), m_widget(widget)
+ : m_valid(true), m_style(style), m_widget(widget)
{
Q_ASSERT(style);
if (widget) //###
@@ -112,7 +112,7 @@ public:
return m_defaultSpacing[o - 1];
}
- inline qreal perItemSpacing(QSizePolicy::ControlType control1,
+ inline qreal perItemSpacing(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2,
Qt::Orientation orientation) const
{
@@ -132,7 +132,7 @@ class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPriva
Q_DECLARE_PUBLIC(QGraphicsLayout)
public:
- QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
+ QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
activated(true) { }
void reparentChildItems(QGraphicsItem *newParent);
@@ -148,7 +148,7 @@ public:
QT_END_NAMESPACE
-
+
#endif //QT_NO_GRAPHICSVIEW
#endif
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp
index fb08b9e..c064e01 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp
@@ -296,10 +296,6 @@ bool QGraphicsLayoutItemPrivate::hasHeightForWidth() const
bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
{
- // enable this code when we add QSizePolicy::hasWidthForHeight() (For 4.8)
-#if 1
- return false;
-#else
Q_Q(const QGraphicsLayoutItem);
if (isLayout) {
const QGraphicsLayout *l = static_cast<const QGraphicsLayout *>(q);
@@ -316,7 +312,6 @@ bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
}
}
return q->sizePolicy().hasWidthForHeight();
-#endif
}
/*!
@@ -710,7 +705,7 @@ void QGraphicsLayoutItem::setMaximumHeight(qreal height)
is equivalent to the item's position in parent coordinates).
You must reimplement this function in a subclass of QGraphicsLayoutItem to
- receive geometry updates. The layout will call this function when it does a
+ receive geometry updates. The layout will call this function when it does a
rearrangement.
If \a rect is outside of the bounds of minimumSize and maximumSize, it
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h
index d82b195..7112dd0 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.h
+++ b/src/gui/graphicsview/qgraphicslayoutitem.h
@@ -118,7 +118,7 @@ protected:
private:
QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
-
+
friend class QGraphicsLayout;
};
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 8bbaff9..e6142e6 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -266,8 +266,8 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
}
if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : widget, 0);
- lastWidgetUnderMouse = widget;
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
+ lastWidgetUnderMouse = receiver;
}
// Map event position from us to the receiver
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 85a4e16..7932a73 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -2544,8 +2544,8 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Notify the item that its scene is changing, and allow the item to
// react.
const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(this)));
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
+ QVariant::fromValue<QGraphicsScene *>(this)));
+ QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
if (targetScene != this) {
if (targetScene && item->d_ptr->scene != targetScene)
targetScene->addItem(item);
@@ -2956,8 +2956,8 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
// Notify the item that it's scene is changing to 0, allowing the item to
// react.
const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(0)));
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
+ QVariant::fromValue<QGraphicsScene *>(0)));
+ QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
if (targetScene != 0 && targetScene != this) {
targetScene->addItem(item);
return;
@@ -3462,7 +3462,8 @@ bool QGraphicsScene::event(QEvent *event)
break;
}
case QEvent::Leave:
- d->leaveScene();
+ // hackieshly unpacking the viewport pointer from the leave event.
+ d->leaveScene(reinterpret_cast<QWidget *>(event->d));
break;
case QEvent::GraphicsSceneHelp:
helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));
@@ -3935,20 +3936,19 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
Handles all actions necessary to clean up the scene when the mouse leaves
the view.
*/
-void QGraphicsScenePrivate::leaveScene()
+void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
{
- Q_Q(QGraphicsScene);
#ifndef QT_NO_TOOLTIP
QToolTip::hideText();
#endif
+ QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
// Send HoverLeave events to all existing hover items, topmost first.
- QGraphicsView *senderWidget = qobject_cast<QGraphicsView *>(q->sender());
QGraphicsSceneHoverEvent hoverEvent;
- hoverEvent.setWidget(senderWidget);
+ hoverEvent.setWidget(viewport);
- if (senderWidget) {
+ if (view) {
QPoint cursorPos = QCursor::pos();
- hoverEvent.setScenePos(senderWidget->mapToScene(senderWidget->mapFromGlobal(cursorPos)));
+ hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));
hoverEvent.setLastScenePos(hoverEvent.scenePos());
hoverEvent.setScreenPos(cursorPos);
hoverEvent.setLastScreenPos(hoverEvent.screenPos());
@@ -4369,25 +4369,8 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &
static inline bool transformIsSimple(const QTransform& transform)
{
QTransform::TransformationType type = transform.type();
- if (type == QTransform::TxNone || type == QTransform::TxTranslate) {
+ if (type <= QTransform::TxScale) {
return true;
- } else if (type == QTransform::TxScale) {
- // Check for 0 and 180 degree rotations.
- // (0 might happen after 4 rotations of 90 degrees).
- qreal m11 = transform.m11();
- qreal m12 = transform.m12();
- qreal m21 = transform.m21();
- qreal m22 = transform.m22();
- if (m12 == 0.0f && m21 == 0.0f) {
- if (m11 == 1.0f && m22 == 1.0f)
- return true; // 0 degrees
- else if (m11 == -1.0f && m22 == -1.0f)
- return true; // 180 degrees.
- if(m11 == 1.0f && m22 == -1.0f)
- return true; // 0 degrees inverted y.
- else if(m11 == -1.0f && m22 == 1.0f)
- return true; // 180 degrees inverted y.
- }
} else if (type == QTransform::TxRotate) {
// Check for 90, and 270 degree rotations.
qreal m11 = transform.m11();
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 2b47105..9460a4d 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -202,7 +202,7 @@ public:
bool dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent);
bool itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const;
- void leaveScene();
+ void leaveScene(QWidget *viewport);
void cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
QGraphicsSceneDragDropEvent *source);
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 2b129d7..0e2750d 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -80,9 +80,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
yourself, you can call setSceneRect(). This will adjust the scroll bars'
ranges appropriately. Note that although the scene supports a virtually
unlimited size, the range of the scroll bars will never exceed the range of
- an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll
- bars' values, you can choose to use translate() to navigate the scene
- instead.
+ an integer (INT_MIN, INT_MAX).
QGraphicsView visualizes the scene by calling render(). By default, the
items are drawn onto the viewport by using a regular QPainter, and using
@@ -101,7 +99,8 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
convenience functions rotate(), scale(), translate() or shear(). The most
two common transformations are scaling, which is used to implement
zooming, and rotation. QGraphicsView keeps the center of the view fixed
- during a transformation.
+ during a transformation. Because of the scene alignment (setAligment()),
+ translating the view will have no visual impact.
You can interact with the items on the scene by using the mouse and
keyboard. QGraphicsView translates the mouse and key events into \e scene
@@ -2790,6 +2789,9 @@ bool QGraphicsView::viewportEvent(QEvent *event)
d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
}
d->useLastMouseEvent = false;
+ // a hack to pass a viewport pointer to the scene inside the leave event
+ Q_ASSERT(event->d == 0);
+ event->d = reinterpret_cast<QEventPrivate *>(viewport());
QApplication::sendEvent(d->scene, event);
break;
#ifndef QT_NO_TOOLTIP
@@ -3710,7 +3712,7 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
}
/*!
- \obsolete
+ \obsolete
Draws the items \a items in the scene using \a painter, after the
background and before the foreground are drawn. \a numItems is the number
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 61b843b..5572b7e 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -62,6 +62,7 @@
#include "qgraphicssceneevent.h"
#include <QtGui/qstyleoption.h>
#include <private/qabstractscrollarea_p.h>
+#include <private/qapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -180,21 +181,24 @@ public:
inline void dispatchPendingUpdateRequests()
{
-#ifndef Q_WS_MAC
- // QWidget::update() works slightly different on the Mac; it's not part of
- // our backing store so it needs special threatment.
- if (qt_widget_private(viewport)->paintOnScreen())
- QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
- else
- QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
-#else
- // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
- // is called, which means there's a pending update request. We want to dispatch it
- // now because otherwise graphics view updates would require two
- // round-trips in the event loop before the item is painted.
- extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
- qt_mac_dispatchPendingUpdateRequests(viewport->window());
-#endif
+#ifdef Q_WS_MAC
+ // QWidget::update() works slightly different on the Mac without the raster engine;
+ // it's not part of our backing store so it needs special threatment.
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) {
+ // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
+ // is called, which means there's a pending update request. We want to dispatch it
+ // now because otherwise graphics view updates would require two
+ // round-trips in the event loop before the item is painted.
+ extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
+ qt_mac_dispatchPendingUpdateRequests(viewport->window());
+ } else
+#endif // !Q_WS_MAC
+ {
+ if (qt_widget_private(viewport)->paintOnScreen())
+ QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
+ else
+ QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
+ }
}
void setUpdateClip(QGraphicsItem *);
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index a756fb5..4580055 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include "qgraphicswidget_p.h"
+#include "qgraphicslayoutitem_p.h"
#include "qgraphicslayout.h"
#include "qgraphicsscene_p.h"
#include <QtGui/qapplication.h>
@@ -415,8 +416,7 @@ static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh,
bool heightForWidth = true)
{
qreal minimumHeightForWidth = -1;
- const QSizePolicy sp = widget->layout() ? widget->layout()->sizePolicy() : widget->sizePolicy();
- const bool hasHFW = sp.hasHeightForWidth();
+ const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
if (hasHFW == heightForWidth) {
minimumHeightForWidth = hasHFW
? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height()
@@ -505,21 +505,31 @@ static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
qreal width = qBound(min.width(), proposedRect.width(), max.width());
qreal height = qBound(min.height(), proposedRect.height(), max.height());
- QSizePolicy sp = widget->sizePolicy();
- if (const QGraphicsLayout *l = widget->layout()) {
- sp = l->sizePolicy();
- }
- const bool hasHFW = sp.hasHeightForWidth(); // || sp.hasWidthForHeight();
+ const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
+ const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight();
- const bool widthChanged = proposedRect.width() < widget->size().width();
- const bool heightChanged = proposedRect.height() < widget->size().height();
+ const bool widthChanged = proposedRect.width() != widget->size().width();
+ const bool heightChanged = proposedRect.height() != widget->size().height();
- if (hasHFW) {
+ if (hasHFW || hasWFH) {
if (widthChanged || heightChanged) {
- const qreal minh = min.height();
- const qreal maxh = max.height();
- const qreal proposedHFW = minimumHeightForWidth(width, minh, maxh, widget);
- if (proposedHFW > proposedRect.height()) {
+ qreal minExtent;
+ qreal maxExtent;
+ qreal constraint;
+ qreal proposed;
+ if (hasHFW) {
+ minExtent = min.height();
+ maxExtent = max.height();
+ constraint = width;
+ proposed = proposedRect.height();
+ } else {
+ // width for height
+ minExtent = min.width();
+ maxExtent = max.width();
+ constraint = height;
+ proposed = proposedRect.width();
+ }
+ if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
width = effectiveSize.width();
height = effectiveSize.height();
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index cd30dfb..b8586ce 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -825,6 +825,15 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const
return q_items.at(index);
}
+int QGridLayoutEngine::indexOf(QGraphicsLayoutItem *item) const
+{
+ for (int i = 0; i < q_items.size(); ++i) {
+ if (item == q_items.at(i)->layoutItem())
+ return i;
+ }
+ return -1;
+}
+
int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const
{
ensureEffectiveFirstAndLastRows();
@@ -1166,7 +1175,7 @@ QSizeF QGridLayoutEngine::sizeHint(const QLayoutStyleInfo &styleInfo, Qt::SizeHi
//constraints to find the column widths
q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(),
0, sizehint_totalBoxes[Ver], q_infos[Ver]);
- ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Vertical);
+ ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], styleInfo, sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal);
sizeHintCalculated = true;
}
}
diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h
index 17071b0..c5b35f5 100644
--- a/src/gui/graphicsview/qgridlayoutengine_p.h
+++ b/src/gui/graphicsview/qgridlayoutengine_p.h
@@ -341,6 +341,7 @@ public:
// returns the number of items inserted, which may be less than (rowCount * columnCount)
int itemCount() const;
QGridLayoutItem *itemAt(int index) const;
+ int indexOf(QGraphicsLayoutItem *item) const;
int effectiveFirstRow(Qt::Orientation orientation = Qt::Vertical) const;
int effectiveLastRow(Qt::Orientation orientation = Qt::Vertical) const;
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 4d51fa8..fda76a2 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -5,9 +5,9 @@ DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
-!win32:!embedded:!mac:!symbian:CONFIG += x11
+!win32:!embedded:!qpa:!mac:!symbian:CONFIG += x11
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
@@ -65,21 +65,24 @@ 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
QMAKE_EXTRA_COMPILERS += neon_compiler
}
+win32:!contains(QT_CONFIG, directwrite) {
+ DEFINES += QT_NO_DIRECTWRITE
+}
+
contains(QMAKE_MAC_XARCH, no) {
DEFINES += QT_NO_MAC_XARCH
} else {
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 00dccbe..72738c9 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -23,6 +23,7 @@ HEADERS += \
image/qpictureformatplugin.h \
image/qpixmap.h \
image/qpixmap_raster_p.h \
+ image/qpixmap_blitter_p.h \
image/qpixmapcache.h \
image/qpixmapcache_p.h \
image/qpixmapdata_p.h \
@@ -53,6 +54,7 @@ SOURCES += \
image/qiconengineplugin.cpp \
image/qmovie.cpp \
image/qpixmap_raster.cpp \
+ image/qpixmap_blitter.cpp \
image/qnativeimage.cpp \
image/qimagepixmapcleanuphooks.cpp \
image/qvolatileimage.cpp
@@ -63,6 +65,9 @@ win32 {
else:embedded {
SOURCES += image/qpixmap_qws.cpp
}
+else:qpa {
+ SOURCES += image/qpixmap_qpa.cpp
+}
else:x11 {
HEADERS += image/qpixmap_x11_p.h
SOURCES += image/qpixmap_x11.cpp
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index ae99115..260b397 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -227,6 +227,14 @@ QBitmap::~QBitmap()
}
/*!
+ \fn void QBitmap::swap(QBitmap &other)
+ \since 4.8
+
+ Swaps bitmap \a other with this bitmap. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the bitmap as a QVariant.
*/
QBitmap::operator QVariant() const
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index 525a694..f1771e3 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -63,6 +63,7 @@ public:
~QBitmap();
QBitmap &operator=(const QPixmap &);
+ inline void swap(QBitmap &other) { QPixmap::swap(other); } // prevent QBitmap<->QPixmap swaps
operator QVariant() const;
inline void clear() { fill(Qt::color0); }
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 59c384a..7182062 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -613,6 +613,14 @@ QIcon &QIcon::operator=(const QIcon &other)
}
/*!
+ \fn void QIcon::swap(QIcon &other)
+ \since 4.8
+
+ Swaps icon \a other with this icon. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the icon as a QVariant.
*/
QIcon::operator QVariant() const
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index aadcb48..1705591 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -71,6 +71,12 @@ public:
explicit QIcon(QIconEngineV2 *engine);
~QIcon();
QIcon &operator=(const QIcon &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QIcon &operator=(QIcon &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QIcon &other) { qSwap(d, other.d); }
+
operator QVariant() const;
QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 441bdb1..62116f3 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -139,42 +139,6 @@ QImageData::QImageData()
{
}
-static int depthForFormat(QImage::Format format)
-{
- int depth = 0;
- switch(format) {
- case QImage::Format_Invalid:
- case QImage::NImageFormats:
- Q_ASSERT(false);
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- depth = 1;
- break;
- case QImage::Format_Indexed8:
- depth = 8;
- break;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- depth = 32;
- break;
- case QImage::Format_RGB555:
- case QImage::Format_RGB16:
- case QImage::Format_RGB444:
- case QImage::Format_ARGB4444_Premultiplied:
- depth = 16;
- break;
- case QImage::Format_RGB666:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_RGB888:
- depth = 24;
- break;
- }
- return depth;
-}
-
/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
\internal
@@ -195,7 +159,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
uint width = size.width();
uint height = size.height();
- uint depth = depthForFormat(format);
+ uint depth = qt_depthForFormat(format);
switch (format) {
case QImage::Format_Mono:
@@ -875,7 +839,7 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
return 0;
}
- const int depth = depthForFormat(format);
+ const int depth = qt_depthForFormat(format);
const int calc_bytes_per_line = ((width * depth + 31)/32) * 4;
const int min_bytes_per_line = (width * depth + 7)/8;
@@ -1342,6 +1306,14 @@ QImage &QImage::operator=(const QImage &image)
}
/*!
+ \fn void QImage::swap(QImage &other)
+ \since 4.8
+
+ Swaps image \a other with this image. This operation is very
+ fast and never fails.
+*/
+
+/*!
\internal
*/
int QImage::devType() const
@@ -2035,6 +2007,88 @@ void QImage::fill(uint pixel)
0, 0, d->width, d->height, d->bytes_per_line);
}
+
+/*!
+ \fn void QImage::fill(Qt::GlobalColor color)
+
+ \overload
+
+ \since 4.8
+ */
+
+void QImage::fill(Qt::GlobalColor color)
+{
+ fill(QColor(color));
+}
+
+
+
+/*!
+ \fn void QImage::fill(Qt::GlobalColor color)
+
+ \overload
+
+ Fills the entire image with the given \a color.
+
+ If the depth of the image is 1, the image will be filled with 1 if
+ \a color equals Qt::color1; it will otherwise be filled with 0.
+
+ If the depth of the image is 8, the image will be filled with the
+ index corresponding the \a color in the color table if present; it
+ will otherwise be filled with 0.
+
+ \since 4.8
+*/
+
+void QImage::fill(const QColor &color)
+{
+ if (!d)
+ return;
+ detach();
+
+ // In case we run out of memory
+ if (!d)
+ return;
+
+ if (d->depth == 32) {
+ uint pixel = color.rgba();
+ if (d->format == QImage::Format_ARGB32_Premultiplied)
+ pixel = PREMUL(pixel);
+ fill((uint) pixel);
+
+ } else if (d->depth == 16 && d->format == QImage::Format_RGB16) {
+ qrgb565 p(color.rgba());
+ fill((uint) p.rawValue());
+
+ } else if (d->depth == 1) {
+ if (color == Qt::color1)
+ fill((uint) 1);
+ else
+ fill((uint) 0);
+
+ } else if (d->depth == 8) {
+ uint pixel = 0;
+ for (int i=0; i<d->colortable.size(); ++i) {
+ if (color.rgba() == d->colortable.at(i)) {
+ pixel = i;
+ break;
+ }
+ }
+ fill(pixel);
+
+ } else {
+ QPainter p(this);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.fillRect(rect(), color);
+ }
+
+}
+
+
+
+
+
+
/*!
Inverts all pixel values in the image.
@@ -3792,6 +3846,26 @@ void qInitImageConversions()
#endif
}
+void qGamma_correct_back_to_linear_cs(QImage *image)
+{
+ extern uchar qt_pow_rgb_gamma[256];
+
+ // gamma correct the pixels back to linear color space...
+ int h = image->height();
+ int w = image->width();
+
+ for (int y=0; y<h; ++y) {
+ uint *pixels = (uint *) image->scanLine(y);
+ for (int x=0; x<w; ++x) {
+ uint p = pixels[x];
+ uint r = qt_pow_rgb_gamma[qRed(p)];
+ uint g = qt_pow_rgb_gamma[qGreen(p)];
+ uint b = qt_pow_rgb_gamma[qBlue(p)];
+ pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
+ }
+ }
+}
+
/*!
Returns a copy of the image in the given \a format.
@@ -6244,7 +6318,7 @@ int QImage::bitPlaneCount() const
bpc = 12;
break;
default:
- bpc = depthForFormat(d->format);
+ bpc = qt_depthForFormat(d->format);
break;
}
return bpc;
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index a83d70f..496fe93 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -140,6 +140,12 @@ public:
~QImage();
QImage &operator=(const QImage &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QImage &operator=(QImage &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QImage &other) { qSwap(d, other.d); }
+
bool isNull() const;
int devType() const;
@@ -210,6 +216,9 @@ public:
void setColorTable(const QVector<QRgb> colors);
void fill(uint pixel);
+ void fill(const QColor &color);
+ void fill(Qt::GlobalColor color);
+
bool hasAlphaChannel() const;
void setAlphaChannel(const QImage &alphaChannel);
@@ -326,6 +335,7 @@ private:
QImageData *d;
friend class QRasterPixmapData;
+ friend class QBlittablePixmapData;
friend class QPixmapCacheEntry;
friend Q_GUI_EXPORT qint64 qt_image_id(const QImage &image);
friend const QVector<QRgb> *qt_image_colortable(const QImage &image);
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index e8e36d0..db6620b 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -111,6 +111,43 @@ struct Q_GUI_EXPORT QImageData { // internal image data
};
void qInitImageConversions();
+Q_GUI_EXPORT void qGamma_correct_back_to_linear_cs(QImage *image);
+
+inline int qt_depthForFormat(QImage::Format format)
+{
+ int depth = 0;
+ switch(format) {
+ case QImage::Format_Invalid:
+ case QImage::NImageFormats:
+ Q_ASSERT(false);
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ depth = 1;
+ break;
+ case QImage::Format_Indexed8:
+ depth = 8;
+ break;
+ case QImage::Format_RGB32:
+ case QImage::Format_ARGB32:
+ case QImage::Format_ARGB32_Premultiplied:
+ depth = 32;
+ break;
+ case QImage::Format_RGB555:
+ case QImage::Format_RGB16:
+ case QImage::Format_RGB444:
+ case QImage::Format_ARGB4444_Premultiplied:
+ depth = 16;
+ break;
+ case QImage::Format_RGB666:
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_RGB888:
+ depth = 24;
+ break;
+ }
+ return depth;
+}
QT_END_NAMESPACE
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 1fa1058..ab05bf1 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -1092,7 +1092,7 @@ QColor QImageReader::backgroundColor() const
if (!d->initHandler())
return QColor();
if (d->handler->supportsOption(QImageIOHandler::BackgroundColor))
- return qVariantValue<QColor>(d->handler->option(QImageIOHandler::BackgroundColor));
+ return qvariant_cast<QColor>(d->handler->option(QImageIOHandler::BackgroundColor));
return QColor();
}
diff --git a/src/gui/image/qmnghandler.cpp b/src/gui/image/qmnghandler.cpp
index e4c3b4f..6b918af 100644
--- a/src/gui/image/qmnghandler.cpp
+++ b/src/gui/image/qmnghandler.cpp
@@ -481,7 +481,7 @@ void QMngHandler::setOption(ImageOption option, const QVariant & value)
{
Q_D(QMngHandler);
if (option == QImageIOHandler::BackgroundColor)
- d->setBackgroundColor(qVariantValue<QColor>(value));
+ d->setBackgroundColor(qvariant_cast<QColor>(value));
}
/*! \reimp */
diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp
index 5fb97e0..8b6e360 100644
--- a/src/gui/image/qmovie.cpp
+++ b/src/gui/image/qmovie.cpp
@@ -381,10 +381,14 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
QPixmap aPixmap = QPixmap::fromImage(anImage);
int aDelay = reader->nextImageDelay();
return QFrameInfo(aPixmap, aDelay);
- } else {
+ } else if (frameNumber != 0) {
// We've read all frames now. Return an end marker
haveReadAll = true;
return QFrameInfo::endMarker();
+ } else {
+ // No readable frames
+ haveReadAll = true;
+ return QFrameInfo();
}
}
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index b560af3..8face87 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -45,6 +45,9 @@
#include "private/qpaintengine_raster_p.h"
+#include "private/qapplication_p.h"
+#include "private/qgraphicssystem_p.h"
+
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
#include <qx11info_x11.h>
#include <sys/ipc.h>
@@ -178,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) {
@@ -241,8 +246,21 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /*
: image(width, height, format)
{
-
uint cgflags = kCGImageAlphaNoneSkipFirst;
+ switch (format) {
+ case QImage::Format_ARGB32:
+ cgflags = kCGImageAlphaFirst;
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_ARGB4444_Premultiplied:
+ cgflags = kCGImageAlphaPremultipliedFirst;
+ break;
+ default:
+ break;
+ }
#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
cgflags |= kCGBitmapByteOrder32Host;
@@ -284,7 +302,11 @@ QNativeImage::~QNativeImage()
QImage::Format QNativeImage::systemFormat()
{
+#ifdef Q_WS_QPA
+ return QApplicationPrivate::platformIntegration()->screens().at(0)->format();
+#else
return QImage::Format_RGB32;
+#endif
}
#endif // platforms
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index a06c2bc..053d1fc 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1030,6 +1030,14 @@ QPicture& QPicture::operator=(const QPicture &p)
}
/*!
+ \fn void QPicture::swap(QPicture &other)
+ \since 4.8
+
+ Swaps picture \a other with this picture. This operation is very
+ fast and never fails.
+*/
+
+/*!
\internal
Constructs a QPicturePrivate
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index 8d8c2ce..c478ed9 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -81,6 +81,11 @@ public:
void setBoundingRect(const QRect &r);
QPicture& operator=(const QPicture &p);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPicture &operator=(QPicture &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
+ inline void swap(QPicture &other) { d_ptr.swap(other.d_ptr); }
void detach();
bool isDetached() const;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 1a83318..34804e5 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -71,6 +71,10 @@
# include "private/qpixmap_mac_p.h"
#endif
+#ifdef Q_WS_QPA
+# include "qplatformintegration_qpa.h"
+#endif
+
#if defined(Q_WS_X11)
# include "qx11info_x11.h"
# include <private/qt_x11_p.h>
@@ -98,12 +102,26 @@ static bool qt_pixmap_thread_test()
qFatal("QPixmap: Must construct a QApplication before a QPaintDevice");
return false;
}
-#ifndef Q_WS_WIN
+
if (qApp->thread() != QThread::currentThread()) {
- qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
- return false;
- }
+ bool fail = false;
+#if defined (Q_WS_X11)
+ if (!QApplication::testAttribute(Qt::AA_X11InitThreads))
+ fail = true;
+#elif defined (Q_WS_QPA)
+ if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
+ printf("Lighthouse plugin does not support threaded pixmaps!\n");
+ fail = true;
+ }
+#else
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ fail = true;
#endif
+ if (fail) {
+ qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
+ return false;
+ }
+ }
return true;
}
@@ -112,8 +130,16 @@ void QPixmap::init(int w, int h, Type type)
init(w, h, int(type));
}
+extern QApplication::Type qt_appType;
+
void QPixmap::init(int w, int h, int type)
{
+ if (qt_appType == QApplication::Tty) {
+ qWarning("QPixmap: Cannot create a QPixmap when no GUI is being used");
+ data = 0;
+ return;
+ }
+
if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
data = QPixmapData::create(w, h, (QPixmapData::PixelType) type);
else
@@ -440,6 +466,14 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap)
}
/*!
+ \fn void QPixmap::swap(QPixmap &other)
+ \since 4.8
+
+ Swaps pixmap \a other with this pixmap. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the pixmap as a QVariant.
*/
QPixmap::operator QVariant() const
@@ -1178,7 +1212,12 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
\warning This function is X11 specific; using it is non-portable.
+ \warning Since 4.8, pixmaps do not have an X11 handle unless
+ created with \l {QPixmap::}{fromX11Pixmap()}, or if the native
+ graphics system is explicitly enabled.
+
\sa detach()
+ \sa QApplication::setGraphicsSystem()
*/
Qt::HANDLE QPixmap::handle() const
@@ -1623,16 +1662,6 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode)
{Implicit Data Sharing} documentation. QPixmap objects can also be
streamed.
- Depending on the system, QPixmap is stored using a RGB32 or a
- premultiplied alpha format. If the image has an alpha channel, and
- if the system allows, the preferred format is premultiplied alpha.
- Note also that QPixmap, unlike QImage, may be hardware dependent.
- On X11, Mac and Symbian, a QPixmap is stored on the server side while
- a QImage is stored on the client side (on Windows, these two classes
- have an equivalent internal representation, i.e. both QImage and
- QPixmap are stored on the client side and don't use any GDI
- resources).
-
Note that the pixel data in a pixmap is internal and is managed by
the underlying window system. Because QPixmap is a QPaintDevice
subclass, QPainter can be used to draw directly onto pixmaps.
@@ -1962,6 +1991,8 @@ int QPixmap::defaultDepth()
return 32;
#elif defined(Q_OS_SYMBIAN)
return S60->screenDepth;
+#elif defined(Q_WS_QPA)
+ return 32; //LITE: use graphicssystem (we should do that in general)
#endif
}
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index ace0d86..f2e79c1 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -83,6 +83,12 @@ public:
~QPixmap();
QPixmap &operator=(const QPixmap &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPixmap &operator=(QPixmap &&other)
+ { qSwap(data, other.data); return *this; }
+#endif
+ inline void swap(QPixmap &other) { qSwap(data, other.data); }
+
operator QVariant() const;
bool isNull() const; // ### Qt 5: make inline
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
new file mode 100644
index 0000000..26d3b87
--- /dev/null
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpixmap_blitter_p.h"
+
+#include <qpainter.h>
+#include <qimage.h>
+
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_p.h>
+#include <private/qblittable_p.h>
+
+#include <private/qdrawhelper_p.h>
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+static int global_ser_no = 0;
+
+QBlittablePixmapData::QBlittablePixmapData()
+ : QPixmapData(QPixmapData::PixmapType,BlitterClass), m_engine(0), m_blittable(0)
+#ifdef QT_BLITTER_RASTEROVERLAY
+ ,m_rasterOverlay(0), m_unmergedCopy(0)
+#endif //QT_BLITTER_RASTEROVERLAY
+{
+ setSerialNumber(++global_ser_no);
+}
+
+QBlittablePixmapData::~QBlittablePixmapData()
+{
+ delete m_blittable;
+ delete m_engine;
+#ifdef QT_BLITTER_RASTEROVERLAY
+ delete m_rasterOverlay;
+ delete m_unmergedCopy;
+#endif //QT_BLITTER_RASTEROVERLAY
+}
+
+QBlittable *QBlittablePixmapData::blittable() const
+{
+ if (!m_blittable) {
+ QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
+ that->m_blittable = this->createBlittable(QSize(w,h));
+ }
+
+ return m_blittable;
+}
+
+void QBlittablePixmapData::setBlittable(QBlittable *blittable)
+{
+ resize(blittable->size().width(),blittable->size().height());
+ m_blittable = blittable;
+}
+
+void QBlittablePixmapData::resize(int width, int height)
+{
+
+ delete m_blittable;
+ m_blittable = 0;
+ delete m_engine;
+ m_engine = 0;
+#ifdef Q_WS_QPA
+ d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth();
+#endif
+ w = width;
+ h = height;
+ is_null = (w <= 0 || h <= 0);
+}
+Q_GUI_EXPORT extern int qt_defaultDpiX();
+Q_GUI_EXPORT extern int qt_defaultDpiY();
+
+int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
+{
+ switch (metric) {
+ case QPaintDevice::PdmWidth:
+ return w;
+ case QPaintDevice::PdmHeight:
+ return h;
+ case QPaintDevice::PdmWidthMM:
+ return qRound(w * 25.4 / qt_defaultDpiX());
+ case QPaintDevice::PdmHeightMM:
+ return qRound(h * 25.4 / qt_defaultDpiY());
+ case QPaintDevice::PdmDepth:
+ return 32;
+ case QPaintDevice::PdmDpiX: // fall-through
+ case QPaintDevice::PdmPhysicalDpiX:
+ return qt_defaultDpiX();
+ case QPaintDevice::PdmDpiY: // fall-through
+ case QPaintDevice::PdmPhysicalDpiY:
+ return qt_defaultDpiY();
+ default:
+ qWarning("QRasterPixmapData::metric(): Unhandled metric type %d", metric);
+ break;
+ }
+
+ return 0;
+}
+
+void QBlittablePixmapData::fill(const QColor &color)
+{
+ //jlind: todo: change when blittables can support non opaque fillRects
+ if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) {
+ blittable()->unlock();
+ blittable()->fillRect(QRectF(0,0,w,h),color);
+ }else {
+ uint pixel;
+ switch (blittable()->lock()->format()) {
+ case QImage::Format_ARGB32_Premultiplied:
+ pixel = PREMUL(color.rgba());
+ break;
+ case QImage::Format_ARGB8565_Premultiplied:
+ pixel = qargb8565(color.rgba()).rawValue();
+ break;
+ case QImage::Format_ARGB8555_Premultiplied:
+ pixel = qargb8555(color.rgba()).rawValue();
+ break;
+ case QImage::Format_ARGB6666_Premultiplied:
+ pixel = qargb6666(color.rgba()).rawValue();
+ break;
+ case QImage::Format_ARGB4444_Premultiplied:
+ pixel = qargb4444(color.rgba()).rawValue();
+ break;
+ default:
+ pixel = color.rgba();
+ break;
+ }
+ //so premultiplied formats are supported and ARGB32 and RGB32
+ blittable()->lock()->fill(pixel);
+ }
+
+}
+
+QImage *QBlittablePixmapData::buffer()
+{
+ return blittable()->lock();
+}
+
+QImage QBlittablePixmapData::toImage() const
+{
+ return blittable()->lock()->copy();
+}
+
+bool QBlittablePixmapData::hasAlphaChannel() const
+{
+ return blittable()->lock()->hasAlphaChannel();
+}
+
+void QBlittablePixmapData::fromImage(const QImage &image,
+ Qt::ImageConversionFlags flags)
+{
+ resize(image.width(),image.height());
+ markRasterOverlay(QRect(0,0,w,h));
+ QImage *thisImg = buffer();
+
+ QImage correctFormatPic = image;
+ if (correctFormatPic.format() != thisImg->format())
+ correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags);
+
+ uchar *mem = thisImg->bits();
+ const uchar *bits = correctFormatPic.bits();
+ int bytesCopied = 0;
+ while (bytesCopied < correctFormatPic.byteCount()) {
+ memcpy(mem,bits,correctFormatPic.bytesPerLine());
+ mem += thisImg->bytesPerLine();
+ bits += correctFormatPic.bytesPerLine();
+ bytesCopied+=correctFormatPic.bytesPerLine();
+ }
+}
+
+QPaintEngine *QBlittablePixmapData::paintEngine() const
+{
+ if (!m_engine) {
+ QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
+ that->m_engine = new QBlitterPaintEngine(that);
+ }
+ return m_engine;
+}
+
+#ifdef QT_BLITTER_RASTEROVERLAY
+
+static bool showRasterOverlay = !qgetenv("QT_BLITTER_RASTEROVERLAY").isEmpty();
+
+void QBlittablePixmapData::mergeOverlay()
+{
+ if (m_unmergedCopy || !showRasterOverlay)
+ return;
+ m_unmergedCopy = new QImage(buffer()->copy());
+ QPainter p(buffer());
+ p.setCompositionMode(QPainter::CompositionMode_SourceOver);
+ p.drawImage(0,0,*overlay());
+ p.end();
+}
+
+void QBlittablePixmapData::unmergeOverlay()
+{
+ if (!m_unmergedCopy || !showRasterOverlay)
+ return;
+ QPainter p(buffer());
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.drawImage(0,0,*m_unmergedCopy);
+ p.end();
+
+ delete m_unmergedCopy;
+ m_unmergedCopy = 0;
+}
+
+QImage *QBlittablePixmapData::overlay()
+{
+ if (!m_rasterOverlay||
+ m_rasterOverlay->size() != QSize(w,h)){
+ m_rasterOverlay = new QImage(w,h,QImage::Format_ARGB32_Premultiplied);
+ m_rasterOverlay->fill(0x00000000);
+ uint color = (qrand() % 11)+7;
+ m_overlayColor = QColor(Qt::GlobalColor(color));
+ m_overlayColor.setAlpha(0x88);
+
+ }
+ return m_rasterOverlay;
+}
+
+void QBlittablePixmapData::markRasterOverlayImpl(const QRectF &rect)
+{
+ if (!showRasterOverlay)
+ return;
+ QRectF transformationRect = clipAndTransformRect(rect);
+ if(!transformationRect.isEmpty()) {
+ QPainter p(overlay());
+ p.setBrush(m_overlayColor);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.fillRect(transformationRect,QBrush(m_overlayColor));
+ }
+}
+
+void QBlittablePixmapData::unmarkRasterOverlayImpl(const QRectF &rect)
+{
+ if (!showRasterOverlay)
+ return;
+ QRectF transformationRect = clipAndTransformRect(rect);
+ if (!transformationRect.isEmpty()) {
+ QPainter p(overlay());
+ QColor color(0x00,0x00,0x00,0x00);
+ p.setBrush(color);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.fillRect(transformationRect,QBrush(color));
+ }
+}
+
+QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const
+{
+ QRectF transformationRect = rect;
+ paintEngine();
+ if (m_engine->state()) {
+ transformationRect = m_engine->state()->matrix.mapRect(rect);
+ const QClipData *clipData = m_engine->clip();
+ if (clipData) {
+ if (clipData->hasRectClip) {
+ transformationRect &= clipData->clipRect;
+ } else if (clipData->hasRegionClip) {
+ const QVector<QRect> rects = clipData->clipRegion.rects();
+ for (int i = 0; i < rects.size(); i++) {
+ transformationRect &= rects.at(i);
+ }
+ }
+ }
+ }
+ return transformationRect;
+}
+
+#endif //QT_BLITTER_RASTEROVERLAY
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_BLITTABLE
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
new file mode 100644
index 0000000..9f4260c
--- /dev/null
+++ b/src/gui/image/qpixmap_blitter_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** 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 QPIXMAP_BLITTER_P_H
+#define QPIXMAP_BLITTER_P_H
+
+#include <private/qpixmapdata_p.h>
+#include <private/qpaintengine_blitter_p.h>
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData
+{
+// Q_DECLARE_PRIVATE(QBlittablePixmapData);
+public:
+ QBlittablePixmapData();
+ ~QBlittablePixmapData();
+
+ virtual QBlittable *createBlittable(const QSize &size) const = 0;
+ QBlittable *blittable() const;
+ void setBlittable(QBlittable *blittable);
+
+ void resize(int width, int height);
+ int metric(QPaintDevice::PaintDeviceMetric metric) const;
+ void fill(const QColor &color);
+ QImage *buffer();
+ QImage toImage() const;
+ bool hasAlphaChannel() const;
+ void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
+
+ QPaintEngine *paintEngine() const;
+
+ void markRasterOverlay(const QRectF &);
+ void markRasterOverlay(const QPointF &, const QTextItem &);
+ void markRasterOverlay(const QVectorPath &);
+ void markRasterOverlay(const QRect *rects, int rectCount);
+ void markRasterOverlay(const QRectF *rects, int rectCount);
+ void unmarkRasterOverlay(const QRectF &);
+
+#ifdef QT_BLITTER_RASTEROVERLAY
+ void mergeOverlay();
+ void unmergeOverlay();
+ QImage *overlay();
+
+#endif //QT_BLITTER_RASTEROVERLAY
+protected:
+ QBlitterPaintEngine *m_engine;
+ QBlittable *m_blittable;
+
+#ifdef QT_BLITTER_RASTEROVERLAY
+ QImage *m_rasterOverlay;
+ QImage *m_unmergedCopy;
+ QColor m_overlayColor;
+
+ void markRasterOverlayImpl(const QRectF &);
+ void unmarkRasterOverlayImpl(const QRectF &);
+ QRectF clipAndTransformRect(const QRectF &) const;
+#endif //QT_BLITTER_RASTEROVERLAY
+
+};
+
+inline void QBlittablePixmapData::markRasterOverlay(const QRectF &rect)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ markRasterOverlayImpl(rect);
+#else
+ Q_UNUSED(rect)
+#endif
+}
+
+inline void QBlittablePixmapData::markRasterOverlay(const QVectorPath &path)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ markRasterOverlayImpl(path.convertToPainterPath().boundingRect());
+#else
+ Q_UNUSED(path)
+#endif
+}
+
+inline void QBlittablePixmapData::markRasterOverlay(const QPointF &pos, const QTextItem &ti)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ QFontMetricsF fm(ti.font());
+ QRectF rect = fm.tightBoundingRect(ti.text());
+ rect.moveBottomLeft(pos);
+ markRasterOverlay(rect);
+#else
+ Q_UNUSED(pos)
+ Q_UNUSED(ti)
+#endif
+}
+
+inline void QBlittablePixmapData::markRasterOverlay(const QRect *rects, int rectCount)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ for (int i = 0; i < rectCount; i++) {
+ markRasterOverlay(rects[i]);
+ }
+#else
+ Q_UNUSED(rects)
+ Q_UNUSED(rectCount)
+#endif
+}
+inline void QBlittablePixmapData::markRasterOverlay(const QRectF *rects, int rectCount)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ for (int i = 0; i < rectCount; i++) {
+ markRasterOverlay(rects[i]);
+ }
+#else
+ Q_UNUSED(rects)
+ Q_UNUSED(rectCount)
+#endif
+}
+
+inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect)
+{
+#ifdef QT_BLITTER_RASTEROVERLAY
+ unmarkRasterOverlayImpl(rect);
+#else
+ Q_UNUSED(rect)
+#endif
+}
+
+QT_END_NAMESPACE
+#endif // QT_NO_BLITTABLE
+#endif // QPIXMAP_BLITTER_P_H
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index bbddd60..72e2aa6 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -413,7 +413,11 @@ void QMacPixmapData::fill(const QColor &fillColor)
*(dptr + i) = colr;
}
}
- macSetHasAlpha(fillColor.alpha() != 255);
+
+ // If we had an alpha channel from before, don't
+ // switch it off. Only go from no alpha to alpha:
+ if (fillColor.alpha() != 255)
+ macSetHasAlpha(true);
}
QPixmap QMacPixmapData::alphaChannel() const
diff --git a/src/gui/image/qpixmap_qpa.cpp b/src/gui/image/qpixmap_qpa.cpp
new file mode 100644
index 0000000..61be216
--- /dev/null
+++ b/src/gui/image/qpixmap_qpa.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qpixmap.h>
+#include <private/qgraphicssystem_p.h>
+#include <private/qapplication_p.h>
+
+QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
+{
+ return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h);
+}
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 5e0ffa8..a5f42c1 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -208,7 +208,13 @@ void QRasterPixmapData::fill(const QColor &color)
else
#endif
toFormat = QImage::Format_ARGB32_Premultiplied;
- image = QImage(image.width(), image.height(), toFormat);
+
+ if (!image.isNull() && qt_depthForFormat(image.format()) == qt_depthForFormat(toFormat)) {
+ image.detach();
+ image.d->format = toFormat;
+ } else {
+ image = QImage(image.width(), image.height(), toFormat);
+ }
}
switch (image.format()) {
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 674c09f..bc468cb 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -310,7 +310,7 @@ static int defaultScreen = -1;
QPixmap member functions
*****************************************************************************/
-static int qt_pixmap_serial = 0;
+QBasicAtomicInt qt_pixmap_serial = Q_BASIC_ATOMIC_INITIALIZER(0);
int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0;
QX11PixmapData::QX11PixmapData(PixelType type)
@@ -327,7 +327,7 @@ QPixmapData *QX11PixmapData::createCompatiblePixmapData() const
void QX11PixmapData::resize(int width, int height)
{
- setSerialNumber(++qt_pixmap_serial);
+ setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
w = width;
h = height;
@@ -410,7 +410,7 @@ struct QX11AlphaDetector
void QX11PixmapData::fromImage(const QImage &img,
Qt::ImageConversionFlags flags)
{
- setSerialNumber(++qt_pixmap_serial);
+ setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
w = img.width();
h = img.height();
@@ -2013,7 +2013,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display,
RootWindow(X11->display, xinfo.screen()),
w, h, d);
- x11Data->setSerialNumber(++qt_pixmap_serial);
+ x11Data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
#ifndef QT_NO_XRENDER
if (X11->use_xrender) {
@@ -2264,7 +2264,7 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect)
const QX11PixmapData *x11Data = static_cast<const QX11PixmapData*>(data);
- setSerialNumber(++qt_pixmap_serial);
+ setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
flags &= ~Uninitialized;
xinfo = x11Data->xinfo;
@@ -2384,7 +2384,7 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode)
}
QX11PixmapData *data = new QX11PixmapData(depth == 1 ? QPixmapData::BitmapType : QPixmapData::PixmapType);
- data->setSerialNumber(++qt_pixmap_serial);
+ data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1));
data->flags = QX11PixmapData::Readonly;
data->share_mode = mode;
data->w = width;
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 0d0d417..6bbce09 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -77,7 +77,8 @@ public:
};
#endif
enum ClassId { RasterClass, X11Class, MacClass, DirectFBClass,
- OpenGLClass, OpenVGClass, RuntimeClass, CustomClass = 1024 };
+ OpenGLClass, OpenVGClass, RuntimeClass, BlitterClass,
+ CustomClass = 1024 };
QPixmapData(PixelType pixelType, int classId);
virtual ~QPixmapData();
diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp
index e94c6ab..ec53dcb 100644
--- a/src/gui/image/qpixmapdatafactory.cpp
+++ b/src/gui/image/qpixmapdatafactory.cpp
@@ -53,6 +53,9 @@
#ifdef Q_WS_MAC
# include <private/qpixmap_mac_p.h>
#endif
+#ifdef Q_WS_QPA
+# include <private/qpixmap_raster_p.h>
+#endif
#ifdef Q_OS_SYMBIAN
# include <private/qpixmap_s60_p.h>
#endif
@@ -82,8 +85,10 @@ QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
#elif defined(Q_WS_MAC)
return new QMacPixmapData(type);
+#elif defined(Q_WS_QPA)
+ return new QRasterPixmapData(type);
#elif defined(Q_OS_SYMBIAN)
- return new QS60PixmapData(type);
+ return new QS60PixmapData(type);
#else
#error QSimplePixmapDataFactory::create() not implemented
#endif
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 31d12fe..d88c437 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -100,6 +100,7 @@ public:
float gamma;
int quality;
QString description;
+ QStringList readTexts;
png_struct *png_ptr;
png_info *info_ptr;
@@ -108,6 +109,7 @@ public:
bool readPngHeader();
bool readPngImage(QImage *image);
+ void readPngTexts(png_info *info);
QImage::Format readImageFormat();
@@ -362,6 +364,38 @@ static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const
/*!
\internal
*/
+void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info)
+{
+#ifndef QT_NO_IMAGE_TEXT
+ png_textp text_ptr;
+ int num_text=0;
+ png_get_text(png_ptr, info, &text_ptr, &num_text);
+
+ while (num_text--) {
+ QString key, value;
+ key = QString::fromLatin1(text_ptr->key);
+#if defined(PNG_iTXt_SUPPORTED)
+ if (text_ptr->itxt_length) {
+ value = QString::fromUtf8(text_ptr->text, int(text_ptr->itxt_length));
+ } else
+#endif
+ {
+ value = QString::fromLatin1(text_ptr->text, int(text_ptr->text_length));
+ }
+ if (!description.isEmpty())
+ description += QLatin1String("\n\n");
+ description += key + QLatin1String(": ") + value.simplified();
+ readTexts.append(key);
+ readTexts.append(value);
+ text_ptr++;
+ }
+#endif
+}
+
+
+/*!
+ \internal
+*/
bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
{
state = Error;
@@ -394,35 +428,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
png_set_read_fn(png_ptr, this, iod_read_fn);
png_read_info(png_ptr, info_ptr);
-#ifndef QT_NO_IMAGE_TEXT
- png_textp text_ptr;
- int num_text=0;
- png_get_text(png_ptr,info_ptr,&text_ptr,&num_text);
-
- while (num_text--) {
- QString key, value;
-#if defined(PNG_iTXt_SUPPORTED) && !defined(QT_NO_TEXTCODEC)
- if (text_ptr->lang) {
- QTextCodec *codec = QTextCodec::codecForName(text_ptr->lang);
- if (codec) {
- key = codec->toUnicode(text_ptr->lang_key);
- value = codec->toUnicode(QByteArray(text_ptr->text, text_ptr->itxt_length));
- } else {
- key = QString::fromLatin1(text_ptr->key);
- value = QString::fromLatin1(QByteArray(text_ptr->text, int(text_ptr->text_length)));
- }
- } else
-#endif
- {
- key = QString::fromLatin1(text_ptr->key);
- value = QString::fromLatin1(QByteArray(text_ptr->text, int(text_ptr->text_length)));
- }
- if (!description.isEmpty())
- description += QLatin1String("\n\n");
- description += key + QLatin1String(": ") + value.simplified();
- text_ptr++;
- }
-#endif
+ readPngTexts(info_ptr);
state = ReadHeader;
return true;
@@ -497,28 +503,15 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
outImage->setDotsPerMeterX(png_get_x_pixels_per_meter(png_ptr,info_ptr));
outImage->setDotsPerMeterY(png_get_y_pixels_per_meter(png_ptr,info_ptr));
-#ifndef QT_NO_IMAGE_TEXT
- png_textp text_ptr;
- int num_text=0;
- png_get_text(png_ptr,info_ptr,&text_ptr,&num_text);
- while (num_text--) {
- outImage->setText(text_ptr->key,0,QString::fromAscii(text_ptr->text));
- text_ptr++;
- }
+ state = ReadingEnd;
+ png_read_end(png_ptr, end_info);
- foreach (const QString &pair, description.split(QLatin1String("\n\n"))) {
- int index = pair.indexOf(QLatin1Char(':'));
- if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) {
- outImage->setText(QLatin1String("Description"), pair.simplified());
- } else {
- QString key = pair.left(index);
- outImage->setText(key, pair.mid(index + 2).simplified());
- }
- }
+#ifndef QT_NO_IMAGE_TEXT
+ readPngTexts(end_info);
+ for (int i = 0; i < readTexts.size()-1; i+=2)
+ outImage->setText(readTexts.at(i), readTexts.at(i+1));
#endif
- state = ReadingEnd;
- png_read_end(png_ptr, end_info);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
delete [] row_pointers;
png_ptr = 0;
@@ -647,29 +640,40 @@ static void set_text(const QImage &image, png_structp png_ptr, png_infop info_pt
return;
png_textp text_ptr = new png_text[text.size()];
+ qMemSet(text_ptr, 0, text.size() * sizeof(png_text));
QMap<QString, QString>::ConstIterator it = text.constBegin();
int i = 0;
while (it != text.constEnd()) {
- QString t = it.value();
- if (t.length() < 40)
- text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE;
- else
- text_ptr[i].compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr[i].key = qstrdup(it.key().left(79).toLatin1().constData());
+ bool noCompress = (it.value().length() < 40);
-#ifndef PNG_iTXt_SUPPORTED
- QByteArray value = it.value().toLatin1();
- text_ptr[i].text = qstrdup(value.constData());
- text_ptr[i].text_length = value.size();
-#else
- QByteArray value = it.value().toUtf8();
- text_ptr[i].text = qstrdup(value.constData());
- text_ptr[i].text_length = 0;
- text_ptr[i].itxt_length = value.size();
- text_ptr[i].lang = const_cast<char*>("UTF-8");
- text_ptr[i].lang_key = qstrdup(it.key().toUtf8().constData());
+#ifdef PNG_iTXt_SUPPORTED
+ bool needsItxt = false;
+ foreach(const QChar c, it.value()) {
+ uchar ch = c.cell();
+ if (c.row() || (ch < 0x20 && ch != '\n') || (ch > 0x7e && ch < 0xa0)) {
+ needsItxt = true;
+ break;
+ }
+ }
+
+ if (needsItxt) {
+ text_ptr[i].compression = noCompress ? PNG_ITXT_COMPRESSION_NONE : PNG_ITXT_COMPRESSION_zTXt;
+ QByteArray value = it.value().toUtf8();
+ text_ptr[i].text = qstrdup(value.constData());
+ text_ptr[i].itxt_length = value.size();
+ text_ptr[i].lang = const_cast<char*>("UTF-8");
+ text_ptr[i].lang_key = qstrdup(it.key().toUtf8().constData());
+ }
+ else
#endif
+ {
+ text_ptr[i].compression = noCompress ? PNG_TEXT_COMPRESSION_NONE : PNG_TEXT_COMPRESSION_zTXt;
+ QByteArray value = it.value().toLatin1();
+ text_ptr[i].text = qstrdup(value.constData());
+ text_ptr[i].text_length = value.size();
+ }
++i;
++it;
}
diff --git a/src/gui/image/qtiffhandler.cpp b/src/gui/image/qtiffhandler.cpp
index c93009f..5939ad5 100644
--- a/src/gui/image/qtiffhandler.cpp
+++ b/src/gui/image/qtiffhandler.cpp
@@ -196,9 +196,12 @@ bool QTiffHandler::read(QImage *image)
uint16 bitPerSample;
if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bitPerSample))
bitPerSample = 1;
+ uint16 samplesPerPixel; // they may be e.g. grayscale with 2 samples per pixel
+ if (!TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesPerPixel))
+ samplesPerPixel = 1;
bool grayscale = photometric == PHOTOMETRIC_MINISBLACK || photometric == PHOTOMETRIC_MINISWHITE;
- if (grayscale && bitPerSample == 1) {
+ if (grayscale && bitPerSample == 1 && samplesPerPixel == 1) {
if (image->size() != QSize(width, height) || image->format() != QImage::Format_Mono)
*image = QImage(width, height, QImage::Format_Mono);
QVector<QRgb> colortable(2);
@@ -220,7 +223,7 @@ bool QTiffHandler::read(QImage *image)
}
}
} else {
- if ((grayscale || photometric == PHOTOMETRIC_PALETTE) && bitPerSample == 8) {
+ if ((grayscale || photometric == PHOTOMETRIC_PALETTE) && bitPerSample == 8 && samplesPerPixel == 1) {
if (image->size() != QSize(width, height) || image->format() != QImage::Format_Indexed8)
*image = QImage(width, height, QImage::Format_Indexed8);
if (!image->isNull()) {
diff --git a/src/gui/image/qvolatileimagedata.cpp b/src/gui/image/qvolatileimagedata.cpp
index 51b5995..d7b964c 100644
--- a/src/gui/image/qvolatileimagedata.cpp
+++ b/src/gui/image/qvolatileimagedata.cpp
@@ -68,6 +68,7 @@ QVolatileImageData::QVolatileImageData(void *, void *)
}
QVolatileImageData::QVolatileImageData(const QVolatileImageData &other)
+ : QSharedData()
{
image = other.image;
// The detach is not mandatory here but we do it nonetheless in order to
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 76cd813..075d5da 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -54,12 +54,6 @@
#include "qplatformdefs.h"
#endif
-#include <stdlib.h>
-
-#if defined(Q_OS_WINCE)
-#include "qguifunctions_wince.h"
-#endif
-
QT_BEGIN_NAMESPACE
static quint64 xpmHash(const QString &str)
@@ -751,27 +745,15 @@ static const struct XPMRGBData {
{ QRGB(139,139, 0), "yellow4" },
{ QRGB(154,205, 50), "yellowgreen" } };
-#if defined(Q_C_CALLBACKS)
-extern "C" {
-#endif
-static int rgb_cmp(const void *d1, const void *d2)
-{
- return qstricmp(((XPMRGBData *)d1)->name, ((XPMRGBData *)d2)->name);
-}
-#if defined(Q_C_CALLBACKS)
-}
-#endif
+inline bool operator<(const char *name, const XPMRGBData &data)
+{ return qstrcmp(name, data.name) < 0; }
+inline bool operator<(const XPMRGBData &data, const char *name)
+{ return qstrcmp(data.name, name) < 0; }
-static bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb)
+static inline bool qt_get_named_xpm_rgb(const char *name_no_space, QRgb *rgb)
{
- XPMRGBData x;
- x.name = name_no_space;
- // Function bsearch() is supposed to be
- // void *bsearch(const void *key, const void *base, ...
- // So why (char*)? Are there broken bsearch() declarations out there?
- XPMRGBData *r = (XPMRGBData *)bsearch((char *)&x, (char *)xpmRgbTbl, xpmRgbTblSize,
- sizeof(XPMRGBData), rgb_cmp);
- if (r) {
+ const XPMRGBData *r = qBinaryFind(xpmRgbTbl, xpmRgbTbl + xpmRgbTblSize, name_no_space);
+ if (r != xpmRgbTbl + xpmRgbTblSize) {
*rgb = r->value;
return true;
} else {
diff --git a/src/gui/inputmethod/inputmethod.pri b/src/gui/inputmethod/inputmethod.pri
index 02e3e57..d439438 100644
--- a/src/gui/inputmethod/inputmethod.pri
+++ b/src/gui/inputmethod/inputmethod.pri
@@ -19,7 +19,7 @@ embedded {
HEADERS += inputmethod/qwsinputcontext_p.h
SOURCES += inputmethod/qwsinputcontext_qws.cpp
}
-mac:!embedded {
+mac:!embedded:!qpa {
HEADERS += inputmethod/qmacinputcontext_p.h
SOURCES += inputmethod/qmacinputcontext_mac.cpp
}
diff --git a/src/gui/itemviews/qabstractitemdelegate.cpp b/src/gui/itemviews/qabstractitemdelegate.cpp
index f929e2e..478c474 100644
--- a/src/gui/itemviews/qabstractitemdelegate.cpp
+++ b/src/gui/itemviews/qabstractitemdelegate.cpp
@@ -362,7 +362,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
case QEvent::ToolTip: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
QVariant tooltip = index.data(Qt::ToolTipRole);
- if (qVariantCanConvert<QString>(tooltip)) {
+ if (tooltip.canConvert<QString>()) {
QToolTip::showText(he->globalPos(), tooltip.toString(), view);
return true;
}
@@ -376,7 +376,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
case QEvent::WhatsThis: {
QHelpEvent *he = static_cast<QHelpEvent*>(event);
QVariant whatsthis = index.data(Qt::WhatsThisRole);
- if (qVariantCanConvert<QString>(whatsthis)) {
+ if (whatsthis.canConvert<QString>()) {
QWhatsThis::showText(he->globalPos(), whatsthis.toString(), view);
return true;
}
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 081a6d9..d671496 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -62,6 +62,9 @@
#include <qaccessible.h>
#endif
#include <private/qsoftkeymanager_p.h>
+#ifndef QT_NO_GESTURE
+# include <qscroller.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -79,6 +82,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
pressedAlreadySelected(false),
viewportEnteredNeeded(false),
state(QAbstractItemView::NoState),
+ stateBeforeAnimation(QAbstractItemView::NoState),
editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed),
lastTrigger(QAbstractItemView::NoEditTriggers),
tabKeyNavigation(false),
@@ -190,6 +194,40 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index
}
}
+#ifndef QT_NO_GESTURES
+
+// stores and restores the selection and current item when flicking
+void QAbstractItemViewPrivate::_q_scrollerStateChanged()
+{
+ Q_Q(QAbstractItemView);
+
+ if (QScroller *scroller = QScroller::scroller(viewport)) {
+ switch (scroller->state()) {
+ case QScroller::Pressed:
+ // store the current selection in case we start scrolling
+ if (q->selectionModel()) {
+ oldSelection = q->selectionModel()->selection();
+ oldCurrent = q->selectionModel()->currentIndex();
+ }
+ break;
+
+ case QScroller::Dragging:
+ // restore the old selection if we really start scrolling
+ if (q->selectionModel()) {
+ q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
+ q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
+ }
+ // fall through
+
+ default:
+ oldSelection = QItemSelection();
+ oldCurrent = QModelIndex();
+ break;
+ }
+ }
+}
+
+#endif // QT_NO_GESTURES
/*!
\class QAbstractItemView
@@ -661,7 +699,7 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
"QAbstractItemView::setModel",
"A model should return the exact same index "
"(including its internal id/pointer) when asked for it twice in a row.");
- Q_ASSERT_X(d->model->index(0,0).parent() == QModelIndex(),
+ Q_ASSERT_X(!d->model->index(0,0).parent().isValid(),
"QAbstractItemView::setModel",
"The parent of a top level index should be invalid");
@@ -1045,10 +1083,12 @@ void QAbstractItemView::reset()
{
Q_D(QAbstractItemView);
d->delayedReset.stop(); //make sure we stop the timer
- QList<QEditorInfo>::const_iterator it = d->editors.constBegin();
- for (; it != d->editors.constEnd(); ++it)
- d->releaseEditor(it->editor);
- d->editors.clear();
+ foreach (const QEditorInfo &info, d->indexEditorHash) {
+ if (info.widget)
+ d->releaseEditor(info.widget.data());
+ }
+ d->editorIndexHash.clear();
+ d->indexEditorHash.clear();
d->persistent.clear();
d->currentIndexSet = false;
setState(NoState);
@@ -1622,6 +1662,13 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
case QEvent::WindowDeactivate:
d->viewport->update();
break;
+ case QEvent::ScrollPrepare:
+ executeDelayedItemsLayout();
+#ifndef QT_NO_GESTURES
+ connect(QScroller::scroller(d->viewport), SIGNAL(stateChanged(QScroller::State)), this, SLOT(_q_scrollerStateChanged()), Qt::UniqueConnection);
+#endif
+ break;
+
default:
break;
}
@@ -2342,7 +2389,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
case Qt::Key_Return:
// Propagate the enter if you couldn't edit the item and there are no
// current editors (if there are editors, the event was most likely propagated from it).
- if (!edit(currentIndex(), EditKeyPressed, event) && d->editors.isEmpty())
+ if (!edit(currentIndex(), EditKeyPressed, event) && d->editorIndexHash.isEmpty())
event->ignore();
break;
#else
@@ -2527,7 +2574,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
if (!d->isIndexValid(index))
return false;
- if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).editor.data())) {
+ if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) {
if (w->focusPolicy() == Qt::NoFocus)
return false;
w->setFocus();
@@ -2587,15 +2634,15 @@ void QAbstractItemView::updateEditorData()
void QAbstractItemView::updateEditorGeometries()
{
Q_D(QAbstractItemView);
- if(d->editors.isEmpty())
+ if(d->editorIndexHash.isEmpty())
return;
QStyleOptionViewItemV4 option = d->viewOptionsV4();
- QList<QEditorInfo>::iterator it = d->editors.begin();
+ QEditorIndexHash::iterator it = d->editorIndexHash.begin();
QWidgetList editorsToRelease;
QWidgetList editorsToHide;
- while (it != d->editors.end()) {
- QModelIndex index = it->index;
- QWidget *editor = it->editor;
+ while (it != d->editorIndexHash.end()) {
+ QModelIndex index = it.value();
+ QWidget *editor = it.key();
if (index.isValid() && editor) {
option.rect = visualRect(index);
if (option.rect.isValid()) {
@@ -2608,13 +2655,14 @@ void QAbstractItemView::updateEditorGeometries()
}
++it;
} else {
- it = d->editors.erase(it);
+ d->indexEditorHash.remove(it.value());
+ it = d->editorIndexHash.erase(it);
editorsToRelease << editor;
}
}
//we hide and release the editor outside of the loop because it might change the focus and try
- //to change the d->editors list.
+ //to change the editors hashes.
for (int i = 0; i < editorsToHide.count(); ++i) {
editorsToHide.at(i)->hide();
}
@@ -2954,7 +3002,7 @@ int QAbstractItemView::sizeHintForRow(int row) const
{
Q_D(const QAbstractItemView);
- if (row < 0 || row >= d->model->rowCount() || !model())
+ if (row < 0 || row >= d->model->rowCount(d->root))
return -1;
ensurePolished();
@@ -2965,8 +3013,8 @@ int QAbstractItemView::sizeHintForRow(int row) const
QModelIndex index;
for (int c = 0; c < colCount; ++c) {
index = d->model->index(row, c, d->root);
- if (QWidget *editor = d->editorForIndex(index).editor)
- height = qMax(height, editor->size().height());
+ if (QWidget *editor = d->editorForIndex(index).widget.data())
+ height = qMax(height, editor->height());
int hint = d->delegateForIndex(index)->sizeHint(option, index).height();
height = qMax(height, hint);
}
@@ -2985,7 +3033,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
{
Q_D(const QAbstractItemView);
- if (column < 0 || column >= d->model->columnCount() || !model())
+ if (column < 0 || column >= d->model->columnCount(d->root))
return -1;
ensurePolished();
@@ -2996,7 +3044,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
QModelIndex index;
for (int r = 0; r < rows; ++r) {
index = d->model->index(r, column, d->root);
- if (QWidget *editor = d->editorForIndex(index).editor)
+ if (QWidget *editor = d->editorForIndex(index).widget.data())
width = qMax(width, editor->sizeHint().width());
int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
width = qMax(width, hint);
@@ -3032,8 +3080,7 @@ void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
{
Q_D(QAbstractItemView);
- QWidget *editor = d->editorForIndex(index).editor;
- if (editor) {
+ if (QWidget *editor = d->editorForIndex(index).widget.data()) {
if (index == selectionModel()->currentIndex())
closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
d->persistent.remove(editor);
@@ -3097,9 +3144,11 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget
QWidget* QAbstractItemView::indexWidget(const QModelIndex &index) const
{
Q_D(const QAbstractItemView);
- if (!d->isIndexValid(index))
- return 0;
- return d->editorForIndex(index).editor;
+ if (d->isIndexValid(index))
+ if (QWidget *editor = d->editorForIndex(index).widget.data())
+ return editor;
+
+ return 0;
}
/*!
@@ -3161,12 +3210,12 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde
// Single item changed
Q_D(QAbstractItemView);
if (topLeft == bottomRight && topLeft.isValid()) {
- const QEditorInfo editorInfo = d->editorForIndex(topLeft);
+ const QEditorInfo &editorInfo = d->editorForIndex(topLeft);
//we don't update the edit data if it is static
- if (!editorInfo.isStatic && editorInfo.editor) {
+ if (!editorInfo.isStatic && editorInfo.widget) {
QAbstractItemDelegate *delegate = d->delegateForIndex(topLeft);
if (delegate) {
- delegate->setEditorData(editorInfo.editor, topLeft);
+ delegate->setEditorData(editorInfo.widget.data(), topLeft);
}
}
if (isVisible() && !d->delayedPendingLayout) {
@@ -3240,12 +3289,17 @@ void QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int star
}
// Remove all affected editors; this is more efficient than waiting for updateGeometries() to clean out editors for invalid indexes
- for (int i = d->editors.size() - 1; i >= 0; --i) {
- const QModelIndex index = d->editors.at(i).index;
- QWidget *editor = d->editors.at(i).editor;
+ QEditorIndexHash::iterator i = d->editorIndexHash.begin();
+ while (i != d->editorIndexHash.end()) {
+ const QModelIndex index = i.value();
if (index.row() >= start && index.row() <= end && d->model->parent(index) == parent) {
- d->editors.removeAt(i);
- d->releaseEditor(editor);
+ QWidget *editor = i.key();
+ QEditorInfo info = d->indexEditorHash.take(index);
+ i = d->editorIndexHash.erase(i);
+ if (info.widget)
+ d->releaseEditor(editor);
+ } else {
+ ++i;
}
}
}
@@ -3302,17 +3356,20 @@ void QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &par
}
// Remove all affected editors; this is more efficient than waiting for updateGeometries() to clean out editors for invalid indexes
- QList<QEditorInfo>::iterator it = editors.begin();
- while (it != editors.end()) {
- QModelIndex index = it->index;
+ QEditorIndexHash::iterator it = editorIndexHash.begin();
+ while (it != editorIndexHash.end()) {
+ QModelIndex index = it.value();
if (index.column() <= start && index.column() >= end && model->parent(index) == parent) {
- QWidget *editor = it->editor;
- it = editors.erase(it);
- releaseEditor(editor);
+ QWidget *editor = it.key();
+ QEditorInfo info = indexEditorHash.take(it.value());
+ it = editorIndexHash.erase(it);
+ if (info.widget)
+ releaseEditor(editor);
} else {
++it;
}
}
+
}
/*!
@@ -3394,7 +3451,7 @@ void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelI
if (previous.isValid()) {
QModelIndex buddy = d->model->buddy(previous);
- QWidget *editor = d->editorForIndex(buddy).editor;
+ QWidget *editor = d->editorForIndex(buddy).widget.data();
if (editor && !d->persistent.contains(editor)) {
commitData(editor);
if (current.row() != previous.row())
@@ -3920,7 +3977,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,
const QStyleOptionViewItem &options)
{
Q_Q(QAbstractItemView);
- QWidget *w = editorForIndex(index).editor;
+ QWidget *w = editorForIndex(index).widget.data();
if (!w) {
QAbstractItemDelegate *delegate = delegateForIndex(index);
if (!delegate)
@@ -3951,6 +4008,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,
#endif
}
}
+
return w;
}
@@ -3959,11 +4017,11 @@ void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QMo
// we are counting on having relatively few editors
const bool checkIndexes = tl.isValid() && br.isValid();
const QModelIndex parent = tl.parent();
- QList<QEditorInfo>::const_iterator it = editors.constBegin();
- for (; it != editors.constEnd(); ++it) {
- QWidget *editor = it->editor;
- const QModelIndex index = it->index;
- if (it->isStatic || editor == 0 || !index.isValid() ||
+ QIndexEditorHash::const_iterator it = indexEditorHash.constBegin();
+ for (; it != indexEditorHash.constEnd(); ++it) {
+ QWidget *editor = it.value().widget.data();
+ const QModelIndex index = it.key();
+ if (it.value().isStatic || !editor || !index.isValid() ||
(checkIndexes
&& (index.row() < tl.row() || index.row() > br.row()
|| index.column() < tl.column() || index.column() > br.column()
@@ -4036,41 +4094,40 @@ void QAbstractItemViewPrivate::checkPersistentEditorFocus()
}
-QEditorInfo QAbstractItemViewPrivate::editorForIndex(const QModelIndex &index) const
+const QEditorInfo & QAbstractItemViewPrivate::editorForIndex(const QModelIndex &index) const
{
- QList<QEditorInfo>::const_iterator it = editors.constBegin();
- for (; it != editors.constEnd(); ++it) {
- if (it->index == index)
- return *it;
- }
+ static QEditorInfo nullInfo;
- return QEditorInfo();
+ QIndexEditorHash::const_iterator it = indexEditorHash.find(index);
+ if (it == indexEditorHash.end())
+ return nullInfo;
+
+ return it.value();
}
QModelIndex QAbstractItemViewPrivate::indexForEditor(QWidget *editor) const
{
- QList<QEditorInfo>::const_iterator it = editors.constBegin();
- for (; it != editors.constEnd(); ++it) {
- if (it->editor == editor)
- return it->index;
- }
- return QModelIndex();
+ QEditorIndexHash::const_iterator it = editorIndexHash.find(editor);
+ if (it == editorIndexHash.end())
+ return QModelIndex();
+
+ return it.value();
}
void QAbstractItemViewPrivate::removeEditor(QWidget *editor)
{
- QList<QEditorInfo>::iterator it = editors.begin();
- for (; it != editors.end(); ) {
- if (it->editor == editor)
- it = editors.erase(it);
- else
- ++it;
+ QEditorIndexHash::iterator it = editorIndexHash.find(editor);
+ if (it != editorIndexHash.end())
+ {
+ indexEditorHash.remove(it.value());
+ editorIndexHash.erase(it);
}
}
void QAbstractItemViewPrivate::addEditor(const QModelIndex &index, QWidget *editor, bool isStatic)
{
- editors.append(QEditorInfo(index, editor, isStatic));
+ editorIndexHash.insert(editor, index);
+ indexEditorHash.insert(index, QEditorInfo(editor, isStatic));
}
bool QAbstractItemViewPrivate::sendDelegateEvent(const QModelIndex &index, QEvent *event) const
@@ -4097,13 +4154,13 @@ bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *even
if (!w)
return false;
- if (event)
- QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event);
-
q->setState(QAbstractItemView::EditingState);
w->show();
w->setFocus();
+ if (event)
+ QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event);
+
return true;
}
diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h
index 7043a5f..f11f209 100644
--- a/src/gui/itemviews/qabstractitemview.h
+++ b/src/gui/itemviews/qabstractitemview.h
@@ -359,6 +359,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
+#ifndef QT_NO_GESTURES
+ Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
+#endif
friend class QTreeViewPrivate; // needed to compile with MSVC
friend class QAccessibleItemRow;
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index da9537d..6041e5e 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -70,22 +70,18 @@
QT_BEGIN_NAMESPACE
-struct QEditorInfo
-{
- QEditorInfo() : isStatic(false)
- {
- }
-
- QEditorInfo(const QPersistentModelIndex &i, QWidget *e, bool b) : index(i), editor(e), isStatic(b)
- {
- }
-
- QPersistentModelIndex index;
- QPointer<QWidget> editor;
- bool isStatic; //true when called from setIndexWidget
+struct QEditorInfo {
+ QEditorInfo(QWidget *e, bool s): widget(QWeakPointer<QWidget>(e)), isStatic(s) {}
+ QEditorInfo(): isStatic(false) {}
+ QWeakPointer<QWidget> widget;
+ bool isStatic;
};
+// Fast associativity between Persistent editors and indices.
+typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash;
+typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash;
+
typedef QPair<QRect, QModelIndex> QItemViewPaintPair;
typedef QList<QItemViewPaintPair> QItemViewPaintPairs;
@@ -118,6 +114,7 @@ public:
virtual void _q_modelDestroyed();
virtual void _q_layoutChanged();
void _q_headerDataChanged() { doDelayedItemsLayout(); }
+ void _q_scrollerStateChanged();
void fetchMore();
@@ -135,8 +132,9 @@ public:
}
void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;}
-
- bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
+#ifndef QT_NO_DRAGANDDROP
+ virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
+#endif
bool droppingOnItself(QDropEvent *event, const QModelIndex &index);
QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options);
@@ -247,9 +245,9 @@ public:
: q->horizontalOffset(), q->verticalOffset());
}
- QEditorInfo editorForIndex(const QModelIndex &index) const;
+ const QEditorInfo &editorForIndex(const QModelIndex &index) const;
inline bool hasEditor(const QModelIndex &index) const {
- return editorForIndex(index).editor != 0;
+ return indexEditorHash.find(index) != indexEditorHash.constEnd();
}
QModelIndex indexForEditor(QWidget *editor) const;
@@ -352,7 +350,8 @@ public:
QAbstractItemView::SelectionMode selectionMode;
QAbstractItemView::SelectionBehavior selectionBehavior;
- QList<QEditorInfo> editors;
+ QEditorIndexHash editorIndexHash;
+ QIndexEditorHash indexEditorHash;
QSet<QWidget*> persistent;
QWidget *currentlyCommittingEditor;
@@ -367,6 +366,7 @@ public:
bool viewportEnteredNeeded;
QAbstractItemView::State state;
+ QAbstractItemView::State stateBeforeAnimation;
QAbstractItemView::EditTriggers editTriggers;
QAbstractItemView::EditTrigger lastTrigger;
@@ -415,6 +415,12 @@ public:
QAbstractItemView::ScrollMode verticalScrollMode;
QAbstractItemView::ScrollMode horizontalScrollMode;
+#ifndef QT_NO_GESTURES
+ // the selection before the last mouse down. In case we have to restore it for scrolling
+ QItemSelection oldSelection;
+ QModelIndex oldCurrent;
+#endif
+
bool currentIndexSet;
bool wrapItemText;
diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp
index 368b351..34ca7df 100644
--- a/src/gui/itemviews/qabstractproxymodel.cpp
+++ b/src/gui/itemviews/qabstractproxymodel.cpp
@@ -45,6 +45,9 @@
#include "qitemselectionmodel.h"
#include <private/qabstractproxymodel_p.h>
+#include <QtCore/QSize>
+#include <QtCore/QStringList>
+
QT_BEGIN_NAMESPACE
@@ -118,12 +121,15 @@ QAbstractProxyModel::~QAbstractProxyModel()
void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
Q_D(QAbstractProxyModel);
- if (d->model)
+ if (d->model) {
disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
+ disconnect(d->model, SIGNAL(modelReset()), this, SLOT(resetInternalData()));
+ }
if (sourceModel) {
d->model = sourceModel;
connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
+ connect(d->model, SIGNAL(modelReset()), this, SLOT(resetInternalData()));
} else {
d->model = QAbstractItemModelPrivate::staticEmptyModel();
}
@@ -270,6 +276,15 @@ bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &valu
/*!
\reimp
*/
+bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap< int, QVariant >& roles)
+{
+ Q_D(QAbstractProxyModel);
+ return d->model->setItemData(mapToSource(index), roles);
+}
+
+/*!
+ \reimp
+ */
bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
{
Q_D(QAbstractProxyModel);
@@ -284,6 +299,109 @@ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation
return d->model->setHeaderData(sourceSection, orientation, value, role);
}
+/*!
+ \reimp
+ */
+QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const
+{
+ Q_D(const QAbstractProxyModel);
+ return mapFromSource(d->model->buddy(mapToSource(index)));
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->canFetchMore(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QAbstractProxyModel::fetchMore(const QModelIndex &parent)
+{
+ Q_D(QAbstractProxyModel);
+ d->model->fetchMore(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QAbstractProxyModel::sort(int column, Qt::SortOrder order)
+{
+ Q_D(QAbstractProxyModel);
+ d->model->sort(column, order);
+}
+
+/*!
+ \reimp
+ */
+QSize QAbstractProxyModel::span(const QModelIndex &index) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->span(mapToSource(index));
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->hasChildren(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
+{
+ Q_D(const QAbstractProxyModel);
+ QModelIndexList list;
+ foreach(const QModelIndex &index, indexes)
+ list << mapToSource(index);
+ return d->model->mimeData(list);
+}
+
+/*!
+ \reimp
+ */
+QStringList QAbstractProxyModel::mimeTypes() const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->mimeTypes();
+}
+
+/*!
+ \reimp
+ */
+Qt::DropActions QAbstractProxyModel::supportedDropActions() const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->supportedDropActions();
+}
+
+/*
+ \since 4.8
+
+ This slot is called just after the internal data of a model is cleared
+ while it is being reset.
+
+ This slot is provided the convenience of subclasses of concrete proxy
+ models, such as subclasses of QSortFilterProxyModel which maintain extra
+ data.
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 10
+
+ \sa modelAboutToBeReset(), modelReset()
+*/
+void QAbstractProxyModel::resetInternalData()
+{
+
+}
+
QT_END_NAMESPACE
#include "moc_qabstractproxymodel.cpp"
diff --git a/src/gui/itemviews/qabstractproxymodel.h b/src/gui/itemviews/qabstractproxymodel.h
index 256433a..6e485ae 100644
--- a/src/gui/itemviews/qabstractproxymodel.h
+++ b/src/gui/itemviews/qabstractproxymodel.h
@@ -81,8 +81,23 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+ bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles);
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);
+ QModelIndex buddy(const QModelIndex &index) const;
+ bool canFetchMore(const QModelIndex &parent) const;
+ void fetchMore(const QModelIndex &parent);
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+ QSize span(const QModelIndex &index) const;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ QMimeData* mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+
+protected Q_SLOTS:
+ void resetInternalData();
+
protected:
QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent);
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index 7901dca..ae93054 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -234,7 +234,7 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const
const QString fileExtension = QLatin1Char('.') + fileInfo.suffix().toUpper();
QString key;
- if (fileInfo.isFile() && !fileInfo.isExecutable() && !fileInfo.isSymLink())
+ if (fileInfo.isFile() && !fileInfo.isExecutable() && !fileInfo.isSymLink() && fileExtension != QLatin1String(".ICO"))
key = QLatin1String("qt_") + fileExtension;
QPixmap pixmap;
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 2ccf792..471c199 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -2109,7 +2109,7 @@ void QHeaderView::paintEvent(QPaintEvent *e)
QVariant variant = d->model->headerData(logical, d->orientation,
Qt::FontRole);
- if (variant.isValid() && qVariantCanConvert<QFont>(variant)) {
+ if (variant.isValid() && variant.canConvert<QFont>()) {
QFont sectionFont = qvariant_cast<QFont>(variant);
painter.setFont(sectionFont);
}
@@ -2489,13 +2489,13 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
opt.icon = qvariant_cast<QPixmap>(variant);
QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation,
Qt::ForegroundRole);
- if (qVariantCanConvert<QBrush>(foregroundBrush))
+ if (foregroundBrush.canConvert<QBrush>())
opt.palette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(foregroundBrush));
QPointF oldBO = painter->brushOrigin();
QVariant backgroundBrush = d->model->headerData(logicalIndex, d->orientation,
Qt::BackgroundRole);
- if (qVariantCanConvert<QBrush>(backgroundBrush)) {
+ if (backgroundBrush.canConvert<QBrush>()) {
opt.palette.setBrush(QPalette::Button, qvariant_cast<QBrush>(backgroundBrush));
opt.palette.setBrush(QPalette::Window, qvariant_cast<QBrush>(backgroundBrush));
painter->setBrushOrigin(opt.rect.topLeft());
@@ -2556,7 +2556,7 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const
QVariant var = d->model->headerData(logicalIndex, d->orientation,
Qt::FontRole);
QFont fnt;
- if (var.isValid() && qVariantCanConvert<QFont>(var))
+ if (var.isValid() && var.canConvert<QFont>())
fnt = qvariant_cast<QFont>(var);
else
fnt = font();
@@ -3278,9 +3278,17 @@ void QHeaderViewPrivate::clear()
void QHeaderViewPrivate::flipSortIndicator(int section)
{
Q_Q(QHeaderView);
- bool ascending = (sortIndicatorSection != section
- || sortIndicatorOrder == Qt::DescendingOrder);
- q->setSortIndicator(section, ascending ? Qt::AscendingOrder : Qt::DescendingOrder);
+ Qt::SortOrder sortOrder;
+ if (sortIndicatorSection == section) {
+ sortOrder = (sortIndicatorOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
+ } else {
+ const QVariant value = model->headerData(section, orientation, Qt::InitialSortOrderRole);
+ if (value.canConvert(QVariant::Int))
+ sortOrder = static_cast<Qt::SortOrder>(value.toInt());
+ else
+ sortOrder = Qt::AscendingOrder;
+ }
+ q->setSortIndicator(section, sortOrder);
}
void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index e061273..f211438 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -850,7 +850,7 @@ void QItemDelegate::drawBackground(QPainter *painter,
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
} else {
QVariant value = index.data(Qt::BackgroundRole);
- if (qVariantCanConvert<QBrush>(value)) {
+ if (value.canConvert<QBrush>()) {
QPointF oldBO = painter->brushOrigin();
painter->setBrushOrigin(option.rect.topLeft());
painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
@@ -1278,7 +1278,8 @@ bool QItemDelegate::editorEvent(QEvent *event,
// make sure that we have the right event type
if ((event->type() == QEvent::MouseButtonRelease)
- || (event->type() == QEvent::MouseButtonDblClick)) {
+ || (event->type() == QEvent::MouseButtonDblClick)
+ || (event->type() == QEvent::MouseButtonPress)) {
QRect checkRect = check(option, option.rect, Qt::Checked);
QRect emptyRect;
doLayout(option, &checkRect, &emptyRect, &emptyRect, false);
@@ -1287,7 +1288,8 @@ bool QItemDelegate::editorEvent(QEvent *event,
return false;
// eat the double click events inside the check rect
- if (event->type() == QEvent::MouseButtonDblClick)
+ if ((event->type() == QEvent::MouseButtonPress)
+ || (event->type() == QEvent::MouseButtonDblClick))
return true;
} else if (event->type() == QEvent::KeyPress) {
@@ -1326,7 +1328,7 @@ QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index,
// set foreground brush
value = index.data(Qt::ForegroundRole);
- if (qVariantCanConvert<QBrush>(value))
+ if (value.canConvert<QBrush>())
opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
return opt;
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index 73c562e..27a4a40 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -212,6 +212,7 @@ bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
{
return (isValid() && other.isValid()
&& parent() == other.parent()
+ && model() == other.model()
&& ((top() <= other.top() && bottom() >= other.top())
|| (top() >= other.top() && top() <= other.bottom()))
&& ((left() <= other.left() && right() >= other.left())
@@ -508,7 +509,7 @@ void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::Sel
void QItemSelection::split(const QItemSelectionRange &range,
const QItemSelectionRange &other, QItemSelection *result)
{
- if (range.parent() != other.parent())
+ if (range.parent() != other.parent() || range.model() != other.model())
return;
QModelIndex parent = other.parent();
@@ -634,6 +635,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
}
QItemSelection deselected;
+ QItemSelection newParts;
QItemSelection::iterator it = ranges.begin();
while (it != ranges.end()) {
if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range
@@ -659,13 +661,20 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare
deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight()));
*it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent()));
++it;
- } else {
- if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing)
- deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()),
- model->index(end, it->left(), it->parent())));
+ } else if (it->top() < start && end < it->bottom()) { // Middle intersection
+ // If the parent contains (1, 2, 3, 4, 5, 6, 7, 8) and [3, 4, 5, 6] is selected,
+ // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6].
+ // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection
+ // in ranges.
+ const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()),
+ model->index(end, it->left(), it->parent()));
+ deselected.append(removedRange);
+ QItemSelection::split(*it, removedRange, &newParts);
+ it = ranges.erase(it);
+ } else
++it;
- }
}
+ ranges.append(newParts);
if (!deselected.isEmpty())
emit q->selectionChanged(QItemSelection(), deselected);
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h
index 11aa0d5..12b875b 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/gui/itemviews/qitemselectionmodel.h
@@ -101,6 +101,30 @@ public:
{ return (tl == other.tl && br == other.br); }
inline bool operator!=(const QItemSelectionRange &other) const
{ return !operator==(other); }
+ inline bool operator<(const QItemSelectionRange &other) const
+ {
+ // Comparing parents will compare the models, but if two equivalent ranges
+ // in two different models have invalid parents, they would appear the same
+ if (other.tl.model() == tl.model()) {
+ // parent has to be calculated, so we only do so once.
+ const QModelIndex topLeftParent = tl.parent();
+ const QModelIndex otherTopLeftParent = other.tl.parent();
+ if (topLeftParent == otherTopLeftParent) {
+ if (other.tl.row() == tl.row()) {
+ if (other.tl.column() == tl.column()) {
+ if (other.br.row() == br.row()) {
+ return br.column() < other.br.column();
+ }
+ return br.row() < other.br.row();
+ }
+ return tl.column() < other.tl.column();
+ }
+ return tl.row() < other.tl.row();
+ }
+ return topLeftParent < otherTopLeftParent;
+ }
+ return tl.model() < other.tl.model();
+ }
inline bool isValid() const
{
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 18fa3b9..44b45d8 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -756,10 +756,13 @@ void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e
// if the parent is above d->root in the tree, nothing will happen
QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
if (parent == d->root) {
- for (int i = d->hiddenRows.count() - 1; i >= 0; --i) {
- int hiddenRow = d->hiddenRows.at(i).row();
+ QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin();
+ while (it != d->hiddenRows.end()) {
+ int hiddenRow = it->row();
if (hiddenRow >= start && hiddenRow <= end) {
- d->hiddenRows.remove(i);
+ it = d->hiddenRows.erase(it);
+ } else {
+ ++it;
}
}
}
@@ -1033,16 +1036,7 @@ void QListView::paintEvent(QPaintEvent *e)
previousRow = row;
}
- if (const QWidget *widget = d->editorForIndex(*it).editor) {
- QRegion itemGeometry(option.rect);
- QRegion widgetGeometry(widget->geometry());
- painter.save();
- painter.setClipRegion(itemGeometry.subtracted(widgetGeometry));
- d->delegateForIndex(*it)->paint(&painter, option, *it);
- painter.restore();
- } else {
- d->delegateForIndex(*it)->paint(&painter, option, *it);
- }
+ d->delegateForIndex(*it)->paint(&painter, option, *it);
}
#ifndef QT_NO_DRAGANDDROP
@@ -1496,19 +1490,20 @@ void QListView::updateGeometries()
// if the scroll bars are turned off, we resize the contents to the viewport
if (d->movement == Static && !d->isWrapping()) {
- d->layoutChildren(); // we need the viewport size to be updated
+ const QSize maxSize = maximumViewportSize();
if (d->flow == TopToBottom) {
if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(viewport()->width(), contentsSize().height());
+ d->setContentsSize(maxSize.width(), contentsSize().height());
horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway
}
} else { // LeftToRight
if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(contentsSize().width(), viewport()->height());
+ d->setContentsSize(contentsSize().width(), maxSize.height());
verticalScrollBar()->setRange(0, 0); // we see all the contents anyway
}
}
}
+
}
/*!
@@ -1833,6 +1828,14 @@ QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint
else
return QAbstractItemViewPrivate::position(pos, rect, idx);
}
+
+bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
+{
+ if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
+ return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);
+ else
+ return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);
+}
#endif
/*
@@ -1841,12 +1844,12 @@ QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint
void QCommonListViewBase::appendHiddenRow(int row)
{
- dd->hiddenRows.append(dd->model->index(row, 0, qq->rootIndex()));
+ dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex()));
}
void QCommonListViewBase::removeHiddenRow(int row)
{
- dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0, qq->rootIndex())));
+ dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex()));
}
void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
@@ -1960,7 +1963,13 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
// ignore by default
event->ignore();
- QModelIndex index = qq->indexAt(event->pos());
+ // can't use indexAt, doesn't account for spacing.
+ QPoint p = event->pos();
+ QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
+ rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
+ const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
+ QModelIndex index = intersectVector.count() > 0
+ ? intersectVector.last() : QModelIndex();
dd->hover = index;
if (!dd->droppingOnItself(event, index)
&& dd->canDecode(event)) {
@@ -1968,10 +1977,11 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
if (index.isValid() && dd->showDropIndicator) {
QRect rect = qq->visualRect(index);
dd->dropIndicatorPosition = position(event->pos(), rect, index);
+ // if spacing, should try to draw between items, not just next to item.
switch (dd->dropIndicatorPosition) {
case QAbstractItemView::AboveItem:
if (dd->isIndexDropEnabled(index.parent())) {
- dd->dropIndicatorRect = QRect(rect.left(), rect.top(), 0, rect.height());
+ dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height());
event->accept();
} else {
dd->dropIndicatorRect = QRect();
@@ -1979,7 +1989,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
break;
case QAbstractItemView::BelowItem:
if (dd->isIndexDropEnabled(index.parent())) {
- dd->dropIndicatorRect = QRect(rect.right(), rect.top(), 0, rect.height());
+ dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height());
event->accept();
} else {
dd->dropIndicatorRect = QRect();
@@ -2014,6 +2024,68 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
qq->startAutoScroll();
}
+/*!
+ If the event hasn't already been accepted, determines the index to drop on.
+
+ if (row == -1 && col == -1)
+ // append to this drop index
+ else
+ // place at row, col in drop index
+
+ If it returns true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop.
+ \internal
+ */
+bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
+{
+ if (event->isAccepted())
+ return false;
+
+ QModelIndex index;
+ if (dd->viewport->rect().contains(event->pos())) {
+ // can't use indexAt, doesn't account for spacing.
+ QPoint p = event->pos();
+ QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
+ rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
+ const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
+ index = intersectVector.count() > 0
+ ? intersectVector.last() : QModelIndex();
+ if (!index.isValid())
+ index = dd->root;
+ }
+
+ // If we are allowed to do the drop
+ if (dd->model->supportedDropActions() & event->dropAction()) {
+ int row = -1;
+ int col = -1;
+ if (index != dd->root) {
+ dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index);
+ switch (dd->dropIndicatorPosition) {
+ case QAbstractItemView::AboveItem:
+ row = index.row();
+ col = index.column();
+ index = index.parent();
+ break;
+ case QAbstractItemView::BelowItem:
+ row = index.row() + 1;
+ col = index.column();
+ index = index.parent();
+ break;
+ case QAbstractItemView::OnItem:
+ case QAbstractItemView::OnViewport:
+ break;
+ }
+ } else {
+ dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
+ }
+ *dropIndex = index;
+ *dropRow = row;
+ *dropCol = col;
+ if (!dd->droppingOnItself(event, index))
+ return true;
+ }
+ return false;
+}
+
#endif //QT_NO_DRAGANDDROP
void QListModeViewBase::updateVerticalScrollBar(const QSize &step)
@@ -2107,7 +2179,7 @@ int QListModeViewBase::verticalOffset() const
int value = verticalScrollBar()->value();
if (value >= segmentPositions.count())
return 0;
- return segmentPositions.at(value);
+ return segmentPositions.at(value) - spacing();
}
} else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) {
int value = verticalScrollBar()->value();
@@ -2155,14 +2227,14 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
if (horizontal && flow() == QListView::TopToBottom && dx != 0) {
int currentValue = qBound(0, horizontalValue, max);
int previousValue = qBound(0, currentValue + dx, max);
- int currentCoordinate = segmentPositions.at(currentValue);
- int previousCoordinate = segmentPositions.at(previousValue);
+ int currentCoordinate = segmentPositions.at(currentValue) - spacing();
+ int previousCoordinate = segmentPositions.at(previousValue) - spacing();
dx = previousCoordinate - currentCoordinate;
} else if (vertical && flow() == QListView::LeftToRight && dy != 0) {
int currentValue = qBound(0, verticalValue, max);
int previousValue = qBound(0, currentValue + dy, max);
- int currentCoordinate = segmentPositions.at(currentValue);
- int previousCoordinate = segmentPositions.at(previousValue);
+ int currentCoordinate = segmentPositions.at(currentValue) - spacing();
+ int previousCoordinate = segmentPositions.at(previousValue) - spacing();
dy = previousCoordinate - currentCoordinate;
}
} else {
@@ -2330,6 +2402,8 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
segmentExtents.append(flowPosition);
flowPosition = info.spacing + segStartPosition;
segPosition += deltaSegPosition;
+ if (info.wrap)
+ segPosition += info.spacing;
segmentPositions.append(segPosition);
segmentStartRows.append(row);
deltaSegPosition = 0;
diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h
index 5e50a67..84aaaca 100644
--- a/src/gui/itemviews/qlistview_p.h
+++ b/src/gui/itemviews/qlistview_p.h
@@ -237,6 +237,7 @@ public:
// WARNING: Plenty of duplicated code from QAbstractItemView{,Private}.
QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
void dragMoveEvent(QDragMoveEvent *e);
+ bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
#endif
private:
@@ -364,6 +365,7 @@ public:
#ifndef QT_NO_DRAGANDDROP
virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+ bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
#endif
inline void setGridSize(const QSize &size) { grid = size; }
@@ -376,7 +378,10 @@ public:
inline bool isSelectionRectVisible() const { return showElasticBand; }
inline QModelIndex modelIndex(int row) const { return model->index(row, column, root); }
- inline bool isHidden(int row) const { return hiddenRows.contains(model->index(row, 0, root)); }
+ inline bool isHidden(int row) const {
+ QModelIndex idx = model->index(row, 0, root);
+ return isPersistent(idx) && hiddenRows.contains(idx);
+ }
inline bool isHiddenOrDisabled(int row) const { return isHidden(row) || !isIndexEnabled(modelIndex(row)); }
inline void removeCurrentAndDisabled(QVector<QModelIndex> *indexes, const QModelIndex &current) const {
@@ -430,7 +435,7 @@ public:
QBasicTimer batchLayoutTimer;
// used for hidden items
- QVector<QPersistentModelIndex> hiddenRows;
+ QSet<QPersistentModelIndex> hiddenRows;
int column;
bool uniformItemSizes;
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 9f89bf5..eb56f56 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -362,6 +362,7 @@ QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &pro
return QModelIndex(); // for now; we may want to be able to set a root index later
if (proxy_index.model() != q_func()) {
qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource";
+ Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapToSource");
return QModelIndex();
}
IndexMap::const_iterator it = index_to_iterator(proxy_index);
@@ -379,6 +380,7 @@ QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &sou
return QModelIndex(); // for now; we may want to be able to set a root index later
if (source_index.model() != model) {
qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource";
+ Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapFromSource");
return QModelIndex();
}
QModelIndex source_parent = source_index.parent();
diff --git a/src/gui/itemviews/qstringlistmodel.cpp b/src/gui/itemviews/qstringlistmodel.cpp
index cadb731..d2e4c22 100644
--- a/src/gui/itemviews/qstringlistmodel.cpp
+++ b/src/gui/itemviews/qstringlistmodel.cpp
@@ -290,8 +290,9 @@ QStringList QStringListModel::stringList() const
*/
void QStringListModel::setStringList(const QStringList &strings)
{
+ emit beginResetModel();
lst = strings;
- reset();
+ emit endResetModel();
}
/*!
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index 0d1473d..33293f7 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -326,7 +326,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option,
option->displayAlignment = Qt::Alignment(value.toInt());
value = index.data(Qt::ForegroundRole);
- if (qVariantCanConvert<QBrush>(value))
+ if (value.canConvert<QBrush>())
option->palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
if (QStyleOptionViewItemV4 *v4 = qstyleoption_cast<QStyleOptionViewItemV4 *>(option)) {
@@ -727,7 +727,8 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
// make sure that we have the right event type
if ((event->type() == QEvent::MouseButtonRelease)
- || (event->type() == QEvent::MouseButtonDblClick)) {
+ || (event->type() == QEvent::MouseButtonDblClick)
+ || (event->type() == QEvent::MouseButtonPress)) {
QStyleOptionViewItemV4 viewOpt(option);
initStyleOption(&viewOpt, index);
QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget);
@@ -735,8 +736,8 @@ bool QStyledItemDelegate::editorEvent(QEvent *event,
if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
return false;
- // eat the double click events inside the check rect
- if (event->type() == QEvent::MouseButtonDblClick)
+ if ((event->type() == QEvent::MouseButtonPress)
+ || (event->type() == QEvent::MouseButtonDblClick))
return true;
} else if (event->type() == QEvent::KeyPress) {
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 49053c1..e494ee5 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -926,14 +926,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItemV4
q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, q);
- if (const QWidget *widget = editorForIndex(index).editor) {
- painter->save();
- painter->setClipRect(widget->geometry());
- q->itemDelegate(index)->paint(painter, opt, index);
- painter->restore();
- } else {
- q->itemDelegate(index)->paint(painter, opt, index);
- }
+ q->itemDelegate(index)->paint(painter, opt, index);
}
/*!
@@ -2166,7 +2159,7 @@ int QTableView::sizeHintForRow(int row) const
option.rect.setWidth(columnWidth(index.column()));
}
- QWidget *editor = d->editorForIndex(index).editor;
+ QWidget *editor = d->editorForIndex(index).widget.data();
if (editor && d->persistent.contains(editor)) {
hint = qMax(hint, editor->sizeHint().height());
int min = editor->minimumSize().height();
@@ -2219,7 +2212,7 @@ int QTableView::sizeHintForColumn(int column) const
continue;
index = d->model->index(logicalRow, column, d->root);
- QWidget *editor = d->editorForIndex(index).editor;
+ QWidget *editor = d->editorForIndex(index).widget.data();
if (editor && d->persistent.contains(editor)) {
hint = qMax(hint, editor->sizeHint().width());
int min = editor->minimumSize().width();
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index c0573bb..21c9d3b 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1493,7 +1493,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
// when the row contains an index widget which has focus,
// we want to paint the entire row as active
bool indexWidgetHasFocus = false;
- if ((current.row() == index.row()) && !d->editors.isEmpty()) {
+ if ((current.row() == index.row()) && !d->editorIndexHash.isEmpty()) {
const int r = index.row();
QWidget *fw = QApplication::focusWidget();
for (int c = 0; c < header->count(); ++c) {
@@ -1669,14 +1669,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
opt.state = oldState;
}
- if (const QWidget *widget = d->editorForIndex(modelIndex).editor) {
- painter->save();
- painter->setClipRect(widget->geometry());
- d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
- painter->restore();
- } else {
- d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
- }
+ d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
}
if (currentRowHasFocus) {
@@ -2395,7 +2388,7 @@ void QTreeView::scrollContentsBy(int dx, int dy)
int viewCount = d->viewport->height() / itemHeight;
int maxDeltaY = qMin(d->viewItems.count(), viewCount);
// no need to do a lot of work if we are going to redraw the whole thing anyway
- if (qAbs(dy) > qAbs(maxDeltaY) && d->editors.isEmpty()) {
+ if (qAbs(dy) > qAbs(maxDeltaY) && d->editorIndexHash.isEmpty()) {
verticalScrollBar()->update();
d->viewport->update();
return;
@@ -2469,11 +2462,9 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
}
const int parentItem = d->viewIndex(parent);
- if (((parentItem != -1) && d->viewItems.at(parentItem).expanded && updatesEnabled())
+ if (((parentItem != -1) && d->viewItems.at(parentItem).expanded)
|| (parent == d->root)) {
d->doDelayedItemsLayout();
- } else if ((parentItem != -1) && d->viewItems.at(parentItem).expanded) {
- d->doDelayedItemsLayout();
} else if (parentItem != -1 && (d->model->rowCount(parent) == end - start + 1)) {
// the parent just went from 0 children to more. update to re-paint the decoration
d->viewItems[parentItem].hasChildren = true;
@@ -2727,7 +2718,7 @@ int QTreeView::sizeHintForColumn(int column) const
continue; // we have no good size hint
QModelIndex index = viewItems.at(i).index;
index = index.sibling(index.row(), column);
- QWidget *editor = d->editorForIndex(index).editor;
+ QWidget *editor = d->editorForIndex(index).widget.data();
if (editor && d->persistent.contains(editor)) {
w = qMax(w, editor->sizeHint().width());
int min = editor->minimumSize().width();
@@ -2792,7 +2783,7 @@ int QTreeView::indexRowSizeHint(const QModelIndex &index) const
continue;
QModelIndex idx = d->model->index(indexRow, logicalColumn, parent);
if (idx.isValid()) {
- QWidget *editor = d->editorForIndex(idx).editor;
+ QWidget *editor = d->editorForIndex(idx).widget.data();
if (editor && d->persistent.contains(editor)) {
height = qMax(height, editor->sizeHint().height());
int min = editor->minimumSize().height();
@@ -2871,13 +2862,13 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
if (emitSignal && animationsEnabled)
prepareAnimatedOperation(item, QVariantAnimation::Forward);
#endif //QT_NO_ANIMATION
- QAbstractItemView::State oldState = state;
+ stateBeforeAnimation = state;
q->setState(QAbstractItemView::ExpandingState);
const QModelIndex index = viewItems.at(item).index;
storeExpanded(index);
viewItems[item].expanded = true;
layout(item);
- q->setState(oldState);
+ q->setState(stateBeforeAnimation);
if (model->canFetchMore(index))
model->fetchMore(index);
@@ -2946,7 +2937,7 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal)
prepareAnimatedOperation(item, QVariantAnimation::Backward);
#endif //QT_NO_ANIMATION
- QAbstractItemView::State oldState = state;
+ stateBeforeAnimation = state;
q->setState(QAbstractItemView::CollapsingState);
expandedIndexes.erase(it);
viewItems[item].expanded = false;
@@ -2956,7 +2947,7 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal)
index = viewItems[index].parentItem;
}
removeViewItems(item + 1, total); // collapse
- q->setState(oldState);
+ q->setState(stateBeforeAnimation);
if (emitSignal) {
emit q->collapsed(modelIndex);
@@ -3041,9 +3032,9 @@ QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) cons
//and now let's render the editors the editors
QStyleOptionViewItemV4 option = viewOptionsV4();
- for (QList<QEditorInfo>::const_iterator it = editors.constBegin(); it != editors.constEnd(); ++it) {
- QWidget *editor = it->editor;
- QModelIndex index = it->index;
+ for (QEditorIndexHash::const_iterator it = editorIndexHash.constBegin(); it != editorIndexHash.constEnd(); ++it) {
+ QWidget *editor = it.key();
+ const QModelIndex &index = it.value();
option.rect = q->visualRect(index);
if (option.rect.isValid()) {
@@ -3067,7 +3058,7 @@ QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) cons
void QTreeViewPrivate::_q_endAnimatedOperation()
{
Q_Q(QTreeView);
- q->setState(QAbstractItemView::NoState);
+ q->setState(stateBeforeAnimation);
q->updateGeometries();
viewport->update();
}
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index f9c84c1..32fa3d3 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -32,8 +32,6 @@ HEADERS += \
kernel/qshortcutmap_p.h \
kernel/qsizepolicy.h \
kernel/qpalette.h \
- kernel/qsound.h \
- kernel/qsound_p.h \
kernel/qstackedlayout.h \
kernel/qtooltip.h \
kernel/qwhatsthis.h \
@@ -50,7 +48,7 @@ HEADERS += \
kernel/qgesturemanager_p.h \
kernel/qsoftkeymanager_p.h \
kernel/qsoftkeymanager_common_p.h \
- kernel/qguiplatformplugin_p.h
+ kernel/qguiplatformplugin_p.h \
SOURCES += \
kernel/qaction.cpp \
@@ -72,7 +70,6 @@ SOURCES += \
kernel/qpalette.cpp \
kernel/qshortcut.cpp \
kernel/qshortcutmap.cpp \
- kernel/qsound.cpp \
kernel/qstackedlayout.cpp \
kernel/qtooltip.cpp \
kernel/qguivariant.cpp \
@@ -200,7 +197,70 @@ embedded {
}
}
-!embedded:!x11:mac {
+!qpa {
+ HEADERS += \
+ kernel/qsound.h \
+ kernel/qsound_p.h
+
+ SOURCES += \
+ kernel/qsound.cpp
+}
+
+qpa {
+ HEADERS += \
+ kernel/qgenericpluginfactory_qpa.h \
+ kernel/qgenericplugin_qpa.h \
+ kernel/qeventdispatcher_qpa_p.h \
+ kernel/qwindowsysteminterface_qpa.h \
+ kernel/qwindowsysteminterface_qpa_p.h \
+ kernel/qplatformintegration_qpa.h \
+ kernel/qplatformscreen_qpa.h \
+ kernel/qplatformintegrationfactory_qpa_p.h \
+ kernel/qplatformintegrationplugin_qpa.h \
+ kernel/qplatformwindow_qpa.h \
+ kernel/qplatformwindowformat_qpa.h \
+ kernel/qplatformglcontext_qpa.h \
+ kernel/qdesktopwidget_qpa_p.h \
+ kernel/qplatformeventloopintegration_qpa.h \
+ kernel/qplatformcursor_qpa.h \
+ kernel/qplatformclipboard_qpa.h \
+ kernel/qplatformnativeinterface_qpa.h
+
+ SOURCES += \
+ kernel/qapplication_qpa.cpp \
+ kernel/qclipboard_qpa.cpp \
+ kernel/qcursor_qpa.cpp \
+ kernel/qdnd_qws.cpp \
+ kernel/qdesktopwidget_qpa.cpp \
+ kernel/qgenericpluginfactory_qpa.cpp \
+ kernel/qgenericplugin_qpa.cpp \
+ kernel/qkeymapper_qws.cpp \
+ kernel/qwidget_qpa.cpp \
+ kernel/qeventdispatcher_qpa.cpp \
+ kernel/qwindowsysteminterface_qpa.cpp \
+ kernel/qplatformintegration_qpa.cpp \
+ kernel/qplatformscreen_qpa.cpp \
+ kernel/qplatformintegrationfactory_qpa.cpp \
+ kernel/qplatformintegrationplugin_qpa.cpp \
+ kernel/qplatformwindow_qpa.cpp \
+ kernel/qplatformwindowformat_qpa.cpp \
+ kernel/qplatformeventloopintegration_qpa.cpp \
+ kernel/qplatformglcontext_qpa.cpp \
+ kernel/qplatformcursor_qpa.cpp \
+ kernel/qplatformclipboard_qpa.cpp \
+ kernel/qplatformnativeinterface_qpa.cpp
+
+ contains(QT_CONFIG, glib) {
+ SOURCES += \
+ kernel/qeventdispatcher_glib_qpa.cpp
+ HEADERS += \
+ kernel/qeventdispatcher_glib_qpa_p.h
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ }
+}
+
+!embedded:!qpa:!x11:mac {
SOURCES += \
kernel/qclipboard_mac.cpp \
kernel/qmime_mac.cpp \
@@ -216,7 +276,8 @@ embedded {
qcocoaapplicationdelegate_mac_p.h \
qmacgesturerecognizer_mac_p.h \
qmultitouch_mac_p.h \
- qcocoasharedwindowmethods_mac_p.h
+ qcocoasharedwindowmethods_mac_p.h \
+ qcocoaintrospection_p.h
OBJECTIVE_SOURCES += \
kernel/qcursor_mac.mm \
@@ -236,7 +297,8 @@ embedded {
kernel/qeventdispatcher_mac.mm \
kernel/qcocoawindowcustomthemeframe_mac.mm \
kernel/qmacgesturerecognizer_mac.mm \
- kernel/qmultitouch_mac.mm
+ kernel/qmultitouch_mac.mm \
+ kernel/qcocoaintrospection_mac.mm
HEADERS += \
kernel/qt_cocoa_helpers_mac_p.h \
diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri
index 1538510..21acd06 100644
--- a/src/gui/kernel/mac.pri
+++ b/src/gui/kernel/mac.pri
@@ -1,4 +1,4 @@
-!x11:!embedded:mac {
+!x11:!embedded:!qpa:mac {
LIBS_PRIVATE += -framework Carbon -lz
*-mwerks:INCLUDEPATH += compat
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 59aec91..e91fe04 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -153,8 +153,6 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT void qt_call_post_routines();
-int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0
-
QApplication::Type qt_appType=QApplication::Tty;
QApplicationPrivate *QApplicationPrivate::self = 0;
@@ -169,8 +167,8 @@ bool QApplicationPrivate::autoSipEnabled = false;
bool QApplicationPrivate::autoSipEnabled = true;
#endif
-QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type)
- : QCoreApplicationPrivate(argc, argv)
+QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags)
+ : QCoreApplicationPrivate(argc, argv, flags)
{
application_type = type;
qt_appType = type;
@@ -452,6 +450,9 @@ QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
+#if defined(Q_WS_QPA)
+QPlatformIntegration *QApplicationPrivate::platform_integration = 0;
+#endif
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
bool QApplicationPrivate::runtime_graphics_system = false;
@@ -514,7 +515,7 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget)
{
if (!widget)
return false;
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
return !widget->isWindow()
# ifdef Q_BACKINGSTORE_SUBSURFACES
&& !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
@@ -724,12 +725,12 @@ void QApplicationPrivate::process_cmdline()
*/
QApplication::QApplication(int &argc, char **argv)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
-{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;}
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
+{ Q_D(QApplication); d->construct(); }
/*!
@@ -758,12 +759,12 @@ QApplication::QApplication(int &argc, char **argv, int _internal)
*/
QApplication::QApplication(int &argc, char **argv, bool GUIenabled )
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty))
-{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;}
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
+{ Q_D(QApplication); d->construct();}
@@ -781,12 +782,12 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern
\c -qws option).
*/
QApplication::QApplication(int &argc, char **argv, Type type)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, type))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, Type type , int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, type))
-{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;}
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, type, _internal))
+{ Q_D(QApplication); d->construct(); }
#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data)
@@ -892,7 +893,7 @@ static char *aargv[] = { (char*)"unknown", 0 };
This function is only available on X11.
*/
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
- : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@@ -901,7 +902,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
}
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
- : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@@ -926,7 +927,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
*/
QApplication::QApplication(Display *dpy, int &argc, char **argv,
Qt::HANDLE visual, Qt::HANDLE colormap)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@@ -936,7 +937,7 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv,
QApplication::QApplication(Display *dpy, int &argc, char **argv,
Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@@ -966,10 +967,11 @@ void QApplicationPrivate::initialize()
QWidgetPrivate::mapper = new QWidgetMapper;
QWidgetPrivate::allWidgets = new QWidgetSet;
-#if !defined(Q_WS_X11) && !defined(Q_WS_QWS)
+#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
// initialize the graphics system - on X11 this is initialized inside
// qt_init() in qapplication_x11.cpp because of several reasons.
// On QWS, the graphics system is set by the QScreen plugin.
+ // We don't use graphics systems in Qt QPA
graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
#endif
@@ -1643,14 +1645,18 @@ QStyle* QApplication::setStyle(const QString& style)
void QApplication::setGraphicsSystem(const QString &system)
{
-#ifdef QT_GRAPHICSSYSTEM_RUNTIME
+#ifdef Q_WS_QPA
+ Q_UNUSED(system);
+#else
+# ifdef QT_GRAPHICSSYSTEM_RUNTIME
if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
QRuntimeGraphicsSystem *r =
static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system);
r->setGraphicsSystem(system);
} else
-#endif
+# endif
QApplicationPrivate::graphics_system_name = system;
+#endif
}
/*!
@@ -2765,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
@@ -2796,7 +2802,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
// Update cursor for alien/graphics widgets.
const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
-#if defined(Q_WS_X11)
+#if defined(Q_WS_X11) || defined(Q_WS_QPA)
//Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor.
// This is not required on Windows as the cursor is reset on every single mouse move.
QWidget *parentOfLeavingCursor = 0;
@@ -2820,7 +2826,15 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
#endif
{
+#if defined(Q_WS_X11)
qt_x11_enforce_cursor(parentOfLeavingCursor,true);
+#elif defined(Q_WS_QPA)
+ if (enter == QApplication::desktop()) {
+ qt_qpa_set_cursor(enter, true);
+ } else {
+ qt_qpa_set_cursor(parentOfLeavingCursor, true);
+ }
+#endif
}
}
#endif
@@ -2844,6 +2858,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
qt_x11_enforce_cursor(cursorWidget, true);
#elif defined(Q_OS_SYMBIAN)
qt_symbian_set_cursor(cursorWidget, true);
+#elif defined(Q_WS_QPA)
+ qt_qpa_set_cursor(cursorWidget, true);
#endif
}
}
@@ -3126,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;
@@ -3148,7 +3162,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
return result;
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
/*
This function should only be called when the widget changes visibility, i.e.
when the \a widget is shown, hidden or deleted. This function does nothing
@@ -3160,7 +3174,7 @@ extern QWidget *qt_button_down;
void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
{
#ifndef QT_NO_CURSOR
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
if (!widget || widget->isWindow())
return;
#else
@@ -3679,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
@@ -3754,11 +3759,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
d->checkReceiverThread(receiver);
#endif
-#ifdef QT3_SUPPORT
- if (e->type() == QEvent::ChildRemoved && !receiver->d_func()->pendingChildInsertedEvents.isEmpty())
- receiver->d_func()->removePendingChildInsertedEvents(static_cast<QChildEvent *>(e)->child());
-#endif // QT3_SUPPORT
-
// capture the current mouse/keyboard state
if(e->spontaneous()) {
if (e->type() == QEvent::KeyPress
@@ -4423,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;
@@ -5861,12 +5879,12 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
#ifndef QT_NO_GESTURES
QGestureManager* QGestureManager::instance()
{
- if (QApplicationPrivate *qAppPriv = QApplicationPrivate::instance()) {
- if (!qAppPriv->gestureManager)
- qAppPriv->gestureManager = new QGestureManager(qApp);
- return qAppPriv->gestureManager;
- }
- return 0;
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ if (!qAppPriv)
+ return 0;
+ if (!qAppPriv->gestureManager)
+ qAppPriv->gestureManager = new QGestureManager(qApp);
+ return qAppPriv->gestureManager;
}
#endif // QT_NO_GESTURES
@@ -6090,6 +6108,8 @@ QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
default:
break;
}
+#else
+ Q_UNUSED(cshape);
#endif
return QPixmap();
}
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index b65cf91..aa62518 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -123,15 +123,15 @@ public:
#endif
#ifndef qdoc
- QApplication(int &argc, char **argv, int = QT_VERSION);
- QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION);
- QApplication(int &argc, char **argv, Type, int = QT_VERSION);
+ QApplication(int &argc, char **argv, int = ApplicationFlags);
+ QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags);
+ QApplication(int &argc, char **argv, Type, int = ApplicationFlags);
#if defined(Q_WS_X11)
- QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION);
- QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION);
+ QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags);
+ QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags);
#endif
#if defined(Q_OS_SYMBIAN)
- QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION);
+ QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags);
#endif
#endif
virtual ~QApplication();
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index bcf8cf2..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 );
@@ -549,7 +550,7 @@ void qt_mac_update_os_settings()
FontMap("QTipLabel", kThemeSmallSystemFont),
FontMap("QLabel", kThemeSystemFont),
FontMap("QToolButton", kThemeSmallSystemFont),
- FontMap("QMenuItem", kThemeMenuItemCmdKeyFont), // It doesn't exist, but its unique.
+ FontMap("QMenuItem", kThemeMenuItemFont), // It doesn't exist, but its unique.
FontMap("QComboLineEdit", kThemeViewsFont), // It doesn't exist, but its unique.
FontMap("QSmallFont", kThemeSmallSystemFont), // It doesn't exist, but its unique.
FontMap("QMiniFont", kThemeMiniSystemFont), // It doesn't exist, but its unique.
@@ -1243,8 +1244,10 @@ void qt_init(QApplicationPrivate *priv, int)
// Cocoa application delegate
#ifdef QT_MAC_USE_COCOA
NSApplication *cocoaApp = [QNSApplication sharedApplication];
+ qt_redirectNSApplicationSendEvent();
+
QMacCocoaAutoReleasePool pool;
- NSObject *oldDelegate = [cocoaApp delegate];
+ id oldDelegate = [cocoaApp delegate];
QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate];
Q_ASSERT(newDelegate);
[newDelegate setQtPrivate:priv];
@@ -1362,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
}
@@ -1409,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
}
@@ -1429,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
}
@@ -1478,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)
@@ -1510,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))
@@ -1936,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
@@ -2130,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)
@@ -2153,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; }
@@ -2238,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;
}
@@ -2501,7 +2498,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
void QApplicationPrivate::qt_initAfterNSAppStarted()
{
setupAppleEvents();
- updateOverrideCursor();
+ qt_mac_update_cursor();
}
void QApplicationPrivate::setupAppleEvents()
@@ -2608,25 +2605,26 @@ OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, Ap
/*!
\fn bool QApplication::macEventFilter(EventHandlerCallRef caller, EventRef event)
- \warning This virtual function is only implemented under Mac OS X when against Carbon.
+ \warning This virtual function is only used under Mac OS X, and behaves different
+ depending on if Qt is based on Carbon or Cocoa.
- If you create an application that inherits QApplication and reimplement
+ For the Carbon port, If you create an application that inherits QApplication and reimplement
this function, you get direct access to all Carbon Events that Qt registers
for from Mac OS X with this function being called with the \a caller and
the \a event.
+ For the Cocoa port, If you create an application that inherits QApplication and reimplement
+ this function, you get direct access to all Cocoa Events that Qt receives
+ from Mac OS X with this function being called with the \a caller being 0 and
+ the \a event being an NSEvent pointer:
+
+ NSEvent *e = reinterpret_cast<NSEvent *>(event);
+
Return true if you want to stop the event from being processed.
Return false for normal event dispatching. The default
implementation returns false.
- Cocoa uses a different event system which means this function is NOT CALLED
- when building Qt against Cocoa. If you want similar functionality subclass
- NSApplication and reimplement the sendEvent: message to handle all the
- NSEvents. You also will need to to instantiate your custom NSApplication
- before creating a QApplication. See \l
- {http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html}{Apple's
- NSApplication Reference} for more information.
-
+ \sa macEventFilter(void *nsevent)
*/
bool QApplication::macEventFilter(EventHandlerCallRef, EventRef)
{
@@ -3077,7 +3075,7 @@ void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
}
QMenuBar::macUpdateMenuBar();
- QApplicationPrivate::updateOverrideCursor();
+ qt_mac_update_cursor();
#else
Q_UNUSED(widget);
Q_UNUSED(activated);
@@ -3107,15 +3105,12 @@ void onApplicationChangedActivation( bool activated )
}
if (!app->activeWindow()) {
-#if QT_MAC_USE_COCOA
- OSWindowRef wp = [NSApp keyWindow];
-#else
- OSWindowRef wp = ActiveNonFloatingWindow();
-#endif
+ OSWindowRef wp = [NSApp keyWindow];
if (QWidget *tmp_w = qt_mac_find_window(wp))
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 3d2c9d6..954c6de 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -65,8 +65,10 @@
#include "QtCore/qhash.h"
#include "QtCore/qpointer.h"
#include "private/qcoreapplication_p.h"
-#include "private/qshortcutmap_p.h"
+#include "QtGui/private/qshortcutmap_p.h"
#include <private/qthread_p.h>
+#include "QtCore/qpoint.h"
+#include <QTime>
#ifdef Q_WS_QWS
#include "QtGui/qscreen_qws.h"
#include <private/qgraphicssystem_qws_p.h>
@@ -74,6 +76,11 @@
#ifdef Q_OS_SYMBIAN
#include <w32std.h>
#endif
+#ifdef Q_WS_QPA
+#include <QWindowSystemInterface>
+#include "qwindowsysteminterface_qpa_p.h"
+#include "QtGui/qplatformintegration_qpa.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -291,7 +298,7 @@ class Q_GUI_EXPORT QApplicationPrivate : public QCoreApplicationPrivate
{
Q_DECLARE_PUBLIC(QApplication)
public:
- QApplicationPrivate(int &argc, char **argv, QApplication::Type type);
+ QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags);
~QApplicationPrivate();
#if defined(Q_WS_X11)
@@ -312,10 +319,18 @@ public:
static QString desktopStyleKey();
static QGraphicsSystem *graphicsSystem()
-#if !defined(Q_WS_QWS)
- { return graphics_system; }
-#else
+#if defined(Q_WS_QWS)
{ return QScreen::instance()->graphicsSystem(); }
+#else
+ { return graphics_system; }
+#endif
+
+#if defined(Q_WS_QPA)
+ static QPlatformIntegration *platformIntegration()
+ { return platform_integration; }
+
+ static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
+ { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
#endif
void createEventDispatcher();
@@ -418,6 +433,9 @@ public:
static QGraphicsSystem *graphics_system;
static QString graphics_system_name;
static bool runtime_graphics_system;
+#ifdef Q_WS_QPA
+ static QPlatformIntegration *platform_integration;
+#endif
private:
static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
@@ -471,12 +489,36 @@ 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
+#ifdef Q_WS_QPA
+ static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
+ static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
+ static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
+ static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
+
+ static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
+
+ static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
+
+ static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
+ static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
+
+ static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+
+ static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
+
+// static void reportScreenCount(int count);
+ static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
+// static void reportGeometryChange(int screenIndex);
+ static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
+// static void reportAvailableGeometryChange(int screenIndex);
+ static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
+
+#endif
+
#ifdef Q_WS_QWS
QPointer<QWSManager> last_manager;
QWSServerCleaner qwsServerCleaner;
@@ -492,8 +534,6 @@ public:
static QString styleOverride;
- static int app_compile_version;
-
#ifdef QT_KEYPAD_NAVIGATION
static QWidget *oldEditFocus;
static Qt::NavigationMode navigationMode;
@@ -524,7 +564,7 @@ public:
void _q_aboutToQuit();
#endif
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
void sendSyntheticEnterLeave(QWidget *widget);
#endif
@@ -634,6 +674,8 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
extern void qt_x11_enforce_cursor(QWidget *);
#elif defined(Q_OS_SYMBIAN)
extern void qt_symbian_set_cursor(QWidget *, bool);
+#elif defined (Q_WS_QPA)
+ extern void qt_qpa_set_cursor(QWidget *, bool);
#endif
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
new file mode 100644
index 0000000..cb5439c
--- /dev/null
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -0,0 +1,952 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qapplication_p.h"
+#include "qcolormap.h"
+#include "qpixmapcache.h"
+#if !defined(QT_NO_GLIB)
+#include "qeventdispatcher_glib_qpa_p.h"
+#endif
+#include "qeventdispatcher_qpa_p.h"
+#ifndef QT_NO_CURSOR
+#include "private/qcursor_p.h"
+#endif
+
+#include "private/qwidget_p.h"
+#include "private/qevent_p.h"
+
+#include "qgenericpluginfactory_qpa.h"
+#include "qplatformintegrationfactory_qpa_p.h"
+#include <qdesktopwidget.h>
+
+#include <qinputcontext.h>
+#include <QPlatformCursor>
+#include <qdebug.h>
+#include <QWindowSystemInterface>
+#include "qwindowsysteminterface_qpa_p.h"
+#include <QPlatformIntegration>
+
+#include "qdesktopwidget_qpa_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static QString appName;
+static QString appFont;
+
+QWidget *qt_button_down = 0; // widget got last button-down
+
+static bool app_do_modal = false;
+extern QWidgetList *qt_modal_stack; // stack of modal widgets
+
+int qt_last_x = 0;
+int qt_last_y = 0;
+QPointer<QWidget> qt_last_mouse_receiver = 0;
+
+static Qt::MouseButtons buttons = Qt::NoButton;
+static ulong mousePressTime;
+static Qt::MouseButton mousePressButton = Qt::NoButton;
+static int mousePressX;
+static int mousePressY;
+static int mouse_double_click_distance = 5;
+
+void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+{
+ switch(e->type) {
+ case QWindowSystemInterfacePrivate::Mouse:
+ QApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Wheel:
+ QApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Key:
+ QApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Touch:
+ QApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::GeometryChange:
+ QApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Enter:
+ QApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Leave:
+ QApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ActivatedWindow:
+ QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Close:
+ QApplicationPrivate::processCloseEvent(
+ static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenCountChange:
+ QApplicationPrivate::reportScreenCount(
+ static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenGeometry:
+ QApplicationPrivate::reportGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
+ QApplicationPrivate::reportAvailableGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
+ break;
+ default:
+ qWarning() << "Unknown user input event type:" << e->type;
+ break;
+ }
+}
+
+QString QApplicationPrivate::appName() const
+{
+ return QT_PREPEND_NAMESPACE(appName);
+}
+
+void QApplicationPrivate::createEventDispatcher()
+{
+ Q_Q(QApplication);
+#if !defined(QT_NO_GLIB)
+ if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
+ eventDispatcher = new QPAEventDispatcherGlib(q);
+ else
+#endif
+ eventDispatcher = new QEventDispatcherQPA(q);
+}
+
+static bool qt_try_modal(QWidget *widget, QEvent::Type type)
+{
+ QWidget * top = 0;
+
+ if (QApplicationPrivate::tryModalHelper(widget, &top))
+ return true;
+
+ bool block_event = false;
+ bool paint_event = false;
+
+ switch (type) {
+#if 0
+ case QEvent::Focus:
+ if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
+ break;
+ // drop through
+#endif
+ case QEvent::MouseButtonPress: // disallow mouse/key events
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ block_event = true;
+ break;
+ default:
+ break;
+ }
+
+ if ((block_event || paint_event) && top->parentWidget() == 0)
+ top->raise();
+
+ return !block_event;
+}
+
+
+
+void QApplicationPrivate::enterModal_sys(QWidget *widget)
+{
+ if (!qt_modal_stack)
+ qt_modal_stack = new QWidgetList;
+ qt_modal_stack->insert(0, widget);
+ app_do_modal = true;
+}
+
+void QApplicationPrivate::leaveModal_sys(QWidget *widget )
+{
+ if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
+ if (qt_modal_stack->isEmpty()) {
+ delete qt_modal_stack;
+ qt_modal_stack = 0;
+ }
+ }
+ app_do_modal = qt_modal_stack != 0;
+}
+
+bool QApplicationPrivate::modalState()
+{
+ return app_do_modal;
+}
+
+void QApplicationPrivate::closePopup(QWidget *popup)
+{
+ Q_Q(QApplication);
+ if (!popupWidgets)
+ return;
+ popupWidgets->removeAll(popup);
+
+//###
+// if (popup == qt_popup_down) {
+// qt_button_down = 0;
+// qt_popup_down = 0;
+// }
+
+ if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
+ delete QApplicationPrivate::popupWidgets;
+ QApplicationPrivate::popupWidgets = 0;
+
+ //### replay mouse event?
+
+ //### transfer/release mouse grab
+
+ //### transfer/release keyboard grab
+
+ //give back focus
+
+ if (active_window) {
+ if (QWidget *fw = active_window->focusWidget()) {
+ if (fw != QApplication::focusWidget()) {
+ fw->setFocus(Qt::PopupFocusReason);
+ } else {
+ QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
+ q->sendEvent(fw, &e);
+ }
+ }
+ }
+
+ } else {
+ // A popup was closed, so the previous popup gets the focus.
+
+ QWidget* aw = QApplicationPrivate::popupWidgets->last();
+ if (QWidget *fw = aw->focusWidget())
+ fw->setFocus(Qt::PopupFocusReason);
+
+ //### regrab the keyboard and mouse in case 'popup' lost the grab
+
+
+ }
+
+}
+
+static int openPopupCount = 0;
+void QApplicationPrivate::openPopup(QWidget *popup)
+{
+ openPopupCount++;
+ if (!popupWidgets) { // create list
+ popupWidgets = new QWidgetList;
+
+ /* only grab if you are the first/parent popup */
+ //#### ->grabMouse(popup,true);
+ //#### ->grabKeyboard(popup,true);
+ //### popupGrabOk = true;
+ }
+ popupWidgets->append(popup); // add to end of list
+
+ // popups are not focus-handled by the window system (the first
+ // popup grabbed the keyboard), so we have to do that manually: A
+ // new popup gets the focus
+ if (popup->focusWidget()) {
+ popup->focusWidget()->setFocus(Qt::PopupFocusReason);
+ } else if (popupWidgets->count() == 1) { // this was the first popup
+ if (QWidget *fw = QApplication::focusWidget()) {
+ QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
+ QApplication::sendEvent(fw, &e);
+ }
+ }
+}
+
+void QApplicationPrivate::initializeMultitouch_sys()
+{
+}
+
+void QApplicationPrivate::cleanupMultitouch_sys()
+{
+}
+
+void QApplicationPrivate::initializeWidgetPaletteHash()
+{
+}
+
+void QApplication::setCursorFlashTime(int msecs)
+{
+ QApplicationPrivate::cursor_flash_time = msecs;
+}
+
+int QApplication::cursorFlashTime()
+{
+ return QApplicationPrivate::cursor_flash_time;
+}
+
+void QApplication::setDoubleClickInterval(int ms)
+{
+ QApplicationPrivate::mouse_double_click_time = ms;
+}
+
+int QApplication::doubleClickInterval()
+{
+ return QApplicationPrivate::mouse_double_click_time;
+}
+
+void QApplication::setKeyboardInputInterval(int ms)
+{
+ QApplicationPrivate::keyboard_input_time = ms;
+}
+
+int QApplication::keyboardInputInterval()
+{
+ return QApplicationPrivate::keyboard_input_time;
+}
+
+#ifndef QT_NO_WHEELEVENT
+void QApplication::setWheelScrollLines(int lines)
+{
+ QApplicationPrivate::wheel_scroll_lines = lines;
+}
+
+int QApplication::wheelScrollLines()
+{
+ return QApplicationPrivate::wheel_scroll_lines;
+}
+#endif
+
+void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
+{
+ switch (effect) {
+ case Qt::UI_AnimateMenu:
+ QApplicationPrivate::animate_menu = enable;
+ break;
+ case Qt::UI_FadeMenu:
+ if (enable)
+ QApplicationPrivate::animate_menu = true;
+ QApplicationPrivate::fade_menu = enable;
+ break;
+ case Qt::UI_AnimateCombo:
+ QApplicationPrivate::animate_combo = enable;
+ break;
+ case Qt::UI_AnimateTooltip:
+ QApplicationPrivate::animate_tooltip = enable;
+ break;
+ case Qt::UI_FadeTooltip:
+ if (enable)
+ QApplicationPrivate::animate_tooltip = true;
+ QApplicationPrivate::fade_tooltip = enable;
+ break;
+ case Qt::UI_AnimateToolBox:
+ QApplicationPrivate::animate_toolbox = enable;
+ break;
+ default:
+ QApplicationPrivate::animate_ui = enable;
+ break;
+ }
+}
+
+bool QApplication::isEffectEnabled(Qt::UIEffect effect)
+{
+ if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui)
+ return false;
+
+ switch(effect) {
+ case Qt::UI_AnimateMenu:
+ return QApplicationPrivate::animate_menu;
+ case Qt::UI_FadeMenu:
+ return QApplicationPrivate::fade_menu;
+ case Qt::UI_AnimateCombo:
+ return QApplicationPrivate::animate_combo;
+ case Qt::UI_AnimateTooltip:
+ return QApplicationPrivate::animate_tooltip;
+ case Qt::UI_FadeTooltip:
+ return QApplicationPrivate::fade_tooltip;
+ case Qt::UI_AnimateToolBox:
+ return QApplicationPrivate::animate_toolbox;
+ default:
+ return QApplicationPrivate::animate_ui;
+ }
+}
+
+#ifndef QT_NO_CURSOR
+void QApplication::setOverrideCursor(const QCursor &cursor)
+{
+ qApp->d_func()->cursor_list.prepend(cursor);
+ qt_qpa_set_cursor(0, false);
+}
+
+void QApplication::restoreOverrideCursor()
+{
+ if (qApp->d_func()->cursor_list.isEmpty())
+ return;
+ qApp->d_func()->cursor_list.removeFirst();
+ qt_qpa_set_cursor(0, false);
+}
+
+#endif// QT_NO_CURSOR
+
+QWidget *QApplication::topLevelAt(const QPoint &pos)
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+
+ QList<QPlatformScreen *> screens = pi->screens();
+ QList<QPlatformScreen *>::const_iterator screen = screens.constBegin();
+ QList<QPlatformScreen *>::const_iterator end = screens.constEnd();
+
+ // The first screen in a virtual environment should know about all top levels
+ if (pi->isVirtualDesktop()) {
+ QWidget *w = (*screen)->topLevelAt(pos);
+ return w;
+ }
+
+ while (screen != end) {
+ if ((*screen)->geometry().contains(pos))
+ return (*screen)->topLevelAt(pos);
+ ++screen;
+ }
+ return 0;
+}
+
+void QApplication::beep()
+{
+}
+
+void QApplication::alert(QWidget *, int)
+{
+}
+
+static void init_platform(const QString &name, const QString &platformPluginPath)
+{
+ QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
+ if (!QApplicationPrivate::platform_integration) {
+ QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
+ QString fatalMessage =
+ QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
+ foreach(QString key, keys) {
+ fatalMessage.append(key + QString::fromLatin1("\n"));
+ }
+ qFatal("%s", fatalMessage.toLocal8Bit().constData());
+
+ }
+
+}
+
+
+static void cleanup_platform()
+{
+ delete QApplicationPrivate::platform_integration;
+ QApplicationPrivate::platform_integration = 0;
+}
+
+static void init_plugins(const QList<QByteArray> pluginList)
+{
+ for (int i = 0; i < pluginList.count(); ++i) {
+ QByteArray pluginSpec = pluginList.at(i);
+ qDebug() << "init_plugins" << i << pluginSpec;
+ int colonPos = pluginSpec.indexOf(':');
+ QObject *plugin;
+ if (colonPos < 0)
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
+ else
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
+ QLatin1String(pluginSpec.mid(colonPos+1)));
+ qDebug() << " created" << plugin;
+ }
+}
+
+#ifndef QT_NO_QWS_INPUTMETHODS
+class QDummyInputContext : public QInputContext
+{
+public:
+ explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {}
+ ~QDummyInputContext() {}
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+ bool isComposing() const { return false; }
+
+};
+#endif // QT_NO_QWS_INPUTMETHODS
+
+void qt_init(QApplicationPrivate *priv, int type)
+{
+ Q_UNUSED(type);
+
+ qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
+ char *p;
+ char **argv = priv->argv;
+ int argc = priv->argc;
+
+ if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
+ p = strrchr(argv[0], '/');
+ appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
+ }
+
+ QList<QByteArray> pluginList;
+ QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
+ QString platformName = QLatin1String(qgetenv("QT_QPA_PLATFORM"));
+
+ // Get command line params
+
+ int j = argc ? 1 : 0;
+ for (int i=1; i<argc; i++) {
+ if (argv[i] && *argv[i] != '-') {
+ argv[j++] = argv[i];
+ continue;
+ }
+ QByteArray arg = argv[i];
+ if (arg == "-fn" || arg == "-font") {
+ if (++i < argc)
+ appFont = QString::fromLocal8Bit(argv[i]);
+ } else if (arg == "-platformpluginpath") {
+ if (++i < argc)
+ platformPluginPath = QLatin1String(argv[i]);
+ } else if (arg == "-platform") {
+ if (++i < argc)
+ platformName = QLatin1String(argv[i]);
+ } else if (arg == "-plugin") {
+ if (++i < argc)
+ pluginList << argv[i];
+ } else {
+ argv[j++] = argv[i];
+ }
+ }
+
+ if (j < priv->argc) {
+ priv->argv[j] = 0;
+ priv->argc = j;
+ }
+
+#if 0
+ QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
+ if (!pluginEnv.isEmpty()) {
+ pluginList.append(pluginEnv.split(';'));
+ }
+#endif
+
+ init_platform(platformName, platformPluginPath);
+ init_plugins(pluginList);
+
+ QColormap::initialize();
+ QFont::initialize();
+#ifndef QT_NO_CURSOR
+// QCursorData::initialize();
+#endif
+
+ qApp->setObjectName(appName);
+
+#ifndef QT_NO_QWS_INPUTMETHODS
+ qApp->setInputContext(new QDummyInputContext(qApp));
+#endif
+}
+
+void qt_cleanup()
+{
+ cleanup_platform();
+
+ QPixmapCache::clear();
+#ifndef QT_NO_CURSOR
+ QCursorData::cleanup();
+#endif
+ QFont::cleanup();
+ QColormap::cleanup();
+ delete QApplicationPrivate::inputContext;
+ QApplicationPrivate::inputContext = 0;
+
+ QApplicationPrivate::active_window = 0; //### this should not be necessary
+}
+
+
+#ifdef QT3_SUPPORT
+void QApplication::setMainWidget(QWidget *mainWidget)
+{
+ QApplicationPrivate::main_widget = mainWidget;
+ if (QApplicationPrivate::main_widget && windowIcon().isNull()
+ && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon))
+ setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
+}
+#endif
+
+void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
+{
+ // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons();
+ static QWeakPointer<QWidget> implicit_mouse_grabber;
+
+ QEvent::Type type;
+ // move first
+ Qt::MouseButtons stateChange = e->buttons ^ buttons;
+ if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
+ QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
+ new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
+ stateChange = Qt::NoButton;
+ }
+
+ QWidget * tlw = e->widget.data();
+
+ QPoint localPoint = e->localPos;
+ QPoint globalPoint = e->globalPos;
+ QWidget *mouseWindow = tlw;
+
+ Qt::MouseButton button = Qt::NoButton;
+
+
+ if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
+ type = QEvent::MouseMove;
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+ if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
+ qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
+ mousePressButton = Qt::NoButton;
+ }
+ else { // check to see if a new button has been pressed/released
+ for (int check = Qt::LeftButton;
+ check <= Qt::XButton2;
+ check = check << 1) {
+ if (check & stateChange) {
+ button = Qt::MouseButton(check);
+ break;
+ }
+ }
+ if (button == Qt::NoButton) {
+ // Ignore mouse events that don't change the current state
+ return;
+ }
+ buttons = e->buttons;
+ if (button & e->buttons) {
+ if ((e->timestamp - mousePressTime) < static_cast<ulong>(QApplication::doubleClickInterval()) && button == mousePressButton) {
+ type = QEvent::MouseButtonDblClick;
+ mousePressButton = Qt::NoButton;
+ }
+ else {
+ type = QEvent::MouseButtonPress;
+ mousePressTime = e->timestamp;
+ mousePressButton = button;
+ mousePressX = qt_last_x;
+ mousePressY = qt_last_y;
+ }
+ }
+ else
+ type = QEvent::MouseButtonRelease;
+ }
+
+ if (self->inPopupMode()) {
+ //popup mouse handling is magical...
+ mouseWindow = qApp->activePopupWidget();
+
+ implicit_mouse_grabber.clear();
+ //### how should popup mode and implicit mouse grab interact?
+
+ } else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) {
+ //even if we're blocked by modality, we should deliver the mouse release event..
+ //### this code is not completely correct: multiple buttons can be pressed simultaneously
+ if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
+ //qDebug() << "modal blocked mouse event to" << tlw;
+ return;
+ }
+ }
+
+ // find the tlw if we didn't get it from the plugin
+ if (!mouseWindow) {
+ mouseWindow = QApplication::topLevelAt(globalPoint);
+ }
+
+ if (!mouseWindow && !implicit_mouse_grabber)
+ mouseWindow = QApplication::desktop();
+
+ if (mouseWindow && mouseWindow != tlw) {
+ //we did not get a sensible localPoint from the window system, so let's calculate it
+ localPoint = mouseWindow->mapFromGlobal(globalPoint);
+ }
+
+ // which child should have it?
+ QWidget *mouseWidget = mouseWindow;
+ if (mouseWindow) {
+ QWidget *w = mouseWindow->childAt(localPoint);
+ if (w) {
+ mouseWidget = w;
+ }
+ }
+
+ //handle implicit mouse grab
+ if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) {
+ implicit_mouse_grabber = mouseWidget;
+
+ Q_ASSERT(mouseWindow);
+ mouseWindow->activateWindow(); //focus
+ } else if (implicit_mouse_grabber) {
+ mouseWidget = implicit_mouse_grabber.data();
+ mouseWindow = mouseWidget->window();
+ if (mouseWindow != tlw)
+ localPoint = mouseWindow->mapFromGlobal(globalPoint);
+ }
+
+ Q_ASSERT(mouseWidget);
+
+ //localPoint is local to mouseWindow, but it needs to be local to mouseWidget
+ localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
+
+ if (buttons == Qt::NoButton) {
+ //qDebug() << "resetting mouse grabber";
+ implicit_mouse_grabber.clear();
+ }
+
+ if (mouseWidget != qt_last_mouse_receiver) {
+ dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = mouseWidget;
+ }
+
+ // Remember, we might enter a modal event loop when sending the event,
+ // so think carefully before adding code below this point.
+
+ // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
+
+ QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QApplication::keyboardModifiers());
+
+ QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
+ foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
+ if (cursor)
+ cursor.data()->pointerEvent(ev);
+ }
+
+ int oldOpenPopupCount = openPopupCount;
+ QApplication::sendSpontaneousEvent(mouseWidget, &ev);
+
+#ifndef QT_NO_CONTEXTMENU
+ if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
+ QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QApplication::keyboardModifiers());
+ QApplication::sendSpontaneousEvent(mouseWidget, &e);
+ }
+#endif // QT_NO_CONTEXTMENU
+}
+
+
+//### there's a lot of duplicated logic here -- refactoring required!
+
+void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
+{
+// QPoint localPoint = ev.pos();
+ QPoint globalPoint = e->globalPos;
+// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
+ QWidget *mouseWidget;
+
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+
+ QWidget *mouseWindow = e->widget.data();
+
+ // find the tlw if we didn't get it from the plugin
+ if (!mouseWindow) {
+ mouseWindow = QApplication::topLevelAt(globalPoint);
+ }
+
+ if (!mouseWindow)
+ return;
+
+ mouseWidget = mouseWindow;
+
+ if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
+ qDebug() << "modal blocked wheel event" << mouseWindow;
+ return;
+ }
+ QPoint p = mouseWindow->mapFromGlobal(globalPoint);
+ QWidget *w = mouseWindow->childAt(p);
+ if (w) {
+ mouseWidget = w;
+ p = mouseWidget->mapFromGlobal(globalPoint);
+ }
+
+ QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
+ e->orient);
+ QApplication::sendSpontaneousEvent(mouseWidget, &ev);
+}
+
+
+
+// Remember, Qt convention is: keyboard state is state *before*
+
+void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
+{
+ QWidget *focusW = 0;
+ if (self->inPopupMode()) {
+ QWidget *popupW = qApp->activePopupWidget();
+ focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
+ }
+ if (!focusW)
+ focusW = QApplication::focusWidget();
+ if (!focusW) {
+ focusW = e->widget.data();
+ }
+ if (!focusW)
+ focusW = QApplication::activeWindow();
+
+ //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
+
+ if (!focusW)
+ return;
+ if (app_do_modal && !qt_try_modal(focusW, e->keyType))
+ return;
+
+ if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
+ QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
+ e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
+ QApplication::sendSpontaneousEvent(focusW, &ev);
+ } else {
+ QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
+ QApplication::sendSpontaneousEvent(focusW, &ev);
+ }
+}
+
+void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
+{
+ QApplicationPrivate::dispatchEnterLeave(e->enter.data(),0);
+ qt_last_mouse_receiver = e->enter.data();
+}
+
+void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
+{
+ QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver);
+
+ if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
+ QApplicationPrivate::dispatchEnterLeave(0, e->leave.data());
+ qt_last_mouse_receiver = 0;
+
+}
+
+void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
+{
+ QApplication::setActiveWindow(e->activated.data());
+}
+
+void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
+{
+ if (e->tlw.isNull())
+ return;
+ QWidget *tlw = e->tlw.data();
+ if (!tlw->isWindow())
+ return; //geo of native child widgets is controlled by lighthouse
+ //so we already have sent the events; besides this new rect
+ //is not mapped to parent
+
+ QRect newRect = e->newGeometry;
+ QRect cr(tlw->geometry());
+ bool isResize = cr.size() != newRect.size();
+ bool isMove = cr.topLeft() != newRect.topLeft();
+ tlw->data->crect = newRect;
+ if (isResize) {
+ QResizeEvent e(tlw->data->crect.size(), cr.size());
+ QApplication::sendSpontaneousEvent(tlw, &e);
+ tlw->update();
+ }
+
+ if (isMove) {
+ //### frame geometry
+ QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
+ QApplication::sendSpontaneousEvent(tlw, &e);
+ }
+}
+
+void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
+{
+ if (e->topLevel.isNull()) {
+ //qDebug() << "QApplicationPrivate::processCloseEvent NULL";
+ return;
+ }
+ e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
+}
+
+void QApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
+{
+ translateRawTouchEvent(e->widget.data(), e->devType, e->points);
+}
+
+void QApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e)
+{
+ // This operation only makes sense after the QApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+
+ QApplication::desktop()->d_func()->updateScreenList();
+ // signal anything listening for creation or deletion of screens
+ QDesktopWidget *desktop = QApplication::desktop();
+ emit desktop->screenCountChanged(e->count);
+}
+
+void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
+{
+ // This operation only makes sense after the QApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+
+ QApplication::desktop()->d_func()->updateScreenList();
+
+ // signal anything listening for screen geometry changes
+ QDesktopWidget *desktop = QApplication::desktop();
+ emit desktop->resized(e->index);
+
+ // make sure maximized and fullscreen windows are updated
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = list.size() - 1; i >= 0; --i) {
+ QWidget *w = list.at(i);
+ if (w->isFullScreen())
+ w->d_func()->setFullScreenSize_helper();
+ else if (w->isMaximized())
+ w->d_func()->setMaxWindowState_helper();
+ }
+}
+
+void QApplicationPrivate::reportAvailableGeometryChange(
+ QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e)
+{
+ // This operation only makes sense after the QApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+
+ QApplication::desktop()->d_func()->updateScreenList();
+
+ // signal anything listening for screen geometry changes
+ QDesktopWidget *desktop = QApplication::desktop();
+ emit desktop->workAreaResized(e->index);
+
+ // make sure maximized and fullscreen windows are updated
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = list.size() - 1; i >= 0; --i) {
+ QWidget *w = list.at(i);
+ if (w->isFullScreen())
+ w->d_func()->setFullScreenSize_helper();
+ else if (w->isMaximized())
+ w->d_func()->setMaxWindowState_helper();
+ }
+}
+
+QT_END_NAMESPACE
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 0427ae4..769b136 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -1528,7 +1528,7 @@ void QSymbianControl::ensureFixNativeOrientation()
This function is only available on S60.
*/
QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
{
Q_D(QApplication);
S60->s60ApplicationFactory = factory;
@@ -1536,7 +1536,7 @@ QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int
}
QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient))
+ : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
{
Q_D(QApplication);
S60->s60ApplicationFactory = factory;
@@ -1672,6 +1672,8 @@ void qt_init(QApplicationPrivate * /* priv */, int)
repository = 0;
#endif
+ qt_keymapper_private()->updateInputLanguage();
+
#ifdef QT_KEYPAD_NAVIGATION
if (touch) {
QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
@@ -1769,13 +1771,18 @@ void qt_init(QApplicationPrivate * /* priv */, int)
qRegisterMetaType<WId>("WId");
}
+#ifdef QT_NO_FREETYPE
extern void qt_cleanup_symbianFontDatabase(); // qfontdatabase_s60.cpp
+#endif
/*****************************************************************************
qt_cleanup() - cleans up when the application is finished
*****************************************************************************/
void qt_cleanup()
{
+#ifdef Q_WS_S60
+ S60->setButtonGroupContainer(0);
+#endif
if(qt_S60Beep) {
delete qt_S60Beep;
qt_S60Beep = 0;
@@ -1783,7 +1790,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
+#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
@@ -2241,6 +2250,13 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent
}
break;
#endif
+
+#ifdef Q_WS_S60
+ case KEikInputLanguageChange:
+ qt_keymapper_private()->updateInputLanguage();
+ break;
+#endif
+
default:
break;
}
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 6e89ceb..5f5da59 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -115,12 +115,25 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
# if defined(Q_WS_WINCE)
# include <bldver.h>
# endif
-# include <winable.h>
+# if !defined(Q_WS_WINCE)
+# include <winable.h>
+# endif
+#endif
+
+#ifndef QT_NO_GESTURES
+# ifndef GID_ZOOM
+# define GID_ZOOM 3
+# define GID_TWOFINGERTAP 6
+# define GID_PRESSANDTAP 7
+# define GID_ROLLOVER GID_PRESSANDTAP
+# endif
#endif
#ifndef WM_TOUCH
# define WM_TOUCH 0x0240
+#endif
+#ifndef TOUCHEVENTF_MOVE
# define TOUCHEVENTF_MOVE 0x0001
# define TOUCHEVENTF_DOWN 0x0002
# define TOUCHEVENTF_UP 0x0004
@@ -207,8 +220,6 @@ static void resolveAygLibs()
if (!aygResolved) {
aygResolved = true;
QSystemLibrary ayglib(QLatin1String("aygshell"));
- if (!ayglib.load())
- return;
ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture");
}
}
@@ -944,29 +955,36 @@ bool qt_nograb() // application no-grab option
typedef QHash<QString, int> WinClassNameHash;
Q_GLOBAL_STATIC(WinClassNameHash, winclassNames)
+//
+// If 0 is passed as the widget pointer, register a window class
+// for QWidget as default. This is used in QGLTemporaryContext
+// during GL initialization, where we don't want to use temporary
+// QWidgets or QGLWidgets, neither do we want to have separate code
+// to register window classes.
+//
const QString qt_reg_winclass(QWidget *w) // register window class
{
- int flags = w->windowFlags();
- int type = flags & Qt::WindowType_Mask;
+ Qt::WindowFlags flags = w ? w->windowFlags() : (Qt::WindowFlags)0;
+ Qt::WindowFlags type = flags & Qt::WindowType_Mask;
uint style;
bool icon;
QString cname;
- if (qt_widget_private(w)->isGLWidget) {
+ if (w && qt_widget_private(w)->isGLWidget) {
cname = QLatin1String("QGLWidget");
style = CS_DBLCLKS;
#ifndef Q_WS_WINCE
style |= CS_OWNDC;
#endif
icon = true;
- } else if (flags & Qt::MSWindowsOwnDC) {
+ } else if (w && (flags & Qt::MSWindowsOwnDC)) {
cname = QLatin1String("QWidgetOwnDC");
style = CS_DBLCLKS;
#ifndef Q_WS_WINCE
style |= CS_OWNDC;
#endif
icon = true;
- } else if (type == Qt::Tool || type == Qt::ToolTip){
+ } else if (w && (type == Qt::Tool || type == Qt::ToolTip)) {
style = CS_DBLCLKS;
if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) {
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
@@ -981,7 +999,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
style |= CS_SAVEBITS;
#endif
icon = false;
- } else if (type == Qt::Popup) {
+ } else if (w && (type == Qt::Popup)) {
cname = QLatin1String("QPopup");
style = CS_DBLCLKS;
#ifndef Q_WS_WINCE
@@ -1035,7 +1053,12 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (winclassNames()->contains(cname)) // already registered in our list
return cname;
+#ifndef Q_WS_WINCE
+ WNDCLASSEX wc;
+ wc.cbSize = sizeof(WNDCLASSEX);
+#else
WNDCLASS wc;
+#endif
wc.style = style;
wc.lpfnWndProc = (WNDPROC)QtWndProc;
wc.cbClsExtra = 0;
@@ -1044,22 +1067,38 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (icon) {
wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
#ifndef Q_WS_WINCE
- if (!wc.hIcon)
+ if (wc.hIcon) {
+ int sw = GetSystemMetrics(SM_CXSMICON);
+ int sh = GetSystemMetrics(SM_CYSMICON);
+ wc.hIconSm = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, sw, sh, 0);
+ } else {
wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+ wc.hIconSm = 0;
+ }
#endif
} else {
wc.hIcon = 0;
+#ifndef Q_WS_WINCE
+ wc.hIconSm = 0;
+#endif
}
wc.hCursor = 0;
#ifndef Q_WS_WINCE
- wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
+ HBRUSH brush = 0;
+ if (w && !qt_widget_private(w)->isGLWidget)
+ brush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
+ wc.hbrBackground = brush;
#else
wc.hbrBackground = 0;
#endif
wc.lpszMenuName = 0;
wc.lpszClassName = (wchar_t*)cname.utf16();
+#ifndef Q_WS_WINCE
+ ATOM atom = RegisterClassEx(&wc);
+#else
ATOM atom = RegisterClass(&wc);
+#endif
#ifndef QT_NO_DEBUG
if (!atom)
@@ -1074,8 +1113,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
Q_GUI_EXPORT const QString qt_getRegisteredWndClass()
{
- QWidget w;
- return qt_reg_winclass(&w);
+ return qt_reg_winclass(0);
}
static void unregWinClasses()
@@ -2324,7 +2362,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
case WM_GETOBJECT:
{
// Ignoring all requests while starting up
- if (QApplication::startingUp() || QApplication::closingDown() || (LONG)lParam != OBJID_CLIENT) {
+ if (QApplication::startingUp() || QApplication::closingDown() || lParam != (LPARAM)OBJID_CLIENT) {
result = false;
break;
}
@@ -3676,13 +3714,11 @@ static void initWinTabFunctions()
return;
QSystemLibrary library(QLatin1String("wintab32"));
- if (library.load()) {
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
- ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
- ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable");
- ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap");
- ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet");
- }
+ ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
+ ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
+ ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable");
+ ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap");
+ ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet");
#endif // Q_OS_WINCE
}
#endif // QT_NO_TABLETEVENT
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index e0447cc..31f70c7 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -483,11 +483,9 @@ static void* qt_load_library_runtime(const char *library, int vernum,
Q_FOREACH(int version, versions) {
QLatin1String libName(library);
QLibrary xfixesLib(libName, version);
- if (xfixesLib.load()) {
- void *ptr = xfixesLib.resolve(symbol);
- if (ptr)
- return ptr;
- }
+ void *ptr = xfixesLib.resolve(symbol);
+ if (ptr)
+ return ptr;
}
return 0;
}
@@ -1589,6 +1587,9 @@ static void getXDefault(const char *group, const char *key, int *val)
int v = strtol(str, &end, 0);
if (str != end)
*val = v;
+ // otherwise use fontconfig to convert the string to integer
+ else
+ FcNameConstant((FcChar8 *) str, val);
}
}
@@ -1739,6 +1740,9 @@ void qt_init(QApplicationPrivate *priv, int,
} else {
// Qt controls everything (default)
+ if (QApplication::testAttribute(Qt::AA_X11InitThreads))
+ XInitThreads();
+
// Set application name and class
char *app_class = 0;
if (argv && argv[0]) {
@@ -2014,12 +2018,15 @@ void qt_init(QApplicationPrivate *priv, int,
(PtrXRRRootToScreen) xrandrLib.resolve("XRRRootToScreen");
X11->ptrXRRQueryExtension =
(PtrXRRQueryExtension) xrandrLib.resolve("XRRQueryExtension");
+ X11->ptrXRRSizes =
+ (PtrXRRSizes) xrandrLib.resolve("XRRSizes");
}
# else
X11->ptrXRRSelectInput = XRRSelectInput;
X11->ptrXRRUpdateConfiguration = XRRUpdateConfiguration;
X11->ptrXRRRootToScreen = XRRRootToScreen;
X11->ptrXRRQueryExtension = XRRQueryExtension;
+ X11->ptrXRRSizes = XRRSizes;
# endif
if (X11->ptrXRRQueryExtension
@@ -2233,6 +2240,7 @@ void qt_init(QApplicationPrivate *priv, int,
}
getXDefault("Xft", FC_ANTIALIAS, &X11->fc_antialias);
#ifdef FC_HINT_STYLE
+ X11->fc_hint_style = -1;
getXDefault("Xft", FC_HINT_STYLE, &X11->fc_hint_style);
#endif
#if 0
@@ -2608,22 +2616,20 @@ void qt_init(QApplicationPrivate *priv, int,
#if !defined (Q_OS_IRIX) && !defined (QT_NO_TABLET)
QLibrary wacom(QString::fromLatin1("wacomcfg"), 0); // version 0 is the latest release at time of writing this.
- if (wacom.load()) {
- // NOTE: C casts instead of reinterpret_cast for GCC 3.3.x
- ptrWacomConfigInit = (PtrWacomConfigInit)wacom.resolve("WacomConfigInit");
- ptrWacomConfigOpenDevice = (PtrWacomConfigOpenDevice)wacom.resolve("WacomConfigOpenDevice");
- ptrWacomConfigGetRawParam = (PtrWacomConfigGetRawParam)wacom.resolve("WacomConfigGetRawParam");
- ptrWacomConfigCloseDevice = (PtrWacomConfigCloseDevice)wacom.resolve("WacomConfigCloseDevice");
- ptrWacomConfigTerm = (PtrWacomConfigTerm)wacom.resolve("WacomConfigTerm");
-
- if (ptrWacomConfigInit == 0 || ptrWacomConfigOpenDevice == 0 || ptrWacomConfigGetRawParam == 0
- || ptrWacomConfigCloseDevice == 0 || ptrWacomConfigTerm == 0) { // either we have all, or we have none.
+ // NOTE: C casts instead of reinterpret_cast for GCC 3.3.x
+ ptrWacomConfigInit = (PtrWacomConfigInit)wacom.resolve("WacomConfigInit");
+ ptrWacomConfigOpenDevice = (PtrWacomConfigOpenDevice)wacom.resolve("WacomConfigOpenDevice");
+ ptrWacomConfigGetRawParam = (PtrWacomConfigGetRawParam)wacom.resolve("WacomConfigGetRawParam");
+ ptrWacomConfigCloseDevice = (PtrWacomConfigCloseDevice)wacom.resolve("WacomConfigCloseDevice");
+ ptrWacomConfigTerm = (PtrWacomConfigTerm)wacom.resolve("WacomConfigTerm");
+
+ if (ptrWacomConfigInit == 0 || ptrWacomConfigOpenDevice == 0 || ptrWacomConfigGetRawParam == 0
+ || ptrWacomConfigCloseDevice == 0 || ptrWacomConfigTerm == 0) { // either we have all, or we have none.
ptrWacomConfigInit = 0;
ptrWacomConfigOpenDevice = 0;
ptrWacomConfigGetRawParam = 0;
ptrWacomConfigCloseDevice = 0;
ptrWacomConfigTerm = 0;
- }
}
#endif
}
@@ -5225,14 +5231,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();
@@ -5258,6 +5265,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
@@ -5270,6 +5278,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();
@@ -5312,18 +5333,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();
@@ -5332,7 +5341,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);
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index bae43fa..ba7ad0c 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -631,7 +631,7 @@ QByteArray QMimeDataWrapper::encodedData(const char *format) const
return data->data(QLatin1String(format));
} else{
QVariant variant = data->imageData();
- QImage img = qVariantValue<QImage>(variant);
+ QImage img = qvariant_cast<QImage>(variant);
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
new file mode 100644
index 0000000..b8ce60e
--- /dev/null
+++ b/src/gui/kernel/qclipboard_qpa.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qclipboard.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qmimedata.h"
+#include "private/qapplication_p.h"
+#include "qplatformclipboard_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+void QClipboard::clear(Mode mode)
+{
+ setMimeData(0,mode);
+}
+
+
+bool QClipboard::event(QEvent *e)
+{
+ return QObject::event(e);
+}
+
+const QMimeData* QClipboard::mimeData(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return 0;
+ return clipboard->mimeData(mode);
+}
+
+void QClipboard::setMimeData(QMimeData* src, Mode mode)
+{
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return;
+
+ clipboard->setMimeData(src,mode);
+
+ emitChanged(mode);
+}
+
+bool QClipboard::supportsMode(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ return clipboard->supportsMode(mode);
+}
+
+bool QClipboard::ownsMode(Mode mode) const
+{
+ if (mode == Clipboard)
+ qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!");
+ return false;
+}
+
+void QClipboard::connectNotify( const char * )
+{
+}
+
+void QClipboard::ownerDestroyed()
+{
+}
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index 478bc96..872f31d 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -78,6 +78,7 @@
#include <private/qcocoaapplication_mac_p.h>
#include <private/qcocoaapplicationdelegate_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qcocoaintrospection_p.h>
QT_USE_NAMESPACE
@@ -116,12 +117,30 @@ QT_USE_NAMESPACE
quint64 lower = [event data1];
quint64 upper = [event data2];
QCocoaPostMessageArgs *args = reinterpret_cast<QCocoaPostMessageArgs *>(lower | (upper << 32));
- [args->target performSelector:args->selector];
+ // Special case for convenience: if the argument is an NSNumber, we unbox it directly.
+ // Use NSValue instead if this behaviour is unwanted.
+ id a1 = ([args->arg1 isKindOfClass:[NSNumber class]]) ? (id)[args->arg1 intValue] : args->arg1;
+ id a2 = ([args->arg2 isKindOfClass:[NSNumber class]]) ? (id)[args->arg2 intValue] : args->arg2;
+ switch (args->argCount) {
+ case 0:
+ [args->target performSelector:args->selector];
+ break;
+ case 1:
+ [args->target performSelector:args->selector withObject:a1];
+ break;
+ case 3:
+ [args->target performSelector:args->selector withObject:a1 withObject:a2];
+ break;
+ }
+
delete args;
}
-- (BOOL)qt_sendEvent:(NSEvent *)event
+- (BOOL)qt_filterEvent:(NSEvent *)event
{
+ if (qApp->macEventFilter(0, reinterpret_cast<EventRef>(event)))
+ return true;
+
if ([event type] == NSApplicationDefined) {
switch ([event subtype]) {
case QtCocoaEventSubTypePostMessage:
@@ -138,20 +157,66 @@ QT_USE_NAMESPACE
@implementation QNSApplication
-// WARNING: If Qt did not create NSApplication (this can e.g.
-// happend if Qt is used as a plugin from a 3rd-party cocoa
-// application), QNSApplication::sendEvent will never be called.
-// SO DO NOT RELY ON THIS FUNCTION BEING AVAILABLE.
-// Plugin developers that _do_ control the NSApplication sub-class
-// implementation of the 3rd-party application can call qt_sendEvent
-// from the sub-class event handler (like we do here) to work around
-// any issues.
+- (void)qt_sendEvent_original:(NSEvent *)event
+{
+ Q_UNUSED(event);
+ // This method will only be used as a signature
+ // template for the method we add into NSApplication
+ // containing the original [NSApplication sendEvent:] implementation
+}
+
+- (void)qt_sendEvent_replacement:(NSEvent *)event
+{
+ // This method (or its implementation to be precise) will
+ // be called instead of sendEvent if redirection occurs.
+ // 'self' will then be an instance of NSApplication
+ // (and not QNSApplication)
+ if (![NSApp qt_filterEvent:event])
+ [self qt_sendEvent_original:event];
+}
+
- (void)sendEvent:(NSEvent *)event
{
- if (![self qt_sendEvent:event])
+ // This method will be called if
+ // no redirection occurs
+ if (![NSApp qt_filterEvent:event])
[super sendEvent:event];
}
+- (void)qtDispatcherToQAction:(id)sender
+{
+ // Forward actions sendt from the menu bar (e.g. quit) to the menu loader.
+ // Having this method here means that we are the last stop in the responder
+ // chain, and that we are able to handle menu actions even when no window is
+ // visible on screen. Note: If Qt is used as a plugin, Qt will not use a
+ // native menu bar. Hence, we will also not need to do any redirection etc. as
+ // we do with sendEvent.
+ [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
+}
+
@end
+QT_BEGIN_NAMESPACE
+
+void qt_redirectNSApplicationSendEvent()
+{
+ if ([NSApp isMemberOfClass:[QNSApplication class]]) {
+ // No need to change implementation since Qt
+ // already controls a subclass of NSApplication
+ return;
+ }
+
+ // Change the implementation of [NSApplication sendEvent] to the
+ // implementation of qt_sendEvent_replacement found in QNSApplication.
+ // And keep the old implementation that gets overwritten inside a new
+ // method 'qt_sendEvent_original' that we add to NSApplication
+ qt_cocoa_change_implementation(
+ [NSApplication class],
+ @selector(sendEvent:),
+ [QNSApplication class],
+ @selector(qt_sendEvent_replacement:),
+ @selector(qt_sendEvent_original:));
+ }
+
+QT_END_NAMESPACE
#endif
diff --git a/src/gui/kernel/qcocoaapplication_mac_p.h b/src/gui/kernel/qcocoaapplication_mac_p.h
index 230e780..0c3f5e4 100644
--- a/src/gui/kernel/qcocoaapplication_mac_p.h
+++ b/src/gui/kernel/qcocoaapplication_mac_p.h
@@ -101,11 +101,17 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate)
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
- (void)qt_sendPostedMessage:(NSEvent *)event;
-- (BOOL)qt_sendEvent:(NSEvent *)event;
+- (BOOL)qt_filterEvent:(NSEvent *)event;
@end
@interface QNSApplication : NSApplication {
}
@end
+QT_BEGIN_NAMESPACE
+
+void qt_redirectNSApplicationSendEvent();
+
+QT_END_NAMESPACE
+
#endif
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index a520e27..77cd890 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -78,6 +78,7 @@
#import <private/qcocoaapplicationdelegate_mac_p.h>
#import <private/qcocoamenuloader_mac_p.h>
+#import <private/qcocoaapplication_mac_p.h>
#include <private/qapplication_p.h>
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
@@ -89,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)
@@ -173,7 +178,7 @@ static void cleanupCocoaApplicationDelegate()
qtMenuLoader = menuLoader;
}
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
+- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader
{
return [[qtMenuLoader retain] autorelease];
}
@@ -253,15 +258,35 @@ 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;
+- (void)applicationDidResignActive:(NSNotification *)notification
{
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/qcocoaintrospection_mac.mm b/src/gui/kernel/qcocoaintrospection_mac.mm
new file mode 100644
index 0000000..70c893a
--- /dev/null
+++ b/src/gui/kernel/qcocoaintrospection_mac.mm
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (c) 2007-2008, Apple, Inc.
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are met:
+**
+** * Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** * 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.
+**
+** * Neither the name of Apple, Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR
+** 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 <private/qcocoaintrospection_p.h>
+
+QT_BEGIN_NAMESPACE
+
+void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
+{
+#ifndef QT_MAC_USE_COCOA
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
+#endif
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ // The following code replaces the _implementation_ for the selector we want to hack
+ // (originalSel) with the implementation found in proxyClass. Then it creates
+ // a new 'backup' method inside baseClass containing the old, original,
+ // implementation (fakeSel). You can let the proxy implementation of originalSel
+ // call fakeSel if needed (similar approach to calling a super class implementation).
+ // fakeSel must also be implemented in proxyClass, as the signature is used
+ // as template for the method one we add into baseClass.
+ // NB: You will typically never create any instances of proxyClass; we use it
+ // only for stealing its contents and put it into baseClass.
+ if (!replacementSel)
+ replacementSel = originalSel;
+
+ Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
+ Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
+ IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
+
+ if (backupSel) {
+ Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
+ class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
+ }
+#endif
+ }
+}
+
+void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
+{
+#ifndef QT_MAC_USE_COCOA
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
+#endif
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
+ Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
+ method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
+#endif
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoaintrospection_p.h b/src/gui/kernel/qcocoaintrospection_p.h
new file mode 100644
index 0000000..1c7d6ac
--- /dev/null
+++ b/src/gui/kernel/qcocoaintrospection_p.h
@@ -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 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$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Copyright (c) 2007-2008, Apple, Inc.
+**
+** All rights reserved.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are met:
+**
+** * Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** * 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.
+**
+** * Neither the name of Apple, Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT OWNER OR
+** 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 <qglobal.h>
+#import <objc/objc-class.h>
+
+QT_BEGIN_NAMESPACE
+
+void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel = 0, SEL backupSel = 0);
+void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel);
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 0b00211..71ff011 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -70,13 +70,13 @@ QT_USE_NAMESPACE
showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
// Get the names in the nib to match the app name set by Qt.
- NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qAppName()));
+ const NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qAppName()));
[quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:appName]];
+ withString:const_cast<NSString *>(appName)]];
[hideItem setTitle:[[hideItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:appName]];
+ withString:const_cast<NSString *>(appName)]];
[aboutItem setTitle:[[aboutItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:appName]];
+ withString:const_cast<NSString *>(appName)]];
[appName release];
// Disable the items that don't do anything. If someone associates a QAction with them
// They should get synced back in.
@@ -170,12 +170,12 @@ QT_USE_NAMESPACE
return [[aboutQtItem retain] autorelease];
}
-- (NSMenuItem *)hideMenuItem;
+- (NSMenuItem *)hideMenuItem
{
return [[hideItem retain] autorelease];
}
-- (NSMenuItem *)appSpecificMenuItem;
+- (NSMenuItem *)appSpecificMenuItem
{
// Create an App-Specific menu item, insert it into the menu and return
// it as an autorelease item.
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..5426159 100644
--- a/src/gui/kernel/qcocoapanel_mac_p.h
+++ b/src/gui/kernel/qcocoapanel_mac_p.h
@@ -50,20 +50,34 @@
// 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 NSPanel (QtIntegration)
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
+- (void)draggingExited:(id <NSDraggingInfo>)sender;
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
+@end
@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 6254061..7d41f3d 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
@@ -140,16 +139,6 @@ QT_END_NAMESPACE
qt_dispatchTabletProximityEvent(tabletEvent);
}
-- (void)qtDispatcherToQAction:(id)sender
-{
- // If this window is modal, the menu bar will be modally shaddowed.
- // In that case, since the window will be in the first responder chain,
- // we can still catch the trigger here and forward it to the menu bar.
- // This is needed as a single modal dialog on Qt should be able to access
- // the application menu (e.g. quit).
- [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender];
-}
-
- (void)terminate:(id)sender
{
// This function is called from the quit item in the menubar when this window
@@ -159,77 +148,27 @@ QT_END_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- if ([event type] == NSApplicationDefined) {
- switch ([event subtype]) {
- case QtCocoaEventSubTypePostMessage:
- [NSApp qt_sendPostedMessage:event];
- return;
- default:
- break;
- }
- return;
- }
-
- 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];
}
@@ -262,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
@@ -284,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
@@ -311,80 +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];
-- (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];
+ 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 {
- // 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;
+ // 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());
}
- *currentDragTarget() = target;
- return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingEntered:sender];
+
+ QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
+ [self changeDraggingCursor:nsActions];
+ return nsActions;
}
-}
+ }
-- (void)draggingExited:(id < NSDraggingInfo >)sender
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
- QWidget *target = [self dragTargetHitTest:sender];
- if (!target)
- return [super draggingExited:sender];
+ 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];
+ }
+ 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;
- if (*currentDragTarget()) {
- [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingExited:sender];
- *currentDragTarget() = 0;
+ // 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;
}
-- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender
+- (void)draggingExited:(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;
+ 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 (dropData) {
+ QDragLeaveEvent de;
+ QApplication::sendEvent(qwidget, &de);
+ [self removeDropData];
}
- return dropResult;
+
+ // Clean-up:
+ [self removeDropData];
+ *currentDragTarget() = 0;
+ [self changeDraggingCursor:NSDragOperationEvery];
}
-- (void)displayIfNeeded
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
+ QWidget *qwidget = *currentDragTarget();
+ if (!qwidget)
+ return NO;
- QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- if (qwidget == 0) {
- [super displayIfNeeded];
- return;
- }
+ *currentDragTarget() = 0;
+ NSPoint nswindowPoint = [sender draggingLocation];
+ NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
+ QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
- if (QApplicationPrivate::graphicsSystem() != 0) {
- if (QWidgetBackingStore *bs = qt_widget_private(qwidget)->maybeBackingStore())
- bs->sync(qwidget, qwidget->rect());
- }
- [super displayIfNeeded];
+ [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();
}
// This is a hack and it should be removed once we find the real cause for
@@ -419,8 +565,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.
@@ -440,3 +586,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 d9f428c..54e7e3e 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -49,9 +49,10 @@
#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>
+#include <private/qwindowsurface_raster_p.h>
+#include <private/qunifiedtoolbarsurface_mac_p.h>
#include <qscrollarea.h>
#include <qhash.h>
@@ -76,70 +77,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 +132,7 @@ extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
}
+//#define ALIEN_DEBUG 1
#ifdef ALIEN_DEBUG
static int qCocoaViewCount = 0;
#endif
@@ -202,11 +150,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;
}
@@ -221,262 +172,28 @@ 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 globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
- 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 globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
- QPoint posDrag(localPoint.x, localPoint.y);
- if (qt_mac_mouse_inside_answer_rect(posDrag)
- && 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 globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
- 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];
}
-- (BOOL)isOpaque;
+- (BOOL)isOpaque
{
if (!qwidgetprivate)
return [super isOpaque];
return qwidgetprivate->isOpaque;
}
-- (BOOL)isFlipped;
+- (BOOL)isFlipped
{
return YES;
}
@@ -508,7 +225,7 @@ static int qCocoaViewCount = 0;
}
// Make sure the opengl context is updated on resize.
- if (qwidgetprivate && qwidgetprivate->isGLWidget) {
+ if (qwidgetprivate && qwidgetprivate->isGLWidget && [self window]) {
qwidgetprivate->needWindowChange = true;
QEvent event(QEvent::MacGLWindowChange);
qApp->sendEvent(qwidget, &event);
@@ -532,17 +249,101 @@ static int qCocoaViewCount = 0;
if (!qwidget)
return;
+ // Getting context.
+ CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+ qt_mac_retain_graphics_context(context);
+
+ // We use a different graphics system.
if (QApplicationPrivate::graphicsSystem() != 0) {
- if (qwidgetprivate->maybeBackingStore()) {
- // Drawing is handled on the window level
- // See qcocoasharedwindowmethods_mac_p.h
- if (!qwidget->testAttribute(Qt::WA_PaintOnScreen))
- return;
+
+ // Raster engine.
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) {
+
+ if (!qwidgetprivate->isInUnifiedToolbar) {
+
+ // Qt handles the painting occuring inside the window.
+ // Cocoa also keeps track of all widgets as NSView and therefore might
+ // ask for a repainting of a widget even if Qt is already taking care of it.
+ //
+ // The only valid reason for Cocoa to call drawRect: is for window manipulation
+ // (ie. resize, ...).
+ //
+ // Qt will then forward the update to the children.
+ if (!qwidget->isWindow()) {
+ qt_mac_release_graphics_context(context);
+ return;
+ }
+
+ QRasterWindowSurface *winSurface = dynamic_cast<QRasterWindowSurface *>(qwidget->windowSurface());
+ if (!winSurface || !winSurface->needsFlush) {
+ qt_mac_release_graphics_context(context);
+ return;
+ }
+
+ // Clip to region.
+ const QVector<QRect> &rects = winSurface->regionToFlush.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect &rect = rects.at(i);
+ CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
+ }
+ CGContextClip(context);
+
+ QRect r = winSurface->regionToFlush.boundingRect();
+ const CGRect area = CGRectMake(r.x(), r.y(), r.width(), r.height());
+
+ qt_mac_draw_image(context, winSurface->imageContext(), area, area);
+
+ winSurface->needsFlush = false;
+ winSurface->regionToFlush = QRegion();
+
+ } else {
+
+ QUnifiedToolbarSurface *unifiedSurface = qwidgetprivate->unifiedSurface;
+ if (!unifiedSurface) {
+ qt_mac_release_graphics_context(context);
+ return;
+ }
+
+ int areaX = qwidgetprivate->toolbar_offset.x();
+ int areaY = qwidgetprivate->toolbar_offset.y();
+ int areaWidth = qwidget->geometry().width();
+ int areaHeight = qwidget->geometry().height();
+ const CGRect area = CGRectMake(areaX, areaY, areaWidth, areaHeight);
+ const CGRect drawingArea = CGRectMake(0, 0, areaWidth, areaHeight);
+
+ qt_mac_draw_image(context, unifiedSurface->imageContext(), area, drawingArea);
+
+ qwidgetprivate->flushRequested = false;
+
+ }
+
+ CGContextFlush(context);
+ qt_mac_release_graphics_context(context);
+ return;
}
+
+ // Qt handles the painting occuring inside the window.
+ // Cocoa also keeps track of all widgets as NSView and therefore might
+ // ask for a repainting of a widget even if Qt is already taking care of it.
+ //
+ // The only valid reason for Cocoa to call drawRect: is for window manipulation
+ // (ie. resize, ...).
+ //
+ // Qt will then forward the update to the children.
+ if (qwidget->isWindow()) {
+ qwidget->update(qwidget->rect());
+ qwidgetprivate->syncBackingStore(qwidget->rect());
+ }
+
+ // Since we don't want to use the native engine, we must exit, however
+ // widgets that are set to paint on screen, specifically QGLWidget,
+ // requires the following code to execute in order to be drawn.
+ if (!qwidget->testAttribute(Qt::WA_PaintOnScreen))
+ return;
}
- CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
- qwidgetprivate->hd = cg;
- CGContextSaveGState(cg);
+
+ // Native engine.
+ qwidgetprivate->hd = context;
if (qwidget->isVisible() && qwidget->updatesEnabled()) { //process the actual paint event.
if (qwidget->testAttribute(Qt::WA_WState_InPaintEvent))
@@ -551,13 +352,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();
@@ -577,48 +378,37 @@ static int qCocoaViewCount = 0;
engine->setSystemClip(qrgn);
if (qwidgetprivate->extra && qwidgetprivate->extra->hasMask) {
CGRect widgetRect = CGRectMake(0, 0, qwidget->width(), qwidget->height());
- CGContextTranslateCTM (cg, 0, widgetRect.size.height);
- CGContextScaleCTM(cg, 1, -1);
+ CGContextTranslateCTM (context, 0, widgetRect.size.height);
+ CGContextScaleCTM(context, 1, -1);
if (qwidget->isWindow())
- CGContextClearRect(cg, widgetRect);
- CGContextClipToMask(cg, widgetRect, qwidgetprivate->extra->imageMask);
- CGContextScaleCTM(cg, 1, -1);
- CGContextTranslateCTM (cg, 0, -widgetRect.size.height);
+ CGContextClearRect(context, widgetRect);
+ CGContextClipToMask(context, widgetRect, qwidgetprivate->extra->imageMask);
+ CGContextScaleCTM(context, 1, -1);
+ CGContextTranslateCTM (context, 0, -widgetRect.size.height);
}
if (qwidget->isWindow() && !qwidgetprivate->isOpaque
- && !qwidget->testAttribute(Qt::WA_MacBrushedMetal)) {
- CGContextClearRect(cg, NSRectToCGRect(aRect));
+ && !qwidget->testAttribute(Qt::WA_MacBrushedMetal)) {
+ CGContextClearRect(context, 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);
@@ -627,19 +417,21 @@ 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);
+ qt_mac_release_graphics_context(context);
}
- (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
@@ -690,161 +482,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
@@ -855,21 +606,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;
@@ -898,46 +642,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
}
@@ -952,35 +680,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;
+- (void)magnifyWithEvent:(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
@@ -989,13 +696,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;
+- (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
@@ -1004,13 +716,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;
+- (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
@@ -1026,13 +743,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;
+- (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
@@ -1040,13 +762,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;
+- (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
@@ -1054,9 +781,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
{
@@ -1099,16 +826,32 @@ 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;
}
@@ -1116,10 +859,13 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
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;
}
@@ -1148,11 +894,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);
}
}
@@ -1167,49 +913,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)) {
- [qt_mac_nativeview_for(widgetToGetKey) interpretKeyEvents:[NSArray arrayWithObject: theEvent]];
+ fromKeyDownEvent = true;
+ [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];
+ }
}
}
}
@@ -1219,12 +953,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];
+ }
}
}
}
@@ -1269,13 +1012,17 @@ static int qCocoaViewCount = 0;
};
}
- if ([aString length] && composing) {
+ // 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) {
// 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
@@ -1297,7 +1044,7 @@ static int qCocoaViewCount = 0;
QString qtText;
// Cursor position is retrived from the range.
QList<QInputMethodEvent::Attribute> attrs;
- attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, selRange.location, 1, QVariant());
+ attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, selRange.location + selRange.length, 1, QVariant());
if ([aString isKindOfClass:[NSAttributedString class]]) {
qtText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
composingLength = qtText.length();
@@ -1339,8 +1086,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;
}
@@ -1350,7 +1100,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;
@@ -1383,7 +1134,7 @@ static int qCocoaViewCount = 0;
if (!selectedText.isEmpty()) {
QCFString string(selectedText.mid(theRange.location, theRange.length));
const NSString *tmpString = reinterpret_cast<const NSString *>((CFStringRef)string);
- return [[[NSAttributedString alloc] initWithString:tmpString] autorelease];
+ return [[[NSAttributedString alloc] initWithString:const_cast<NSString *>(tmpString)] autorelease];
} else {
return nil;
}
@@ -1423,8 +1174,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());
@@ -1442,10 +1197,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.
@@ -1459,7 +1215,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);
@@ -1476,7 +1232,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];
}
@@ -1569,39 +1325,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];
- NSPoint windowPoint = [dndParams.theEvent locationInWindow];
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);
@@ -1618,6 +1380,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 45eafdd..cc79b67 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -58,56 +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 f1a2f67..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>
@@ -55,7 +57,7 @@ QT_USE_NAMESPACE
@implementation NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
-- (id)QT_MANGLE_NAMESPACE(qt_initWithQWidget):(QWidget*)widget contentRect:(NSRect)rect styleMask:(NSUInteger)mask;
+- (id)QT_MANGLE_NAMESPACE(qt_initWithQWidget):(QWidget*)widget contentRect:(NSRect)rect styleMask:(NSUInteger)mask
{
self = [self initWithContentRect:rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
if (self) {
diff --git a/src/gui/kernel/qcocoawindow_mac_p.h b/src/gui/kernel/qcocoawindow_mac_p.h
index 81e0be1..d567cab 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;
@@ -71,14 +74,24 @@ QT_FORWARD_DECLARE_CLASS(QStringList);
- (QWidget *)QT_MANGLE_NAMESPACE(qt_qwidget);
@end
+@interface NSWindow (QtIntegration)
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
+- (void)draggingExited:(id <NSDraggingInfo>)sender;
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
+@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/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm
index ebce6ac..1faf068 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm
@@ -48,6 +48,9 @@
#include <qlayout.h>
#include <qcoreapplication.h>
#include <qmenubar.h>
+#include <QMainWindow>
+#include <QToolBar>
+#include <private/qmainwindowlayout_p.h>
QT_BEGIN_NAMESPACE
extern QWidgetData *qt_qwidget_data(QWidget *); // qwidget.cpp
@@ -138,7 +141,7 @@ static void cleanupCocoaWindowDelegate()
}
}
-- (void)dumpMaximizedStateforWidget:(QWidget*)qwidget window:(NSWindow *)window;
+- (void)dumpMaximizedStateforWidget:(QWidget*)qwidget window:(NSWindow *)window
{
if (!window)
return; // Nothing to do.
@@ -215,6 +218,24 @@ static void cleanupCocoaWindowDelegate()
QWidgetPrivate::qt_mac_update_sizer(qwidget);
[self syncSizeForWidget:qwidget toSize:newSize fromSize:oldSize];
}
+
+ // We force the repaint to be synchronized with the resize of the window.
+ // Otherwise, the resize looks sluggish because we paint one event loop later.
+ if ([[window contentView] inLiveResize]) {
+ qwidget->repaint();
+
+ // We need to repaint the toolbar as well.
+ QMainWindow* mWindow = qobject_cast<QMainWindow*>(qwidget->window());
+ if (mWindow) {
+ QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
+ QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
+
+ for (int i = 0; i < toolbarList.size(); ++i) {
+ QToolBar* toolbar = toolbarList.at(i);
+ toolbar->repaint();
+ }
+ }
+ }
}
- (void)windowDidMove:(NSNotification *)notification
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 610469f..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();
@@ -96,6 +96,10 @@ public:
QCursor(const QCursor &cursor);
~QCursor();
QCursor &operator=(const QCursor &cursor);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QCursor &operator=(QCursor &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
operator QVariant() const;
Qt::CursorShape shape() const;
@@ -126,7 +130,7 @@ public:
static int x11Screen();
#elif defined(Q_WS_MAC)
Qt::HANDLE handle() const;
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
int handle() const;
#elif defined(Q_OS_SYMBIAN)
Qt::HANDLE handle() const;
@@ -137,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..0afa3ee 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;
+ 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/qcursor_p.h b/src/gui/kernel/qcursor_p.h
index 885c345..660a2a5 100644
--- a/src/gui/kernel/qcursor_p.h
+++ b/src/gui/kernel/qcursor_p.h
@@ -91,7 +91,7 @@ public:
short hx, hy;
#if defined (Q_WS_MAC)
int mId;
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
int id;
#endif
#if defined (Q_WS_WIN)
diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/kernel/qcursor_qpa.cpp
new file mode 100644
index 0000000..a6ae7d3
--- /dev/null
+++ b/src/gui/kernel/qcursor_qpa.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qcursor.h>
+#include <private/qcursor_p.h>
+#include <qbitmap.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+#ifndef QT_NO_CURSOR
+
+static int nextCursorId = Qt::BitmapCursor;
+
+/*****************************************************************************
+ Internal QCursorData class
+ *****************************************************************************/
+
+QCursorData::QCursorData(Qt::CursorShape s)
+ : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s)
+{
+ ref = 1;
+}
+
+QCursorData::~QCursorData()
+{
+ delete bm;
+ delete bmm;
+}
+
+
+/*****************************************************************************
+ Global cursors
+ *****************************************************************************/
+
+extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp
+
+int QCursor::handle() const
+{
+ return d->id;
+}
+
+
+QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
+ qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
+ QCursorData *c = qt_cursorTable[0];
+ c->ref.ref();
+ return c;
+ }
+ QCursorData *d = new QCursorData;
+ d->bm = new QBitmap(bitmap);
+ d->bmm = new QBitmap(mask);
+ d->cshape = Qt::BitmapCursor;
+ d->id = ++nextCursorId;
+ d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
+ d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
+
+ return d;
+}
+
+void QCursorData::update()
+{
+}
+
+#endif //QT_NO_CURSOR
+
+extern int qt_last_x,qt_last_y;
+
+QPoint QCursor::pos()
+{
+ return QPoint(qt_last_x, qt_last_y);
+}
+
+void QCursor::setPos(int x, int y)
+{
+ // Need to check, since some X servers generate null mouse move
+ // events, causing looping in applications which call setPos() on
+ // every mouse move event.
+ //
+ if (pos() == QPoint(x, y))
+ return;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget_qpa.cpp b/src/gui/kernel/qdesktopwidget_qpa.cpp
new file mode 100644
index 0000000..cff05f5
--- /dev/null
+++ b/src/gui/kernel/qdesktopwidget_qpa.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdesktopwidget.h"
+#include "private/qapplication_p.h"
+#include "private/qgraphicssystem_p.h"
+#include <QWidget>
+#include "private/qwidget_p.h"
+#include "private/qdesktopwidget_qpa_p.h"
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+void QDesktopWidgetPrivate::updateScreenList()
+{
+ QList<QPlatformScreen *> screenList = QApplicationPrivate::platformIntegration()->screens();
+ int targetLength = screenList.length();
+ int currentLength = screens.length();
+
+ // Add or remove screen widgets as necessary
+ if(currentLength > targetLength) {
+ QDesktopScreenWidget *screen;
+ while (currentLength-- > targetLength) {
+ screen = screens.takeLast();
+ delete screen;
+ }
+ }
+ else if (currentLength < targetLength) {
+ QDesktopScreenWidget *screen;
+ while (currentLength < targetLength) {
+ screen = new QDesktopScreenWidget(currentLength++);
+ screens.append(screen);
+ }
+ }
+
+ QRegion virtualGeometry;
+ bool doVirtualGeometry = QApplicationPrivate::platformIntegration()->isVirtualDesktop();
+
+ // update the geometry of each screen widget
+ for (int i = 0; i < screens.length(); i++) {
+ QRect screenGeometry = screenList.at(i)->geometry();
+ screens.at(i)->setGeometry(screenGeometry);
+ if (doVirtualGeometry)
+ virtualGeometry += screenGeometry;
+ }
+
+ virtualScreen.setGeometry(virtualGeometry.boundingRect());
+ Q_Q(QDesktopWidget);
+ q->setGeometry(virtualScreen.geometry());
+}
+
+QDesktopWidget::QDesktopWidget()
+ : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
+{
+ Q_D(QDesktopWidget);
+ setObjectName(QLatin1String("desktop"));
+ d->updateScreenList();
+}
+
+QDesktopWidget::~QDesktopWidget()
+{
+}
+
+bool QDesktopWidget::isVirtualDesktop() const
+{
+ return QApplicationPrivate::platformIntegration()->isVirtualDesktop();
+}
+
+int QDesktopWidget::primaryScreen() const
+{
+ return 0;
+}
+
+int QDesktopWidget::numScreens() const
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ return qMax(pi->screens().size(), 1);
+}
+
+QWidget *QDesktopWidget::screen(int screen)
+{
+ Q_D(QDesktopWidget);
+ if (QApplicationPrivate::platformIntegration()->isVirtualDesktop())
+ return &d->virtualScreen;
+ if (screen < 0 || screen >= d->screens.length())
+ return d->screens.at(0);
+ return d->screens.at(screen);
+}
+
+const QRect QDesktopWidget::availableGeometry(int screenNo) const
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return QRect();
+ else
+ return screens[screenNo]->availableGeometry();
+}
+
+const QRect QDesktopWidget::screenGeometry(int screenNo) const
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return QRect();
+ else
+ return screens[screenNo]->geometry();
+}
+
+int QDesktopWidget::screenNumber(const QWidget *w) const
+{
+ if (!w)
+ return 0;
+
+ QRect frame = w->frameGeometry();
+ if (!w->isWindow())
+ frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
+ const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
+ return screenNumber(midpoint);
+}
+
+int QDesktopWidget::screenNumber(const QPoint &p) const
+{
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+
+ for (int i = 0; i < screens.size(); ++i)
+ if (screens[i]->geometry().contains(p))
+ return i;
+
+ return primaryScreen(); //even better would be closest screen
+}
+
+void QDesktopWidget::resizeEvent(QResizeEvent *)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/gui/kernel/qdesktopwidget_qpa_p.h
new file mode 100644
index 0000000..abee8a1
--- /dev/null
+++ b/src/gui/kernel/qdesktopwidget_qpa_p.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$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QDESKTOPWIDGET_QPA_P_H
+#define QDESKTOPWIDGET_QPA_P_H
+
+#include "QDesktopWidget"
+#include "private/qwidget_p.h"
+
+class QDesktopScreenWidget : public QWidget {
+ Q_OBJECT
+public:
+ QDesktopScreenWidget(int screenNumber = -1)
+ {
+ setWindowFlags(Qt::Desktop);
+ setVisible(false);
+ QTLWExtra *topData = d_func()->topData();
+ topData->screenIndex = screenNumber;
+ }
+};
+
+class QDesktopWidgetPrivate : public QWidgetPrivate {
+ Q_DECLARE_PUBLIC(QDesktopWidget)
+
+public:
+ ~QDesktopWidgetPrivate() {foreach(QDesktopScreenWidget *s, screens) delete s; }
+ void updateScreenList();
+
+ QList<QDesktopScreenWidget *> screens;
+ QDesktopScreenWidget virtualScreen;
+};
+
+#endif // QDESKTOPWIDGET_QPA_P_H
diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/gui/kernel/qdesktopwidget_win.cpp
index b822644..d57b355 100644
--- a/src/gui/kernel/qdesktopwidget_win.cpp
+++ b/src/gui/kernel/qdesktopwidget_win.cpp
@@ -156,10 +156,8 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
#ifndef Q_OS_WINCE
QSystemLibrary user32Lib(QLatin1String("user32"));
- if (user32Lib.load()) {
- enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
- getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
- }
+ enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
+ getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
if (!enumDisplayMonitors || !getMonitorInfo) {
screenCount = GetSystemMetrics(80); // SM_CMONITORS
@@ -174,11 +172,9 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
getMonitorInfo = 0;
#else
QSystemLibrary coreLib(QLatin1String("coredll"));
- if (coreLib.load()) {
- // CE >= 4.0 case
- enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors");
- getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo");
- }
+ // CE >= 4.0 case
+ enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors");
+ getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo");
if ((!enumDisplayMonitors || !getMonitorInfo)) {
screenCount = GetSystemMetrics(SM_CMONITORS);
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/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index 2ebe78c..7543666 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -76,7 +76,7 @@ class QEventLoop;
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-class QInternalMimeData : public QMimeData
+class Q_GUI_EXPORT QInternalMimeData : public QMimeData
{
Q_OBJECT
public:
@@ -261,11 +261,11 @@ public:
#endif
private:
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
Qt::DropAction currentActionForOverrideCursor;
#endif
#ifdef Q_OS_SYMBIAN
-#ifndef QT_NO_CURSOR
+#ifndef QT_NO_CURSOR
QCursor overrideCursor;
#endif
#endif
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index f0ddd83..277a5e8 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -43,6 +43,7 @@
#include "qcursor.h"
#include "qapplication.h"
#include "private/qapplication_p.h"
+#include "private/qevent_p.h"
#include "private/qkeysequence_p.h"
#include "qwidget.h"
#include "qgraphicsview.h"
@@ -53,6 +54,10 @@
#include "qgesture.h"
#include "qgesture_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -724,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,
@@ -1658,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.
@@ -3023,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
@@ -3049,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()
@@ -3074,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
@@ -3622,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
@@ -4392,7 +4453,7 @@ void QGestureEvent::accept(QGesture *gesture)
of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
Clearing the accept flag indicates that the event receiver does not
- want the gesture. Unwanted gestures may be propgated to the parent widget.
+ want the gesture. Unwanted gestures may be propagated to the parent widget.
\sa QGestureEvent::accept()
*/
@@ -4568,4 +4629,223 @@ const QGestureEventPrivate *QGestureEvent::d_func() const
#endif // QT_NO_GESTURES
+/*!
+ \class QScrollPrepareEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
+
+ The scroll prepare event is send before scrolling (usually by QScroller) is started.
+ The object receiving this event should set viewportSize, maxContentPos and contentPos.
+ It also should accept this event to indicate that scrolling should be started.
+
+ It is not guaranteed that a QScrollEvent will be send after an acceepted
+ QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
+
+ \sa QScrollEvent, QScroller
+*/
+
+/*!
+ Creates new QScrollPrepareEvent
+ The \a startPos is the position of a touch or mouse event that started the scrolling.
+*/
+QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
+ : QEvent(QEvent::ScrollPrepare)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
+ d_func()->startPos = startPos;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollPrepareEvent::~QScrollPrepareEvent()
+{
+ delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ Returns the position of the touch or mouse event that started the scrolling.
+*/
+QPointF QScrollPrepareEvent::startPos() const
+{
+ return d_func()->startPos;
+}
+
+/*!
+ Returns size of the area that is to be scrolled as set by setViewportSize
+
+ \sa setViewportSize()
+*/
+QSizeF QScrollPrepareEvent::viewportSize() const
+{
+ return d_func()->viewportSize;
+}
+
+/*!
+ Returns the range of coordinates for the content as set by setContentPosRange().
+*/
+QRectF QScrollPrepareEvent::contentPosRange() const
+{
+ return d_func()->contentPosRange;
+}
+
+/*!
+ Returns the current position of the content as set by setContentPos.
+*/
+QPointF QScrollPrepareEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+
+/*!
+ Sets the size of the area that is to be scrolled to \a size.
+
+ \sa viewportSize()
+*/
+void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
+{
+ d_func()->viewportSize = size;
+}
+
+/*!
+ Sets the range of content coordinates to \a rect.
+
+ \sa contentPosRange()
+*/
+void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
+{
+ d_func()->contentPosRange = rect;
+}
+
+/*!
+ Sets the current content position to \a pos.
+
+ \sa contentPos()
+*/
+void QScrollPrepareEvent::setContentPos(const QPointF &pos)
+{
+ d_func()->contentPos = pos;
+}
+
+
+/*!
+ \internal
+*/
+QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
+{
+ return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \class QScrollEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollEvent class is send when scrolling.
+
+ The scroll event is send to indicate that the receiver should be scrolled.
+ Usually the receiver should be something visual like QWidget or QGraphicsObject.
+
+ Some care should be taken that no conflicting QScrollEvents are sent from two
+ sources. Using QScroller::scrollTo is save however.
+
+ \sa QScrollPrepareEvent, QScroller
+*/
+
+/*!
+ \enum QScrollEvent::ScrollState
+
+ This enum describes the states a scroll event can have.
+
+ \value ScrollStarted Set for the first scroll event of a scroll activity.
+
+ \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
+
+ \value ScrollFinished Set for the last scroll event of a scroll activity.
+
+ \sa QScrollEvent::scrollState()
+*/
+
+/*!
+ Creates a new QScrollEvent
+ \a contentPos is the new content position, \a overshootDistance is the
+ new overshoot distance while \a scrollState indicates if this scroll
+ event is the first one, the last one or some event in between.
+*/
+QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
+ : QEvent(QEvent::Scroll)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
+ d_func()->contentPos = contentPos;
+ d_func()->overshoot= overshootDistance;
+ d_func()->state = scrollState;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollEvent::~QScrollEvent()
+{
+ delete reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ Returns the new scroll position.
+*/
+QPointF QScrollEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+/*!
+ Returns the new overshoot distance.
+ See QScroller for an explanation of the term overshoot.
+
+ \sa QScroller
+*/
+QPointF QScrollEvent::overshootDistance() const
+{
+ return d_func()->overshoot;
+}
+
+/*!
+ Returns the current scroll state as a combination of ScrollStateFlag values.
+ ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
+ Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
+ All other scroll events in between will have their state set to ScrollUpdated.
+
+ A widget could for example revert selections when scrolling is started and stopped.
+*/
+QScrollEvent::ScrollState QScrollEvent::scrollState() const
+{
+ return d_func()->state;
+}
+
+/*!
+ \internal
+*/
+QScrollEventPrivate *QScrollEvent::d_func()
+{
+ return reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollEventPrivate *QScrollEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollEventPrivate *>(d);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 879ac2d..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;
};
@@ -880,6 +889,52 @@ private:
};
#endif // QT_NO_GESTURES
+class QScrollPrepareEventPrivate;
+class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
+{
+public:
+ QScrollPrepareEvent(const QPointF &startPos);
+ ~QScrollPrepareEvent();
+
+ QPointF startPos() const;
+
+ QSizeF viewportSize() const;
+ QRectF contentPosRange() const;
+ QPointF contentPos() const;
+
+ void setViewportSize(const QSizeF &size);
+ void setContentPosRange(const QRectF &rect);
+ void setContentPos(const QPointF &pos);
+
+private:
+ QScrollPrepareEventPrivate *d_func();
+ const QScrollPrepareEventPrivate *d_func() const;
+};
+
+
+class QScrollEventPrivate;
+class Q_GUI_EXPORT QScrollEvent : public QEvent
+{
+public:
+ enum ScrollState
+ {
+ ScrollStarted,
+ ScrollUpdated,
+ ScrollFinished
+ };
+
+ QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
+ ~QScrollEvent();
+
+ QPointF contentPos() const;
+ QPointF overshootDistance() const;
+ ScrollState scrollState() const;
+
+private:
+ QScrollEventPrivate *d_func();
+ const QScrollEventPrivate *d_func() const;
+};
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 784062e..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,40 @@ public:
: url(url)
{
}
+ ~QFileOpenEventPrivate();
QUrl url;
+#ifdef Q_OS_SYMBIAN
+ RFile file;
+#endif
+};
+
+
+class QScrollPrepareEventPrivate
+{
+public:
+ inline QScrollPrepareEventPrivate()
+ : target(0)
+ {
+ }
+
+ QObject* target;
+ QPointF startPos;
+ QSizeF viewportSize;
+ QRectF contentPosRange;
+ QPointF contentPos;
+};
+
+class QScrollEventPrivate
+{
+public:
+ inline QScrollEventPrivate()
+ {
+ }
+
+ QPointF contentPos;
+ QPointF overshoot;
+ QScrollEvent::ScrollState state;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
new file mode 100644
index 0000000..603aa2d
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** 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 "qeventdispatcher_glib_qpa_p.h"
+
+#include "qapplication.h"
+
+#include "qplatformdefs.h"
+#include "qapplication.h"
+
+#include <glib.h>
+#include "qapplication_p.h"
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+struct GUserEventSource
+{
+ GSource source;
+ QPAEventDispatcherGlib *q;
+};
+
+static gboolean userEventSourcePrepare(GSource *s, gint *timeout)
+{
+ Q_UNUSED(s)
+ Q_UNUSED(timeout)
+
+ return QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0;
+}
+
+static gboolean userEventSourceCheck(GSource *source)
+{
+ return userEventSourcePrepare(source, 0);
+}
+
+static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
+{
+ GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
+
+ QWindowSystemInterfacePrivate::WindowSystemEvent * event;
+ while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+
+ // send through event filter
+ if (source->q->filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ QApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ return true;
+}
+
+
+static GSourceFuncs userEventSourceFuncs = {
+ userEventSourcePrepare,
+ userEventSourceCheck,
+ userEventSourceDispatch,
+ NULL,
+ NULL,
+ NULL
+};
+
+QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
+ : QEventDispatcherGlibPrivate(context)
+{
+ userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs,
+ sizeof(GUserEventSource)));
+ userEventSource->q = 0;
+ g_source_set_can_recurse(&userEventSource->source, true);
+ g_source_attach(&userEventSource->source, mainContext);
+}
+
+
+QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
+ : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
+{
+ Q_D(QPAEventDispatcherGlib);
+ d->userEventSource->q = this;
+}
+
+QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
+{
+ Q_D(QPAEventDispatcherGlib);
+
+ g_source_destroy(&d->userEventSource->source);
+ g_source_unref(&d->userEventSource->source);
+ d->userEventSource = 0;
+}
+
+bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ static bool init = false;
+ if (!init) {
+ if (QApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
+ qWarning("Eventloop integration is not supported by the glib event dispatcher");
+ qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
+ }
+ init = true;
+ }
+ return QEventDispatcherGlib::processEvents(flags);
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkaccessdatabackend_p.h b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
index 18569ec..701f673 100644
--- a/src/network/access/qnetworkaccessdatabackend_p.h
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa_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 QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,46 +39,50 @@
**
****************************************************************************/
-#ifndef QNETWORKACCESSDATABACKEND_P_H
-#define QNETWORKACCESSDATABACKEND_P_H
+#ifndef QEVENTDISPATCHER_GLIB_QPA_P_H
+#define QEVENTDISPATCHER_GLIB_QPA_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
+// of the QLibrary class. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//
-#include "qnetworkaccessbackend_p.h"
+#include <QtCore/private/qeventdispatcher_glib_p.h>
+
+typedef struct _GMainContext GMainContext;
QT_BEGIN_NAMESPACE
+class QPAEventDispatcherGlibPrivate;
-class QNetworkAccessDataBackend: public QNetworkAccessBackend
+class QPAEventDispatcherGlib : public QEventDispatcherGlib
{
-public:
- QNetworkAccessDataBackend();
- virtual ~QNetworkAccessDataBackend();
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPAEventDispatcherGlib)
- virtual void open();
- virtual void closeDownstreamChannel();
- virtual void closeUpstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
- virtual bool waitForUpstreamBytesWritten(int msecs);
+public:
+ explicit QPAEventDispatcherGlib(QObject *parent = 0);
+ ~QPAEventDispatcherGlib();
- virtual bool processRequestSynchronously();
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
};
-class QNetworkAccessDataBackendFactory: public QNetworkAccessBackendFactory
+struct GUserEventSource;
+
+class QPAEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate
{
+ Q_DECLARE_PUBLIC(QPAEventDispatcherGlib)
public:
- virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op,
- const QNetworkRequest &request) const;
+ QPAEventDispatcherGlibPrivate(GMainContext *context = 0);
+ GUserEventSource *userEventSource;
};
+
QT_END_NAMESPACE
-#endif
+#endif // QEVENTDISPATCHER_GLIB_QPA_P_H
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index 8f024f5..677a736 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -561,6 +561,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
wakeUp();
emit awake();
+ bool excludeUserEvents = flags & QEventLoop::ExcludeUserInputEvents;
bool retVal = false;
forever {
if (d->interrupt)
@@ -571,7 +572,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
NSEvent* event = 0;
// First, send all previously excluded input events, if any:
- if (!(flags & QEventLoop::ExcludeUserInputEvents)) {
+ if (!excludeUserEvents) {
while (!d->queuedUserInputEvents.isEmpty()) {
event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
if (!filterEvent(event)) {
@@ -586,9 +587,12 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
// application, we should not run or stop NSApplication; This will be
// done from the application itself. And if processEvents is called
// manually (rather than from a QEventLoop), we cannot enter a tight
- // loop and block this call, but instead we need to return after one flush:
+ // loop and block this call, but instead we need to return after one flush.
+ // Finally, if we are to exclude user input events, we cannot call [NSApp run]
+ // as we then loose control over which events gets dispatched:
const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
- const bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec;
+ const bool canExec_Qt = !excludeUserEvents &&
+ (flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec) ;
if (canExec_Qt && canExec_3rdParty) {
// We can use exec-mode, meaning that we can stay in a tight loop until
@@ -616,22 +620,46 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
// Instead we will process all current pending events and return.
d->ensureNSAppInitialized();
if (NSModalSession session = d->currentModalSession()) {
- if (flags & QEventLoop::WaitForMoreEvents)
- qt_mac_waitForMoreModalSessionEvents();
- NSInteger status = [NSApp runModalSession:session];
- if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
- // INVARIANT: Someone called [NSApp stopModal:] from outside the event
- // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
- // 'session' as well. As a result, we need to restart all internal sessions:
- d->temporarilyStopAllModalSessions();
- }
- retVal = true;
- } else do {
- event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ // INVARIANT: a modal window is executing.
+ if (!excludeUserEvents) {
+ // Since we can dispatch all kinds of events, we choose
+ // to use cocoa's native way of running modal sessions:
+ if (flags & QEventLoop::WaitForMoreEvents)
+ qt_mac_waitForMoreModalSessionEvents();
+ NSInteger status = [NSApp runModalSession:session];
+ if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+ // INVARIANT: Someone called [NSApp stopModal:] from outside the event
+ // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+ // 'session' as well. As a result, we need to restart all internal sessions:
+ d->temporarilyStopAllModalSessions();
+ }
+ retVal = true;
+ } else do {
+ // Dispatch all non-user events (but que non-user events up for later). In
+ // this case, we need more control over which events gets dispatched, and
+ // cannot use [NSApp runModalSession:session]:
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:nil
- inMode:NSDefaultRunLoopMode
+ inMode:NSModalPanelRunLoopMode
dequeue: YES];
+ if (event) {
+ if (IsMouseOrKeyEvent(event)) {
+ [event retain];
+ d->queuedUserInputEvents.append(event);
+ continue;
+ }
+ if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))
+ retVal = true;
+ }
+ } while (!d->interrupt && event != nil);
+ } else do {
+ // INVARIANT: No modal window is executing.
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:nil
+ inMode:NSDefaultRunLoopMode
+ dequeue: YES];
+
if (event) {
if (flags & QEventLoop::ExcludeUserInputEvents) {
if (IsMouseOrKeyEvent(event)) {
@@ -645,6 +673,11 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
}
} while (!d->interrupt && event != nil);
+ // Be sure to flush the Qt posted events when not using exec mode
+ // (exec mode will always do this call from the event loop source):
+ if (!d->interrupt)
+ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+
// Since the window that holds modality might have changed while processing
// events, we we need to interrupt when we return back the previous process
// event recursion to ensure that we spin the correct modal session.
diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp
new file mode 100644
index 0000000..de53618
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_qpa.cpp
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+#include "qapplication.h"
+#include "qeventdispatcher_qpa_p.h"
+#include "private/qeventdispatcher_unix_p.h"
+#include "qapplication_p.h"
+#include "qplatformeventloopintegration_qpa.h"
+
+#include <QWindowSystemInterface>
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QAtomicInt>
+#include <QtCore/QSemaphore>
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class Rendezvous
+{
+public:
+ void checkpoint()
+ {
+ if (state.testAndSetOrdered(0,1)) {
+ semaphore.acquire();
+ } else if (state.testAndSetAcquire(1,0)) {
+ semaphore.release();
+ } else {
+ qWarning("Barrier internal error");
+ }
+ }
+private:
+ QSemaphore semaphore;
+ QAtomicInt state;
+};
+
+class SelectWorker : public QThread
+{
+public:
+ SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
+ : QThread(),
+ m_edPrivate(eventDispatcherPrivate),
+ m_retVal(0)
+ {
+ }
+
+ void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+ {
+ m_nfds = nfds;
+ m_readfds = readfds;
+ m_writefds = writefds;
+ m_exceptfds = exceptfds;
+
+
+ }
+
+ int retVal() const {
+ return m_retVal;
+ }
+
+protected:
+ void run();
+
+private:
+ QEventDispatcherQPAPrivate *m_edPrivate;
+ int m_retVal;
+
+ int m_nfds;
+ fd_set *m_readfds, *m_writefds, *m_exceptfds;
+};
+
+class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate
+{
+ Q_DECLARE_PUBLIC(QEventDispatcherQPA)
+public:
+ QEventDispatcherQPAPrivate()
+ : eventLoopIntegration(0),
+ barrierBeforeBlocking(0),
+ barrierReturnValue(0),
+ selectReturnMutex(0),
+ selectWorkerNeedsSync(true),
+ selectWorkerHasResult(false),
+ m_integrationInitialised(false),
+ m_hasIntegration(false),
+ m_isEventLoopIntegrationRunning(false)
+ {
+
+ }
+
+ ~QEventDispatcherQPAPrivate()
+ {
+ delete selectWorker;
+ delete eventLoopIntegration;
+ delete barrierBeforeBlocking;
+ delete barrierReturnValue;
+ delete selectReturnMutex;
+ }
+
+ bool hasIntegration() const
+ {
+ if (!m_integrationInitialised) {
+ QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
+ if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
+ if (QApplicationPrivate::platformIntegration()) {
+ that->eventLoopIntegration = QApplicationPrivate::platformIntegration()->createEventLoopIntegration();
+ if (that->eventLoopIntegration) {
+ that->selectWorker = new SelectWorker(that);
+ that->barrierBeforeBlocking = new Rendezvous;
+ that->barrierReturnValue = new Rendezvous;
+ that->selectReturnMutex = new QMutex;
+ that->selectWorker->start();
+ that->m_hasIntegration = true;
+ if (!QElapsedTimer::isMonotonic())
+ qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
+ }
+ }
+ }
+ that->m_integrationInitialised = true;
+ }
+ return m_hasIntegration;
+ }
+
+ bool isEventLoopIntegrationRunning() const
+ {
+ return m_isEventLoopIntegrationRunning;
+ }
+
+ void runEventLoopIntegration()
+ {
+ if (qApp && (qApp->thread() == QThread::currentThread())) {
+ m_isEventLoopIntegrationRunning = true;
+ eventLoopIntegration->startEventLoop();
+ }
+ }
+
+ QPlatformEventLoopIntegration *eventLoopIntegration;
+ Rendezvous *barrierBeforeBlocking;
+ Rendezvous *barrierReturnValue;
+
+ QMutex *selectReturnMutex;
+ bool selectWorkerNeedsSync;
+ bool selectWorkerHasResult;
+
+ SelectWorker *selectWorker;
+private:
+ bool m_integrationInitialised;
+ bool m_hasIntegration;
+ bool m_isEventLoopIntegrationRunning;
+};
+
+QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
+ : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent)
+{ }
+
+QEventDispatcherQPA::~QEventDispatcherQPA()
+{ }
+
+bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ Q_D(QEventDispatcherQPA);
+
+ if (d->hasIntegration()) {
+ if (!d->isEventLoopIntegrationRunning()) {
+ d->runEventLoopIntegration();
+ }
+ if (d->threadData->quitNow) {
+ d->eventLoopIntegration->quitEventLoop();
+ return false;
+ }
+ }
+
+ int nevents = 0;
+
+ // handle gui and posted events
+ d->interrupt = false;
+ QApplication::sendPostedEvents();
+
+ while (!d->interrupt) { // also flushes output buffer ###can be optimized
+ QWindowSystemInterfacePrivate::WindowSystemEvent *event;
+ if (!(flags & QEventLoop::ExcludeUserInputEvents)
+ && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) {
+ // process a pending user input event
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+ } else {
+ break;
+ }
+
+ if (filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ nevents++;
+
+ QApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ if (!d->interrupt) {
+ if (QEventDispatcherUNIX::processEvents(flags)) {
+ QEventDispatcherUNIX::processEvents(flags);
+ return true;
+ }
+ }
+ return (nevents > 0);
+}
+
+bool QEventDispatcherQPA::hasPendingEvents()
+{
+ extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
+ return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
+}
+
+void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::registerSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+
+}
+
+void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+}
+
+void QEventDispatcherQPA::flush()
+{
+ if(qApp)
+ qApp->sendPostedEvents();
+}
+
+int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout)
+{
+ Q_D(QEventDispatcherQPA);
+ int retVal = 0;
+ if (d->hasIntegration()) {
+ qint64 timeoutmsec = 0;
+ if (timeout)
+ timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
+ d->selectReturnMutex->lock();
+ if (d->selectWorkerNeedsSync) {
+ if (d->selectWorkerHasResult) {
+ retVal = d->selectWorker->retVal();
+ d->selectWorkerHasResult = false;
+
+ d->selectReturnMutex->unlock();
+ d->barrierReturnValue->checkpoint();
+ d->eventLoopIntegration->setNextTimerEvent(0);
+ return retVal;
+ } else {
+ d->selectWorkerNeedsSync = false;
+ d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
+ d->barrierBeforeBlocking->checkpoint();
+ }
+ }
+ d->selectReturnMutex->unlock();
+ d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
+ retVal = 0; //is 0 if select has not returned
+ } else {
+ retVal = QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
+ }
+ return retVal;
+}
+
+
+void SelectWorker::run()
+{
+
+ while(true) {
+ m_retVal = 0;
+ m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
+ int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
+ m_edPrivate->selectReturnMutex->lock();
+ m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
+
+ m_edPrivate->selectWorkerNeedsSync = true;
+ m_edPrivate->selectWorkerHasResult = true;
+ m_retVal = tmpRet;
+
+ m_edPrivate->selectReturnMutex->unlock();
+ m_edPrivate->barrierReturnValue->checkpoint();
+ }
+}
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h
new file mode 100644
index 0000000..d4d2be1
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_qpa_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QEVENTDISPATCHER_QPA_P_H
+#define QEVENTDISPATCHER_QPA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qeventdispatcher_unix_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEventDispatcherQPAPrivate;
+
+class QEventDispatcherQPA : public QEventDispatcherUNIX
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QEventDispatcherQPA)
+
+public:
+ explicit QEventDispatcherQPA(QObject *parent = 0);
+ ~QEventDispatcherQPA();
+
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
+ bool hasPendingEvents();
+
+ void registerSocketNotifier(QSocketNotifier *notifier);
+ void unregisterSocketNotifier(QSocketNotifier *notifier);
+
+ void flush();
+
+protected:
+ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout);
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENTDISPATCHER_QPA_P_H
diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/kernel/qgenericplugin_qpa.cpp
new file mode 100644
index 0000000..43d6525
--- /dev/null
+++ b/src/gui/kernel/qgenericplugin_qpa.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgenericplugin_qpa.h"
+
+#ifndef QT_NO_LIBRARY
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QGenericPlugin
+ \ingroup plugins
+ \ingroup qpa
+
+ \brief The QGenericPlugin class is an abstract base class for
+ window-system related plugins in Qt QPA.
+
+ Note that this class is only available in \l{Qt QPA}.
+
+ A mouse plugin can be created by subclassing
+ QGenericPlugin and reimplementing the pure virtual keys() and
+ create() functions. By exporting the derived class using the
+ Q_EXPORT_PLUGIN2() macro, The default implementation of the
+ QGenericPluginFactory class will automatically detect the plugin and
+ load the driver into the server application at run-time. See \l
+ {How to Create Qt Plugins} for details.
+
+ \sa QGenericPluginFactory
+*/
+
+/*!
+ \fn QStringList QGenericPlugin::keys() const
+
+ Implement this function to return the list of valid keys, i.e. the
+ drivers supported by this plugin.
+
+ \sa create()
+*/
+
+/*!
+ Constructs a plugin with the given \a parent.
+
+ Note that this constructor is invoked automatically by the
+ Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
+ explicitly.
+*/
+QGenericPlugin::QGenericPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ Destroys the plugin.
+
+ Note that Qt destroys a plugin automatically when it is no longer
+ used, so there is no need for calling the destructor explicitly.
+*/
+QGenericPlugin::~QGenericPlugin()
+{
+}
+
+/*!
+ \fn QObject* QGenericPlugin::create(const QString &key, const QString& specification)
+
+ Implement this function to create a driver matching the type
+ specified by the given \a key and \a specification parameters. Note that
+ keys are case-insensitive.
+
+ \sa keys()
+*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_LIBRARY
diff --git a/src/gui/kernel/qgenericplugin_qpa.h b/src/gui/kernel/qgenericplugin_qpa.h
new file mode 100644
index 0000000..e1792cd
--- /dev/null
+++ b/src/gui/kernel/qgenericplugin_qpa.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 QGENERICPLUGIN_QPA_H
+#define QGENERICPLUGIN_QPA_H
+
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LIBRARY
+
+//class QGenericObject; ?????
+
+ struct Q_GUI_EXPORT QGenericPluginFactoryInterface : public QFactoryInterface
+{
+ virtual QObject* create(const QString &name, const QString &spec) = 0;
+};
+
+#define QGenericPluginFactoryInterface_iid "com.trolltech.Qt.QGenericPluginFactoryInterface"
+Q_DECLARE_INTERFACE(QGenericPluginFactoryInterface, QGenericPluginFactoryInterface_iid)
+
+class Q_GUI_EXPORT QGenericPlugin : public QObject, public QGenericPluginFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGenericPluginFactoryInterface:QFactoryInterface)
+public:
+ explicit QGenericPlugin(QObject *parent = 0);
+ ~QGenericPlugin();
+
+ virtual QStringList keys() const = 0;
+ virtual QObject* create(const QString& name, const QString &spec) = 0;
+};
+
+#endif // QT_NO_LIBRARY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGENERICPLUGIN_QPA_H
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp
new file mode 100644
index 0000000..abc575a
--- /dev/null
+++ b/src/gui/kernel/qgenericpluginfactory_qpa.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgenericpluginfactory_qpa.h"
+
+#include "qapplication.h"
+#include "private/qfactoryloader_p.h"
+#include "qgenericplugin_qpa.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QGenericPluginFactoryInterface_iid,
+ QLatin1String("/generic"), Qt::CaseInsensitive))
+
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+
+/*!
+ \class QGenericPluginFactory
+ \ingroup qpa
+
+ \brief The QGenericPluginFactory class creates window-system
+ related plugin drivers in Qt QPA.
+
+ Note that this class is only available in \l{Qt QPA}.
+
+
+ \sa QGenericPlugin
+*/
+
+/*!
+ Creates the driver specified by \a key, using the given \a specification.
+
+ Note that the keys are case-insensitive.
+
+ \sa keys()
+*/
+QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
+{
+ QString driver = key.toLower();
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ if (QGenericPluginFactoryInterface *factory = qobject_cast<QGenericPluginFactoryInterface*>(loader()->instance(driver)))
+ return factory->create(driver, specification);
+#endif
+#endif
+ return 0;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the available mouse drivers.
+
+ \sa create()
+*/
+QStringList QGenericPluginFactory::keys()
+{
+ QStringList list;
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ QStringList plugins = loader()->keys();
+ for (int i = 0; i < plugins.size(); ++i) {
+ if (!list.contains(plugins.at(i)))
+ list += plugins.at(i);
+ }
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+ return list;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.h b/src/gui/kernel/qgenericpluginfactory_qpa.h
new file mode 100644
index 0000000..59eac38
--- /dev/null
+++ b/src/gui/kernel/qgenericpluginfactory_qpa.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 QGENERICPLUGINFACTORY_QPA_H
+#define QGENERICPLUGINFACTORY_QPA_H
+
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QString;
+class QObject;
+
+class Q_GUI_EXPORT QGenericPluginFactory
+{
+public:
+ static QStringList keys();
+ static QObject *create(const QString&, const QString &);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGENERICPLUGINFACTORY_QPA_H
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 22bfb26..5359fb3 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -243,52 +243,53 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *,
// TODO: sort contexts by the gesture type and check if one of the contexts
// is already active.
- bool ret = false;
+ bool consumeEventHint = false;
// filter the event through recognizers
typedef QMultiMap<QObject *, Qt::GestureType>::const_iterator ContextIterator;
- for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) {
- Qt::GestureType gestureType = cit.value();
+ ContextIterator contextEnd = contexts.end();
+ for (ContextIterator context = contexts.begin(); context != contextEnd; ++context) {
+ Qt::GestureType gestureType = context.value();
QMap<Qt::GestureType, QGestureRecognizer *>::const_iterator
- rit = m_recognizers.lowerBound(gestureType),
- re = m_recognizers.upperBound(gestureType);
- for (; rit != re; ++rit) {
- QGestureRecognizer *recognizer = rit.value();
- QObject *target = cit.key();
+ typeToRecognizerIterator = m_recognizers.lowerBound(gestureType),
+ typeToRecognizerEnd = m_recognizers.upperBound(gestureType);
+ for (; typeToRecognizerIterator != typeToRecognizerEnd; ++typeToRecognizerIterator) {
+ QGestureRecognizer *recognizer = typeToRecognizerIterator.value();
+ QObject *target = context.key();
QGesture *state = getState(target, recognizer, gestureType);
if (!state)
continue;
- QGestureRecognizer::Result result = recognizer->recognize(state, target, event);
- QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask;
- result &= QGestureRecognizer::ResultHint_Mask;
- if (type == QGestureRecognizer::TriggerGesture) {
+ QGestureRecognizer::Result recognizerResult = recognizer->recognize(state, target, event);
+ QGestureRecognizer::Result recognizerState = recognizerResult & QGestureRecognizer::ResultState_Mask;
+ QGestureRecognizer::Result resultHint = recognizerResult & QGestureRecognizer::ResultHint_Mask;
+ if (recognizerState == QGestureRecognizer::TriggerGesture) {
DEBUG() << "QGestureManager:Recognizer: gesture triggered: " << state;
triggeredGestures << state;
- } else if (type == QGestureRecognizer::FinishGesture) {
+ } else if (recognizerState == QGestureRecognizer::FinishGesture) {
DEBUG() << "QGestureManager:Recognizer: gesture finished: " << state;
finishedGestures << state;
- } else if (type == QGestureRecognizer::MayBeGesture) {
+ } else if (recognizerState == QGestureRecognizer::MayBeGesture) {
DEBUG() << "QGestureManager:Recognizer: maybe gesture: " << state;
newMaybeGestures << state;
- } else if (type == QGestureRecognizer::CancelGesture) {
+ } else if (recognizerState == QGestureRecognizer::CancelGesture) {
DEBUG() << "QGestureManager:Recognizer: not gesture: " << state;
notGestures << state;
- } else if (type == QGestureRecognizer::Ignore) {
+ } else if (recognizerState == QGestureRecognizer::Ignore) {
DEBUG() << "QGestureManager:Recognizer: ignored the event: " << state;
} else {
DEBUG() << "QGestureManager:Recognizer: hm, lets assume the recognizer"
<< "ignored the event: " << state;
}
- if (result & QGestureRecognizer::ConsumeEventHint) {
+ if (resultHint & QGestureRecognizer::ConsumeEventHint) {
DEBUG() << "QGestureManager: we were asked to consume the event: "
<< state;
- ret = true;
+ consumeEventHint = true;
}
}
}
if (triggeredGestures.isEmpty() && finishedGestures.isEmpty()
&& newMaybeGestures.isEmpty() && notGestures.isEmpty())
- return ret;
+ return consumeEventHint;
QSet<QGesture *> startedGestures = triggeredGestures - m_activeGestures;
triggeredGestures &= m_activeGestures;
@@ -390,7 +391,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *,
qDeleteAll(m_gesturesToDelete);
m_gesturesToDelete.clear();
- return ret;
+ return consumeEventHint;
}
// Cancel all gestures of children of the widget that original is associated with
diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp
index 9098a05..bb4ed11 100644
--- a/src/gui/kernel/qguifunctions_wince.cpp
+++ b/src/gui/kernel/qguifunctions_wince.cpp
@@ -112,6 +112,9 @@ struct AygSIPINFO
#ifndef SPI_GETSIPINFO
#define SPI_GETSIPINFO 225
#endif
+#ifndef SPI_GETPLATFORMTYPE
+#define SPI_GETPLATFORMTYPE 257
+#endif
typedef BOOL (*AygInitDialog)(AygSHINITDLGINFO*);
typedef BOOL (*AygFullScreen)(HWND, DWORD);
@@ -129,8 +132,6 @@ static void resolveAygLibs()
if (!aygResolved) {
aygResolved = true;
QLibrary ayglib(QLatin1String("aygshell"));
- if (!ayglib.load())
- return;
ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog");
ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen");
ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo");
diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/gui/kernel/qguiplatformplugin.cpp
index 636e351..011b816 100644
--- a/src/gui/kernel/qguiplatformplugin.cpp
+++ b/src/gui/kernel/qguiplatformplugin.cpp
@@ -152,7 +152,7 @@ QString QGuiPlatformPlugin::styleName()
return QLatin1String("Windows"); // default style for Symbian without S60
#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
return QLatin1String("SGI"); // default style for X11 on IRIX
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
return QLatin1String("Plastique"); // default style for X11 and small devices
#elif defined(Q_WS_MAC)
return QLatin1String("Macintosh"); // default style for all Mac's
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/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index b5473d3..3cf5dc5 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -76,7 +76,7 @@ static const MacSpecialKey entries[NumEntries] = {
{ Qt::Key_Backtab, 0x21E4 },
{ Qt::Key_Backspace, 0x232B },
{ Qt::Key_Return, 0x21B5 },
- { Qt::Key_Enter, 0x21B5 },
+ { Qt::Key_Enter, 0x2324 },
{ Qt::Key_Delete, 0x2326 },
{ Qt::Key_Home, 0x2196 },
{ Qt::Key_End, 0x2198 },
@@ -240,7 +240,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins \i Ctrl+V
\row \i Preferences \i \i Ctrl+, \i \i \i (none)
\row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14 \i Ctrl+Z
- \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z, Ctrl+Y \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none)
+ \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none)
\row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left \i (none)
\row \i Forward \i Alt+Right, Shift+Backspace \i Ctrl+] \i Alt+Right \i Alt+Right \i (none)
\row \i Refresh \i F5 \i F5 \i F5 \i Ctrl+R, F5 \i (none)
@@ -718,7 +718,6 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = {
{QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Mac},
{QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QApplicationPrivate::KB_All},
{QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_S60},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Mac},//different priority from above
{QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QApplicationPrivate::KB_All},
{QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QApplicationPrivate::KB_Mac},
{QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QApplicationPrivate::KB_Mac},
@@ -747,7 +746,7 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = {
{QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QApplicationPrivate::KB_KDE},
{QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
{QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::Redo, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac}, //different priority from above
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac},
{QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
{QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above
{QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11},
@@ -1522,6 +1521,14 @@ QKeySequence &QKeySequence::operator=(const QKeySequence &other)
}
/*!
+ \fn void QKeySequence::swap(QKeySequence &other)
+ \since 4.8
+
+ Swaps key sequence \a other with this key sequence. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn bool QKeySequence::operator!=(const QKeySequence &other) const
Returns true if this key sequence is not equal to the \a other
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index f3ab19b..9eabb89 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -179,6 +179,11 @@ public:
operator int() const;
int operator[](uint i) const;
QKeySequence &operator=(const QKeySequence &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QKeySequence &operator=(QKeySequence &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QKeySequence &other) { qSwap(d, other.d); }
bool operator==(const QKeySequence &other) const;
inline bool operator!= (const QKeySequence &other) const
{ return !(*this == other); }
diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/gui/kernel/qlayoutitem.cpp
index 929e115..aeb96e9 100644
--- a/src/gui/kernel/qlayoutitem.cpp
+++ b/src/gui/kernel/qlayoutitem.cpp
@@ -516,9 +516,7 @@ bool QWidgetItem::hasHeightForWidth() const
{
if (isEmpty())
return false;
- if (wid->layout())
- return wid->layout()->hasHeightForWidth();
- return wid->sizePolicy().hasHeightForWidth();
+ return wid->d_func()->hasHeightForWidth();
}
/*!
diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/gui/kernel/qmacdefines_mac.h
index 1d2d284..d6ccb93 100644
--- a/src/gui/kernel/qmacdefines_mac.h
+++ b/src/gui/kernel/qmacdefines_mac.h
@@ -94,12 +94,6 @@ Yes, it is an informative comment ;-)
#include <QtCore/qglobal.h>
-#undef OLD_DEBUG
-#ifdef DEBUG
-# define OLD_DEBUG DEBUG
-# undef DEBUG
-#endif
-#define DEBUG 0
#ifdef qDebug
# define old_qDebug qDebug
# undef qDebug
@@ -179,12 +173,6 @@ typedef AERecord AppleEvent;
#undef check
#endif
-#undef DEBUG
-#ifdef OLD_DEBUG
-# define DEBUG OLD_DEBUG
-# undef OLD_DEBUG
-#endif
-
#ifdef old_qDebug
# undef qDebug
# define qDebug QT_NO_QDEBUG_MACRO
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index b48ad12..dffd2cb 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -78,6 +78,14 @@ public:
QPalette(const QPalette &palette);
~QPalette();
QPalette &operator=(const QPalette &palette);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPalette &operator=(QPalette &&other)
+ {
+ resolve_mask = other.resolve_mask;
+ current_group = other.current_group;
+ qSwap(d, other.d); return *this;
+ }
+#endif
operator QVariant() const;
// Do not change the order, the serialization format depends on it
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
new file mode 100644
index 0000000..957a4df
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qplatformclipboard_qpa.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+QT_BEGIN_NAMESPACE
+
+class QClipboardData
+{
+public:
+ QClipboardData();
+ ~QClipboardData();
+
+ void setSource(QMimeData* s)
+ {
+ if (s == src)
+ return;
+ delete src;
+ src = s;
+ }
+ QMimeData* source()
+ { return src; }
+
+private:
+ QMimeData* src;
+};
+
+QClipboardData::QClipboardData()
+{
+ src = 0;
+}
+
+QClipboardData::~QClipboardData()
+{
+ delete src;
+}
+
+Q_GLOBAL_STATIC(QClipboardData,q_clipboardData);
+
+QPlatformClipboard::~QPlatformClipboard()
+{
+
+}
+
+const QMimeData *QPlatformClipboard::mimeData(QClipboard::Mode mode) const
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ return q_clipboardData()->source();
+}
+
+void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ q_clipboardData()->setSource(data);
+}
+
+bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ return mode == QClipboard::Clipboard;
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/kernel/qplatformclipboard_qpa.h
new file mode 100644
index 0000000..3381c06
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QPLATFORMCLIPBOARD_QPA_H
+#define QPLATFORMCLIPBOARD_QPA_H
+
+#include <qplatformdefs.h>
+
+#ifndef QT_NO_CLIPBOARD
+
+#include <QtGui/QClipboard>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformClipboard
+{
+public:
+ virtual ~QPlatformClipboard();
+
+ virtual const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard ) const;
+ virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
+ virtual bool supportsMode(QClipboard::Mode mode) const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_CLIPBOARD
+
+#endif //QPLATFORMCLIPBOARD_QPA_H
diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp
new file mode 100644
index 0000000..2ea8332
--- /dev/null
+++ b/src/gui/kernel/qplatformcursor_qpa.cpp
@@ -0,0 +1,660 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 "qplatformcursor_qpa.h"
+
+#include <QWidget>
+#include <QPainter>
+#include <QBitmap>
+#include <QApplication>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QList <QWeakPointer<QPlatformCursor> > QPlatformCursorPrivate::instances;
+
+/*!
+ \class QGraphicsSystemCursor
+
+ \brief The QGraphicsSystemCursor class provides information about
+ pointer device events (movement, buttons), and requests to change
+ the currently displayed cursor.
+
+ Note that QGraphicsSystemCursor does not include any graphics for
+ display. An application that sets a QCursor may provide its own
+ graphics.
+
+ \sa QGraphicsSystemCursorImage
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event)
+
+ This method is called by Qt whenever a QMouseEvent is generated by the
+ underlying pointer input. \a event is a reference to the QMouseEvent in
+ question. A default do-nothing implementation is provided.
+
+ \sa QApplicationPrivate::handleMouseEvent()
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+
+ \brief This method is called by Qt whenever the cursor graphic should be changed.
+
+ Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor.
+
+ \a widgetCursor is a pointer to the QCursor that should be displayed.
+
+ \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note
+ that this may be 0 if the current position is not occupied by a displayed widget.
+
+ \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos()
+*/
+
+/*!
+ \fn QGraphicsSystemCursor::QGraphicsSystemCursor()
+
+ \brief Constructs a QGraphicsSystemCursor
+*/
+QPlatformCursor::QPlatformCursor(QPlatformScreen *scr )
+ : screen(scr)
+{
+ QPlatformCursorPrivate::instances.append(this);
+}
+
+// End of display and pointer event handling code
+// Beginning of built-in cursor graphics
+// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp
+
+/*!
+ \class QGraphicsSystemCursorImage
+
+ \brief The QGraphicsSystemCursorImage class provides a set of graphics
+ intended to be used as cursors.
+
+ \sa QGraphicsSystemCursor
+*/
+
+static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1];
+static bool systemCursorTableInit = false;
+
+// 16 x 16
+static const uchar cur_arrow_bits[] = {
+ 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
+ 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
+ 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
+static const uchar mcur_arrow_bits[] = {
+ 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
+ 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
+ 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
+
+static const unsigned char cur_up_arrow_bits[] = {
+ 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
+ 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
+static const unsigned char mcur_up_arrow_bits[] = {
+ 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
+ 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
+
+static const unsigned char cur_cross_bits[] = {
+ 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
+static const unsigned char mcur_cross_bits[] = {
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
+
+static const uchar cur_ibeam_bits[] = {
+ 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_ibeam_bits[] = {
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
+
+static const uchar cur_ver_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
+ 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
+static const uchar mcur_ver_bits[] = {
+ 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
+ 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
+ 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
+
+static const uchar cur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
+ 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
+ 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
+ 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
+static const uchar cur_bdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
+ 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
+ 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_bdiag_bits[] = {
+ 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
+ 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
+ 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
+static const uchar cur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
+ 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
+ 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
+ 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
+ 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
+
+// 20 x 20
+static const uchar forbidden_bits[] = {
+ 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
+ 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
+ 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
+ 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
+
+static const uchar forbiddenm_bits[] = {
+ 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
+ 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
+ 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
+ 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
+
+// 32 x 32
+static const uchar wait_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
+ 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
+ 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar wait_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
+ 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar hsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
+ 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar hsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
+ 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
+ 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
+ 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phand_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
+ 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
+ 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
+ 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
+ 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phandm_bits[] = {
+ 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
+ 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
+ 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
+ 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
+ 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar size_all_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
+ 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar size_all_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
+ 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar whatsthis_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
+ 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
+ 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
+ 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
+ 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
+ 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+static const uchar whatsthism_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
+ 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
+ 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
+ 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
+ 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
+ 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+
+static const uchar busy_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+ 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
+ 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
+ 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
+ 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
+ 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static const uchar busym_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+ 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
+ 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
+ 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
+ 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
+ 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// 16 x 16
+static const uchar openhand_bits[] = {
+ 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
+ 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
+ 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
+static const uchar openhandm_bits[] = {
+ 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
+ 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
+ 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
+static const uchar closedhand_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
+ 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
+ 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
+static const uchar closedhandm_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
+ 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
+ 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
+
+void QPlatformCursorImage::createSystemCursor(int id)
+{
+ if (!systemCursorTableInit) {
+ for (int i = 0; i <= Qt::LastCursor; i++)
+ systemCursorTable[i] = 0;
+ systemCursorTableInit = true;
+ }
+ switch (id) {
+ // 16x16 cursors
+ case Qt::ArrowCursor:
+ systemCursorTable[Qt::ArrowCursor] =
+ new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
+ break;
+
+ case Qt::UpArrowCursor:
+ systemCursorTable[Qt::UpArrowCursor] =
+ new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
+ break;
+
+ case Qt::CrossCursor:
+ systemCursorTable[Qt::CrossCursor] =
+ new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::IBeamCursor:
+ systemCursorTable[Qt::IBeamCursor] =
+ new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeVerCursor:
+ systemCursorTable[Qt::SizeVerCursor] =
+ new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeHorCursor:
+ systemCursorTable[Qt::SizeHorCursor] =
+ new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeBDiagCursor:
+ systemCursorTable[Qt::SizeBDiagCursor] =
+ new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeFDiagCursor:
+ systemCursorTable[Qt::SizeFDiagCursor] =
+ new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::BlankCursor:
+ systemCursorTable[Qt::BlankCursor] =
+ new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+ break;
+
+ // 20x20 cursors
+ case Qt::ForbiddenCursor:
+ systemCursorTable[Qt::ForbiddenCursor] =
+ new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
+ break;
+
+ // 32x32 cursors
+ case Qt::WaitCursor:
+ systemCursorTable[Qt::WaitCursor] =
+ new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitVCursor:
+ systemCursorTable[Qt::SplitVCursor] =
+ new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitHCursor:
+ systemCursorTable[Qt::SplitHCursor] =
+ new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SizeAllCursor:
+ systemCursorTable[Qt::SizeAllCursor] =
+ new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::PointingHandCursor:
+ systemCursorTable[Qt::PointingHandCursor] =
+ new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::WhatsThisCursor:
+ systemCursorTable[Qt::WhatsThisCursor] =
+ new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
+ break;
+ case Qt::BusyCursor:
+ systemCursorTable[Qt::BusyCursor] =
+ new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::OpenHandCursor:
+ systemCursorTable[Qt::OpenHandCursor] =
+ new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8);
+ break;
+ case Qt::ClosedHandCursor:
+ systemCursorTable[Qt::ClosedHandCursor] =
+ new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
+ break;
+ default:
+ qWarning("Unknown system cursor %d", id);
+ }
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id)
+
+ \brief Calling this method sets the cursor image to the specified shape
+
+ \a id is one of the defined Qt::CursorShape values.
+
+ If id is invalid, Qt::BitmapCursor, or unknown by the implementation,
+ Qt::ArrowCursor is used instead.
+*/
+
+void QPlatformCursorImage::set(Qt::CursorShape id)
+{
+ QPlatformCursorImage *cursor = 0;
+ if (id >= 0 && id <= Qt::LastCursor) {
+ if (!systemCursorTable[id])
+ createSystemCursor(id);
+ cursor = systemCursorTable[id];
+ }
+
+ if (cursor == 0) {
+ if (!systemCursorTable[Qt::ArrowCursor])
+ createSystemCursor(Qt::ArrowCursor);
+ cursor = systemCursorTable[Qt::ArrowCursor];
+ }
+ cursorImage = cursor->cursorImage;
+ hot = cursor->hot;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy)
+
+ \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy)
+
+ \a image A pointer to a QImage
+
+ \a hx The x coordinate of the cursor's hotspot
+
+ \a hy the y coordinate of the cursor's hotspot
+*/
+
+void QPlatformCursorImage::set(const QImage &image, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+ cursorImage = image;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hx The X hotspot of the cursor graphic
+
+ \a hy The Y hotspot of the cursor graphic
+*/
+void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
+ int width, int height, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+
+ cursorImage = QImage(width,height, QImage::Format_Indexed8);
+
+ if (!width || !height || !data || !mask || cursorImage.isNull())
+ return;
+
+ cursorImage.setNumColors(3);
+ cursorImage.setColor(0, 0xff000000);
+ cursorImage.setColor(1, 0xffffffff);
+ cursorImage.setColor(2, 0x00000000);
+
+ int bytesPerLine = (width + 7) / 8;
+ int p = 0;
+ int d, m;
+
+ int x = -1, w = 0;
+
+ uchar *cursor_data = cursorImage.bits();
+ int bpl = cursorImage.bytesPerLine();
+ for (int i = 0; i < height; i++)
+ {
+ for (int j = 0; j < bytesPerLine; j++, data++, mask++)
+ {
+ for (int b = 0; b < 8 && j*8+b < width; b++)
+ {
+ d = *data & (1 << b);
+ m = *mask & (1 << b);
+ if (d && m) p = 0;
+ else if (!d && m) p = 1;
+ else p = 2;
+ cursor_data[j*8+b] = p;
+
+ // calc region
+ if (x < 0 && m)
+ x = j*8+b;
+ else if (x >= 0 && !m) {
+ x = -1;
+ w = 0;
+ }
+ if (m)
+ w++;
+ }
+ }
+ if (x >= 0) {
+ x = -1;
+ w = 0;
+ }
+ cursor_data += bpl;
+ }
+
+}
+
+/*!
+ \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hotX The X hotspot of the cursor graphic
+
+ \a hotY The Y hotspot of the cursor graphic
+
+ \sa set
+*/
+
+/*!
+ \fn QImage *QGraphicsSystemCursorImage::image()
+
+ \brief Return the cursor graphic as a pointer to a QImage
+*/
+
+/*!
+ \fn QPoint QGraphicsSystemCursorImage::hotspot()
+
+ \brief Return the cursor's hotspot
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformcursor_qpa.h b/src/gui/kernel/qplatformcursor_qpa.h
new file mode 100644
index 0000000..71d0e87
--- /dev/null
+++ b/src/gui/kernel/qplatformcursor_qpa.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 QGRAPHICSSYSTEMCURSOR_H
+#define QGRAPHICSSYSTEMCURSOR_H
+
+#include <QtCore/QList>
+#include <QtGui/QImage>
+#include <QtGui/QMouseEvent>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QObject>
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QCursor>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+// Cursor graphics management
+class Q_GUI_EXPORT QPlatformCursorImage {
+public:
+ QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+ { set(data, mask, width, height, hotX, hotY); }
+ QImage * image() { return &cursorImage; }
+ QPoint hotspot() { return hot; }
+ void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
+ void set(const QImage &image, int hx, int hy);
+ void set(Qt::CursorShape);
+private:
+ static void createSystemCursor(int id);
+ QImage cursorImage;
+ QPoint hot;
+};
+
+class QPlatformCursor;
+
+class QPlatformCursorPrivate {
+public:
+ static QList<QWeakPointer<QPlatformCursor> > getInstances() { return instances; }
+ static QList<QWeakPointer<QPlatformCursor> > instances;
+};
+
+class Q_GUI_EXPORT QPlatformCursor : public QObject {
+public:
+ QPlatformCursor(QPlatformScreen *);
+
+ // input methods
+ virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
+ virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0;
+
+protected:
+ QPlatformScreen* screen; // Where to request an update
+
+private:
+ Q_DECLARE_PRIVATE(QPlatformCursor);
+ friend void qt_qpa_set_cursor(QWidget * w, bool force);
+ friend class QApplicationPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRAPHICSSYSTEMCURSOR_H
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
new file mode 100644
index 0000000..0ed43eb
--- /dev/null
+++ b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformeventloopintegration_qpa.h"
+
+#include <QtCore/QCoreApplication>
+
+#include <QtCore/QDebug>
+
+class QPlatformEventLoopIntegrationPrivate
+{
+public:
+ QPlatformEventLoopIntegrationPrivate();
+ qint64 nextTimerEvent;
+};
+
+QPlatformEventLoopIntegrationPrivate::QPlatformEventLoopIntegrationPrivate()
+ : nextTimerEvent(0)
+{
+}
+
+QPlatformEventLoopIntegration::QPlatformEventLoopIntegration()
+ : d_ptr(new QPlatformEventLoopIntegrationPrivate)
+
+{
+}
+
+QPlatformEventLoopIntegration::~QPlatformEventLoopIntegration()
+{
+}
+
+qint64 QPlatformEventLoopIntegration::nextTimerEvent() const
+{
+ Q_D(const QPlatformEventLoopIntegration);
+ return d->nextTimerEvent;
+}
+
+
+void QPlatformEventLoopIntegration::setNextTimerEvent(qint64 nextTimerEvent)
+{
+ Q_D(QPlatformEventLoopIntegration);
+ d->nextTimerEvent = nextTimerEvent;
+}
+
+void QPlatformEventLoopIntegration::processEvents()
+{
+ QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
+}
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h
new file mode 100644
index 0000000..87df7ae
--- /dev/null
+++ b/src/gui/kernel/qplatformeventloopintegration_qpa.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 QPLATFORMEVENTLOOPINTEGRATION_QPA_H
+#define QPLATFORMEVENTLOOPINTEGRATION_QPA_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/QScopedPointer>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformEventLoopIntegrationPrivate;
+
+class Q_GUI_EXPORT QPlatformEventLoopIntegration
+{
+ Q_DECLARE_PRIVATE(QPlatformEventLoopIntegration);
+public:
+ QPlatformEventLoopIntegration();
+ virtual ~QPlatformEventLoopIntegration();
+
+ virtual void startEventLoop() = 0;
+ virtual void quitEventLoop() = 0;
+ virtual void qtNeedsToProcessEvents() = 0;
+
+ qint64 nextTimerEvent() const;
+ void setNextTimerEvent(qint64 nextTimerEvent);
+
+ static void processEvents();
+protected:
+ QScopedPointer<QPlatformEventLoopIntegrationPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformEventLoopIntegration);
+ friend class QEventDispatcherQPA;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp
new file mode 100644
index 0000000..86740e8
--- /dev/null
+++ b/src/gui/kernel/qplatformglcontext_qpa.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 "qplatformglcontext_qpa.h"
+
+#include <QtCore/QThreadStorage>
+#include <QtCore/QThread>
+
+#include <QDebug>
+
+class QPlatformGLThreadContext
+{
+public:
+ ~QPlatformGLThreadContext() {
+ if (context)
+ context->doneCurrent();
+ }
+ QPlatformGLContext *context;
+};
+
+static QThreadStorage<QPlatformGLThreadContext *> qplatformgl_context_storage;
+
+class QPlatformGLContextPrivate
+{
+public:
+ QPlatformGLContextPrivate()
+ :qGLContextHandle(0)
+ {
+ }
+
+ virtual ~QPlatformGLContextPrivate()
+ {
+ //do not delete the QGLContext handle here as it is deleted in
+ //QWidgetPrivate::deleteTLSysExtra()
+ }
+ void *qGLContextHandle;
+ void (*qGLContextDeleteFunction)(void *handle);
+ static QPlatformGLContext *staticSharedContext;
+
+ static void setCurrentContext(QPlatformGLContext *context);
+};
+
+QPlatformGLContext *QPlatformGLContextPrivate::staticSharedContext = 0;
+
+void QPlatformGLContextPrivate::setCurrentContext(QPlatformGLContext *context)
+{
+ QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData();
+ if (!threadContext) {
+ if (!QThread::currentThread()) {
+ qWarning("No QTLS available. currentContext wont work");
+ return;
+ }
+ threadContext = new QPlatformGLThreadContext;
+ qplatformgl_context_storage.setLocalData(threadContext);
+ }
+ threadContext->context = context;
+}
+
+/*!
+ Returns the last context which called makeCurrent. This function is thread aware.
+*/
+const QPlatformGLContext* QPlatformGLContext::currentContext()
+{
+ QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData();
+ if(threadContext) {
+ return threadContext->context;
+ }
+ return 0;
+}
+
+/*!
+ All subclasses needs to specify the platformWindow. It can be a null window.
+*/
+QPlatformGLContext::QPlatformGLContext()
+ :d_ptr(new QPlatformGLContextPrivate())
+{
+}
+
+/*!
+ If this is the current context for the thread, doneCurrent is called
+*/
+QPlatformGLContext::~QPlatformGLContext()
+{
+ if (QPlatformGLContext::currentContext() == this) {
+ doneCurrent();
+ }
+
+}
+
+
+/*!
+ Makes it possible to set the context which can be the default for making new contexts.
+*/
+void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext)
+{
+ QPlatformGLContextPrivate::staticSharedContext = sharedContext;
+}
+
+/*!
+ Default shared context is intended to be a globally awailable pointer to a context which can
+ be used for sharing resources when creating new contexts. Its default value is 0;
+*/
+QPlatformGLContext *QPlatformGLContext::defaultSharedContext()
+{
+ return QPlatformGLContextPrivate::staticSharedContext;
+}
+
+/*!
+ Reimplement in subclass to do makeCurrent on native GL context
+*/
+void QPlatformGLContext::makeCurrent()
+{
+ QPlatformGLContextPrivate::setCurrentContext(this);
+}
+
+/*!
+ Reimplement in subclass to release current context.
+ Typically this is calling makeCurrent with 0 "surface"
+*/
+void QPlatformGLContext::doneCurrent()
+{
+ QPlatformGLContextPrivate::setCurrentContext(0);
+}
+
+/*
+ internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
+ have any type information.
+*/
+void *QPlatformGLContext::qGLContextHandle() const
+{
+ Q_D(const QPlatformGLContext);
+ return d->qGLContextHandle;
+}
+
+void QPlatformGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))
+{
+ Q_D(QPlatformGLContext);
+ d->qGLContextHandle = handle;
+ d->qGLContextDeleteFunction = qGLContextDeleteFunction;
+}
+
+void QPlatformGLContext::deleteQGLContext()
+{
+ Q_D(QPlatformGLContext);
+ if (d->qGLContextDeleteFunction && d->qGLContextHandle) {
+ d->qGLContextDeleteFunction(d->qGLContextHandle);
+ d->qGLContextDeleteFunction = 0;
+ d->qGLContextHandle = 0;
+ }
+}
+
+/*!
+ \class QPlatformGLContext
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformGLContext class provides an abstraction for native GL contexts.
+
+ In QPA the way to support OpenGL or OpenVG or other technologies that requires a native GL
+ context is through the QPlatformGLContext wrapper.
+
+ There is no factory function for QPlatformGLContexts, but rather only one accessor function.
+ The only place to retrieve a QPlatformGLContext from is through a QPlatformWindow.
+
+ The context which is current for a specific thread can be collected by the currentContext()
+ function. This is how QPlatformGLContext also makes it possible to use the QtOpenGL module
+ withhout using QGLWidget. When using QGLContext::currentContext(), it will ask
+ QPlatformGLContext for the currentContext. Then a corresponding QGLContext will be returned,
+ which maps to the QPlatformGLContext.
+*/
+
+/*! \fn void swapBuffers()
+ Reimplement in subclass to native swap buffers calls
+*/
+
+/*! getProcAddress(const QString& procName)
+ Reimplement in subclass to native getProcAddr calls.
+
+ Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer
+*/
+
+/*! platformWindowFormat() const
+ QWidget has the function qplatformWindowFormat(). That function is for the application
+ programmer to request the format of the window and the context that he wants.
+
+ Reimplement this function in a subclass to indicate what format the glContext actually has.
+*/
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
new file mode 100644
index 0000000..a680c85
--- /dev/null
+++ b/src/gui/kernel/qplatformglcontext_qpa.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 QPLATFORM_GL_CONTEXT_H
+#define QPLATFORM_GL_CONTEXT_H
+
+#include <QtCore/qnamespace.h>
+#include <QtGui/QPlatformWindowFormat>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformGLContextPrivate;
+
+class Q_OPENGL_EXPORT QPlatformGLContext
+{
+Q_DECLARE_PRIVATE(QPlatformGLContext);
+
+public:
+ explicit QPlatformGLContext();
+ virtual ~QPlatformGLContext();
+
+ virtual void makeCurrent();
+ virtual void doneCurrent();
+ virtual void swapBuffers() = 0;
+ virtual void* getProcAddress(const QString& procName) = 0;
+
+ virtual QPlatformWindowFormat platformWindowFormat() const = 0;
+
+ const static QPlatformGLContext *currentContext();
+ static QPlatformGLContext *defaultSharedContext();
+
+protected:
+
+ static void setDefaultSharedContext(QPlatformGLContext *sharedContext);
+
+ QScopedPointer<QPlatformGLContextPrivate> d_ptr;
+private:
+ //hack to make it work with QGLContext::CurrentContext
+ friend class QGLContext;
+ friend class QWidgetPrivate;
+ void *qGLContextHandle() const;
+ void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *));
+ void deleteQGLContext();
+ Q_DISABLE_COPY(QPlatformGLContext);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QPLATFORM_GL_INTEGRATION_P_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
new file mode 100644
index 0000000..c45a953
--- /dev/null
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -0,0 +1,234 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformintegration_qpa.h"
+
+#include <QtGui/QPlatformFontDatabase>
+#include <QtGui/QPlatformClipboard>
+
+QT_BEGIN_NAMESPACE
+
+QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ Q_UNUSED(window);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ return QPixmap();
+}
+
+/*!
+ Factory function for the eventloop integration interface.
+
+ Default implementation returns 0, which causes the eventloop to run in a single thread mode.
+
+ \sa QPlatformEventLoopIntegration
+*/
+QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
+{
+ return 0;
+}
+
+/*!
+ Returns whether the given platform integration supports OpenGL.
+
+ Default implementation returns false,
+*/
+bool QPlatformIntegration::hasOpenGL() const
+{
+ return false;
+}
+
+/*!
+ Accessor for the platform integrations fontdatabase.
+
+ Default implementation returns a default QPlatformFontDatabase.
+
+ \sa QPlatformFontDatabase
+*/
+QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
+{
+ static QPlatformFontDatabase *db = 0;
+ if (!db) {
+ db = new QPlatformFontDatabase;
+ }
+ return db;
+}
+
+/*!
+ Accessor for the platform integrations clipboard.
+
+ Default implementation returns a default QPlatformClipboard.
+
+ \sa QPlatformClipboard
+
+*/
+
+#ifndef QT_NO_CLIPBOARD
+
+QPlatformClipboard *QPlatformIntegration::clipboard() const
+{
+ static QPlatformClipboard *clipboard = 0;
+ if (!clipboard) {
+ clipboard = new QPlatformClipboard;
+ }
+ return clipboard;
+}
+
+#endif
+
+QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformIntegration
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+ \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
+
+ QPlatformIntegration is the single entry point for windowsystem specific functionality when
+ using the QPA platform. It has factory functions for creating platform specific pixmaps and
+ windows. The class also controls the font subsystem.
+
+ QPlatformIntegration is a singelton class which gets instansiated in the QApplication
+ constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
+ functions where the name starts with create. However, functions which don't have a name
+ starting with create acts as assessors to member variables.
+
+ It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefor
+ the recommended approach for making new platform plugin is to copy an existing plugin inside
+ the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
+
+ The minimal platformintegration is the smallest platform integration it is possible to make,
+ which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
+ consider reviewing the directfb plugin, or the testlite plugin.
+*/
+
+/*!
+ \fn QPixmapData *createPixmapData(QPixmapData::PixelType type) const
+
+ Factory function for QPixmapData. PixelType can be either PixmapType or BitmapType.
+ \sa QPixmapData
+*/
+
+/*!
+ \fn QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const
+
+ Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
+ widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
+ never used, but there for future reference. Its purpose is if it is going to be possible to
+ create QPlatformWindows on existing WId.
+
+ All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set
+ to be visible for the first time. If the tlw's window flags are changed, or if the tlw's
+ QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is
+ created.
+
+ \sa QPlatformWindow, QPlatformWindowFormat
+ \sa createWindowSurface(QWidget *widget, WId winId) const
+*/
+
+/*!
+ \fn QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const
+
+ Factory function for QWindowSurface. The QWidget parameter is a pointer to the
+ top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
+ before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is
+ possible to create top level QWidgets without a QWindowSurface by specifying
+ QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.
+
+ \sa QWindowSurface
+ \sa createPlatformWindow(QWidget *widget, WId winId = 0) const
+*/
+
+/*!
+ \fn void moveToScreen(QWidget *window, int screen)
+
+ This function is called when a QWidget is displayed on screen, or the QWidget is to be
+ displayed on a new screen. The QWidget parameter is a pointer to the top level widget and
+ the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
+
+ Default implementation does nothing.
+
+ \sa screens() const
+*/
+
+/*!
+ \fn QList<QPlatformScreen *> screens() const
+
+ Accessor function to a list of all the screens on the current system. The screen with the
+ index == 0 is the default/main screen.
+*/
+
+/*!
+ \fn bool isVirtualDesktop()
+
+ Returns if the current windowing system configuration defines all the screens to be one
+ desktop(virtual desktop), or if each screen is a desktop of its own.
+
+ Default implementation returns false.
+*/
+
+/*!
+ \fn QPixmap grabWindow(WId window, int x, int y, int width, int height) const
+
+ This function is called when Qt needs to be able to grab the content of a window.
+
+ Returnes the content of the window specified with the WId handle within the boundaries of
+ QRect(x,y,width,height).
+*/
+
+
+bool QPlatformIntegration::hasCapability(Capability cap) const
+{
+ return false;
+}
+
+
+
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
new file mode 100644
index 0000000..0aacefa
--- /dev/null
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** 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 QPLATFORMINTEGRATION_H
+#define QPLATFORMINTEGRATION_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtGui/qplatformscreen_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindow;
+class QWindowSurface;
+class QBlittable;
+class QWidget;
+class QPlatformEventLoopIntegration;
+class QPlatformFontDatabase;
+class QPlatformClipboard;
+class QPlatformNativeInterface;
+
+class Q_GUI_EXPORT QPlatformIntegration
+{
+public:
+ enum Capability {
+ ThreadedPixmaps = 1,
+ };
+
+ virtual ~QPlatformIntegration() { }
+
+ virtual bool hasCapability(Capability cap) const;
+
+// GraphicsSystem functions
+ virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
+ virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0;
+ virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0;
+
+// Window System functions
+ virtual QList<QPlatformScreen *> screens() const = 0;
+ virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
+ virtual bool isVirtualDesktop() { return false; }
+ virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+//Deeper window system integrations
+ virtual QPlatformFontDatabase *fontDatabase() const;
+#ifndef QT_NO_CLIPBOARD
+ virtual QPlatformClipboard *clipboard() const;
+#endif
+
+// Experimental in mainthread eventloop integration
+// This should only be used if it is only possible to do window system event processing in
+// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
+ virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+//jl:XXX should it be hasGLContext and do we need it at all?
+ virtual bool hasOpenGL() const;
+
+// Access native handles. The window handle is already available from Wid;
+ virtual QPlatformNativeInterface *nativeInterface() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
new file mode 100644
index 0000000..4135c9e
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformintegrationfactory_qpa_p.h"
+#include <QPlatformIntegrationPlugin>
+#include "private/qfactoryloader_p.h"
+#include "qmutex.h"
+
+#include "qapplication.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
+{
+ QPlatformIntegration *ret = 0;
+ QStringList paramList = key.split(QLatin1Char(':'));
+ QString platform = paramList.takeFirst().toLower();
+
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ // Try loading the plugin from platformPluginPath first:
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ if (QPlatformIntegrationFactoryInterface *factory =
+ qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
+ ret = factory->create(key, paramList);
+
+ if (ret)
+ return ret;
+ }
+ if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
+ ret = factory->create(platform, paramList);
+#endif
+
+ return ret;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the keys this factory can
+ create styles for.
+
+ \sa create()
+*/
+QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
+{
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ QStringList list;
+
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ foreach (const QString &key, directLoader()->keys()) {
+ list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
+ }
+ }
+
+ list += loader()->keys();
+#else
+ QStringList list;
+#endif
+ return list;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
new file mode 100644
index 0000000..a6042a8
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 QPLATFORMINTEGRATIONFACTORY_H
+#define QPLATFORMINTEGRATIONFACTORY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformIntegration;
+
+class QPlatformIntegrationFactory
+{
+public:
+ static QStringList keys(const QString &platformPluginPath = QString());
+ static QPlatformIntegration *create(const QString &key, const QString &platformPluginPath = QString());
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATIONFACTORY_H
+
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.cpp b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp
new file mode 100644
index 0000000..62920b6
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformintegrationplugin_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.h b/src/gui/kernel/qplatformintegrationplugin_qpa.h
new file mode 100644
index 0000000..17bcba0
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationplugin_qpa.h
@@ -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 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 QPLATFORMINTEGRATIONPLUGIN_H
+#define QPLATFORMINTEGRATIONPLUGIN_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformIntegration;
+
+struct QPlatformIntegrationFactoryInterface : public QFactoryInterface
+{
+ virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList) = 0;
+};
+
+#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface"
+
+Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid)
+
+class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject, public QPlatformIntegrationFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QPlatformIntegrationFactoryInterface:QFactoryInterface)
+public:
+ explicit QPlatformIntegrationPlugin(QObject *parent = 0);
+ ~QPlatformIntegrationPlugin();
+
+ virtual QStringList keys() const = 0;
+ virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATIONPLUGIN_H
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
new file mode 100644
index 0000000..ace4a7b
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformnativeinterface_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(widget);
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h
new file mode 100644
index 0000000..5ea2c13
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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 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 QPLATFORMNATIVEINTERFACE_QPA_H
+#define QPLATFORMNATIVEINTERFACE_QPA_H
+
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidget;
+
+class Q_GUI_EXPORT QPlatformNativeInterface
+{
+public:
+ virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMNATIVEINTERFACE_QPA_H
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
new file mode 100644
index 0000000..c9f3dc6
--- /dev/null
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformscreen_qpa.h"
+#include <QtGui/qapplication.h>
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/qdesktopwidget.h>
+#include <QtGui/qplatformintegration_qpa.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/private/qwidget_p.h>
+
+/*!
+ Return the given top level widget for a given position.
+
+ Default implementation retrieves a list of all top level widgets and finds the first widget
+ which contains point \a pos
+*/
+QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const
+{
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = list.size()-1; i >= 0; --i) {
+ QWidget *w = list[i];
+ //### mask is ignored
+ if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
+ return w;
+ }
+
+ return 0;
+}
+
+/*! \fn physicalSize() const
+ Reimplement in subclass to return the physical size of the screen. This function is used by
+ QFont to convert point sizes to pixel sizes.
+
+ Default implementation takes the pixel size of the screen, considers a dpi of 100 and returns
+ the calculated (and probably wrong) physical size
+*/
+QSize QPlatformScreen::physicalSize() const
+{
+ static const int dpi = 100;
+ int width = geometry().width() / dpi * qreal(25.4) ;
+ int height = geometry().height() / dpi * qreal(25.4) ;
+ return QSize(width,height);
+}
+
+Q_GUI_EXPORT extern QWidgetPrivate *qt_widget_private(QWidget *widget);
+QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget)
+{
+ QWidget *window = widget->window();
+ QWidgetPrivate *windowPrivate = qt_widget_private(window);
+ QTLWExtra * topData = windowPrivate->topData();
+ QPlatformIntegration *integration =
+ QApplicationPrivate::platformIntegration();
+ return integration->screens()[topData->screenIndex];
+}
+
+/*!
+ \class QPlatformScreen
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformScreen class provides an abstraction for visual displays.
+
+ Many window systems has support for retrieving information on the attached displays. To be able
+ to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the
+ physicalSize() function, since this is the function it uses to calculate the dpi to use when
+ converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the
+ native system fakes its dpi size.
+
+ QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop.
+ */
+
+/*! \fn geometry() const
+ Reimplement in subclass to return the pixel geometry of the screen
+*/
+
+/*! \fn availableGeometry() const
+ Reimplement in subclass to return the pixel geometry of the available space
+ This normally is the desktop screen minus the task manager, global menubar etc.
+*/
+
+/*! \fn depth() const
+ Reimplement in subclass to return current depth of the screen
+*/
+
+/*! \fn format() const
+ Reimplement in subclass to return the image format which corresponds to the screen format
+*/
+
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
new file mode 100644
index 0000000..b3bb121
--- /dev/null
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QPLATFORMSCREEN_H
+#define QPLATFORMSCREEN_H
+
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qobject.h>
+
+#include <QtGui/qcursor.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformScreen : public QObject
+{
+ Q_OBJECT
+public:
+ virtual ~QPlatformScreen() { }
+
+ virtual QRect geometry() const = 0;
+ virtual QRect availableGeometry() const {return geometry();}
+ virtual int depth() const = 0;
+ virtual QImage::Format format() const = 0;
+ virtual QSize physicalSize() const;
+ //jl: should setDirty be removed.
+ virtual void setDirty(const QRect &) {}
+ virtual QWidget *topLevelAt(const QPoint &point) const;
+
+ //jl: should this function be in QPlatformIntegration
+ //jl: maybe screenForWidget is a better name?
+ static QPlatformScreen *platformScreenForWidget(const QWidget *widget);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
new file mode 100644
index 0000000..19bf7a9
--- /dev/null
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformwindow_qpa.h"
+
+#include <QtGui/qwindowsysteminterface_qpa.h>
+#include <QtGui/qwidget.h>
+
+class QPlatformWindowPrivate
+{
+ QWidget *tlw;
+ QRect rect;
+ Qt::WindowFlags flags;
+ friend class QPlatformWindow;
+};
+
+/*!
+ Constructs a platform window with the given top level widget.
+*/
+
+QPlatformWindow::QPlatformWindow(QWidget *tlw)
+ : d_ptr(new QPlatformWindowPrivate)
+{
+ Q_D(QPlatformWindow);
+ d->tlw = tlw;
+ tlw->setPlatformWindow(this);
+}
+
+/*!
+ Virtual destructor does not delete its top level widget.
+*/
+QPlatformWindow::~QPlatformWindow()
+{
+}
+
+/*!
+ Returnes the widget which belongs to the QPlatformWindow
+*/
+QWidget *QPlatformWindow::widget() const
+{
+ Q_D(const QPlatformWindow);
+ return d->tlw;
+}
+
+/*!
+ This function is called by Qt whenever a window is moved or the window is resized. The resize
+ can happen programatically(from ie. user application) or by the window manager. This means that
+ there is no need to call this function specifically from the window manager callback, instead
+ call QWindowSystemInterface::handleGeometryChange(QWidget *w, const QRect &newRect);
+*/
+void QPlatformWindow::setGeometry(const QRect &rect)
+{
+ Q_D(QPlatformWindow);
+ d->rect = rect;
+}
+
+/*!
+ Returnes the current geometry of a window
+*/
+QRect QPlatformWindow::geometry() const
+{
+ Q_D(const QPlatformWindow);
+ return d->rect;
+}
+
+/*!
+ Reimplemented in subclasses to show the surface
+ if \a visible is \c true, and hide it if \a visible is \c false.
+*/
+void QPlatformWindow::setVisible(bool visible)
+{
+ Q_UNUSED(visible);
+}
+/*!
+ Requests setting the window flags of this surface
+ to \a type. Returns the actual flags set.
+*/
+Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ Q_D(QPlatformWindow);
+ d->flags = flags;
+ return flags;
+}
+
+/*!
+ Returns the effective window flags for this surface.
+*/
+Qt::WindowFlags QPlatformWindow::windowFlags() const
+{
+ Q_D(const QPlatformWindow);
+ return d->flags;
+}
+
+/*!
+ Reimplement in subclasses to return a handle to the native window
+*/
+WId QPlatformWindow::winId() const { return WId(0); }
+
+/*!
+ This function is called to enable native child widgets in QPA. It is common not to support this
+ feature in Window systems, but can be faked. When this function is called all geometry of this
+ platform window will be relative to the parent.
+*/
+//jl: It would be useful to have a property on the platform window which indicated if the sub-class
+// supported the setParent. If not, then geometry would be in screen coordinates.
+void QPlatformWindow::setParent(const QPlatformWindow *parent)
+{
+ Q_UNUSED(parent);
+ qWarning("This plugin does not support setParent!");
+}
+
+/*!
+ Reimplement to set the window title to \a title
+*/
+void QPlatformWindow::setWindowTitle(const QString &title) {}
+
+/*!
+ Reimplement to be able to let Qt rais windows to the top of the desktop
+*/
+void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); }
+
+/*!
+ Reimplement to be able to let Qt lower windows to the bottom of the desktop
+*/
+void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); }
+
+/*!
+ Reimplement to be able to let Qt set the opacity level of a window
+*/
+void QPlatformWindow::setOpacity(qreal level)
+{
+ Q_UNUSED(level);
+ qWarning("This plugin does not support setting window opacity");
+}
+
+/*!
+ Reimplement to let Qt be able to request activation/focus for a window
+
+ Some window systems will probably not have callbacks for this functionality,
+ and then calling QWindowSystemInterface::handleWindowActivated(QWidget *w)
+ would be sufficient.
+
+ If the window system has some event handling/callbacks then call
+ QWindowSystemInterface::handleWindowActivated(QWidget *w) when the window system
+ gives the notification.
+
+ Default implementation calls QWindowSystem::handleWindowActivated(QWidget *w)
+*/
+void QPlatformWindow::requestActivateWindow()
+{
+ QWindowSystemInterface::handleWindowActivated(widget());
+}
+
+/*!
+ Reimplement to return the glContext associated with the window.
+*/
+QPlatformGLContext *QPlatformWindow::glContext() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformWindow
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformWindow class provides an abstraction for top-level windows.
+
+ The QPlatformWindow abstraction is used by QWidget for all its top level widgets. It is being
+ created by calling the createPlatformWindow function in the loaded QPlatformIntegration
+ instance.
+
+ QPlatformWindow is used to signal to the windowing system, how Qt persieves its frame.
+ However, it is not concerned with how Qt renders into the window it represents.
+
+ Top level QWidgets(tlw) will always have a QPlatformWindow. However, it is not necessary for
+ all tlw to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
+ widgets where some 3.party renders into it.
+
+ The platform specific window handle can be retrieved by the winId function.
+
+ QPlatformWindow is also the way QPA defines how native child windows should be supported
+ through the setParent function.
+
+ The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
+ on QPlatformWindow.
+
+ \sa QWindowSurface, QWidget
+*/
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
new file mode 100644
index 0000000..41a4bac
--- /dev/null
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QPLATFORMWINDOW_H
+#define QPLATFORMWINDOW_H
+
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qwindowdefs.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindowPrivate;
+class QWidget;
+class QPlatformGLContext;
+
+class Q_GUI_EXPORT QPlatformWindow
+{
+ Q_DECLARE_PRIVATE(QPlatformWindow)
+public:
+ QPlatformWindow(QWidget *tlw);
+ virtual ~QPlatformWindow();
+
+ QWidget *widget() const;
+ virtual void setGeometry(const QRect &rect);
+ virtual QRect geometry() const;
+
+ virtual void setVisible(bool visible);
+ virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ virtual Qt::WindowFlags windowFlags() const;
+ virtual WId winId() const;
+ virtual void setParent(const QPlatformWindow *window);
+
+ virtual void setWindowTitle(const QString &title);
+ virtual void raise();
+ virtual void lower();
+
+ virtual void setOpacity(qreal level);
+ virtual void requestActivateWindow();
+
+ virtual QPlatformGLContext *glContext() const;
+protected:
+ QScopedPointer<QPlatformWindowPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformWindow)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp
new file mode 100644
index 0000000..ddc6239
--- /dev/null
+++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp
@@ -0,0 +1,1019 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformwindowformat_qpa.h"
+
+#include <QtCore/QDebug>
+
+Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format);
+
+class QPlatformWindowFormatPrivate
+{
+public:
+ QPlatformWindowFormatPrivate()
+ : ref(1)
+ , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer
+ | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering
+ | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions
+ | QPlatformWindowFormat::UseDefaultSharedContext | QPlatformWindowFormat::HasWindowSurface)
+ , depthSize(-1)
+ , accumSize(-1)
+ , stencilSize(-1)
+ , redSize(-1)
+ , greenSize(-1)
+ , blueSize(-1)
+ , alphaSize(-1)
+ , numSamples(-1)
+ , swapInterval(-1)
+ , windowApi(QPlatformWindowFormat::Raster)
+ , sharedContext(0)
+ {
+ }
+
+ QPlatformWindowFormatPrivate(const QPlatformWindowFormatPrivate *other)
+ : ref(1),
+ opts(other->opts),
+ depthSize(other->depthSize),
+ accumSize(other->accumSize),
+ stencilSize(other->stencilSize),
+ redSize(other->redSize),
+ greenSize(other->greenSize),
+ blueSize(other->blueSize),
+ alphaSize(other->alphaSize),
+ numSamples(other->numSamples),
+ swapInterval(other->swapInterval),
+ windowApi(other->windowApi),
+ sharedContext(other->sharedContext)
+ {
+ }
+ QAtomicInt ref;
+ QPlatformWindowFormat::FormatOptions opts;
+ int depthSize;
+ int accumSize;
+ int stencilSize;
+ int redSize;
+ int greenSize;
+ int blueSize;
+ int alphaSize;
+ int numSamples;
+ int swapInterval;
+ QPlatformWindowFormat::WindowApi windowApi;
+ QPlatformGLContext *sharedContext;
+};
+
+/*!
+ \class QPlatformWindowFormat
+ \brief The QPlatformWindowFormat class specifies the display format of an OpenGL
+ rendering context and if possible attributes of the corresponding QPlatformWindow.
+
+ \ingroup painting
+
+ QWidget has a setter and getter function for QPlatformWindowFormat. These functions can be used
+ by the application programmer to signal what kind of format he wants to the window and glcontext
+ should have. However, it is not always possible to fulfill these requirements. The application
+ programmer should therefore check the resulting QPlatformWindowFormat from QPlatformGLContext
+ to see the format that was actually created.
+
+ A display format has several characteristics:
+ \list
+ \i \link setDoubleBuffer() Double or single buffering.\endlink
+ \i \link setDepth() Depth buffer.\endlink
+ \i \link setRgba() RGBA or color index mode.\endlink
+ \i \link setAlpha() Alpha channel.\endlink
+ \i \link setAccum() Accumulation buffer.\endlink
+ \i \link setStencil() Stencil buffer.\endlink
+ \i \link setStereo() Stereo buffers.\endlink
+ \i \link setDirectRendering() Direct rendering.\endlink
+ \i \link setOverlay() Presence of an overlay.\endlink
+ \i \link setPlane() Plane of an overlay.\endlink
+ \i \link setSampleBuffers() Multisample buffers.\endlink
+ \endlist
+
+ You can also specify preferred bit depths for the color buffer,
+ depth buffer, alpha buffer, accumulation buffer and the stencil
+ buffer with the functions: setRedBufferSize(), setGreenBufferSize(),
+ setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(),
+ setAccumBufferSize() and setStencilBufferSize().
+
+ Note that even if you specify that you prefer a 32 bit depth
+ buffer (e.g. with setDepthBufferSize(32)), the format that is
+ chosen may not have a 32 bit depth buffer, even if there is a
+ format available with a 32 bit depth buffer. The main reason for
+ this is how the system dependant picking algorithms work on the
+ different platforms, and some format options may have higher
+ precedence than others.
+
+ You create and tell a QPlatformWindowFormat object what rendering options you
+ want from an OpenGL rendering context.
+
+ OpenGL drivers or accelerated hardware may or may not support
+ advanced features such as alpha channel or stereographic viewing.
+ If you request some features that the driver/hardware does not
+ provide when you create a QGLWidget, you will get a rendering
+ context with the nearest subset of features.
+
+ There are different ways to define the display characteristics of
+ a rendering context. One is to create a QPlatformWindowFormat and make it the
+ default for the entire application:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 0
+
+ Or you can specify the desired format when creating an object of
+ your QGLWidget subclass:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 1
+
+ After the widget has been created, you can find out which of the
+ requested features the system was able to provide:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 2
+
+ \legalese
+ OpenGL is a trademark of Silicon Graphics, Inc. in the
+ United States and other countries.
+ \endlegalese
+
+ \sa QPlatformContext, QWidget
+*/
+
+/*!
+ Constructs a QPlatformWindowFormat object with the following default settings:
+ \list
+ \i \link setDoubleBuffer() Double buffer:\endlink Enabled.
+ \i \link setDepth() Depth buffer:\endlink Enabled.
+ \i \link setRgba() RGBA:\endlink Enabled (i.e., color index disabled).
+ \i \link setAlpha() Alpha channel:\endlink Disabled.
+ \i \link setAccum() Accumulator buffer:\endlink Disabled.
+ \i \link setStencil() Stencil buffer:\endlink Enabled.
+ \i \link setStereo() Stereo:\endlink Disabled.
+ \i \link setDirectRendering() Direct rendering:\endlink Enabled.
+ \i \link setOverlay() Overlay:\endlink Disabled.
+ \i \link setPlane() Plane:\endlink 0 (i.e., normal plane).
+ \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
+ \endlist
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat()
+{
+ d = new QPlatformWindowFormatPrivate;
+}
+
+
+/*!
+ Creates a QPlatformWindowFormat object that is a copy of the current
+ defaultFormat().
+
+ If \a options is not 0, the default format is modified by the
+ specified format options. The \a options parameter should be
+ QGL::FormatOption values OR'ed together.
+
+ This constructor makes it easy to specify a certain desired format
+ in classes derived from QGLWidget, for example:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 3
+
+ Note that there are QGL::FormatOption values to turn format settings
+ both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer,
+ QGL::DirectRendering and QGL::IndirectRendering, etc.
+
+ The \a plane parameter defaults to 0 and is the plane which this
+ format should be associated with. Not all OpenGL implementations
+ supports overlay/underlay rendering planes.
+
+ \sa defaultFormat(), setOption(), setPlane()
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat(QPlatformWindowFormat::FormatOptions options)
+{
+ d = new QPlatformWindowFormatPrivate;
+ QPlatformWindowFormat::FormatOptions newOpts = options;
+ d->opts = defaultFormat().d->opts;
+ d->opts |= (newOpts & 0xffff);
+ d->opts &= ~(newOpts >> 16);
+}
+
+/*!
+ \internal
+*/
+void QPlatformWindowFormat::detach()
+{
+ if (d->ref != 1) {
+ QPlatformWindowFormatPrivate *newd = new QPlatformWindowFormatPrivate(d);
+ if (!d->ref.deref())
+ delete d;
+ d = newd;
+ }
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other)
+{
+ d = other.d;
+ d->ref.ref();
+}
+
+/*!
+ Assigns \a other to this object.
+*/
+
+QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFormat &other)
+{
+ if (d != other.d) {
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ }
+ return *this;
+}
+
+/*!
+ Destroys the QPlatformWindowFormat.
+*/
+QPlatformWindowFormat::~QPlatformWindowFormat()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ \fn bool QPlatformWindowFormat::doubleBuffer() const
+
+ Returns true if double buffering is enabled; otherwise returns
+ false. Double buffering is enabled by default.
+
+ \sa setDoubleBuffer()
+*/
+
+/*!
+ If \a enable is true sets double buffering; otherwise sets single
+ buffering.
+
+ Double buffering is enabled by default.
+
+ Double buffering is a technique where graphics are rendered on an
+ off-screen buffer and not directly to the screen. When the drawing
+ has been completed, the program calls a swapBuffers() function to
+ exchange the screen contents with the buffer. The result is
+ flicker-free drawing and often better performance.
+
+ \sa doubleBuffer(), QGLContext::swapBuffers(),
+ QGLWidget::swapBuffers()
+*/
+
+void QPlatformWindowFormat::setDoubleBuffer(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::depth() const
+
+ Returns true if the depth buffer is enabled; otherwise returns
+ false. The depth buffer is enabled by default.
+
+ \sa setDepth(), setDepthBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the depth buffer; otherwise disables
+ the depth buffer.
+
+ The depth buffer is enabled by default.
+
+ The purpose of a depth buffer (or Z-buffering) is to remove hidden
+ surfaces. Pixels are assigned Z values based on the distance to
+ the viewer. A pixel with a high Z value is closer to the viewer
+ than a pixel with a low Z value. This information is used to
+ decide whether to draw a pixel or not.
+
+ \sa depth(), setDepthBufferSize()
+*/
+
+void QPlatformWindowFormat::setDepth(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::rgba() const
+
+ Returns true if RGBA color mode is set. Returns false if color
+ index mode is set. The default color mode is RGBA.
+
+ \sa setRgba()
+*/
+
+/*!
+ If \a enable is true sets RGBA mode. If \a enable is false sets
+ color index mode.
+
+ The default color mode is RGBA.
+
+ RGBA is the preferred mode for most OpenGL applications. In RGBA
+ color mode you specify colors as red + green + blue + alpha
+ quadruplets.
+
+ In color index mode you specify an index into a color lookup
+ table.
+
+ \sa rgba()
+*/
+
+void QPlatformWindowFormat::setRgba(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::alpha() const
+
+ Returns true if the alpha buffer in the framebuffer is enabled;
+ otherwise returns false. The alpha buffer is disabled by default.
+
+ \sa setAlpha(), setAlphaBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the alpha buffer; otherwise disables
+ the alpha buffer.
+
+ The alpha buffer is disabled by default.
+
+ The alpha buffer is typically used for implementing transparency
+ or translucency. The A in RGBA specifies the transparency of a
+ pixel.
+
+ \sa alpha(), setAlphaBufferSize()
+*/
+
+void QPlatformWindowFormat::setAlpha(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::accum() const
+
+ Returns true if the accumulation buffer is enabled; otherwise
+ returns false. The accumulation buffer is disabled by default.
+
+ \sa setAccum(), setAccumBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the accumulation buffer; otherwise
+ disables the accumulation buffer.
+
+ The accumulation buffer is disabled by default.
+
+ The accumulation buffer is used to create blur effects and
+ multiple exposures.
+
+ \sa accum(), setAccumBufferSize()
+*/
+
+void QPlatformWindowFormat::setAccum(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::stencil() const
+
+ Returns true if the stencil buffer is enabled; otherwise returns
+ false. The stencil buffer is enabled by default.
+
+ \sa setStencil(), setStencilBufferSize()
+*/
+
+/*!
+ If \a enable is true enables the stencil buffer; otherwise
+ disables the stencil buffer.
+
+ The stencil buffer is enabled by default.
+
+ The stencil buffer masks certain parts of the drawing area so that
+ masked parts are not drawn on.
+
+ \sa stencil(), setStencilBufferSize()
+*/
+
+void QPlatformWindowFormat::setStencil(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::stereo() const
+
+ Returns true if stereo buffering is enabled; otherwise returns
+ false. Stereo buffering is disabled by default.
+
+ \sa setStereo()
+*/
+
+/*!
+ If \a enable is true enables stereo buffering; otherwise disables
+ stereo buffering.
+
+ Stereo buffering is disabled by default.
+
+ Stereo buffering provides extra color buffers to generate left-eye
+ and right-eye images.
+
+ \sa stereo()
+*/
+
+void QPlatformWindowFormat::setStereo(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers);
+}
+
+
+/*!
+ \fn bool QPlatformWindowFormat::directRendering() const
+
+ Returns true if direct rendering is enabled; otherwise returns
+ false.
+
+ Direct rendering is enabled by default.
+
+ \sa setDirectRendering()
+*/
+
+/*!
+ If \a enable is true enables direct rendering; otherwise disables
+ direct rendering.
+
+ Direct rendering is enabled by default.
+
+ Enabling this option will make OpenGL bypass the underlying window
+ system and render directly from hardware to the screen, if this is
+ supported by the system.
+
+ \sa directRendering()
+*/
+
+void QPlatformWindowFormat::setDirectRendering(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering);
+}
+
+/*!
+ \fn bool QPlatformWindowFormat::sampleBuffers() const
+
+ Returns true if multisample buffer support is enabled; otherwise
+ returns false.
+
+ The multisample buffer is disabled by default.
+
+ \sa setSampleBuffers()
+*/
+
+/*!
+ If \a enable is true, a GL context with multisample buffer support
+ is picked; otherwise ignored.
+
+ \sa sampleBuffers(), setSamples(), samples()
+*/
+void QPlatformWindowFormat::setSampleBuffers(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
+}
+
+void QPlatformWindowFormat::setUseDefaultSharedContext(bool enable)
+{
+ if (enable) {
+ setOption(QPlatformWindowFormat::UseDefaultSharedContext);
+ d->sharedContext = 0;
+ } else {
+ setOption(QPlatformWindowFormat::NoDefaultSharedContext);
+ }
+}
+
+/*!
+ Returns the number of samples per pixel when multisampling is
+ enabled. By default, the highest number of samples that is
+ available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), setSamples()
+*/
+int QPlatformWindowFormat::samples() const
+{
+ return d->numSamples;
+}
+
+/*!
+ Set the preferred number of samples per pixel when multisampling
+ is enabled to \a numSamples. By default, the highest number of
+ samples available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), samples()
+*/
+void QPlatformWindowFormat::setSamples(int numSamples)
+{
+ detach();
+ if (numSamples < 0) {
+ qWarning("QPlatformWindowFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
+ return;
+ }
+ d->numSamples = numSamples;
+ setSampleBuffers(numSamples > 0);
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred swap interval. This can be used to sync the GL
+ drawing into a system window to the vertical refresh of the screen.
+ Setting an \a interval value of 0 will turn the vertical refresh syncing
+ off, any value higher than 0 will turn the vertical syncing on.
+
+ Under Windows and under X11, where the \c{WGL_EXT_swap_control}
+ and \c{GLX_SGI_video_sync} extensions are used, the \a interval
+ parameter can be used to set the minimum number of video frames
+ that are displayed before a buffer swap will occur. In effect,
+ setting the \a interval to 10, means there will be 10 vertical
+ retraces between every buffer swap.
+
+ Under Windows the \c{WGL_EXT_swap_control} extension has to be present,
+ and under X11 the \c{GLX_SGI_video_sync} extension has to be present.
+*/
+void QPlatformWindowFormat::setSwapInterval(int interval)
+{
+ detach();
+ d->swapInterval = interval;
+}
+
+/*!
+ \since 4.2
+
+ Returns the currently set swap interval. -1 is returned if setting
+ the swap interval isn't supported in the system GL implementation.
+*/
+int QPlatformWindowFormat::swapInterval() const
+{
+ return d->swapInterval;
+}
+
+void QPlatformWindowFormat::setWindowApi(QPlatformWindowFormat::WindowApi api)
+{
+ detach();
+ d->windowApi = api;
+}
+
+QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const
+{
+ return d->windowApi;
+}
+
+void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context)
+{
+ setUseDefaultSharedContext(false);
+ d->sharedContext = context;
+}
+
+QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const
+{
+ return d->sharedContext;
+}
+
+/*!
+ \fn bool QPlatformWindowFormat::hasWindowSurface() const
+
+ Returns true if the corresponding widget has an instance of QWindowSurface.
+
+ Otherwise returns false.
+
+ WindowSurface is enabled by default.
+
+ \sa setOverlay()
+*/
+
+/*!
+ If \a enable is true a top level QWidget will create a QWindowSurface at creation;
+
+ otherwise the QWidget will only have a QPlatformWindow.
+
+ This is useful for ie. QGLWidget where the QPlatformGLContext controls the surface.
+
+ \sa hasOverlay()
+*/
+
+void QPlatformWindowFormat::setWindowSurface(bool enable)
+{
+ setOption(enable ? QPlatformWindowFormat::HasWindowSurface : QPlatformWindowFormat::NoWindowSurface);
+}
+
+/*!
+ Sets the format option to \a opt.
+
+ \sa testOption()
+*/
+
+void QPlatformWindowFormat::setOption(QPlatformWindowFormat::FormatOptions opt)
+{
+ detach();
+ if (opt & 0xffff)
+ d->opts |= opt;
+ else
+ d->opts &= ~(opt >> 16);
+}
+
+
+
+/*!
+ Returns true if format option \a opt is set; otherwise returns false.
+
+ \sa setOption()
+*/
+
+bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt) const
+{
+ if (opt & 0xffff)
+ return (d->opts & opt) != 0;
+ else
+ return (d->opts & (opt >> 16)) == 0;
+}
+
+/*!
+ Set the minimum depth buffer size to \a size.
+
+ \sa depthBufferSize(), setDepth(), depth()
+*/
+void QPlatformWindowFormat::setDepthBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
+ return;
+ }
+ d->depthSize = size;
+ setDepth(size > 0);
+}
+
+/*!
+ Returns the depth buffer size.
+
+ \sa depth(), setDepth(), setDepthBufferSize()
+*/
+int QPlatformWindowFormat::depthBufferSize() const
+{
+ return d->depthSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred red buffer size to \a size.
+
+ \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setRedBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
+ return;
+ }
+ d->redSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the red buffer size.
+
+ \sa setRedBufferSize()
+*/
+int QPlatformWindowFormat::redBufferSize() const
+{
+ return d->redSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred green buffer size to \a size.
+
+ \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setGreenBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
+ return;
+ }
+ d->greenSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the green buffer size.
+
+ \sa setGreenBufferSize()
+*/
+int QPlatformWindowFormat::greenBufferSize() const
+{
+ return d->greenSize;
+}
+
+/*!
+ \since 4.2
+
+ Set the preferred blue buffer size to \a size.
+
+ \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()
+*/
+void QPlatformWindowFormat::setBlueBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
+ return;
+ }
+ d->blueSize = size;
+}
+
+/*!
+ \since 4.2
+
+ Returns the blue buffer size.
+
+ \sa setBlueBufferSize()
+*/
+int QPlatformWindowFormat::blueBufferSize() const
+{
+ return d->blueSize;
+}
+
+/*!
+ Set the preferred alpha buffer size to \a size.
+ This function implicitly enables the alpha channel.
+
+ \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize()
+*/
+void QPlatformWindowFormat::setAlphaBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
+ return;
+ }
+ d->alphaSize = size;
+ setAlpha(size > 0);
+}
+
+/*!
+ Returns the alpha buffer size.
+
+ \sa alpha(), setAlpha(), setAlphaBufferSize()
+*/
+int QPlatformWindowFormat::alphaBufferSize() const
+{
+ return d->alphaSize;
+}
+
+/*!
+ Set the preferred accumulation buffer size, where \a size is the
+ bit depth for each RGBA component.
+
+ \sa accum(), setAccum(), accumBufferSize()
+*/
+void QPlatformWindowFormat::setAccumBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
+ return;
+ }
+ d->accumSize = size;
+ setAccum(size > 0);
+}
+
+/*!
+ Returns the accumulation buffer size.
+
+ \sa setAccumBufferSize(), accum(), setAccum()
+*/
+int QPlatformWindowFormat::accumBufferSize() const
+{
+ return d->accumSize;
+}
+
+/*!
+ Set the preferred stencil buffer size to \a size.
+
+ \sa stencilBufferSize(), setStencil(), stencil()
+*/
+void QPlatformWindowFormat::setStencilBufferSize(int size)
+{
+ detach();
+ if (size < 0) {
+ qWarning("QPlatformWindowFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
+ return;
+ }
+ d->stencilSize = size;
+ setStencil(size > 0);
+}
+
+/*!
+ Returns the stencil buffer size.
+
+ \sa stencil(), setStencil(), setStencilBufferSize()
+*/
+int QPlatformWindowFormat::stencilBufferSize() const
+{
+ return d->stencilSize;
+}
+
+/*!
+ Returns the default QPlatformWindowFormat for the application. All QGLWidget
+ objects that are created use this format unless another format is
+ specified, e.g. when they are constructed.
+
+ If no special default format has been set using
+ setDefaultFormat(), the default format is the same as that created
+ with QPlatformWindowFormat().
+
+ \sa setDefaultFormat()
+*/
+
+QPlatformWindowFormat QPlatformWindowFormat::defaultFormat()
+{
+ return *q_platformwindow_default_format();
+}
+
+/*!
+ Sets a new default QPlatformWindowFormat for the application to \a f. For
+ example, to set single buffering as the default instead of double
+ buffering, your main() might contain code like this:
+ \snippet doc/src/snippets/code/src_opengl_qgl.cpp 4
+
+ \sa defaultFormat()
+*/
+
+void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f)
+{
+ *q_platformwindow_default_format() = f;
+}
+
+
+/*!
+ Returns the default QPlatformWindowFormat for overlay contexts.
+
+ The default overlay format is:
+ \list
+ \i \link setDoubleBuffer() Double buffer:\endlink Disabled.
+ \i \link setDepth() Depth buffer:\endlink Disabled.
+ \i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled).
+ \i \link setAlpha() Alpha channel:\endlink Disabled.
+ \i \link setAccum() Accumulator buffer:\endlink Disabled.
+ \i \link setStencil() Stencil buffer:\endlink Disabled.
+ \i \link setStereo() Stereo:\endlink Disabled.
+ \i \link setDirectRendering() Direct rendering:\endlink Enabled.
+ \i \link setOverlay() Overlay:\endlink Disabled.
+ \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
+ \i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane).
+ \endlist
+
+ \sa setDefaultFormat()
+*/
+
+//QPlatformWindowFormat QPlatformWindowFormat::defaultOverlayFormat()
+//{
+// return *defaultOverlayFormatInstance();
+//}
+
+///*!
+// Sets a new default QPlatformWindowFormat for overlay contexts to \a f. This
+// format is used whenever a QGLWidget is created with a format that
+// hasOverlay() enabled.
+
+// For example, to get a double buffered overlay context (if
+// available), use code like this:
+
+// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 5
+
+// As usual, you can find out after widget creation whether the
+// underlying OpenGL system was able to provide the requested
+// specification:
+
+// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 6
+
+// \sa defaultOverlayFormat()
+//*/
+
+//void QPlatformWindowFormat::setDefaultOverlayFormat(const QPlatformWindowFormat &f)
+//{
+// QPlatformWindowFormat *defaultFormat = defaultOverlayFormatInstance();
+// *defaultFormat = f;
+// // Make sure the user doesn't request that the overlays themselves
+// // have overlays, since it is unlikely that the system supports
+// // infinitely many planes...
+// defaultFormat->setOverlay(false);
+//}
+
+
+/*!
+ Returns true if all the options of the two QPlatformWindowFormat objects
+ \a a and \a b are equal; otherwise returns false.
+
+ \relates QPlatformWindowFormat
+*/
+
+bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
+{
+ return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
+ && a.d->alphaSize == b.d->alphaSize
+ && a.d->accumSize == b.d->accumSize
+ && a.d->stencilSize == b.d->stencilSize
+ && a.d->depthSize == b.d->depthSize
+ && a.d->redSize == b.d->redSize
+ && a.d->greenSize == b.d->greenSize
+ && a.d->blueSize == b.d->blueSize
+ && a.d->numSamples == b.d->numSamples
+ && a.d->swapInterval == b.d->swapInterval
+ && a.d->windowApi == b.d->windowApi);
+}
+
+
+/*!
+ Returns false if all the options of the two QPlatformWindowFormat objects
+ \a a and \a b are equal; otherwise returns true.
+
+ \relates QPlatformWindowFormat
+*/
+
+bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
+{
+ return !(a == b);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QPlatformWindowFormat &f)
+{
+ const QPlatformWindowFormatPrivate * const d = f.d;
+
+ dbg.nospace() << "QGLFormat("
+ << "options " << d->opts
+ << ", depthBufferSize " << d->depthSize
+ << ", accumBufferSize " << d->accumSize
+ << ", stencilBufferSize " << d->stencilSize
+ << ", redBufferSize " << d->redSize
+ << ", greenBufferSize " << d->greenSize
+ << ", blueBufferSize " << d->blueSize
+ << ", alphaBufferSize " << d->alphaSize
+ << ", samples " << d->numSamples
+ << ", swapInterval " << d->swapInterval
+ << ')';
+
+ return dbg.space();
+}
+#endif
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h
new file mode 100644
index 0000000..fa01a8a
--- /dev/null
+++ b/src/gui/kernel/qplatformwindowformat_qpa.h
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** 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 QPLATFORMWINDOWFORMAT_QPA_H
+#define QPLATFORMWINDOWFORMAT_QPA_H
+
+#include <QtGui/QPlatformWindow>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindowFormatPrivate;
+
+class Q_GUI_EXPORT QPlatformWindowFormat
+{
+public:
+ enum FormatOption {
+ DoubleBuffer = 0x0001,
+ DepthBuffer = 0x0002,
+ Rgba = 0x0004,
+ AlphaChannel = 0x0008,
+ AccumBuffer = 0x0010,
+ StencilBuffer = 0x0020,
+ StereoBuffers = 0x0040,
+ DirectRendering = 0x0080,
+ HasOverlay = 0x0100,
+ SampleBuffers = 0x0200,
+ DeprecatedFunctions = 0x0400,
+ UseDefaultSharedContext = 0x0800,
+ HasWindowSurface = 0x1000,
+ SingleBuffer = DoubleBuffer << 16,
+ NoDepthBuffer = DepthBuffer << 16,
+ ColorIndex = Rgba << 16,
+ NoAlphaChannel = AlphaChannel << 16,
+ NoAccumBuffer = AccumBuffer << 16,
+ NoStencilBuffer = StencilBuffer << 16,
+ NoStereoBuffers = StereoBuffers << 16,
+ IndirectRendering = DirectRendering << 16,
+ NoOverlay = HasOverlay << 16,
+ NoSampleBuffers = SampleBuffers << 16,
+ NoDeprecatedFunctions = DeprecatedFunctions << 16,
+ NoDefaultSharedContext = UseDefaultSharedContext << 16,
+ NoWindowSurface = HasWindowSurface << 16
+
+ };
+ Q_DECLARE_FLAGS(FormatOptions, FormatOption)
+
+ enum WindowApi {
+ Raster,
+ OpenGL,
+ OpenVG
+ };
+
+ QPlatformWindowFormat();
+ QPlatformWindowFormat(FormatOptions options);
+ QPlatformWindowFormat(const QPlatformWindowFormat &other);
+ QPlatformWindowFormat &operator=(const QPlatformWindowFormat &other);
+ ~QPlatformWindowFormat();
+
+ void setDepthBufferSize(int size);
+ int depthBufferSize() const;
+
+ void setAccumBufferSize(int size);
+ int accumBufferSize() const;
+
+ void setRedBufferSize(int size);
+ int redBufferSize() const;
+
+ void setGreenBufferSize(int size);
+ int greenBufferSize() const;
+
+ void setBlueBufferSize(int size);
+ int blueBufferSize() const;
+
+ void setAlphaBufferSize(int size);
+ int alphaBufferSize() const;
+
+ void setStencilBufferSize(int size);
+ int stencilBufferSize() const;
+
+ void setSampleBuffers(bool enable);
+ bool sampleBuffers() const;
+
+ void setSamples(int numSamples);
+ int samples() const;
+
+ void setSwapInterval(int interval);
+ int swapInterval() const;
+
+ void setWindowApi(QPlatformWindowFormat::WindowApi api);
+ WindowApi windowApi() const;
+
+ void setSharedContext(QPlatformGLContext *context);
+ QPlatformGLContext *sharedGLContext() const;
+
+ bool doubleBuffer() const;
+ void setDoubleBuffer(bool enable);
+ bool depth() const;
+ void setDepth(bool enable);
+ bool rgba() const;
+ void setRgba(bool enable);
+ bool alpha() const;
+ void setAlpha(bool enable);
+ bool accum() const;
+ void setAccum(bool enable);
+ bool stencil() const;
+ void setStencil(bool enable);
+ bool stereo() const;
+ void setStereo(bool enable);
+ bool directRendering() const;
+ void setDirectRendering(bool enable);
+ bool useDefaultSharedContext() const;
+ void setUseDefaultSharedContext(bool enable);
+ bool hasWindowSurface() const;
+ void setWindowSurface(bool enable);
+
+ void setOption(QPlatformWindowFormat::FormatOptions opt);
+ bool testOption(QPlatformWindowFormat::FormatOptions opt) const;
+
+ static QPlatformWindowFormat defaultFormat();
+ static void setDefaultFormat(const QPlatformWindowFormat& f);
+
+private:
+ QPlatformWindowFormatPrivate *d;
+
+ void detach();
+
+ friend Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+ friend Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &);
+#endif
+};
+
+Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &);
+#endif
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions)
+
+inline bool QPlatformWindowFormat::doubleBuffer() const
+{
+ return testOption(QPlatformWindowFormat::DoubleBuffer);
+}
+
+inline bool QPlatformWindowFormat::depth() const
+{
+ return testOption(QPlatformWindowFormat::DepthBuffer);
+}
+
+inline bool QPlatformWindowFormat::rgba() const
+{
+ return testOption(QPlatformWindowFormat::Rgba);
+}
+
+inline bool QPlatformWindowFormat::alpha() const
+{
+ return testOption(QPlatformWindowFormat::AlphaChannel);
+}
+
+inline bool QPlatformWindowFormat::accum() const
+{
+ return testOption(QPlatformWindowFormat::AccumBuffer);
+}
+
+inline bool QPlatformWindowFormat::stencil() const
+{
+ return testOption(QPlatformWindowFormat::StencilBuffer);
+}
+
+inline bool QPlatformWindowFormat::stereo() const
+{
+ return testOption(QPlatformWindowFormat::StereoBuffers);
+}
+
+inline bool QPlatformWindowFormat::directRendering() const
+{
+ return testOption(QPlatformWindowFormat::DirectRendering);
+}
+
+inline bool QPlatformWindowFormat::hasWindowSurface() const
+{
+ return testOption(QPlatformWindowFormat::HasWindowSurface);
+}
+
+inline bool QPlatformWindowFormat::sampleBuffers() const
+{
+ return testOption(QPlatformWindowFormat::SampleBuffers);
+}
+
+inline bool QPlatformWindowFormat::useDefaultSharedContext() const
+{
+ return testOption(QPlatformWindowFormat::UseDefaultSharedContext);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QPLATFORMWINDOWFORMAT_QPA_H
diff --git a/src/gui/kernel/qsizepolicy.h b/src/gui/kernel/qsizepolicy.h
index 4b5fbdc..c0a8cc1 100644
--- a/src/gui/kernel/qsizepolicy.h
+++ b/src/gui/kernel/qsizepolicy.h
@@ -62,12 +62,12 @@ private:
HSize = 4,
HMask = 0x0f,
VMask = HMask << HSize,
- CTShift = 9,
- CTSize = 5,
- WFHShift = CTShift + CTSize,
- CTMask = ((0x1 << CTSize) - 1) << CTShift,
- UnusedShift = CTShift + CTSize,
- UnusedSize = 2
+ CTShift = 9,
+ CTSize = 5,
+ CTMask = ((0x1 << CTSize) - 1) << CTShift,
+ WFHShift = CTShift + CTSize,
+ UnusedShift = WFHShift + 1,
+ UnusedSize = 1
};
public:
@@ -134,6 +134,8 @@ public:
void setHeightForWidth(bool b) { data = b ? (data | (1 << 2*HSize)) : (data & ~(1 << 2*HSize)); }
bool hasHeightForWidth() const { return data & (1 << 2*HSize); }
+ void setWidthForHeight(bool b) { data = b ? (data | (1 << (WFHShift))) : (data & ~(1 << (WFHShift))); }
+ bool hasWidthForHeight() const { return data & (1 << (WFHShift)); }
bool operator==(const QSizePolicy& s) const { return data == s.data; }
bool operator!=(const QSizePolicy& s) const { return data != s.data; }
@@ -200,15 +202,18 @@ private:
QSizePolicy(int i) : data(i) { }
quint32 data;
-/* use bit flags instead, keep it here for improved readability for now
+/* Qt5: Use bit flags instead, keep it here for improved readability for now.
+ We can maybe change it for Qt4, but we'd have to be careful, since the behaviour
+ is implementation defined. It usually varies between little- and big-endian compilers, but
+ it might also not vary.
quint32 horzPolicy : 4;
quint32 vertPolicy : 4;
quint32 hfw : 1;
quint32 ctype : 5;
quint32 wfh : 1;
quint32 padding : 1; // we cannot use the highest bit
- quint32 horStretch : 8;
quint32 verStretch : 8;
+ quint32 horStretch : 8;
*/
};
diff --git a/src/gui/kernel/qsizepolicy.qdoc b/src/gui/kernel/qsizepolicy.qdoc
index 66ae438..80e9f20 100644
--- a/src/gui/kernel/qsizepolicy.qdoc
+++ b/src/gui/kernel/qsizepolicy.qdoc
@@ -249,7 +249,7 @@
Sets the flag determining whether the widget's preferred height
depends on its width, to \a dependent.
- \sa hasHeightForWidth()
+ \sa hasHeightForWidth(), setWidthForHeight()
*/
/*!
@@ -262,6 +262,28 @@
*/
/*!
+ \fn void QSizePolicy::setWidthForHeight(bool dependent)
+
+ Sets the flag determining whether the widget's width
+ depends on its height, to \a dependent.
+
+ This is only supported for QGraphicsLayout's subclasses.
+ It is not possible to have a layout with both height-for-width
+ and width-for-height constraints at the same time.
+
+ \sa hasWidthForHeight(), setHeightForWidth()
+*/
+
+/*!
+ \fn bool QSizePolicy::hasWidthForHeight() const
+
+ Returns true if the widget's width depends on its
+ height; otherwise returns false.
+
+ \sa setWidthForHeight()
+*/
+
+/*!
\fn bool QSizePolicy::operator==(const QSizePolicy &other) const
Returns true if this policy is equal to \a other; otherwise
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 20c1ddb..32123ee 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -79,6 +79,7 @@
#include <qdesktopwidget.h>
#include <qevent.h>
#include <qpixmapcache.h>
+#include <qvarlengtharray.h>
#include <private/qevent_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
@@ -88,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()
@@ -140,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)
{
@@ -166,6 +177,70 @@ void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
}
}
}
+struct dndenum_mapper
+{
+ NSDragOperation mac_code;
+ Qt::DropAction qt_code;
+ bool Qt2Mac;
+};
+
+#if defined(QT_MAC_USE_COCOA) && defined(__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 )
{
@@ -300,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
@@ -470,7 +545,6 @@ void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
qt_sendSpontaneousEvent(qApp, &qtabletProximity);
}
-#ifdef QT_MAC_USE_COCOA
// Use this method to keep all the information in the TextSegment. As long as it is ordered
// we are in OK shape, and we can influence that ourselves.
struct KeyPair
@@ -494,69 +568,111 @@ bool operator<(QChar qchar, const KeyPair &entry)
return qchar < entry.cocoaKey;
}
+bool operator<(const Qt::Key &key, const KeyPair &entry)
+{
+ return key < entry.qtKey;
+}
+
+bool operator<(const KeyPair &entry, const Qt::Key &key)
+{
+ return entry.qtKey < key;
+}
+
+static bool qtKey2CocoaKeySortLessThan(const KeyPair &entry1, const KeyPair &entry2)
+{
+ return entry1.qtKey < entry2.qtKey;
+}
+
+static const int NumEntries = 59;
+static const KeyPair entries[NumEntries] = {
+ { NSEnterCharacter, Qt::Key_Enter },
+ { NSBackspaceCharacter, Qt::Key_Backspace },
+ { NSTabCharacter, Qt::Key_Tab },
+ { NSNewlineCharacter, Qt::Key_Return },
+ { NSCarriageReturnCharacter, Qt::Key_Return },
+ { NSBackTabCharacter, Qt::Key_Backtab },
+ { 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 },
+ { NSRightArrowFunctionKey, Qt::Key_Right },
+ { NSF1FunctionKey, Qt::Key_F1 },
+ { NSF2FunctionKey, Qt::Key_F2 },
+ { NSF3FunctionKey, Qt::Key_F3 },
+ { NSF4FunctionKey, Qt::Key_F4 },
+ { NSF5FunctionKey, Qt::Key_F5 },
+ { NSF6FunctionKey, Qt::Key_F6 },
+ { NSF7FunctionKey, Qt::Key_F7 },
+ { NSF8FunctionKey, Qt::Key_F8 },
+ { NSF9FunctionKey, Qt::Key_F8 },
+ { NSF10FunctionKey, Qt::Key_F10 },
+ { NSF11FunctionKey, Qt::Key_F11 },
+ { NSF12FunctionKey, Qt::Key_F12 },
+ { NSF13FunctionKey, Qt::Key_F13 },
+ { NSF14FunctionKey, Qt::Key_F14 },
+ { NSF15FunctionKey, Qt::Key_F15 },
+ { NSF16FunctionKey, Qt::Key_F16 },
+ { NSF17FunctionKey, Qt::Key_F17 },
+ { NSF18FunctionKey, Qt::Key_F18 },
+ { NSF19FunctionKey, Qt::Key_F19 },
+ { NSF20FunctionKey, Qt::Key_F20 },
+ { NSF21FunctionKey, Qt::Key_F21 },
+ { NSF22FunctionKey, Qt::Key_F22 },
+ { NSF23FunctionKey, Qt::Key_F23 },
+ { NSF24FunctionKey, Qt::Key_F24 },
+ { NSF25FunctionKey, Qt::Key_F25 },
+ { NSF26FunctionKey, Qt::Key_F26 },
+ { NSF27FunctionKey, Qt::Key_F27 },
+ { NSF28FunctionKey, Qt::Key_F28 },
+ { NSF29FunctionKey, Qt::Key_F29 },
+ { NSF30FunctionKey, Qt::Key_F30 },
+ { NSF31FunctionKey, Qt::Key_F31 },
+ { NSF32FunctionKey, Qt::Key_F32 },
+ { NSF33FunctionKey, Qt::Key_F33 },
+ { NSF34FunctionKey, Qt::Key_F34 },
+ { NSF35FunctionKey, Qt::Key_F35 },
+ { NSInsertFunctionKey, Qt::Key_Insert },
+ { NSDeleteFunctionKey, Qt::Key_Delete },
+ { NSHomeFunctionKey, Qt::Key_Home },
+ { NSEndFunctionKey, Qt::Key_End },
+ { NSPageUpFunctionKey, Qt::Key_PageUp },
+ { NSPageDownFunctionKey, Qt::Key_PageDown },
+ { NSPrintScreenFunctionKey, Qt::Key_Print },
+ { NSScrollLockFunctionKey, Qt::Key_ScrollLock },
+ { NSPauseFunctionKey, Qt::Key_Pause },
+ { NSSysReqFunctionKey, Qt::Key_SysReq },
+ { NSMenuFunctionKey, Qt::Key_Menu },
+ { NSHelpFunctionKey, Qt::Key_Help },
+};
+static const KeyPair * const end = entries + NumEntries;
+
+QChar qtKey2CocoaKey(Qt::Key key)
+{
+ // The first time this function is called, create a reverse
+ // looup table sorted on Qt Key rather than Cocoa key:
+ static QVector<KeyPair> rev_entries(NumEntries);
+ static bool mustInit = true;
+ if (mustInit){
+ mustInit = false;
+ for (int i=0; i<NumEntries; ++i)
+ rev_entries[i] = entries[i];
+ qSort(rev_entries.begin(), rev_entries.end(), qtKey2CocoaKeySortLessThan);
+ }
+ const QVector<KeyPair>::iterator i
+ = qBinaryFind(rev_entries.begin(), rev_entries.end(), key);
+ if (i == rev_entries.end())
+ return QChar();
+ return i->cocoaKey;
+}
+
+#ifdef QT_MAC_USE_COCOA
static Qt::Key cocoaKey2QtKey(QChar keyCode)
{
- static const int NumEntries = 57;
- static const KeyPair entries[NumEntries] = {
- { NSEnterCharacter, Qt::Key_Enter },
- { NSTabCharacter, Qt::Key_Tab },
- { NSCarriageReturnCharacter, Qt::Key_Return },
- { NSBackTabCharacter, Qt::Key_Backtab },
- { kEscapeCharCode, Qt::Key_Escape },
- { NSDeleteCharacter, Qt::Key_Backspace },
- { NSUpArrowFunctionKey, Qt::Key_Up },
- { NSDownArrowFunctionKey, Qt::Key_Down },
- { NSLeftArrowFunctionKey, Qt::Key_Left },
- { NSRightArrowFunctionKey, Qt::Key_Right },
- { NSF1FunctionKey, Qt::Key_F1 },
- { NSF2FunctionKey, Qt::Key_F2 },
- { NSF3FunctionKey, Qt::Key_F3 },
- { NSF4FunctionKey, Qt::Key_F4 },
- { NSF5FunctionKey, Qt::Key_F5 },
- { NSF6FunctionKey, Qt::Key_F6 },
- { NSF7FunctionKey, Qt::Key_F7 },
- { NSF8FunctionKey, Qt::Key_F8 },
- { NSF9FunctionKey, Qt::Key_F8 },
- { NSF10FunctionKey, Qt::Key_F10 },
- { NSF11FunctionKey, Qt::Key_F11 },
- { NSF12FunctionKey, Qt::Key_F12 },
- { NSF13FunctionKey, Qt::Key_F13 },
- { NSF14FunctionKey, Qt::Key_F14 },
- { NSF15FunctionKey, Qt::Key_F15 },
- { NSF16FunctionKey, Qt::Key_F16 },
- { NSF17FunctionKey, Qt::Key_F17 },
- { NSF18FunctionKey, Qt::Key_F18 },
- { NSF19FunctionKey, Qt::Key_F19 },
- { NSF20FunctionKey, Qt::Key_F20 },
- { NSF21FunctionKey, Qt::Key_F21 },
- { NSF22FunctionKey, Qt::Key_F22 },
- { NSF23FunctionKey, Qt::Key_F23 },
- { NSF24FunctionKey, Qt::Key_F24 },
- { NSF25FunctionKey, Qt::Key_F25 },
- { NSF26FunctionKey, Qt::Key_F26 },
- { NSF27FunctionKey, Qt::Key_F27 },
- { NSF28FunctionKey, Qt::Key_F28 },
- { NSF29FunctionKey, Qt::Key_F29 },
- { NSF30FunctionKey, Qt::Key_F30 },
- { NSF31FunctionKey, Qt::Key_F31 },
- { NSF32FunctionKey, Qt::Key_F32 },
- { NSF33FunctionKey, Qt::Key_F33 },
- { NSF34FunctionKey, Qt::Key_F34 },
- { NSF35FunctionKey, Qt::Key_F35 },
- { NSInsertFunctionKey, Qt::Key_Insert },
- { NSDeleteFunctionKey, Qt::Key_Delete },
- { NSHomeFunctionKey, Qt::Key_Home },
- { NSEndFunctionKey, Qt::Key_End },
- { NSPageUpFunctionKey, Qt::Key_PageUp },
- { NSPageDownFunctionKey, Qt::Key_PageDown },
- { NSPrintScreenFunctionKey, Qt::Key_Print },
- { NSScrollLockFunctionKey, Qt::Key_ScrollLock },
- { NSPauseFunctionKey, Qt::Key_Pause },
- { NSSysReqFunctionKey, Qt::Key_SysReq },
- { NSMenuFunctionKey, Qt::Key_Menu },
- { NSHelpFunctionKey, Qt::Key_Help },
- };
- static const KeyPair * const end = entries + NumEntries;
const KeyPair *i = qBinaryFind(entries, end, keyCode);
if (i == end)
return Qt::Key(keyCode.unicode());
@@ -579,6 +695,27 @@ Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
return qtMods;
}
+NSString *qt_mac_removePrivateUnicode(NSString* string)
+{
+ int len = [string length];
+ if (len) {
+ QVarLengthArray <unichar, 10> characters(len);
+ bool changed = false;
+ for (int i = 0; i<len; i++) {
+ characters[i] = [string characterAtIndex:i];
+ // check if they belong to key codes in private unicode range
+ // currently we need to handle only the NSDeleteFunctionKey
+ if (characters[i] == NSDeleteFunctionKey) {
+ characters[i] = NSDeleteCharacter;
+ changed = true;
+ }
+ }
+ if (changed)
+ return [NSString stringWithCharacters:characters.data() length:len];
+ }
+ return string;
+}
+
Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations)
{
Qt::KeyboardModifiers qtMods =Qt::NoModifier;
@@ -672,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
@@ -684,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]) {
@@ -693,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
@@ -729,7 +859,6 @@ void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget
#endif
}
-
QPointF flipPoint(const NSPoint &p)
{
return QPointF(p.x, flipYCoordinate(p.y));
@@ -745,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;
@@ -877,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;
}
}
@@ -902,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.
+ NSEvent *event,
+ QEvent::Type eventType,
+ QPoint &returnLocalPoint,
+ QPoint &returnGlobalPoint,
+ QWidget *nativeWidget,
+ QWidget **returnWidgetUnderMouse)
+{
+ Q_UNUSED(event);
+ NSPoint nsglobalpoint = event ? [[event window] convertBaseToScreen:[event locationInWindow]] : [NSEvent mouseLocation];
+ returnGlobalPoint = flipPoint(nsglobalpoint).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)
{
@@ -1207,7 +1440,7 @@ void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widge
// We have the original method here. Proceed and swap the methods.
method_exchangeImplementations(m1, m0);
widget->originalDrawMethod = false;
- [window display];
+ [theWindow display];
}
}
@@ -1230,21 +1463,21 @@ void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivat
}
method_exchangeImplementations(m1, m0);
widget->originalDrawMethod = true;
- [window display];
+ [theWindow display];
}
#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)
{
@@ -1264,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)
@@ -1288,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)
@@ -1300,7 +1535,7 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
#else
- CGContextRef context = reinterpret_cast<CGContextRef>([[qt_mac_window_for(widget) graphicsContext] graphicsPort]);
+ CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort];
#endif
return context;
}
@@ -1330,11 +1565,11 @@ QString qt_mac_get_pasteboardString(OSPasteboardRef paste)
QMacCocoaAutoReleasePool pool;
NSPasteboard *pb = nil;
CFStringRef pbname;
- if (PasteboardCopyName (paste, &pbname)) {
- pb = [NSPasteboard generalPasteboard];
+ if (PasteboardCopyName(paste, &pbname) == noErr) {
+ pb = [NSPasteboard pasteboardWithName:const_cast<NSString *>(reinterpret_cast<const NSString *>(pbname))];
+ CFRelease(pbname);
} else {
- pb = [NSPasteboard pasteboardWithName:reinterpret_cast<const NSString *>(pbname)];
- CFRelease (pbname);
+ pb = [NSPasteboard generalPasteboard];
}
if (pb) {
NSString *text = [pb stringForType:NSStringPboardType];
@@ -1389,6 +1624,7 @@ 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;
@@ -1423,47 +1659,46 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse)
}
}
-#ifdef QT_MAC_USE_COCOA
-void qt_cocoaChangeOverrideCursor(const QCursor &cursor)
-{
- QMacCocoaAutoReleasePool pool;
- [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) set];
-}
-
-// WARNING: If Qt did not create NSApplication (e.g. in case it is
-// used as a plugin), and at the same time, there is no window on
-// screen (or the window that the event is sendt to becomes hidden etc
-// before the event gets delivered), the message will not be performed.
-bool qt_cocoaPostMessage(id target, SEL selector)
-{
- if (!target)
- return false;
+class CocoaPostMessageAfterEventLoopExitHelp : public QObject
+{
+ 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();
+ }
- NSInteger windowNumber = 0;
- if (![NSApp isMemberOfClass:[QNSApplication class]]) {
- // INVARIANT: Cocoa is not using our NSApplication subclass. That means
- // we don't control the main event handler either. So target the event
- // for one of the windows on screen:
- NSWindow *nswin = [NSApp mainWindow];
- if (!nswin) {
- nswin = [NSApp keyWindow];
- if (!nswin)
- return false;
- }
- windowNumber = [nswin windowNumber];
+ ~CocoaPostMessageAfterEventLoopExitHelp()
+ {
+ qt_cocoaPostMessage(target, selector, argCount, arg1, arg2);
}
+};
- // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
+void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2)
+{
+ // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5!
// That is why we need to split the address in two parts:
- QCocoaPostMessageArgs *args = new QCocoaPostMessageArgs(target, selector);
+ QCocoaPostMessageArgs *args = new QCocoaPostMessageArgs(target, selector, argCount, arg1, arg2);
quint32 lower = quintptr(args);
quint32 upper = quintptr(args) >> 32;
NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined
- location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:windowNumber
+ location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper];
[NSApp postEvent:e atStart:NO];
- return true;
}
+
+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()
@@ -1487,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
@@ -1501,7 +1742,7 @@ void macDrawRectOnTop(void * /*OSWindowRef */window)
NSRect contentRect = [contentView frame];
// Draw a line on top of the already drawn line.
// We need to check if we are active or not to use the proper color.
- if([window isKeyWindow] || [window isMainWindow]) {
+ if([theWindow isKeyWindow] || [theWindow isMainWindow]) {
[[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set];
} else {
[[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set];
@@ -1521,7 +1762,7 @@ void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window)
{
OSWindowRef theWindow = static_cast<OSWindowRef>(window);
NSApplication *application = [NSApplication sharedApplication];
- NSToolbar *toolbar = [window toolbar];
+ NSToolbar *toolbar = [theWindow toolbar];
if([application isActive]) {
// Launched from finder
[toolbar setShowsBaselineSeparator:NO];
@@ -1549,6 +1790,35 @@ void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *childWidget)
}
}
+void qt_mac_display(QWidget *widget)
+{
+ NSView *theNSView = qt_mac_nativeview_for(widget);
+ [theNSView display];
+}
+
+void qt_mac_setNeedsDisplay(QWidget *widget)
+{
+ NSView *theNSView = qt_mac_nativeview_for(widget);
+ [theNSView setNeedsDisplay:YES];
+}
+
+void qt_mac_setNeedsDisplayInRect(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 // QT_MAC_USE_COCOA
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index d5f4b2b..a49753a 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;
@@ -202,23 +222,119 @@ class QCocoaPostMessageArgs {
public:
id target;
SEL selector;
- QCocoaPostMessageArgs(id target, SEL selector) : target(target), selector(selector)
+ int argCount;
+ id arg1;
+ id arg2;
+ QCocoaPostMessageArgs(id target, SEL selector, int argCount=0, id arg1=0, id arg2=0)
+ : target(target), selector(selector), argCount(argCount), arg1(arg1), arg2(arg2)
{
[target retain];
+ [arg1 retain];
+ [arg2 retain];
}
~QCocoaPostMessageArgs()
{
+ [arg2 release];
+ [arg1 release];
[target release];
}
};
-bool qt_cocoaPostMessage(id target, SEL selector);
+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();
+#ifdef QT_MAC_USE_COCOA
+void qt_mac_display(QWidget *widget);
+void qt_mac_setNeedsDisplay(QWidget *widget);
+void qt_mac_setNeedsDisplayInRect(QWidget *widget, QRegion region);
+#endif // QT_MAC_USE_COCOA
+
+
+// Utility functions to ease the use of Core Graphics contexts.
+
+inline void qt_mac_retain_graphics_context(CGContextRef context)
+{
+ CGContextRetain(context);
+ CGContextSaveGState(context);
+}
+
+inline void qt_mac_release_graphics_context(CGContextRef context)
+{
+ CGContextRestoreGState(context);
+ CGContextRelease(context);
+}
+
+inline void qt_mac_draw_image(CGContextRef context, CGContextRef imageContext, CGRect area, CGRect drawingArea)
+{
+ CGImageRef image = CGBitmapContextCreateImage(imageContext);
+ CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
+
+ CGContextTranslateCTM (context, 0, drawingArea.origin.y + CGRectGetMaxY(drawingArea));
+ CGContextScaleCTM(context, 1, -1);
+ CGContextDrawImage(context, drawingArea, subImage);
+
+ CGImageRelease(subImage);
+ CGImageRelease(image);
+}
+
QT_END_NAMESPACE
#endif // QT_COCOA_HELPERS_MAC_P_H
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index 8ab129c..69079cf 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -226,6 +226,7 @@ typedef void (*PtrXRRSelectInput)(Display *, Window, int);
typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
typedef int (*PtrXRRRootToScreen)(Display *, Window);
typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
+typedef XRRScreenSize *(*PtrXRRSizes)(Display *, int, int *);
#endif // QT_NO_XRANDR
#ifndef QT_NO_XINPUT
@@ -710,6 +711,7 @@ struct QX11Data
PtrXRRUpdateConfiguration ptrXRRUpdateConfiguration;
PtrXRRRootToScreen ptrXRRRootToScreen;
PtrXRRQueryExtension ptrXRRQueryExtension;
+ PtrXRRSizes ptrXRRSizes;
#endif // QT_NO_XRANDR
};
diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp
index dff5e5c..4311df5 100644
--- a/src/gui/kernel/qtooltip.cpp
+++ b/src/gui/kernel/qtooltip.cpp
@@ -353,7 +353,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
#ifndef QT_NO_STYLE_STYLESHEET
if (testAttribute(Qt::WA_StyleSheet) || (w && qobject_cast<QStyleSheetStyle *>(w->style()))) {
//the stylesheet need to know the real parent
- QTipLabel::instance->setProperty("_q_stylesheet_parent", qVariantFromValue(w));
+ QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
//we force the style to be the QStyleSheetStyle, and force to clear the cache as well.
QTipLabel::instance->setStyleSheet(QLatin1String("/* */"));
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 0a73481..3cc3e65 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -76,6 +76,9 @@
# include "qpaintengine.h" // for PorterDuff
# include "private/qwindowsurface_qws_p.h"
#endif
+#if defined(Q_WS_QPA)
+#include "qplatformwindow_qpa.h"
+#endif
#include "qpainter.h"
#include "qtooltip.h"
#include "qwhatsthis.h"
@@ -145,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()) &&
@@ -301,7 +308,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
#endif
#elif defined(Q_WS_MAC)
, needWindowChange(0)
- , hasAlienChildren(0)
, window_event(0)
, qd_hd(0)
#elif defined(Q_OS_SYMBIAN)
@@ -323,6 +329,11 @@ QWidgetPrivate::QWidgetPrivate(int version)
drawRectOriginalAdded = false;
originalDrawMethod = true;
changeMethods = false;
+ isInUnifiedToolbar = false;
+ unifiedSurface = 0;
+ toolbar_ancestor = 0;
+ flushRequested = false;
+ touchEventsEnabled = false;
#endif // QT_MAC_USE_COCOA
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
@@ -357,9 +368,12 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
Q_Q(QWidget);
QWindowSurface *surface;
+#ifndef QT_NO_PROPERTIES
if (q->property("_q_DummyWindowSurface").toBool()) {
surface = new QDummyWindowSurface(q);
- } else {
+ } else
+#endif
+ {
if (QApplicationPrivate::graphicsSystem())
surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
else
@@ -1291,6 +1305,12 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (desktopWidget) {
symbianScreenNumber = qt_widget_private(desktopWidget)->symbianScreenNumber;
}
+#elif defined(Q_WS_QPA)
+ if (desktopWidget) {
+ int screen = desktopWidget->d_func()->topData()->screenIndex;
+ QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
+ platform->moveToScreen(q, screen);
+ }
#else
Q_UNUSED(desktopWidget);
#endif
@@ -1315,9 +1335,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();
@@ -1370,6 +1390,16 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
QApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
extraPaintEngine = 0;
+
+#ifdef QT_MAC_USE_COCOA
+ // If we add a child to the unified toolbar, we have to redirect the painting.
+ if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
+ if (parentWidget->d_func()->unifiedSurface) {
+ QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor;
+ parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
+ }
+ }
+#endif // QT_MAC_USE_COCOA
}
@@ -1422,11 +1452,8 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
flags |= Qt::Window;
}
+#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();
@@ -1442,6 +1469,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
return;
}
}
+#endif //Q_WS_QPA
#ifdef QT3_SUPPORT
if (flags & Qt::WStaticContents)
@@ -1600,13 +1628,13 @@ QWidget::~QWidget()
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)|| defined(Q_WS_MAC)
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
-#ifdef Q_WS_QWS
- } else if (isVisible()) {
+ }
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ else if (isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
-#endif
}
#endif
@@ -1631,7 +1659,8 @@ QWidget::~QWidget()
d->needsFlush = 0;
// set all QPointers for this object to zero
- QObjectPrivate::clearGuards(this);
+ if (d->hasGuards)
+ QObjectPrivate::clearGuards(this);
if (d->declarativeData) {
QAbstractDeclarativeData::destroyed(d->declarativeData, this);
@@ -1733,6 +1762,11 @@ void QWidgetPrivate::createTLExtra()
static int count = 0;
qDebug() << "tlextra" << ++count;
#endif
+#if defined(Q_WS_QPA)
+ x->platformWindow = 0;
+ x->platformWindowFormat = QPlatformWindowFormat::defaultFormat();
+ x->screenIndex = 0;
+#endif
}
}
@@ -1854,13 +1888,7 @@ void QWidgetPrivate::syncBackingStore()
repaint_sys(dirty);
dirty = QRegion();
} else if (QWidgetBackingStore *bs = maybeBackingStore()) {
-#ifdef QT_MAC_USE_COCOA
- Q_UNUSED(bs);
- void qt_mac_set_needs_display(QWidget *, QRegion);
- qt_mac_set_needs_display(q_func(), QRegion());
-#else
bs->sync();
-#endif
}
}
@@ -1869,13 +1897,7 @@ void QWidgetPrivate::syncBackingStore(const QRegion &region)
if (paintOnScreen())
repaint_sys(region);
else if (QWidgetBackingStore *bs = maybeBackingStore()) {
-#ifdef QT_MAC_USE_COCOA
- Q_UNUSED(bs);
- void qt_mac_set_needs_display(QWidget *, QRegion);
- qt_mac_set_needs_display(q_func(), region);
-#else
bs->sync(q_func(), region);
-#endif
}
}
@@ -2092,6 +2114,11 @@ void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirt
if (disableSubtractOpaqueSiblings || q->isWindow())
return;
+#ifdef QT_MAC_USE_COCOA
+ if (q->d_func()->isInUnifiedToolbar)
+ return;
+#endif // QT_MAC_USE_COCOA
+
QRect clipBoundingRect;
bool dirtyClipBoundingRect = true;
@@ -2479,7 +2506,9 @@ WId QWidget::winId() const
qDebug() << "QWidget::winId: creating native window for" << this;
#endif
QWidget *that = const_cast<QWidget*>(this);
+#ifndef Q_WS_QPA
that->setAttribute(Qt::WA_NativeWindow);
+#endif
that->d_func()->createWinId();
return that->data->winid;
}
@@ -2496,6 +2525,7 @@ void QWidgetPrivate::createWinId(WId winid)
#endif
const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
+#ifndef Q_WS_QPA
if (!q->isWindow()) {
QWidget *parent = q->parentWidget();
QWidgetPrivate *pd = parent->d_func();
@@ -2523,6 +2553,11 @@ void QWidgetPrivate::createWinId(WId winid)
} else {
q->create();
}
+#else
+ Q_UNUSED(winid);
+ q->create();
+#endif //Q_WS_QPA
+
}
}
@@ -5406,6 +5441,17 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
if (rgn.isEmpty())
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)
+ return;
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+
+
Q_Q(QWidget);
#ifndef QT_NO_GRAPHICSEFFECT
if (graphicsEffect && graphicsEffect->isEnabled()) {
@@ -5468,6 +5514,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QPaintEngine *paintEngine = pdev->paintEngine();
if (paintEngine) {
setRedirected(pdev, -offset);
+
#ifdef Q_WS_MAC
// (Alien support) Special case for Mac when redirecting: If the paint device
// is of the Widget type we need to set WA_WState_InPaintEvent since painting
@@ -5485,7 +5532,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);
}
@@ -5510,7 +5556,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
//actually send the paint event
QPaintEvent e(toBePainted);
QCoreApplication::sendSpontaneousEvent(q, &e);
-#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS)
+#if !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
backingStore->markDirtyOnScreen(toBePainted, q, offset);
#endif
@@ -5667,10 +5713,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;
@@ -6657,7 +6705,7 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second)
// that can take keyboard focus so that second is inserted after
// that last child, and the focus order within first is (more
// likely to be) preserved.
- QList<QWidget *> l = qFindChildren<QWidget *>(first);
+ QList<QWidget *> l = first->findChildren<QWidget *>();
for (int i = l.size()-1; i >= 0; --i) {
QWidget * next = l.at(i);
if (next->window() == fp->window()) {
@@ -7046,7 +7094,11 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
if (maximized || fullScreen) {
// set geomerty before setting the window state to make
// sure the window is maximized to the right screen.
+ // Skip on windows: the window is restored into a broken
+ // half-maximized state.
+#ifndef Q_WS_WIN
setGeometry(restoredNormalGeometry);
+#endif
Qt::WindowStates ws = windowState();
if (maximized)
ws |= Qt::WindowMaximized;
@@ -7548,7 +7600,7 @@ void QWidgetPrivate::hide_helper()
// next bit tries to move the focus if the focus widget is now
// hidden.
if (wasVisible) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
qApp->d_func()->sendSyntheticEnterLeave(q);
#endif
@@ -7680,7 +7732,7 @@ void QWidget::setVisible(bool visible)
d->show_helper();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
qApp->d_func()->sendSyntheticEnterLeave(this);
#endif
}
@@ -7812,7 +7864,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
widget->d_func()->hide_sys();
}
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
qApp->d_func()->sendSyntheticEnterLeave(widget);
#endif
#ifndef QT_NO_ACCESSIBILITY
@@ -9821,6 +9873,23 @@ int QWidget::heightForWidth(int w) const
return -1;
}
+
+/*!
+ \internal
+
+ *virtual private*
+
+ This is a bit hackish, but ideally we would have created a virtual function
+ in the public API (however, too late...) so that subclasses could reimplement
+ their own function.
+ Instead we add a virtual function to QWidgetPrivate.
+ ### Qt5: move to public class and make virtual
+*/
+bool QWidgetPrivate::hasHeightForWidth() const
+{
+ return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth();
+}
+
/*!
\fn QWidget *QWidget::childAt(int x, int y) const
@@ -10053,7 +10122,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);
@@ -10336,6 +10411,12 @@ void QWidget::repaint(const QRect &rect)
return;
if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
tlwExtra->inRepaint = true;
@@ -10365,6 +10446,12 @@ void QWidget::repaint(const QRegion &rgn)
return;
if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
tlwExtra->inRepaint = true;
@@ -10422,6 +10509,12 @@ void QWidget::update(const QRect &rect)
}
if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
tlwExtra->backingStore->markDirty(rect, this);
@@ -10446,6 +10539,12 @@ void QWidget::update(const QRegion &rgn)
}
if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
tlwExtra->backingStore->markDirty(rgn, this);
@@ -10573,7 +10672,6 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
"QWidget::setAttribute(WidgetAttribute, bool)",
"QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
-
#ifdef Q_WS_WIN
// ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
@@ -10701,7 +10799,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();
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index d08c58c..7d4726e 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -56,6 +56,10 @@
#include <QtGui/qcursor.h>
#include <QtGui/qkeysequence.h>
+#ifdef Q_WS_QPA //should this go somewhere else?
+#include <QtGui/qplatformwindowformat_qpa.h>
+#endif
+
#ifdef QT_INCLUDE_COMPAT
#include <QtGui/qevent.h>
#endif
@@ -94,9 +98,12 @@ class QHideEvent;
class QInputContext;
class QIcon;
class QWindowSurface;
+class QPlatformWindow;
class QLocale;
class QGraphicsProxyWidget;
class QGraphicsEffect;
+class QRasterWindowSurface;
+class QUnifiedToolbarSurface;
#if defined(Q_WS_X11)
class QX11Info;
#endif
@@ -627,6 +634,16 @@ public:
void setWindowSurface(QWindowSurface *surface);
QWindowSurface *windowSurface() const;
+#if defined(Q_WS_QPA)
+ void setPlatformWindow(QPlatformWindow *window);
+ QPlatformWindow *platformWindow() const;
+
+ void setPlatformWindowFormat(const QPlatformWindowFormat &format);
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ friend class QDesktopScreenWidget;
+#endif
+
Q_SIGNALS:
void customContextMenuRequested(const QPoint &pos);
@@ -758,6 +775,8 @@ private:
friend OSViewRef qt_mac_nativeview_for(const QWidget *w);
friend void qt_event_request_window_change(QWidget *widget);
friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref);
+ friend class QRasterWindowSurface;
+ friend class QUnifiedToolbarSurface;
#endif
#ifdef Q_WS_QWS
friend class QWSBackingStore;
@@ -898,13 +917,6 @@ protected:
Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
-#if defined Q_CC_MSVC && _MSC_VER < 1300
-template <> inline QWidget *qobject_cast_helper<QWidget*>(QObject *o, QWidget *)
-{
- if (!o || !o->isWidgetType()) return 0;
- return (QWidget*)(o);
-}
-#else
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
{
if (!o || !o->isWidgetType()) return 0;
@@ -915,7 +927,6 @@ template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
if (!o || !o->isWidgetType()) return 0;
return static_cast<const QWidget*>(o);
}
-#endif
inline QWidget *QWidget::childAt(int ax, int ay) const
{ return childAt(QPoint(ax, ay)); }
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 7e5173f..34918e4 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,20 +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) {
- NSArray *views = [[drawer contentView] subviews];
- for (NSView *view in views) {
- if (view == widgetView)
- return drawer;
- }
+ if ([drawer contentView] == widgetView)
+ return drawer;
}
}
return 0;
@@ -240,6 +235,9 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
static void qt_mac_destructView(OSViewRef view)
{
#ifdef QT_MAC_USE_COCOA
+ NSWindow *window = [view window];
+ if ([window contentView] == view)
+ [window setContentView:[[NSView alloc] initWithFrame:[view bounds]]];
[view removeFromSuperview];
[view release];
#else
@@ -309,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
@@ -416,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)
@@ -474,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).
@@ -486,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 */
@@ -575,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)
@@ -631,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);
@@ -1564,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;
@@ -1630,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;
@@ -1665,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)
@@ -2289,33 +2331,28 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
} else {
[windowRef setHidesOnDeactivate:NO];
}
- [windowRef setHasShadow:YES];
+ if (q->testAttribute(Qt::WA_MacNoShadow))
+ [windowRef setHasShadow:NO];
+ else
+ [windowRef setHasShadow:YES];
Q_UNUSED(parentWidget);
Q_UNUSED(dialog);
data.fstrut_dirty = true; // when we create a toplevel widget, the frame strut should be dirty
+
OSViewRef nsview = (OSViewRef)data.winid;
- OSViewRef window_contentview = qt_mac_get_contentview_for(windowRef);
if (!nsview) {
- nsview = qt_mac_create_widget(q, this, window_contentview);
+ nsview = qt_mac_create_widget(q, this, 0);
setWinId(WId(nsview));
- } else {
- [window_contentview addSubview:nsview];
}
- if (nsview) {
- NSRect bounds = [window_contentview bounds];
- [nsview setFrame:bounds];
- [nsview setHidden:NO];
- if (q->testAttribute(Qt::WA_DropSiteRegistered))
- registerDropSite(true);
- transferChildren();
+ [windowRef setContentView:nsview];
+ [nsview setHidden:NO];
+ 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];
- }
+ // 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):
+ [windowRef makeFirstResponder:nsview];
if (topExtra->posFromMove) {
updateFrameStrut();
@@ -2346,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();
@@ -2438,6 +2476,8 @@ void QWidgetPrivate::createWindow_sys()
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_Q(QWidget);
+ QMacCocoaAutoReleasePool pool;
+
OSViewRef destroyid = 0;
#ifndef QT_MAC_USE_COCOA
window_event = 0;
@@ -2465,8 +2505,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);
@@ -2556,6 +2594,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);
}
@@ -2627,11 +2667,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))) {
@@ -2643,21 +2680,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();
}
/*!
@@ -2691,16 +2733,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
@@ -2756,7 +2811,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();
@@ -2768,7 +2823,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
@@ -2897,11 +2952,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];
@@ -2939,7 +2994,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
// unless this is an alien widget. )
const bool nonWindowWithCreatedParent = !q->isWindow() && parent->testAttribute(Qt::WA_WState_Created);
const bool nativeWidget = q->internalWinId() != 0;
- if (wasCreated || nativeWidget && nonWindowWithCreatedParent) {
+ if (wasCreated || (nativeWidget && nonWindowWithCreatedParent)) {
createWinId();
if (q->isWindow()) {
#ifndef QT_MAC_USE_COCOA
@@ -3023,7 +3078,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);
}
@@ -3050,7 +3105,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();
}
@@ -3077,28 +3132,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)
@@ -3202,11 +3241,13 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
ReleaseIconRef(previousIcon);
#else
QMacCocoaAutoReleasePool pool;
+ if (icon.isNull())
+ return;
NSButton *iconButton = [qt_mac_window_for(q) standardWindowButton:NSWindowDocumentIconButton];
if (iconButton == nil) {
QCFString string(q->windowTitle());
const NSString *tmpString = reinterpret_cast<const NSString *>((CFStringRef)string);
- [qt_mac_window_for(q) setRepresentedURL:[NSURL fileURLWithPath:tmpString]];
+ [qt_mac_window_for(q) setRepresentedURL:[NSURL fileURLWithPath:const_cast<NSString *>(tmpString)]];
iconButton = [qt_mac_window_for(q) standardWindowButton:NSWindowDocumentIconButton];
}
if (icon.isNull()) {
@@ -3240,24 +3281,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()
@@ -3342,35 +3387,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)
@@ -3379,33 +3399,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
@@ -3444,7 +3438,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);
@@ -3491,9 +3484,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();
@@ -3515,21 +3510,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
@@ -3610,6 +3618,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) {
@@ -3657,18 +3666,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);
@@ -3891,12 +3913,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);
+ }
}
}
}
@@ -3913,6 +3937,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
@@ -3953,6 +3978,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);
@@ -4009,6 +4035,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
@@ -4016,7 +4043,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());
@@ -4108,13 +4134,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
@@ -4135,7 +4156,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.
@@ -4143,13 +4172,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
@@ -4168,43 +4215,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);
@@ -4213,7 +4274,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
}
}
@@ -4221,9 +4283,10 @@ 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()) {
@@ -4235,14 +4298,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);
@@ -4250,7 +4314,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()) {
@@ -4261,10 +4326,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) {
@@ -4276,17 +4341,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
}
}
@@ -4321,6 +4425,8 @@ void QWidgetPrivate::adjustWithinMaxAndMinSize(int &w, int &h)
void QWidgetPrivate::applyMaxAndMinSizeOnWindow()
{
Q_Q(QWidget);
+ QMacCocoaAutoReleasePool pool;
+
const float max_f(20000);
#ifndef QT_MAC_USE_COCOA
#define SF(x) ((x > max_f) ? max_f : x)
@@ -4348,7 +4454,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);
@@ -4396,7 +4501,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
@@ -4405,7 +4510,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];
}
@@ -4413,6 +4518,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)
@@ -4463,17 +4570,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) {
@@ -4553,6 +4654,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 {
@@ -4560,37 +4662,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);
@@ -4601,83 +4747,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
@@ -4688,16 +4869,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:
@@ -4812,19 +4996,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
}
@@ -4832,13 +5032,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();
@@ -4846,6 +5050,7 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
syncCocoaMask();
}
+ topLevelAt_cache = 0;
#endif
}
@@ -4923,7 +5128,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 377e3a7..919f8bc 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -102,6 +102,9 @@ class QWSManager;
#if defined(Q_WS_MAC)
class QCoreGraphicsPaintEnginePrivate;
#endif
+#if defined(Q_WS_QPA)
+class QPlatformWindow;
+#endif
class QPaintEngine;
class QPixmap;
class QWidgetBackingStore;
@@ -110,6 +113,8 @@ class QWidgetItemV2;
class QStyle;
+class QUnifiedToolbarSurface;
+
class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
{
@@ -227,6 +232,10 @@ struct QTLWExtra {
#elif defined(Q_OS_SYMBIAN)
uint inExpose : 1; // Prevents drawing recursion
uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
+#elif defined(Q_WS_QPA)
+ QPlatformWindow *platformWindow;
+ QPlatformWindowFormat platformWindowFormat;
+ quint32 screenIndex; // index in qplatformscreenlist
#endif
};
@@ -359,7 +368,8 @@ public:
DrawInvisible = 0x08,
DontSubtractOpaqueChildren = 0x10,
DontSetCompositionMode = 0x20,
- DontDrawOpaqueChildren = 0x40
+ DontDrawOpaqueChildren = 0x40,
+ DontDrawNativeChildren = 0x80
};
enum CloseMode {
@@ -549,6 +559,7 @@ public:
bool setMinimumSize_helper(int &minw, int &minh);
bool setMaximumSize_helper(int &maxw, int &maxh);
+ virtual bool hasHeightForWidth() const;
void setConstraints_sys();
bool pointInsideRectAndMask(const QPoint &) const;
QWidget *childAt_helper(const QPoint &, bool) const;
@@ -793,7 +804,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 +834,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);
@@ -852,7 +863,15 @@ public:
bool originalDrawMethod;
// Do we need to change the methods?
bool changeMethods;
-#endif
+
+ // Unified toolbar variables
+ bool isInUnifiedToolbar;
+ QUnifiedToolbarSurface *unifiedSurface;
+ QPoint toolbar_offset;
+ QWidget *toolbar_ancestor;
+ bool flushRequested;
+ bool touchEventsEnabled;
+#endif // QT_MAC_USE_COCOA
void determineWindowClass();
void transferChildren();
bool qt_mac_dnd_event(uint, DragRef);
@@ -864,7 +883,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();
@@ -879,6 +898,12 @@ public:
void updateCursor() const;
#endif
QScreen* getScreen() const;
+#elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
+ void setMaxWindowState_helper();
+ void setFullScreenSize_helper();
+#ifndef QT_NO_CURSOR
+ void updateCursor() const;
+#endif
#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
static QWidget *mouseGrabber;
static QWidget *keyboardGrabber;
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
new file mode 100644
index 0000000..001810e
--- /dev/null
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -0,0 +1,875 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "QtGui/qwidget.h"
+#include "QtGui/qevent.h"
+#include "QtGui/qapplication.h"
+#include "QtGui/private/qbackingstore_p.h"
+#include "QtGui/private/qwidget_p.h"
+#include "QtGui/private/qgraphicssystem_p.h"
+#include "QtGui/private/qapplication_p.h"
+#include "QtGui/qdesktopwidget.h"
+#include "QtGui/qplatformwindow_qpa.h"
+#include "QtGui/qplatformglcontext_qpa.h"
+
+#include <QtGui/QPlatformCursor>
+
+QT_BEGIN_NAMESPACE
+
+void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget)
+{
+ QObjectList children = parentWidget->children();
+ for (int i = 0; i < children.size(); i++) {
+ if (children.at(i)->isWidgetType()) {
+ const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
+ if (childWidget) { // should not be necessary
+ if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
+ if (!childWidget->platformWindow())
+ childWidget->winId();
+ }
+ if (childWidget->platformWindow()) {
+ childWidget->platformWindow()->setParent(parentWindow);
+ } else {
+ q_createNativeChildrenAndSetParent(parentWindow,childWidget);
+ }
+ }
+ }
+ }
+
+}
+
+void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
+{
+ Q_Q(QWidget);
+
+ Q_UNUSED(window);
+ Q_UNUSED(initializeWindow);
+ Q_UNUSED(destroyOldWindow);
+
+ Qt::WindowFlags flags = data.window_flags;
+
+ if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop )
+ return; // we only care about real toplevels
+
+ QWindowSurface *surface = q->windowSurface();
+ QPlatformWindow *platformWindow = q->platformWindow();
+
+ if (!platformWindow) {
+ platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q);
+ }
+ Q_ASSERT(platformWindow);
+
+ if (!surface ) {
+ if (platformWindow && q->platformWindowFormat().hasWindowSurface()) {
+ surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId());
+ } else {
+ q->setAttribute(Qt::WA_PaintOnScreen,true);
+ }
+ }
+
+ data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags);
+
+ setWinId(q->platformWindow()->winId());
+
+ //first check children. and create them if necessary
+ q_createNativeChildrenAndSetParent(q->platformWindow(),q);
+
+ //if we we have a parent, then set correct parent;
+ if (!q->isWindow()) {
+ if (QWidget *nativeParent = q->nativeParentWidget()) {
+ if (nativeParent->platformWindow()) {
+ platformWindow->setParent(nativeParent->platformWindow());
+ }
+ }
+ }
+
+ QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
+// qDebug() << "create_sys" << q << q->internalWinId();
+}
+
+void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
+{
+ Q_D(QWidget);
+
+ if ((windowType() == Qt::Popup))
+ qApp->d_func()->closePopup(this);
+
+ //### we don't have proper focus event handling yet
+ if (this == QApplicationPrivate::active_window)
+ QApplication::setActiveWindow(0);
+
+ if (windowType() != Qt::Desktop) {
+ if (destroySubWindows) {
+ QObjectList childList(children());
+ for (int i = 0; i < childList.size(); i++) {
+ QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
+ if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
+ if (widget->platformWindow()) {
+ widget->destroy();
+ }
+ }
+ }
+ }
+ if (destroyWindow) {
+ d->deleteTLSysExtra();
+ } else {
+ if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
+ d->hide_sys();
+ }
+ }
+ }
+}
+
+void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
+{
+ Q_Q(QWidget);
+
+ Qt::WindowFlags oldFlags = data.window_flags;
+
+ int targetScreen = -1;
+ // Handle a request to move the widget to a particular screen
+ if (newparent && newparent->windowType() == Qt::Desktop) {
+ // make sure the widget is created on the same screen as the
+ // programmer specified desktop widget
+
+ // get the desktop's screen number
+ targetScreen = newparent->window()->d_func()->topData()->screenIndex;
+ newparent = 0;
+ }
+
+ if (parent != newparent) {
+ QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
+ if (q->platformWindow() && newparent) {
+ QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget();
+ if (parentWithWindow && parentWithWindow->platformWindow()) {
+ q->platformWindow()->setParent(parentWithWindow->platformWindow());
+ }
+ }
+
+ }
+
+ if (!newparent) {
+ f |= Qt::Window;
+ if (targetScreen == -1) {
+ if (parent)
+ targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
+ }
+ }
+
+ bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
+
+ // Reparenting toplevel to child
+ if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
+ //qDebug() << "setParent_sys() change from toplevel";
+ q->destroy();
+ }
+
+ data.window_flags = f;
+ q->setAttribute(Qt::WA_WState_Created, false);
+ q->setAttribute(Qt::WA_WState_Visible, false);
+ q->setAttribute(Qt::WA_WState_Hidden, false);
+
+ if (f & Qt::Window) {
+ //qDebug() << "setParent_sys" << q << newparent << hex << f;
+ if (QPlatformWindow *window = q->platformWindow())
+ data.window_flags = window->setWindowFlags(data.window_flags);
+ }
+
+ if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
+ q->setAttribute(Qt::WA_WState_Hidden);
+ q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
+
+ // move the window to the selected screen
+ if (!newparent && targetScreen != -1) {
+ if (maybeTopData())
+ maybeTopData()->screenIndex = targetScreen;
+ // only if it is already created
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
+ platform->moveToScreen(q, targetScreen);
+ }
+ }
+}
+
+QPoint QWidget::mapToGlobal(const QPoint &pos) const
+{
+ int x=pos.x(), y=pos.y();
+ const QWidget* w = this;
+ while (w) {
+ x += w->data->crect.x();
+ y += w->data->crect.y();
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ return QPoint(x, y);
+}
+
+QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+{
+ int x=pos.x(), y=pos.y();
+ const QWidget* w = this;
+ while (w) {
+ x -= w->data->crect.x();
+ y -= w->data->crect.y();
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ return QPoint(x, y);
+}
+
+void QWidgetPrivate::updateSystemBackground() {}
+
+#ifndef QT_NO_CURSOR
+void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
+{
+ Q_UNUSED(cursor);
+ Q_Q(QWidget);
+ if (q->isVisible())
+ qt_qpa_set_cursor(q, false);
+}
+
+void QWidgetPrivate::unsetCursor_sys()
+{
+ Q_Q(QWidget);
+ if (q->isVisible())
+ qt_qpa_set_cursor(q, false);
+}
+
+void QWidgetPrivate::updateCursor() const
+{
+ // XXX
+}
+
+#endif //QT_NO_CURSOR
+
+void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
+{
+ Q_Q(QWidget);
+ if (!q->isWindow())
+ return;
+
+ if (QPlatformWindow *window = q->platformWindow())
+ window->setWindowTitle(caption);
+
+}
+
+void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
+{
+}
+
+void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
+{
+ Q_UNUSED(iconText);
+}
+
+QWidget *qt_pressGrab = 0;
+QWidget *qt_mouseGrb = 0;
+static QWidget *keyboardGrb = 0;
+
+void QWidget::grabMouse()
+{
+ if (qt_mouseGrb)
+ qt_mouseGrb->releaseMouse();
+
+ // XXX
+ //qwsDisplay()->grabMouse(this,true);
+
+ qt_mouseGrb = this;
+ qt_pressGrab = 0;
+}
+
+#ifndef QT_NO_CURSOR
+void QWidget::grabMouse(const QCursor &cursor)
+{
+ Q_UNUSED(cursor);
+
+ if (qt_mouseGrb)
+ qt_mouseGrb->releaseMouse();
+
+ // XXX
+ //qwsDisplay()->grabMouse(this,true);
+ //qwsDisplay()->selectCursor(this, cursor.handle());
+ qt_mouseGrb = this;
+ qt_pressGrab = 0;
+}
+#endif
+
+void QWidget::releaseMouse()
+{
+ if (qt_mouseGrb == this) {
+ // XXX
+ //qwsDisplay()->grabMouse(this,false);
+ qt_mouseGrb = 0;
+ }
+}
+
+void QWidget::grabKeyboard()
+{
+ if (keyboardGrb)
+ keyboardGrb->releaseKeyboard();
+ // XXX
+ //qwsDisplay()->grabKeyboard(this, true);
+ keyboardGrb = this;
+}
+
+void QWidget::releaseKeyboard()
+{
+ if (keyboardGrb == this) {
+ // XXX
+ //qwsDisplay()->grabKeyboard(this, false);
+ keyboardGrb = 0;
+ }
+}
+
+QWidget *QWidget::mouseGrabber()
+{
+ if (qt_mouseGrb)
+ return qt_mouseGrb;
+ return qt_pressGrab;
+}
+
+QWidget *QWidget::keyboardGrabber()
+{
+ return keyboardGrb;
+}
+
+void QWidget::activateWindow()
+{
+ if (platformWindow())
+ platformWindow()->requestActivateWindow();
+}
+
+void QWidgetPrivate::show_sys()
+{
+ Q_Q(QWidget);
+ q->setAttribute(Qt::WA_Mapped);
+ if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
+ invalidateBuffer(q->rect());
+ return;
+ }
+
+ QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
+
+ QPlatformWindow *window = q->platformWindow();
+ if (window) {
+ QRect geomRect = q->geometry();
+ if (!q->isWindow()) {
+ QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
+ geomRect.moveTopLeft(topLeftOfWindow);
+ }
+ const QRect windowRect = window->geometry();
+ if (windowRect != geomRect) {
+ window->setGeometry(geomRect);
+ }
+ if (QWindowSurface *surface = q->windowSurface()) {
+ if (windowRect.size() != geomRect.size()) {
+ surface->resize(geomRect.size());
+ }
+ }
+ if (window)
+ window->setVisible(true);
+ }
+}
+
+
+void QWidgetPrivate::hide_sys()
+{
+ Q_Q(QWidget);
+ q->setAttribute(Qt::WA_Mapped, false);
+ if (!q->isWindow()) {
+ QWidget *p = q->parentWidget();
+ if (p &&p->isVisible()) {
+ invalidateBuffer(q->rect());
+ }
+ return;
+ }
+ if (QPlatformWindow *window = q->platformWindow()) {
+ window->setVisible(false);
+ }
+
+ //### we don't yet have proper focus event handling
+ if (q == QApplicationPrivate::active_window)
+ QApplication::setActiveWindow(0);
+
+}
+
+void QWidgetPrivate::setMaxWindowState_helper()
+{
+ setFullScreenSize_helper(); //### decoration size
+}
+
+void QWidgetPrivate::setFullScreenSize_helper()
+{
+ Q_Q(QWidget);
+
+ const uint old_state = data.in_set_window_state;
+ data.in_set_window_state = 1;
+
+ const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
+ q->move(screen.topLeft());
+ q->resize(screen.size());
+
+ data.in_set_window_state = old_state;
+}
+
+static Qt::WindowStates effectiveState(Qt::WindowStates state)
+ {
+ if (state & Qt::WindowMinimized)
+ return Qt::WindowMinimized;
+ else if (state & Qt::WindowFullScreen)
+ return Qt::WindowFullScreen;
+ else if (state & Qt::WindowMaximized)
+ return Qt::WindowMaximized;
+ return Qt::WindowNoState;
+ }
+
+void QWidget::setWindowState(Qt::WindowStates newstate)
+{
+ Q_D(QWidget);
+ Qt::WindowStates oldstate = windowState();
+ if (oldstate == newstate)
+ return;
+ if (isWindow() && !testAttribute(Qt::WA_WState_Created))
+ create();
+
+ data->window_state = newstate;
+ data->in_set_window_state = 1;
+ bool needShow = false;
+ Qt::WindowStates newEffectiveState = effectiveState(newstate);
+ Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
+ if (isWindow() && newEffectiveState != oldEffectiveState) {
+ d->createTLExtra();
+ if (oldEffectiveState == Qt::WindowNoState) { //normal
+ d->topData()->normalGeometry = geometry();
+ } else if (oldEffectiveState == Qt::WindowFullScreen) {
+ setParent(0, d->topData()->savedFlags);
+ needShow = true;
+ } else if (oldEffectiveState == Qt::WindowMinimized) {
+ needShow = true;
+ }
+
+ if (newEffectiveState == Qt::WindowMinimized) {
+ //### not ideal...
+ hide();
+ needShow = false;
+ } else if (newEffectiveState == Qt::WindowFullScreen) {
+ d->topData()->savedFlags = windowFlags();
+ setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
+ d->setFullScreenSize_helper();
+ raise();
+ needShow = true;
+ } else if (newEffectiveState == Qt::WindowMaximized) {
+ createWinId();
+ d->setMaxWindowState_helper();
+ } else { //normal
+ QRect r = d->topData()->normalGeometry;
+ if (r.width() >= 0) {
+ d->topData()->normalGeometry = QRect(0,0,-1,-1);
+ setGeometry(r);
+ }
+ }
+ }
+ data->in_set_window_state = 0;
+
+ if (needShow)
+ show();
+
+ if (newstate & Qt::WindowActive)
+ activateWindow();
+
+ QWindowStateChangeEvent e(oldstate);
+ QApplication::sendEvent(this, &e);
+}
+
+void QWidgetPrivate::setFocus_sys()
+{
+
+}
+
+void QWidgetPrivate::raise_sys()
+{
+ Q_Q(QWidget);
+ if (q->isWindow()) {
+ q->platformWindow()->raise();
+ }
+}
+
+void QWidgetPrivate::lower_sys()
+{
+ Q_Q(QWidget);
+ if (q->isWindow()) {
+ Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
+ q->platformWindow()->lower();
+ } else if (QWidget *p = q->parentWidget()) {
+ setDirtyOpaqueRegion();
+ p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
+ }
+}
+
+void QWidgetPrivate::stackUnder_sys(QWidget*)
+{
+ Q_Q(QWidget);
+ if (QWidget *p = q->parentWidget()) {
+ setDirtyOpaqueRegion();
+ p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
+ }
+}
+
+void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
+{
+ Q_Q(QWidget);
+ if (extra) { // any size restrictions?
+ w = qMin(w,extra->maxw);
+ h = qMin(h,extra->maxh);
+ w = qMax(w,extra->minw);
+ h = qMax(h,extra->minh);
+ }
+
+ QPoint oldp = q->geometry().topLeft();
+ QSize olds = q->size();
+ QRect r(x, y, w, h);
+
+ bool isResize = olds != r.size();
+ isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
+
+
+ // We only care about stuff that changes the geometry, or may
+ // cause the window manager to change its state
+ if (r.size() == olds && oldp == r.topLeft())
+ return;
+
+ if (!data.in_set_window_state) {
+ q->data->window_state &= ~Qt::WindowMaximized;
+ q->data->window_state &= ~Qt::WindowFullScreen;
+ if (q->isWindow())
+ topData()->normalGeometry = QRect(0, 0, -1, -1);
+ }
+
+ QPoint oldPos = q->pos();
+ data.crect = r;
+
+ if (q->isVisible()) {
+ if (q->platformWindow()) {
+ if (q->isWindow()) {
+ q->platformWindow()->setGeometry(q->geometry());
+ } else {
+ QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
+ q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size()));
+ }
+ const QWidgetBackingStore *bs = maybeBackingStore();
+ if (bs->windowSurface) {
+ if (isResize)
+ bs->windowSurface->resize(r.size());
+ }
+ } else {
+ if (isMove && !isResize)
+ moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
+ else
+ invalidateBuffer_resizeHelper(oldPos, olds);
+ }
+
+ if (isMove) {
+ QMoveEvent e(q->pos(), oldPos);
+ QApplication::sendEvent(q, &e);
+ }
+ if (isResize) {
+ QResizeEvent e(r.size(), olds);
+ QApplication::sendEvent(q, &e);
+ if (q->platformWindow())
+ q->update();
+ }
+ } else { // not visible
+ if (isMove && q->pos() != oldPos)
+ q->setAttribute(Qt::WA_PendingMoveEvent, true);
+ if (isResize)
+ q->setAttribute(Qt::WA_PendingResizeEvent, true);
+ }
+
+}
+
+void QWidgetPrivate::setConstraints_sys()
+{
+}
+
+void QWidgetPrivate::scroll_sys(int dx, int dy)
+{
+ Q_Q(QWidget);
+ scrollChildren(dx, dy);
+ scrollRect(q->rect(), dx, dy);
+}
+
+void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
+{
+ scrollRect(r, dx, dy);
+}
+
+int QWidget::metric(PaintDeviceMetric m) const
+{
+ Q_D(const QWidget);
+
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWidget(this);
+ if (!screen) {
+ if (m == PdmDpiX || m == PdmDpiY)
+ return 72;
+ return QPaintDevice::metric(m);
+ }
+ int val;
+ if (m == PdmWidth) {
+ val = data->crect.width();
+ } else if (m == PdmWidthMM) {
+ val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width();
+ } else if (m == PdmHeight) {
+ val = data->crect.height();
+ } else if (m == PdmHeightMM) {
+ val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height();
+ } else if (m == PdmDepth) {
+ return screen->depth();
+ } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
+ if (d->extra && d->extra->customDpiX)
+ return d->extra->customDpiX;
+ else if (d->parent)
+ return static_cast<QWidget *>(d->parent)->metric(m);
+ return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
+ } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
+ if (d->extra && d->extra->customDpiY)
+ return d->extra->customDpiY;
+ else if (d->parent)
+ return static_cast<QWidget *>(d->parent)->metric(m);
+ return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
+ } else {
+ val = QPaintDevice::metric(m);// XXX
+ }
+ return val;
+}
+
+/*!
+ \preliminary
+
+ Sets the window to be the \a window specified.
+ The QWidget takes ownership of the \a surface.
+*/
+void QWidget::setPlatformWindow(QPlatformWindow *window)
+{
+ Q_D(QWidget);
+
+ QTLWExtra *topData = d->topData();
+ if (topData->platformWindow == window)
+ return;
+
+ delete topData->platformWindow;
+ topData->platformWindow = window;
+}
+
+/*!
+ \preliminary
+
+ Returns the QPlatformWindow this widget will be drawn into.
+*/
+QPlatformWindow *QWidget::platformWindow() const
+{
+ Q_D(const QWidget);
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra && extra->platformWindow)
+ return extra->platformWindow;
+
+ return 0;
+}
+
+void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format)
+{
+ if (isWindow() || testAttribute(Qt::WA_NativeWindow)) {
+ Q_D(QWidget);
+ QTLWExtra *topData = d->topData();
+ topData->platformWindowFormat = format;
+ if (testAttribute(Qt::WA_WState_Created)) {
+ bool wasVisible = testAttribute(Qt::WA_WState_Visible);
+ destroy();
+ d->create_sys(0,true,true);
+ if (wasVisible)
+ topData->platformWindow->setVisible(true);
+ }
+ }
+}
+
+QPlatformWindowFormat QWidget::platformWindowFormat() const
+{
+ Q_D(const QWidget);
+
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra){
+ return extra->platformWindowFormat;
+ } else {
+ return QPlatformWindowFormat::defaultFormat();
+ }
+}
+
+void QWidgetPrivate::createSysExtra()
+{
+}
+
+void QWidgetPrivate::deleteSysExtra()
+{
+
+}
+
+void QWidgetPrivate::createTLSysExtra()
+{
+}
+
+void QWidgetPrivate::deleteTLSysExtra()
+{
+ if (extra && extra->topextra) {
+ //the toplevel might have a context with a "qglcontext associated with it. We need to
+ //delete the qglcontext before we delete the qplatformglcontext.
+ //One unfortunate thing about this is that we potentially create a glContext just to
+ //delete it straight afterwards.
+ if (extra->topextra->platformWindow) {
+ if (QPlatformGLContext *context = extra->topextra->platformWindow->glContext()) {
+ context->deleteQGLContext();
+ }
+ }
+ setWinId(0);
+ delete extra->topextra->platformWindow;
+ extra->topextra->platformWindow = 0;
+ }
+}
+
+void QWidgetPrivate::registerDropSite(bool on)
+{
+ Q_UNUSED(on);
+}
+
+void QWidgetPrivate::setMask_sys(const QRegion &region)
+{
+ Q_UNUSED(region);
+ // XXX
+}
+
+void QWidgetPrivate::updateFrameStrut()
+{
+ // XXX
+}
+
+void QWidgetPrivate::setWindowOpacity_sys(qreal level)
+{
+ Q_Q(QWidget);
+ q->platformWindow()->setOpacity(level);
+}
+
+void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
+{
+ Q_UNUSED(dontShow);
+ Q_UNUSED(oldRect);
+ // XXX
+}
+
+QPaintEngine *QWidget::paintEngine() const
+{
+ qWarning("QWidget::paintEngine: Should no longer be called");
+ return 0; //##### @@@
+}
+
+QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
+{
+ Q_Q(QWidget);
+ if (q->platformWindowFormat().hasWindowSurface())
+ return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0);
+ else
+ return 0;
+}
+
+void QWidgetPrivate::setModal_sys()
+{
+}
+
+#ifndef QT_NO_CURSOR
+void qt_qpa_set_cursor(QWidget * w, bool force)
+{
+ static QCursor arrowCursor(Qt::ArrowCursor);
+ static QPointer<QWidget> lastUnderMouse = 0;
+
+ QCursor * override = QApplication::overrideCursor();
+
+ if (override && w != 0)
+ return;
+
+ QWidget *cursorWidget;
+ QCursor cursorCursor;
+
+ do {
+ if (w == 0) {
+ if (override) {
+ cursorCursor = *override;
+ cursorWidget = QApplication::topLevelAt(QCursor::pos());
+ break;
+ }
+ w = QApplication::widgetAt(QCursor::pos());
+ if (w == 0) // clear the override cursor while over empty space
+ w = QApplication::desktop();
+ } else if (force) {
+ lastUnderMouse = w;
+ } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
+ && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
+ w = lastUnderMouse;
+ }
+ if (w == QApplication::desktop() && !override) {
+ cursorCursor = arrowCursor;
+ cursorWidget = w;
+ break;
+ }
+
+ QWidget * curWin = QApplication::activeWindow();
+ if (!curWin && w && w->internalWinId())
+ return;
+ QWidget* cW = w && !w->internalWinId() ? w : curWin;
+
+ if (!cW || cW->window() != w->window() ||
+ !cW->isVisible() || !cW->underMouse() || override)
+ return;
+
+ cursorCursor = w->cursor();
+ cursorWidget = w;
+ } while (0);
+ foreach (QWeakPointer<QPlatformCursor> cursor, QPlatformCursorPrivate::getInstances())
+ if (cursor)
+ cursor.data()->changeCursor(&cursorCursor, cursorWidget);
+}
+#endif //QT_NO_CURSOR
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index e7d5e95..d4eadaa 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -384,7 +384,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
if (!q->testAttribute(Qt::WA_Moved) && !q->testAttribute(Qt::WA_DontShowOnScreen))
data.crect.moveTopLeft(QPoint(clientRect.iTl.iX, clientRect.iTl.iY));
- QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
+ QScopedPointer<QSymbianControl> control( new QSymbianControl(q) );
+ Q_CHECK_PTR(control);
+
QT_TRAP_THROWING(control->ConstructL(true, desktop));
control->SetMopParent(static_cast<CEikAppUi*>(S60->appUi()));
@@ -429,7 +431,9 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create native child widget
- QScopedPointer<QSymbianControl> control( q_check_ptr(new QSymbianControl(q)) );
+ QScopedPointer<QSymbianControl> control( new QSymbianControl(q) );
+ Q_CHECK_PTR(control);
+
QT_TRAP_THROWING(control->ConstructL(!parentWidget));
// Symbian windows are always created in an inactive state
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 4d28e99..a02c5ba 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -329,18 +329,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (topLevel) {
if ((type == Qt::Window || dialog || tool)) {
if (!(flags & Qt::FramelessWindowHint)) {
- if (!(flags & Qt::MSWindowsFixedSizeDialogHint)) {
+ style |= WS_POPUP;
+ if (!(flags & Qt::MSWindowsFixedSizeDialogHint))
style |= WS_THICKFRAME;
- if(!(flags &
- ( Qt::WindowSystemMenuHint
- | Qt::WindowTitleHint
- | Qt::WindowMinMaxButtonsHint
- | Qt::WindowCloseButtonHint
- | Qt::WindowContextHelpButtonHint)))
- style |= WS_POPUP;
- } else {
- style |= WS_POPUP | WS_DLGFRAME;
- }
+ else
+ style |= WS_DLGFRAME;
}
if (flags & Qt::WindowTitleHint)
style |= WS_CAPTION;
@@ -424,6 +417,14 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (!q->testAttribute(Qt::WA_Resized)) {
w = sw/2;
h = 4*sh/10;
+ if (extra) {
+ int dx = rect.right - rect.left;
+ int dy = rect.bottom - rect.top;
+ w = qMin(w, extra->maxw + dx);
+ h = qMin(h, extra->maxh + dy);
+ w = qMax(w, extra->minw + dx);
+ h = qMax(h, extra->minh + dy);
+ }
}
if (!wasMoved) {
x = sw/2 - w/2;
@@ -1635,8 +1636,6 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
}
}
-extern Q_GUI_EXPORT HDC qt_win_display_dc();
-
int QWidget::metric(PaintDeviceMetric m) const
{
Q_D(const QWidget);
@@ -1646,7 +1645,7 @@ int QWidget::metric(PaintDeviceMetric m) const
} else if (m == PdmHeight) {
val = data->crect.height();
} else {
- HDC gdc = qt_win_display_dc();
+ HDC gdc = GetDC(0);
switch (m) {
case PdmDpiX:
case PdmPhysicalDpiX:
@@ -1697,6 +1696,7 @@ int QWidget::metric(PaintDeviceMetric m) const
val = 0;
qWarning("QWidget::metric: Invalid metric command");
}
+ ReleaseDC(0, gdc);
}
return val;
}
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index b0375ef..c6753fc 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -346,7 +346,7 @@ Q_GUI_EXPORT void qt_x11_enforce_cursor(QWidget * w)
qt_x11_enforce_cursor(w, false);
}
-Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
+void qt_x11_wait_for_window_manager(QWidget *w, bool sendPostedEvents)
{
if (!w || (!w->isWindow() && !w->internalWinId()))
return;
@@ -361,7 +361,8 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
WId winid = w->internalWinId();
// first deliver events that are already in the local queue
- QApplication::sendPostedEvents();
+ if (sendPostedEvents)
+ QApplication::sendPostedEvents();
// the normal sequence is:
// ... ConfigureNotify ... ReparentNotify ... MapNotify ... Expose
@@ -396,6 +397,11 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
} while(1);
}
+Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget *w)
+{
+ qt_x11_wait_for_window_manager(w, true);
+}
+
void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0)
{
if (!w->isVisible()) // not managed by the window manager
@@ -907,8 +913,17 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
inputContext->setFocusWidget(q);
}
- if (destroyw)
+ if (destroyw) {
qt_XDestroyWindow(q, dpy, destroyw);
+ if (QTLWExtra *topData = maybeTopData()) {
+#ifndef QT_NO_XSYNC
+ if (topData->syncUpdateCounter)
+ XSyncDestroyCounter(dpy, topData->syncUpdateCounter);
+#endif
+ // we destroyed our old window - reset the top-level state
+ createTLSysExtra();
+ }
+ }
// newly created windows are positioned at the window system's
// (0,0) position. If the parent uses wrect mapping to expand the
@@ -1487,7 +1502,7 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
|| !QX11Info::appDefaultColormap(xinfo.screen())) {
// unknown DE or non-default visual/colormap, use 1bpp bitmap
if (!forceReset || !topData->iconPixmap)
- topData->iconPixmap = new QBitmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64))));
+ topData->iconPixmap = new QPixmap(qt_toX11Pixmap(QBitmap(icon.pixmap(QSize(64,64)))));
pixmap_handle = topData->iconPixmap->handle();
} else {
// default depth, use a normal pixmap (even though this
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index 2a731e5..ab8af5f 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -131,6 +131,12 @@ QT_END_HEADER
#endif // Q_WS_QWS
+#if defined(Q_WS_QPA)
+
+typedef unsigned long WId;
+
+#endif // Q_WS_QPA
+
#if defined(Q_OS_SYMBIAN)
class CCoeControl;
typedef CCoeControl * WId;
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
new file mode 100644
index 0000000..740bb82
--- /dev/null
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -0,0 +1,291 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwindowsysteminterface_qpa.h"
+#include "qwindowsysteminterface_qpa_p.h"
+#include "qapplication_p.h"
+#include <QAbstractEventDispatcher>
+
+QT_BEGIN_NAMESPACE
+
+
+QTime QWindowSystemInterfacePrivate::eventTime;
+
+//------------------------------------------------------------
+//
+// Callback functions for plugins:
+//
+
+QList<QWindowSystemInterfacePrivate::WindowSystemEvent *> QWindowSystemInterfacePrivate::windowSystemEventQueue;
+QMutex QWindowSystemInterfacePrivate::queueMutex;
+
+extern QPointer<QWidget> qt_last_mouse_receiver;
+
+
+void QWindowSystemInterface::handleEnterEvent(QWidget *tlw)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ return;
+
+ QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ }
+}
+
+void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ return;
+ }
+ QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleWindowActivated(QWidget *tlw)
+{
+ QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ return;
+ }
+ QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+
+void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
+{
+ if (tlw) {
+ QWindowSystemInterfacePrivate::CloseEvent *e =
+ new QWindowSystemInterfacePrivate::CloseEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ }
+}
+
+/*!
+
+\a tlw == 0 means that \a ev is in global coords only
+
+
+*/
+void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleMouseEvent(w, time, local, global, b);
+}
+
+void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ tlw = 0;
+ }
+ QWindowSystemInterfacePrivate::MouseEvent * e =
+ new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleKeyEvent(w, time, t, k, mods, text, autorep, count);
+}
+
+void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ tlw = 0;
+ }
+
+ QWindowSystemInterfacePrivate::KeyEvent * e =
+ new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
+ text, autorep, count);
+}
+
+void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, int key,
+ Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ tlw = 0;
+ }
+
+ QWindowSystemInterfacePrivate::KeyEvent * e =
+ new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
+ nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleWheelEvent(w, time, local, global, d, o);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ tlw = 0;
+ }
+
+ QWindowSystemInterfacePrivate::WheelEvent *e =
+ new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
+{
+ queueMutex.lock();
+ int ret = windowSystemEventQueue.count();
+ queueMutex.unlock();
+ return ret;
+}
+
+QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
+{
+ queueMutex.lock();
+ QWindowSystemInterfacePrivate::WindowSystemEvent *ret;
+ if (windowSystemEventQueue.isEmpty())
+ ret = 0;
+ else
+ ret = windowSystemEventQueue.takeFirst();
+ queueMutex.unlock();
+ return ret;
+}
+
+void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
+{
+ queueMutex.lock();
+ windowSystemEventQueue.append(ev);
+ queueMutex.unlock();
+
+ QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher();
+ if (dispatcher)
+ dispatcher->wakeUp();
+}
+
+void QWindowSystemInterface::handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleTouchEvent(w, time, type, devType, points);
+}
+
+void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points)
+{
+ if (!points.size()) // Touch events must have at least one point
+ return;
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ Qt::TouchPointStates states;
+ QTouchEvent::TouchPoint p;
+
+ QList<struct TouchPoint>::const_iterator point = points.constBegin();
+ QList<struct TouchPoint>::const_iterator end = points.constEnd();
+ while (point != end) {
+ p.setId(point->id);
+ p.setPressure(point->pressure);
+ states |= point->state;
+ Qt::TouchPointStates state = point->state;
+ if (point->isPrimary) {
+ state |= Qt::TouchPointPrimary;
+ }
+ p.setState(state);
+ p.setRect(point->area);
+ p.setScreenPos(point->area.center());
+ p.setNormalizedPos(point->normalPosition);
+
+ touchPoints.append(p);
+ ++point;
+ }
+
+ QWindowSystemInterfacePrivate::TouchEvent *e =
+ new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, devType, touchPoints);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex)
+{
+ QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screenIndex);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex)
+{
+ QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screenIndex);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenCountChange(int count)
+{
+ QWindowSystemInterfacePrivate::ScreenCountEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenCountEvent(count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
new file mode 100644
index 0000000..a882fc1
--- /dev/null
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.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 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 QWINDOWSYSTEMINTERFACE_H
+#define QWINDOWSYSTEMINTERFACE_H
+
+#include <QtCore/QTime>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/QEvent>
+#include <QtGui/QWidget>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QMutex>
+#include <QtGui/QTouchEvent>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QWindowSystemInterface
+{
+public:
+ static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
+ static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
+
+ static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+ static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+
+ static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+ static void handleExtendedKeyEvent(QWidget *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+
+ static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
+ static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
+
+ struct TouchPoint {
+ int id; // for application use
+ bool isPrimary; // for application use
+ QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
+ QRectF area; // the touched area, centered at position in screen coordinates
+ qreal pressure; // 0 to 1
+ Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
+ };
+
+ static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
+ static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
+
+ static void handleGeometryChange(QWidget *w, const QRect &newRect);
+ static void handleCloseEvent(QWidget *w);
+ static void handleEnterEvent(QWidget *w);
+ static void handleLeaveEvent(QWidget *w);
+ static void handleWindowActivated(QWidget *w);
+
+ // Changes to the screen
+ static void handleScreenGeometryChange(int screenIndex);
+ static void handleScreenAvailableGeometryChange(int screenIndex);
+ static void handleScreenCountChange(int count);
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif // QWINDOWSYSTEMINTERFACE_H
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
new file mode 100644
index 0000000..6be86ad
--- /dev/null
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 QWINDOWSYSTEMINTERFACE_QPA_P_H
+#define QWINDOWSYSTEMINTERFACE_QPA_P_H
+
+#include "qwindowsysteminterface_qpa.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QWindowSystemInterfacePrivate {
+public:
+ enum EventType {
+ Close,
+ GeometryChange,
+ Enter,
+ Leave,
+ ActivatedWindow,
+ Mouse,
+ Wheel,
+ Key,
+ Touch,
+ ScreenGeometry,
+ ScreenAvailableGeometry,
+ ScreenCountChange
+ };
+
+ class WindowSystemEvent {
+ public:
+ WindowSystemEvent(EventType t)
+ : type(t) { }
+ EventType type;
+ };
+
+ class CloseEvent : public WindowSystemEvent {
+ public:
+ CloseEvent(QWidget *tlw)
+ : WindowSystemEvent(Close), topLevel(tlw) { }
+ QWeakPointer<QWidget> topLevel;
+ };
+
+ class GeometryChangeEvent : public WindowSystemEvent {
+ public:
+ GeometryChangeEvent(QWidget *tlw, const QRect &newGeometry)
+ : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
+ { }
+ QWeakPointer<QWidget> tlw;
+ QRect newGeometry;
+ };
+
+ class EnterEvent : public WindowSystemEvent {
+ public:
+ EnterEvent(QWidget *enter)
+ : WindowSystemEvent(Enter), enter(enter)
+ { }
+ QWeakPointer<QWidget> enter;
+ };
+
+ class LeaveEvent : public WindowSystemEvent {
+ public:
+ LeaveEvent(QWidget *leave)
+ : WindowSystemEvent(Leave), leave(leave)
+ { }
+ QWeakPointer<QWidget> leave;
+ };
+
+ class ActivatedWindowEvent : public WindowSystemEvent {
+ public:
+ ActivatedWindowEvent(QWidget *activatedWindow)
+ : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
+ { }
+ QWeakPointer<QWidget> activated;
+ };
+
+ class UserEvent : public WindowSystemEvent {
+ public:
+ UserEvent(QWidget * w, ulong time, EventType t)
+ : WindowSystemEvent(t), widget(w), timestamp(time) { }
+ QWeakPointer<QWidget> widget;
+ unsigned long timestamp;
+ };
+
+ class MouseEvent : public UserEvent {
+ public:
+ MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+ : UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::MouseButtons buttons;
+ };
+
+ class WheelEvent : public UserEvent {
+ public:
+ WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+ : UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
+ int delta;
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::Orientation orient;
+ };
+
+ class KeyEvent : public UserEvent {
+ public:
+ KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
+ KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
+ quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
+ const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { }
+ int key;
+ QString unicode;
+ bool repeat;
+ ushort repeatCount;
+ Qt::KeyboardModifiers modifiers;
+ QEvent::Type keyType;
+ quint32 nativeScanCode;
+ quint32 nativeVirtualKey;
+ quint32 nativeModifiers;
+ };
+
+ class TouchEvent : public UserEvent {
+ public:
+ TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p)
+ :UserEvent(w, time, Touch), devType(d), points(p), touchType(t) { }
+ QTouchEvent::DeviceType devType;
+ QList<QTouchEvent::TouchPoint> points;
+ QEvent::Type touchType;
+
+ };
+
+ class ScreenCountEvent : public WindowSystemEvent {
+ public:
+ ScreenCountEvent (int count)
+ : WindowSystemEvent(ScreenCountChange) , count(count) { }
+ int count;
+ };
+
+ class ScreenGeometryEvent : public WindowSystemEvent {
+ public:
+ ScreenGeometryEvent(int index)
+ : WindowSystemEvent(ScreenGeometry), index(index) { }
+ int index;
+ };
+
+ class ScreenAvailableGeometryEvent : public WindowSystemEvent {
+ public:
+ ScreenAvailableGeometryEvent(int index)
+ : WindowSystemEvent(ScreenAvailableGeometry), index(index) { }
+ int index;
+ };
+
+ static QList<WindowSystemEvent *> windowSystemEventQueue;
+ static QMutex queueMutex;
+
+ static int windowSystemEventsQueued();
+ static WindowSystemEvent * getWindowSystemEvent();
+ static void queueWindowSystemEvent(WindowSystemEvent *ev);
+
+ static QTime eventTime;
+};
+
+QT_END_HEADER
+QT_END_NAMESPACE
+
+#endif // QWINDOWSYSTEMINTERFACE_QPA_P_H
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 710f607..49a8194 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -513,7 +513,7 @@ QX11EmbedWidget::~QX11EmbedWidget()
<< "from container with winId" << d->container;
#endif
XUnmapWindow(x11Info().display(), internalWinId());
- XReparentWindow(x11Info().display(), internalWinId(), x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), internalWinId(), x11Info().appRootWindow(x11Info().screen()), 0, 0);
}
#ifdef QX11EMBED_DEBUG
@@ -792,13 +792,13 @@ bool QX11EmbedWidget::x11Event(XEvent *event)
qDebug() << "QX11EmbedWidget::x11Event: client"
<< (void *)this << "with winId" << winId()
<< "received a ReparentNotify to"
- << ((event->xreparent.parent == x11Info().appRootWindow())
+ << ((event->xreparent.parent == x11Info().appRootWindow(x11Info().screen()))
? QString::fromLatin1("root") : QString::number(event->xreparent.parent));
#endif
// If the container shuts down, we will be reparented to the
// root window. We must also consider the case that we may be
// reparented from one container to another.
- if (event->xreparent.parent == x11Info().appRootWindow()) {
+ if (event->xreparent.parent == x11Info().appRootWindow(x11Info().screen())) {
if (((QHackWidget *)this)->topData()->embedded) {
d->container = 0;
emit containerClosed();
@@ -1118,7 +1118,7 @@ QX11EmbedContainer::~QX11EmbedContainer()
Q_D(QX11EmbedContainer);
if (d->client) {
XUnmapWindow(x11Info().display(), d->client);
- XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
}
if (d->xgrab)
@@ -1382,7 +1382,7 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
// Wait until the messages have been processed. Then ask
// the window manager to delete the window.
XUnmapWindow(x11Info().display(), d->client);
- XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
XSync(x11Info().display(), false);
XEvent ev;
@@ -1630,7 +1630,7 @@ void QX11EmbedContainerPrivate::rejectClient(WId window)
Q_Q(QX11EmbedContainer);
q->setEnabled(false);
XRemoveFromSaveSet(q->x11Info().display(), client);
- XReparentWindow(q->x11Info().display(), window, q->x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(q->x11Info().display(), window, q->x11Info().appRootWindow(q->x11Info().screen()), 0, 0);
}
/*! \internal
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.cpp b/src/gui/math3d/qmatrix4x4.cpp
index e839b25..c18dd3c 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -102,8 +102,6 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
\sa optimize()
*/
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
-
/*!
\fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
@@ -112,7 +110,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
the remaining elements are filled with elements from the identity
matrix.
- \sa toGenericMatrix(), qGenericMatrixToMatrix4x4()
+ \sa toGenericMatrix()
*/
/*!
@@ -122,34 +120,32 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
then the remaining elements are filled with elements from the
identity matrix.
-
- \sa qGenericMatrixFromMatrix4x4()
*/
-#endif
-
/*!
\fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
\relates QMatrix4x4
+ \obsolete
Returns a 4x4 matrix constructed from the left-most 4 columns and
top-most 4 rows of \a matrix. If \a matrix has less than 4 columns
or rows, the remaining elements are filled with elements from the
identity matrix.
- \sa qGenericMatrixFromMatrix4x4()
+ \sa QMatrix4x4(const QGenericMatrix &)
*/
/*!
\fn QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
+ \obsolete
Returns a NxM generic matrix constructed from the left-most N columns
and top-most M rows of \a matrix. If N or M is greater than 4,
then the remaining elements are filled with elements from the
identity matrix.
- \sa qGenericMatrixToMatrix4x4(), QMatrix4x4::toGenericMatrix()
+ \sa QMatrix4x4::toGenericMatrix()
*/
/*!
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 6d8a68b..ad05116 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -69,10 +69,10 @@ public:
qreal m21, qreal m22, qreal m23, qreal m24,
qreal m31, qreal m32, qreal m33, qreal m34,
qreal m41, qreal m42, qreal m43, qreal m44);
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
+
template <int N, int M>
explicit QMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix);
-#endif
+
QMatrix4x4(const qreal *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
@@ -169,14 +169,12 @@ public:
QRect mapRect(const QRect& rect) const;
QRectF mapRect(const QRectF& rect) const;
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
QGenericMatrix<N, M, qreal> toGenericMatrix() const;
-#endif
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();
@@ -223,8 +221,6 @@ inline QMatrix4x4::QMatrix4x4
flagBits = General;
}
-#if !defined(QT_NO_MEMBER_TEMPLATES)
-
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
(const QGenericMatrix<N, M, qreal>& matrix)
@@ -261,8 +257,6 @@ QGenericMatrix<N, M, qreal> QMatrix4x4::toGenericMatrix() const
return result;
}
-#endif
-
inline const qreal& QMatrix4x4::operator()(int aRow, int aColumn) const
{
Q_ASSERT(aRow >= 0 && aRow < 4 && aColumn >= 0 && aColumn < 4);
@@ -980,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
@@ -992,14 +986,15 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QMatrix4x4 &);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QMatrix4x4 &);
#endif
+#ifdef QT_DEPRECATED
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
+QT_DEPRECATED QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QT_DEPRECATED QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
QGenericMatrix<N, M, qreal> result;
const qreal *m = matrix.constData();
@@ -1016,6 +1011,7 @@ QGenericMatrix<N, M, qreal> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix
}
return result;
}
+#endif
#endif
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index bd37d9f..65e7af4 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -34,6 +34,7 @@ HEADERS += \
painting/qprinter.h \
painting/qprinter_p.h \
painting/qprinterinfo.h \
+ painting/qprinterinfo_p.h \
painting/qrasterizer_p.h \
painting/qregion.h \
painting/qstroker_p.h \
@@ -73,6 +74,7 @@ SOURCES += \
painting/qprintengine_pdf.cpp \
painting/qprintengine_ps.cpp \
painting/qprinter.cpp \
+ painting/qprinterinfo.cpp \
painting/qrasterizer.cpp \
painting/qregion.cpp \
painting/qstroker.cpp \
@@ -87,14 +89,18 @@ SOURCES += \
painting/qpaintengine_raster.cpp \
painting/qdrawhelper.cpp \
painting/qimagescale.cpp \
- painting/qgrayraster.c
+ painting/qgrayraster.c \
+ painting/qpaintengine_blitter.cpp \
+ painting/qblittable.cpp \
HEADERS += \
painting/qpaintengine_raster_p.h \
painting/qdrawhelper_p.h \
painting/qblendfunctions_p.h \
painting/qrasterdefs_p.h \
- painting/qgrayraster_p.h
+ painting/qgrayraster_p.h \
+ painting/qpaintengine_blitter_p.h \
+ painting/qblittable_p.h \
win32 {
HEADERS += painting/qprintengine_win_p.h
@@ -115,20 +121,20 @@ embedded {
SOURCES += \
painting/qgraphicssystem_qws.cpp \
-} else {
+} else: if(!qpa) {
HEADERS += \
painting/qgraphicssystem_raster_p.h \
painting/qgraphicssystem_runtime_p.h \
painting/qgraphicssystemfactory_p.h \
painting/qgraphicssystemplugin_p.h \
- painting/qwindowsurface_raster_p.h \
+ painting/qwindowsurface_raster_p.h
SOURCES += \
painting/qgraphicssystem_raster.cpp \
painting/qgraphicssystem_runtime.cpp \
painting/qgraphicssystemfactory.cpp \
painting/qgraphicssystemplugin.cpp \
- painting/qwindowsurface_raster.cpp \
+ painting/qwindowsurface_raster.cpp
}
unix:x11 {
@@ -141,7 +147,7 @@ unix:x11 {
painting/qpaintengine_x11.cpp
}
-!embedded:!x11:mac {
+!embedded:!qpa:!x11:mac {
HEADERS += \
painting/qpaintengine_mac_p.h \
painting/qgraphicssystem_mac_p.h \
@@ -157,14 +163,14 @@ unix:x11 {
painting/qprintengine_mac.mm \
}
-unix:!mac:!symbian {
+unix:!mac:!symbian|qpa {
HEADERS += \
painting/qprinterinfo_unix_p.h
SOURCES += \
painting/qprinterinfo_unix.cpp
}
-win32|x11|mac|embedded|symbian {
+win32|x11|mac|embedded|qpa|symbian {
SOURCES += painting/qbackingstore.cpp
HEADERS += painting/qbackingstore_p.h
}
@@ -181,6 +187,12 @@ embedded {
painting/qpaintdevice_qws.cpp
}
+qpa {
+ SOURCES += \
+ painting/qcolormap_qpa.cpp \
+ painting/qpaintdevice_qpa.cpp
+}
+
symbian {
SOURCES += \
painting/qpaintengine_s60.cpp \
@@ -191,7 +203,7 @@ symbian {
painting/qpaintengine_s60_p.h
}
-x11|embedded {
+x11|embedded|qpa {
contains(QT_CONFIG,qtopia) {
DEFINES += QT_NO_CUPS QT_NO_LPR
} else {
@@ -221,9 +233,11 @@ x11 {
SOURCES += painting/qwindowsurface_x11.cpp
}
-mac {
- HEADERS += painting/qwindowsurface_mac_p.h
- SOURCES += painting/qwindowsurface_mac.cpp
+!embedded:!qpa:mac {
+ HEADERS += painting/qwindowsurface_mac_p.h \
+ painting/qunifiedtoolbarsurface_mac_p.h
+ SOURCES += painting/qwindowsurface_mac.cpp \
+ painting/qunifiedtoolbarsurface_mac.cpp
}
embedded {
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 4fcff1d..e5d8abc 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -98,6 +98,21 @@ static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurfa
QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
#endif
+ //The performance hit by doing this should be negligible. However, be aware that
+ //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
+ static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
+ if (fpsDebug) {
+ static QTime time = QTime::currentTime();
+ static int frames = 0;
+
+ frames++;
+
+ if(time.elapsed() > 5000) {
+ double fps = double(frames * 1000) /time.restart();
+ fprintf(stderr,"FPS: %.1f\n",fps);
+ frames = 0;
+ }
+ }
if (widget != tlw)
windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
else
@@ -271,7 +286,11 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi
void QWidgetBackingStore::releaseBuffer()
{
if (windowSurface)
+#if defined(Q_WS_QPA)
+ windowSurface->resize(QSize());
+#else
windowSurface->setGeometry(QRect());
+#endif
#ifdef Q_BACKINGSTORE_SUBSURFACES
for (int i = 0; i < subSurfaces.size(); ++i)
subSurfaces.at(i)->setGeometry(QRect());
@@ -401,7 +420,11 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
{
const bool widgetDirty = widget && widget != tlw;
const QRect tlwRect(topLevelRect());
+#if defined(Q_WS_QPA)
+ const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
+#else
const QRect surfaceGeometry(windowSurface->geometry());
+#endif
if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
if (widgetDirty) {
const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
@@ -452,7 +475,11 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const
{
if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
+#if defined(Q_WS_QPA)
+ const QSize surfaceGeometry(windowSurface->size());
+#else
const QRect surfaceGeometry(windowSurface->geometry());
+#endif
QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
if (!withinClipRect.isEmpty())
surfaceRect &= withinClipRect;
@@ -720,9 +747,8 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widg
}
// Alien widgets.
- if (!widget->internalWinId()) {
- QWidget *nativeParent = widget->nativeParentWidget();
- // Alien widgets with the top-level as the native parent (common case).
+ if (!widget->internalWinId() && !widget->isWindow()) {
+ QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case).
if (nativeParent == tlw) {
if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
dirtyOnScreen += region.translated(topLevelOffset);
@@ -1157,12 +1183,16 @@ void QWidgetBackingStore::sync()
return;
}
- const bool inTopLevelResize = tlwExtra->inTopLevelResize;
const bool updatesDisabled = !tlw->updatesEnabled();
- const QRect tlwRect(topLevelRect());
- const QRect surfaceGeometry(windowSurface->geometry());
bool repaintAllWidgets = false;
+ const bool inTopLevelResize = tlwExtra->inTopLevelResize;
+ const QRect tlwRect(topLevelRect());
+#ifdef Q_WS_QPA
+ const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
+#else
+ const QRect surfaceGeometry(windowSurface->geometry());
+#endif
if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
if (hasStaticContents()) {
// Repaint existing dirty area and newly visible area.
@@ -1182,8 +1212,13 @@ void QWidgetBackingStore::sync()
}
}
+#ifdef Q_WS_QPA
+ if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size())
+ windowSurface->resize(tlwRect.size());
+#else
if (inTopLevelResize || surfaceGeometry != tlwRect)
windowSurface->setGeometry(tlwRect);
+#endif
if (updatesDisabled)
return;
@@ -1590,7 +1625,11 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn)
extra->staticContentsSize = data.crect.size();
}
+#ifdef Q_WS_QPA //Dont even call q->p
+ QPaintEngine *engine = 0;
+#else
QPaintEngine *engine = q->paintEngine();
+#endif
// QGLWidget does not support partial updates if:
// 1) The context is double buffered
// 2) The context is single buffered and auto-fill background is enabled.
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
index e2b21c3..39bf66c 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)
@@ -261,7 +262,8 @@ private:
}
inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport(); }
+ { return !staticWidgets.isEmpty() && windowSurface->hasStaticContentsSupport()
+ && windowSurface->hasPartialUpdateSupport(); }
friend QRegion qt_dirtyRegion(QWidget *);
friend class QWidgetPrivate;
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 517959e..10674f8 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -309,9 +309,9 @@ 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_ARM) || 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_ARMV6) & SH & AVR32 & SPARC w/GCC
+ // ARM <v6 (QT_ARCH_ARMV5) & SH & AVR32 & SPARC w/GCC
quint16 spix = (quint16(src[2])<<8) + src[1];
#else
quint16 spix = *(quint16 *) (src + 1);
diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp
new file mode 100644
index 0000000..5802531
--- /dev/null
+++ b/src/gui/painting/qblittable.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qblittable_p.h"
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class QBlittablePrivate
+{
+public:
+ QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps)
+ : caps(caps), m_size(size), locked(false), cachedImg(0)
+ {}
+ QBlittable::Capabilities caps;
+ QSize m_size;
+ bool locked;
+ QImage *cachedImg;
+};
+
+
+QBlittable::QBlittable(const QSize &size, Capabilities caps)
+ : d_ptr(new QBlittablePrivate(size,caps))
+{
+}
+
+QBlittable::~QBlittable()
+{
+ delete d_ptr;
+}
+
+
+QBlittable::Capabilities QBlittable::capabilities() const
+{
+ Q_D(const QBlittable);
+ return d->caps;
+}
+
+QSize QBlittable::size() const
+{
+ Q_D(const QBlittable);
+ return d->m_size;
+}
+
+QImage *QBlittable::lock()
+{
+ Q_D(QBlittable);
+ if (!d->locked) {
+ d->cachedImg = doLock();
+ d->locked = true;
+ }
+
+ return d->cachedImg;
+}
+
+void QBlittable::unlock()
+{
+ Q_D(QBlittable);
+ if (d->locked) {
+ doUnlock();
+ d->locked = false;
+ }
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
new file mode 100644
index 0000000..9d0e822
--- /dev/null
+++ b/src/gui/painting/qblittable_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QBLITTABLE_P_H
+#define QBLITTABLE_P_H
+
+#include <QtCore/qsize.h>
+#include <QtGui/private/qpixmap_blitter_p.h>
+
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class QImage;
+class QBlittablePrivate;
+
+class Q_GUI_EXPORT QBlittable
+{
+ Q_DECLARE_PRIVATE(QBlittable);
+public:
+ enum Capability {
+
+ SolidRectCapability = 0x0001,
+ SourcePixmapCapability = 0x0002,
+ SourceOverPixmapCapability = 0x0004,
+ SourceOverScaledPixmapCapability = 0x0008,
+
+ // Internal ones
+ OutlineCapability = 0x0001000,
+ };
+ Q_DECLARE_FLAGS (Capabilities, Capability);
+
+ QBlittable(const QSize &size, Capabilities caps);
+ virtual ~QBlittable();
+
+ Capabilities capabilities() const;
+ QSize size() const;
+
+ virtual void fillRect(const QRectF &rect, const QColor &color) = 0;
+ virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0;
+
+ QImage *lock();
+ void unlock();
+
+protected:
+ virtual QImage *doLock() = 0;
+ virtual void doUnlock() = 0;
+ QBlittablePrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+#endif //QBLITTABLE_P_H
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index dc61e34..811f3ae 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -635,6 +635,15 @@ QBrush &QBrush::operator=(const QBrush &b)
return *this;
}
+
+/*!
+ \fn void QBrush::swap(QBrush &other)
+ \since 4.8
+
+ Swaps brush \a other with this brush. This operation is very
+ fast and never fails.
+*/
+
/*!
Returns the brush as a QVariant
*/
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index ac247a6..8b31319 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -92,6 +92,12 @@ public:
~QBrush();
QBrush &operator=(const QBrush &brush);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QBrush &operator=(QBrush &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QBrush &other) { qSwap(d, other.d); }
+
operator QVariant() const;
inline Qt::BrushStyle style() const;
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 8ebbe35..73a6ed8 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -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/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp
index b9ec0d4..38fed71 100644
--- a/src/gui/painting/qcolor_p.cpp
+++ b/src/gui/painting/qcolor_p.cpp
@@ -49,9 +49,6 @@
#include "qrgb.h"
#include "qstringlist.h"
-#if defined(Q_WS_WINCE)
-#include "qguifunctions_wince.h"
-#endif
QT_BEGIN_NAMESPACE
static inline int h2i(char hex)
@@ -290,33 +287,16 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
#undef rgb
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <stdlib.h>
-QT_END_INCLUDE_NAMESPACE
-
-#if defined(Q_C_CALLBACKS)
-extern "C" {
-#endif
-
-#ifdef Q_OS_WINCE
-static int __cdecl rgb_cmp(const void *d1, const void *d2)
-#else
-static int rgb_cmp(const void *d1, const void *d2)
-#endif
-{
- return qstricmp(((RGBData *)d1)->name, ((RGBData *)d2)->name);
-}
-
-#if defined(Q_C_CALLBACKS)
-}
-#endif
+inline bool operator<(const char *name, const RGBData &data)
+{ return qstrcmp(name, data.name) < 0; }
+inline bool operator<(const RGBData &data, const char *name)
+{ return qstrcmp(data.name, name) < 0; }
-static bool get_named_rgb(const char *name, QRgb *rgb)
+static bool get_named_rgb(const char *name_no_space, QRgb *rgb)
{
- RGBData x;
- x.name = name;
- RGBData *r = (RGBData*)bsearch(&x, rgbTbl, rgbTblSize, sizeof(RGBData), rgb_cmp);
- if (r) {
+ QByteArray name = QByteArray(name_no_space).toLower();
+ const RGBData *r = qBinaryFind(rgbTbl, rgbTbl + rgbTblSize, name.constData());
+ if (r != rgbTbl + rgbTblSize) {
*rgb = r->value;
return true;
}
diff --git a/src/gui/painting/qcolormap_qpa.cpp b/src/gui/painting/qcolormap_qpa.cpp
new file mode 100644
index 0000000..1f4fea8
--- /dev/null
+++ b/src/gui/painting/qcolormap_qpa.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcolormap.h"
+#include "qcolor.h"
+#include "qpaintdevice.h"
+#include "private/qapplication_p.h"
+#include "private/qgraphicssystem_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QColormapPrivate
+{
+public:
+ inline QColormapPrivate()
+ : ref(1), mode(QColormap::Direct), depth(0), numcolors(0)
+ { }
+
+ QAtomicInt ref;
+
+ QColormap::Mode mode;
+ int depth;
+ int numcolors;
+};
+
+static QColormapPrivate *screenMap = 0;
+
+void QColormap::initialize()
+{
+ screenMap = new QColormapPrivate;
+
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen*> screens = pi->screens();
+
+ screenMap->depth = screens[0]->depth();
+ if (screenMap->depth < 8) {
+ screenMap->mode = QColormap::Indexed;
+ screenMap->numcolors = 256;
+ } else {
+ screenMap->mode = QColormap::Direct;
+ screenMap->numcolors = -1;
+ }
+}
+
+void QColormap::cleanup()
+{
+ delete screenMap;
+ screenMap = 0;
+}
+
+QColormap QColormap::instance(int /*screen*/)
+{
+ return QColormap();
+}
+
+QColormap::QColormap()
+ : d(screenMap)
+{ d->ref.ref(); }
+
+QColormap::QColormap(const QColormap &colormap)
+ :d (colormap.d)
+{ d->ref.ref(); }
+
+QColormap::~QColormap()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+QColormap::Mode QColormap::mode() const
+{ return d->mode; }
+
+
+int QColormap::depth() const
+{ return d->depth; }
+
+
+int QColormap::size() const
+{
+ return d->numcolors;
+}
+
+#ifndef QT_QWS_DEPTH16_RGB
+#define QT_QWS_DEPTH16_RGB 565
+#endif
+static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
+static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
+static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
+static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
+static const int qt_green_shift = qt_bbits-(8-qt_gbits);
+static const int qt_neg_blue_shift = 8-qt_bbits;
+static const int qt_blue_mask = (1<<qt_bbits)-1;
+static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
+static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
+
+static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
+static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
+static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
+
+inline ushort qt_convRgbTo16(QRgb c)
+{
+ const int tr = qRed(c) << qt_red_shift;
+ const int tg = qGreen(c) << qt_green_shift;
+ const int tb = qBlue(c) >> qt_neg_blue_shift;
+
+ return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
+}
+
+inline QRgb qt_conv16ToRgb(ushort c)
+{
+ const int r=(c & qt_red_mask);
+ const int g=(c & qt_green_mask);
+ const int b=(c & qt_blue_mask);
+ const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
+ const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
+ const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
+
+ return qRgb(tr,tg,tb);
+}
+
+uint QColormap::pixel(const QColor &color) const
+{
+ QRgb rgb = color.rgba();
+ if (d->mode == QColormap::Direct) {
+ switch(d->depth) {
+ case 16:
+ return qt_convRgbTo16(rgb);
+ case 24:
+ case 32:
+ {
+ const int r = qRed(rgb);
+ const int g = qGreen(rgb);
+ const int b = qBlue(rgb);
+ const int red_shift = 16;
+ const int green_shift = 8;
+ const int red_mask = 0xff0000;
+ const int green_mask = 0x00ff00;
+ const int blue_mask = 0x0000ff;
+ const int tg = g << green_shift;
+#ifdef QT_QWS_DEPTH_32_BGR
+ if (qt_screen->pixelType() == QScreen::BGRPixel) {
+ const int tb = b << red_shift;
+ return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask);
+ }
+#endif
+ const int tr = r << red_shift;
+ return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask);
+ }
+ }
+ }
+ //XXX
+ //return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb));
+ return 0;
+}
+
+const QColor QColormap::colorAt(uint pixel) const
+{
+ if (d->mode == Direct) {
+ if (d->depth == 16) {
+ pixel = qt_conv16ToRgb(pixel);
+ }
+ const int red_shift = 16;
+ const int green_shift = 8;
+ const int red_mask = 0xff0000;
+ const int green_mask = 0x00ff00;
+ const int blue_mask = 0x0000ff;
+#ifdef QT_QWS_DEPTH_32_BGR
+ if (qt_screen->pixelType() == QScreen::BGRPixel) {
+ return QColor((pixel & blue_mask),
+ (pixel & green_mask) >> green_shift,
+ (pixel & red_mask) >> red_shift);
+ }
+#endif
+ return QColor((pixel & red_mask) >> red_shift,
+ (pixel & green_mask) >> green_shift,
+ (pixel & blue_mask));
+ }
+#if 0 // XXX
+ Q_ASSERT_X(int(pixel) < qt_screen->numCols(), "QColormap::colorAt", "pixel out of bounds of palette");
+ return QColor(qt_screen->clut()[pixel]);
+#endif
+ return QColor();
+}
+
+const QVector<QColor> QColormap::colormap() const
+{
+ return QVector<QColor>();
+}
+
+QColormap &QColormap::operator=(const QColormap &colormap)
+{ qAtomicAssign(d, colormap.d); return *this; }
+
+QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h
index 2d61cc5..d8793c3 100644
--- a/src/gui/painting/qdrawingprimitive_sse2_p.h
+++ b/src/gui/painting/qdrawingprimitive_sse2_p.h
@@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_mullo_epi16(pixelVectorAG, alphaChannel); \
pixelVectorRB = _mm_mullo_epi16(pixelVectorRB, alphaChannel); \
\
- /* 3. devide by 255, that's the tricky part. \
+ /* 3. divide by 255, that's the tricky part. \
we do it like for BYTE_MUL(), with bit shift: X/255 ~= (X + X/256 + rounding)/256 */ \
/** so first (X + X/256 + rounding) */\
pixelVectorRB = _mm_add_epi16(pixelVectorRB, _mm_srli_epi16(pixelVectorRB, 8)); \
@@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE
pixelVectorAG = _mm_add_epi16(pixelVectorAG, _mm_srli_epi16(pixelVectorAG, 8)); \
pixelVectorAG = _mm_add_epi16(pixelVectorAG, half); \
\
- /** second devide by 256 */\
+ /** second divide by 256 */\
pixelVectorRB = _mm_srli_epi16(pixelVectorRB, 8); \
/** for AG, we could >> 8 to divide followed by << 8 to put the \
bytes in the correct position. By masking instead, we execute \
diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp
index 5112019..171ef46 100644
--- a/src/gui/painting/qgraphicssystem.cpp
+++ b/src/gui/painting/qgraphicssystem.cpp
@@ -50,6 +50,9 @@
#ifdef Q_WS_MAC
# include <private/qpixmap_mac_p.h>
#endif
+#ifdef Q_WS_QPA
+# include <QtGui/private/qapplication_p.h>
+#endif
#ifdef Q_OS_SYMBIAN
# include <private/qpixmap_s60_p.h>
#endif
@@ -71,8 +74,10 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ
return new QRasterPixmapData(type);
#elif defined(Q_WS_MAC)
return new QMacPixmapData(type);
+#elif defined(Q_WS_QPA)
+ return QApplicationPrivate::platformIntegration()->createPixmapData(type);
#elif defined(Q_OS_SYMBIAN)
- return new QS60PixmapData(type);
+ return new QS60PixmapData(type);
#elif !defined(Q_WS_QWS)
#error QGraphicsSystem::createDefaultPixmapData() not implemented
#endif
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
index 80e8959..0f99a31 100644
--- a/src/gui/painting/qgraphicssystem_p.h
+++ b/src/gui/painting/qgraphicssystem_p.h
@@ -55,10 +55,14 @@
#include "private/qpixmapdata_p.h"
#include "private/qwindowsurface_p.h"
+#include "private/qpaintengine_blitter_p.h"
+
+#include <qdebug.h>
QT_BEGIN_NAMESPACE
class QPixmapFilter;
+class QBlittable;
class Q_GUI_EXPORT QGraphicsSystem
{
@@ -67,7 +71,7 @@ public:
virtual QPixmapData *createPixmapData(QPixmapData *origin);
virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0;
- virtual ~QGraphicsSystem() = 0;
+ virtual ~QGraphicsSystem();
//### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed
// to have a graphics system.
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index 33652ee..46a6f81 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -319,6 +319,16 @@ QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const
return m_windowSurface->offset(widget);
}
+bool QRuntimeWindowSurface::hasStaticContentsSupport() const
+{
+ return m_windowSurface->hasStaticContentsSupport();
+}
+
+bool QRuntimeWindowSurface::hasPartialUpdateSupport() const
+{
+ return m_windowSurface->hasPartialUpdateSupport();
+}
+
QRuntimeGraphicsSystem::QRuntimeGraphicsSystem()
: m_windowSurfaceDestroyPolicy(DestroyImmediately),
m_graphicsSystem(0)
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
index 30b4e3e..998fa98 100644
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ b/src/gui/painting/qgraphicssystem_runtime_p.h
@@ -129,6 +129,9 @@ public:
virtual QPoint offset(const QWidget *widget) const;
+ virtual bool hasStaticContentsSupport() const;
+ virtual bool hasPartialUpdateSupport() const;
+
QScopedPointer<QWindowSurface> m_windowSurface;
QScopedPointer<QWindowSurface> m_pendingWindowSurface;
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
index 22e947c..62a60d7 100644
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ b/src/gui/painting/qgraphicssystemfactory.cpp
@@ -45,6 +45,7 @@
#include "qmutex.h"
#include "qapplication.h"
+#include <private/qapplication_p.h>
#include "qgraphicssystem_raster_p.h"
#include "qgraphicssystem_runtime_p.h"
#include "qdebug.h"
@@ -73,12 +74,13 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
if (system.isEmpty()) {
system = QLatin1String("runtime");
}
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN)
+#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11)
if (system.isEmpty()) {
system = QLatin1String("raster");
}
#endif
+ QApplicationPrivate::graphics_system_name = system;
if (system == QLatin1String("raster"))
return new QRasterGraphicsSystem;
else if (system == QLatin1String("runtime"))
diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c
index 08a6ef8..e5e8ba4 100644
--- a/src/gui/painting/qgrayraster.c
+++ b/src/gui/painting/qgrayraster.c
@@ -408,25 +408,31 @@
/* */
/* Record the current cell in the table. */
/* */
- static PCell
- gray_find_cell( RAS_ARG )
+ static void
+ gray_record_cell( RAS_ARG )
{
PCell *pcell, cell;
int x = ras.ex;
+ if ( ras.invalid || !( ras.area | ras.cover ) )
+ return;
if ( x > ras.max_ex )
x = ras.max_ex;
pcell = &ras.ycells[ras.ey];
+
for (;;)
{
cell = *pcell;
if ( cell == NULL || cell->x > x )
break;
- if ( cell->x == x )
- goto Exit;
+ if ( cell->x == x ) {
+ cell->area += ras.area;
+ cell->cover += ras.cover;
+ return;
+ }
pcell = &cell->next;
}
@@ -436,28 +442,11 @@
cell = ras.cells + ras.num_cells++;
cell->x = x;
- cell->area = 0;
- cell->cover = 0;
+ cell->area = ras.area;
+ cell->cover = ras.cover;
cell->next = *pcell;
*pcell = cell;
-
- Exit:
- return cell;
- }
-
-
- static void
- gray_record_cell( RAS_ARG )
- {
- if ( !ras.invalid && ( ras.area | ras.cover ) )
- {
- PCell cell = gray_find_cell( RAS_VAR );
-
-
- cell->area += ras.area;
- cell->cover += ras.cover;
- }
}
diff --git a/src/gui/painting/qgrayraster_p.h b/src/gui/painting/qgrayraster_p.h
index f2dd9d2..b9a4aed 100644
--- a/src/gui/painting/qgrayraster_p.h
+++ b/src/gui/painting/qgrayraster_p.h
@@ -91,7 +91,7 @@
/* Minimum buffer size for raster object, that accounts
for TWorker and TCell sizes.*/
-#define MINIMUM_POOL_SIZE 4096
+#define MINIMUM_POOL_SIZE 8192
QT_FT_EXPORT_VAR( const QT_FT_Raster_Funcs ) qt_ft_grays_raster;
diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp
index 6e53c35..aac5083 100644
--- a/src/gui/painting/qoutlinemapper.cpp
+++ b/src/gui/painting/qoutlinemapper.cpp
@@ -47,8 +47,6 @@
QT_BEGIN_NAMESPACE
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
#define qreal_to_fixed_26_6(f) (int(f * 64))
@@ -216,13 +214,6 @@ void QOutlineMapper::endOutline()
elements = m_elements_dev.data();
}
- if (m_round_coords) {
- // round coordinates to match outlines drawn with drawLine_midpoint_i
- for (int i = 0; i < m_elements.size(); ++i)
- elements[i] = QPointF(qFloor(elements[i].x() + aliasedCoordinateDelta),
- qFloor(elements[i].y() + aliasedCoordinateDelta));
- }
-
controlPointRect = boundingRect(elements, element_count);
#ifdef QT_DEBUG_CONVERT
diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h
index 0f2303c..4dd28ac 100644
--- a/src/gui/painting/qoutlinemapper_p.h
+++ b/src/gui/painting/qoutlinemapper_p.h
@@ -95,8 +95,7 @@ public:
m_tags(0),
m_contours(0),
m_polygon_dev(0),
- m_in_clip_elements(false),
- m_round_coords(false)
+ m_in_clip_elements(false)
{
}
@@ -202,8 +201,6 @@ public:
QT_FT_Outline *convertPath(const QPainterPath &path);
QT_FT_Outline *convertPath(const QVectorPath &path);
- void setCoordinateRounding(bool coordinateRounding) { m_round_coords = coordinateRounding; }
-
inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? 0 : m_element_types.data(); }
public:
@@ -237,9 +234,6 @@ public:
bool m_valid;
bool m_in_clip_elements;
-
-private:
- bool m_round_coords;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 6ce21dc..fac356c 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -130,7 +130,7 @@ QPaintBufferPrivate::~QPaintBufferPrivate()
for (int i = 0; i < commands.size(); ++i) {
const QPaintBufferCommand &cmd = commands.at(i);
if (cmd.id == QPaintBufferPrivate::Cmd_DrawTextItem)
- delete reinterpret_cast<QTextItemIntCopy *>(qVariantValue<void *>(variants.at(cmd.offset)));
+ delete reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(variants.at(cmd.offset)));
}
}
@@ -330,7 +330,7 @@ QString QPaintBuffer::commandDescription(int command) const
break; }
case QPaintBufferPrivate::Cmd_SetBrush: {
- QBrush brush = qVariantValue<QBrush>(d_ptr->variants.at(cmd.offset));
+ QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.offset));
debug << "Cmd_SetBrush: " << brush;
break; }
@@ -354,27 +354,27 @@ QString QPaintBuffer::commandDescription(int command) const
break; }
case QPaintBufferPrivate::Cmd_StrokeVectorPath: {
- QPen pen = qVariantValue<QPen>(d_ptr->variants.at(cmd.extra));
+ QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.extra));
debug << "ExCmd_StrokeVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
<< "pts/elms:" << cmd.offset << cmd.offset2 << pen;
break; }
case QPaintBufferPrivate::Cmd_FillVectorPath: {
- QBrush brush = qVariantValue<QBrush>(d_ptr->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra));
debug << "ExCmd_FillVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
<< "pts/elms:" << cmd.offset << cmd.offset2 << brush;
break; }
case QPaintBufferPrivate::Cmd_FillRectBrush: {
- QBrush brush = qVariantValue<QBrush>(d_ptr->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset);
debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
break; }
case QPaintBufferPrivate::Cmd_FillRectColor: {
- QColor color = qVariantValue<QColor>(d_ptr->variants.at(cmd.extra));
+ QColor color = qvariant_cast<QColor>(d_ptr->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset);
debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
break; }
@@ -451,12 +451,12 @@ QString QPaintBuffer::commandDescription(int command) const
break; }
case QPaintBufferPrivate::Cmd_SetPen: {
- QPen pen = qVariantValue<QPen>(d_ptr->variants.at(cmd.offset));
+ QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.offset));
debug << "Cmd_SetPen: " << pen;
break; }
case QPaintBufferPrivate::Cmd_SetTransform: {
- QTransform xform = qVariantValue<QTransform>(d_ptr->variants.at(cmd.offset));
+ QTransform xform = qvariant_cast<QTransform>(d_ptr->variants.at(cmd.offset));
debug << "Cmd_SetTransform, offset: " << cmd.offset << xform;
break; }
@@ -532,7 +532,7 @@ QString QPaintBuffer::commandDescription(int command) const
case QPaintBufferPrivate::Cmd_DrawTextItem: {
QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
- QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qVariantValue<void *>(d_ptr->variants.at(cmd.offset)));
+ QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d_ptr->variants.at(cmd.offset)));
QTextItemInt &ti = (*tiCopy)();
QString text(ti.text());
@@ -1287,7 +1287,7 @@ void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti)
qDebug() << "QPaintBufferEngine: drawTextItem: pos:" << pos << ti.text();
#endif
if (m_stream_raw_text_items) {
- QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, qVariantFromValue<void *>(new QTextItemIntCopy(ti)));
+ QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, QVariant::fromValue<void *>(new QTextItemIntCopy(ti)));
QFont font(ti.font());
font.setUnderline(false);
@@ -1429,7 +1429,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_SetPen: {
- QPen pen = qVariantValue<QPen>(d->variants.at(cmd.offset));
+ QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.offset));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_SetPen: " << pen;
#endif
@@ -1437,7 +1437,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_SetBrush: {
- QBrush brush = qVariantValue<QBrush>(d->variants.at(cmd.offset));
+ QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.offset));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_SetBrush: " << brush;
#endif
@@ -1452,7 +1452,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_SetTransform: {
- QTransform xform = qVariantValue<QTransform>(d->variants.at(cmd.offset));
+ QTransform xform = qvariant_cast<QTransform>(d->variants.at(cmd.offset));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_SetTransform, offset: " << cmd.offset << xform;
#endif
@@ -1520,7 +1520,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_StrokeVectorPath: {
- QPen pen = qVariantValue<QPen>(d->variants.at(cmd.extra));
+ QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_StrokeVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
@@ -1531,7 +1531,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillVectorPath: {
- QBrush brush = qVariantValue<QBrush>(d->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_FillVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
@@ -1705,7 +1705,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillRectBrush: {
- QBrush brush = qVariantValue<QBrush>(d->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
@@ -1714,7 +1714,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillRectColor: {
- QColor color = qVariantValue<QColor>(d->variants.at(cmd.extra));
+ QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
@@ -1790,7 +1790,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd)
case QPaintBufferPrivate::Cmd_DrawTextItem: {
QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
- QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qVariantValue<void *>(d->variants.at(cmd.offset)));
+ QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d->variants.at(cmd.offset)));
QTextItemInt &ti = (*tiCopy)();
QString text(ti.text());
@@ -1885,7 +1885,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_StrokeVectorPath: {
- QPen pen = qVariantValue<QPen>(d->variants.at(cmd.extra));
+ QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> ExCmd_StrokeVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
@@ -1896,7 +1896,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillVectorPath: {
- QBrush brush = qVariantValue<QBrush>(d->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> ExCmd_FillVectorPath: size: " << cmd.size
// << ", hints:" << d->ints[cmd.offset2+cmd.size]
@@ -1907,7 +1907,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillRectBrush: {
- QBrush brush = qVariantValue<QBrush>(d->variants.at(cmd.extra));
+ QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
@@ -1916,7 +1916,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd)
break; }
case QPaintBufferPrivate::Cmd_FillRectColor: {
- QColor color = qVariantValue<QColor>(d->variants.at(cmd.extra));
+ QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra));
QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
#ifdef QPAINTBUFFER_DEBUG_DRAW
qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 10463e0..f2ba7f0 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -59,11 +59,13 @@ QPaintDevice::~QPaintDevice()
}
+#ifndef Q_WS_QPA
int QPaintDevice::metric(PaintDeviceMetric) const
{
qWarning("QPaintDevice::metrics: Device has no metric information");
return 0;
}
+#endif
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)
{
diff --git a/src/gui/painting/qpaintdevice_qpa.cpp b/src/gui/painting/qpaintdevice_qpa.cpp
new file mode 100644
index 0000000..0d1ca92
--- /dev/null
+++ b/src/gui/painting/qpaintdevice_qpa.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpaintdevice.h"
+#include "qpainter.h"
+#include "qwidget.h"
+#include "qbitmap.h"
+#include "qapplication.h"
+
+QT_BEGIN_NAMESPACE
+
+extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
+
+int QPaintDevice::metric(PaintDeviceMetric m) const
+{
+ qWarning("QPaintDevice::metrics: Device has no metric information");
+ if (m == PdmDpiX) {
+ return 72;
+ } else if (m == PdmDpiY) {
+ return 72;
+ } else if (m == PdmNumColors) {
+ // FIXME: does this need to be a real value?
+ return 256;
+ } else {
+ qDebug("Unrecognised metric %d!",m);
+ return 0;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index f89a046..93aa63b 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -213,6 +213,7 @@ public:
OpenVG,
OpenGL2,
PaintBuffer,
+ Blitter,
User = 50, // first user type id
MaxUser = 100 // last user type id
@@ -270,6 +271,9 @@ private:
friend class QtopiaPrintEnginePrivate;
friend class QProxyFontEngine;
#endif
+#ifdef Q_WS_QPA
+ friend class QFontEngineQPA;
+#endif
friend class QPainter;
friend class QPainterPrivate;
friend class QWidget;
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
new file mode 100644
index 0000000..500748e
--- /dev/null
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -0,0 +1,663 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qpaintengine_blitter_p.h"
+
+#include "private/qblittable_p.h"
+#include "private/qpaintengine_raster_p.h"
+#include "private/qpainter_p.h"
+#include "private/qapplication_p.h"
+#include "private/qpixmap_blitter_p.h"
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+#define STATE_XFORM_SCALE 0x00000001
+#define STATE_XFORM_COMPLEX 0x00000002
+
+#define STATE_BRUSH_PATTERN 0x00000010
+#define STATE_BRUSH_ALPHA 0x00000020
+
+#define STATE_PEN_ENABLED 0x00000100
+
+#define STATE_ANTIALIASING 0x00001000
+#define STATE_ALPHA 0x00002000
+#define STATE_BLENDING_COMPLEX 0x00004000
+
+#define STATE_CLIPSYS_COMPLEX 0x00010000
+#define STATE_CLIP_COMPLEX 0x00020000
+
+
+static inline void updateStateBits(uint *state, uint mask, bool on)
+{
+ *state = on ? (*state | mask) : (*state & ~mask);
+}
+
+static inline bool checkStateAgainstMask(uint state, uint mask)
+{
+ return !state || (state & mask && !(state & ~mask));
+}
+
+class CapabilitiesToStateMask
+{
+public:
+ CapabilitiesToStateMask(QBlittable::Capabilities capabilities)
+ : m_capabilities(capabilities),
+ fillRectMask(0),
+ drawRectMask(0),
+ drawPixmapMask(0),
+ capabillitiesState(0)
+ {
+ if (capabilities & QBlittable::SolidRectCapability) {
+ setFillRectMask();
+ }
+ if (capabilities & QBlittable::SourcePixmapCapability) {
+ setSourcePixmapMask();
+ }
+ if (capabilities & QBlittable::SourceOverPixmapCapability) {
+ setSourceOverPixmapMask();
+ }
+ if (capabilities & QBlittable::SourceOverScaledPixmapCapability) {
+ setSourceOverScaledPixmapMask();
+ }
+ }
+
+ inline bool canBlitterFillRect() const
+ {
+ return checkStateAgainstMask(capabillitiesState,fillRectMask);
+ }
+
+ inline bool canBlitterDrawRectMask() const
+ {
+ return checkStateAgainstMask(capabillitiesState,drawRectMask);
+ }
+
+ bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const
+ {
+ if (pm.pixmapData()->classId() != QPixmapData::BlitterClass)
+ return false;
+ if (checkStateAgainstMask(capabillitiesState,drawPixmapMask)) {
+ if (m_capabilities & (QBlittable::SourceOverPixmapCapability
+ | QBlittable::SourceOverScaledPixmapCapability)) {
+ if (r.size() != sr.size()) {
+ return m_capabilities & QBlittable::SourceOverScaledPixmapCapability;
+ } else {
+ return m_capabilities & QBlittable::SourceOverPixmapCapability;
+ }
+ }
+ if ((m_capabilities & QBlittable::SourcePixmapCapability) && r.size() == sr.size() && !pm.hasAlphaChannel()) {
+ return m_capabilities & QBlittable::SourcePixmapCapability;
+ }
+ }
+ return false;
+ }
+
+ inline void updateState(uint mask, bool on) {
+ updateStateBits(&capabillitiesState,mask,on);
+ }
+
+public:
+
+ void setFillRectMask() {
+ updateStateBits(&fillRectMask, STATE_XFORM_SCALE, false);
+ updateStateBits(&fillRectMask, STATE_XFORM_COMPLEX, false);
+
+ updateStateBits(&fillRectMask, STATE_BRUSH_PATTERN, false);
+ updateStateBits(&fillRectMask, STATE_BRUSH_ALPHA, false);
+
+ updateStateBits(&fillRectMask, STATE_PEN_ENABLED, true);
+
+ //Sub-pixel aliasing should not be sent to the blitter
+ updateStateBits(&fillRectMask, STATE_ANTIALIASING, true);
+ updateStateBits(&fillRectMask, STATE_ALPHA, false);
+ updateStateBits(&fillRectMask, STATE_BLENDING_COMPLEX, false);
+
+ updateStateBits(&fillRectMask, STATE_CLIPSYS_COMPLEX, false);
+ updateStateBits(&fillRectMask, STATE_CLIP_COMPLEX, false);
+ }
+
+ void setSourcePixmapMask() {
+ updateStateBits(&drawPixmapMask, STATE_XFORM_SCALE, true);
+ updateStateBits(&drawPixmapMask, STATE_XFORM_COMPLEX, false);
+
+ updateStateBits(&drawPixmapMask, STATE_BRUSH_PATTERN, true);
+ updateStateBits(&drawPixmapMask, STATE_BRUSH_ALPHA, false);
+
+ updateStateBits(&drawPixmapMask, STATE_PEN_ENABLED, true);
+
+ updateStateBits(&drawPixmapMask, STATE_ANTIALIASING, true);
+ updateStateBits(&drawPixmapMask, STATE_ALPHA, false);
+ updateStateBits(&drawPixmapMask, STATE_BLENDING_COMPLEX, false);
+
+ updateStateBits(&drawPixmapMask, STATE_CLIPSYS_COMPLEX, false);
+ updateStateBits(&drawPixmapMask, STATE_CLIP_COMPLEX, false);
+ }
+
+ void setSourceOverPixmapMask() {
+ setSourcePixmapMask();
+ }
+
+ void setSourceOverScaledPixmapMask() {
+ setSourceOverPixmapMask();
+ updateStateBits(&drawRectMask, STATE_XFORM_SCALE, true);
+ }
+
+ QBlittable::Capabilities m_capabilities;
+ uint fillRectMask;
+ uint drawRectMask;
+ uint drawPixmapMask;
+ uint capabillitiesState;
+};
+
+class QBlitterPaintEnginePrivate : public QPaintEngineExPrivate
+{
+ Q_DECLARE_PUBLIC(QBlitterPaintEngine);
+public:
+ QBlitterPaintEnginePrivate(QBlittablePixmapData *p)
+ : QPaintEngineExPrivate(),
+ pmData(p),
+ isBlitterLocked(false),
+ hasXForm(false)
+
+ {
+ raster = new QRasterPaintEngine(p->buffer());
+ capabillities = new CapabilitiesToStateMask(pmData->blittable()->capabilities());
+ }
+
+ inline void lock() {
+ if (!isBlitterLocked) {
+ raster->d_func()->rasterBuffer->prepare(pmData->blittable()->lock());
+ isBlitterLocked = true;
+ }
+ }
+
+ inline void unlock() {
+ if (isBlitterLocked) {
+ pmData->blittable()->unlock();
+ isBlitterLocked = false;
+ }
+ }
+
+ void fillRect(const QRectF &rect, const QColor &color) {
+ Q_Q(QBlitterPaintEngine);
+ pmData->unmarkRasterOverlay(rect);
+ QRectF targetRect = rect;
+ if (hasXForm) {
+ targetRect = q->state()->matrix.mapRect(rect);
+ }
+ const QClipData *clipData = q->clip();
+ if (clipData) {
+ if (clipData->hasRectClip) {
+ unlock();
+ pmData->blittable()->fillRect(targetRect & clipData->clipRect, color);
+ } else if (clipData->hasRegionClip) {
+ QVector<QRect> rects = clipData->clipRegion.rects();
+ for ( int i = 0; i < rects.size(); i++ ) {
+ QRect intersectRect = rects.at(i).intersected(targetRect.toRect());
+ if (!intersectRect.isEmpty()) {
+ unlock();
+ pmData->blittable()->fillRect(intersectRect,color);
+ }
+ }
+ }
+ } else {
+ if (targetRect.x() >= 0 && targetRect.y() >= 0
+ && targetRect.width() <= raster->paintDevice()->width()
+ && targetRect.height() <= raster->paintDevice()->height()) {
+ unlock();
+ pmData->blittable()->fillRect(targetRect,color);
+ } else {
+ QRectF deviceRect(0,0,raster->paintDevice()->width(), raster->paintDevice()->height());
+ unlock();
+ pmData->blittable()->fillRect(deviceRect&targetRect,color);
+ }
+ }
+ }
+
+ void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr) {
+ QRectF intersectedRect = clip.intersected(target);
+ if (intersectedRect.isEmpty())
+ return;
+ QRectF source = sr;
+ if(intersectedRect.size() != target.size()) {
+ qreal deltaTop = target.top() - intersectedRect.top();
+ qreal deltaLeft = target.left() - intersectedRect.left();
+ qreal deltaBottom = target.bottom() - intersectedRect.bottom();
+ qreal deltaRight = target.right() - intersectedRect.right();
+ source.adjust(-deltaLeft,-deltaTop,-deltaRight,-deltaBottom);
+ }
+ pmData->unmarkRasterOverlay(intersectedRect);
+ pmData->blittable()->drawPixmap(intersectedRect, pm, source);
+ }
+
+ void updateClip() {
+ Q_Q(QBlitterPaintEngine);
+ const QClipData *clip = q->clip();
+ bool complex = clip && !(clip->hasRectClip || clip->hasRegionClip);
+ capabillities->updateState(STATE_CLIP_COMPLEX, complex);
+ }
+
+ void systemStateChanged() {
+ raster->d_func()->systemStateChanged();
+ }
+
+ QRasterPaintEngine *raster;
+
+ QBlittablePixmapData *pmData;
+ bool isBlitterLocked;
+
+ CapabilitiesToStateMask *capabillities;
+
+ uint hasXForm;
+};
+
+QBlitterPaintEngine::QBlitterPaintEngine(QBlittablePixmapData *p)
+ : QPaintEngineEx(*(new QBlitterPaintEnginePrivate(p)))
+{
+}
+
+QBlitterPaintEngine::~QBlitterPaintEngine()
+{
+}
+
+QPainterState *QBlitterPaintEngine::createState(QPainterState *orig) const
+{
+ Q_D(const QBlitterPaintEngine);
+ return d->raster->createState(orig);
+}
+
+bool QBlitterPaintEngine::begin(QPaintDevice *pdev)
+{
+ Q_D(QBlitterPaintEngine);
+
+ setActive(true);
+ bool ok = d->raster->begin(pdev);
+#ifdef QT_BLITTER_RASTEROVERLAY
+ d->pmData->unmergeOverlay();
+#endif
+ return ok;
+}
+
+
+bool QBlitterPaintEngine::end()
+{
+ Q_D(QBlitterPaintEngine);
+
+ setActive(false);
+#ifdef QT_BLITTER_RASTEROVERLAY
+ d->pmData->mergeOverlay();
+#endif
+ return d->raster->end();
+}
+
+
+void QBlitterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+{
+ Q_D(QBlitterPaintEngine);
+ if (path.shape() == QVectorPath::RectangleHint) {
+ QRectF rect(((QPointF *) path.points())[0], ((QPointF *) path.points())[2]);
+ fillRect(rect, brush);
+ } else {
+ d->lock();
+ d->pmData->markRasterOverlay(path);
+ d->raster->fill(path, brush);
+ }
+}
+
+void QBlitterPaintEngine::fillRect(const QRectF &rect, const QColor &color)
+{
+ Q_D(QBlitterPaintEngine);
+ if (d->capabillities->canBlitterFillRect() && color.alpha() == 0xff) {
+ d->fillRect(rect, color);
+ } else {
+ d->lock();
+ d->pmData->markRasterOverlay(rect);
+ d->raster->fillRect(rect, color);
+ }
+}
+
+void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
+{
+ if(rect.size().isEmpty())
+ return;
+
+ Q_D(QBlitterPaintEngine);
+
+ if (qbrush_style(brush) == Qt::SolidPattern
+ && qbrush_color(brush).alpha() == 0xff
+ && d->capabillities->canBlitterFillRect())
+ {
+ d->fillRect(rect, qbrush_color(brush));
+ }else if (brush.style() == Qt::TexturePattern
+ && d->capabillities->canBlitterDrawPixmap(rect,brush.texture(),rect))
+ {
+ bool rectIsFilled = false;
+ QRectF transformedRect = state()->matrix.mapRect(rect);
+ qreal x = transformedRect.x();
+ qreal y = transformedRect.y();
+ QPixmap pm = brush.texture();
+ d->unlock();
+ int srcX = int(rect.x() - state()->brushOrigin.x()) % pm.width();
+ if (srcX < 0)
+ srcX = pm.width() + srcX;
+ const int startX = srcX;
+ int srcY = int(rect.y() - state()->brushOrigin.y()) % pm.height();
+ if (srcY < 0)
+ srcY = pm.height() + srcY;
+ while (!rectIsFilled) {
+ qreal blitWidth = (pm.width() ) - srcX;
+ qreal blitHeight = (pm.height() ) - srcY;
+ if (x + blitWidth > transformedRect.right())
+ blitWidth = transformedRect.right() -x;
+ if (y + blitHeight > transformedRect.bottom())
+ blitHeight = transformedRect.bottom() - y;
+ const QClipData *clipData = clip();
+ if (clipData->hasRectClip) {
+ QRect targetRect = QRect(x,y,blitWidth,blitHeight).intersected(clipData->clipRect);
+ if (targetRect.isValid()) {
+ int tmpSrcX = srcX + (targetRect.x() - x);
+ int tmpSrcY = srcY + (targetRect.y() - y);
+ QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height());
+ d->pmData->blittable()->drawPixmap(targetRect,pm,srcRect);
+ }
+ } else if (clipData->hasRegionClip) {
+ QVector<QRect> clipRects = clipData->clipRegion.rects();
+ QRect unclippedTargetRect(x,y,blitWidth,blitHeight);
+ QRegion intersectedRects = clipData->clipRegion.intersected(unclippedTargetRect);
+
+ for ( int i = 0; i < intersectedRects.rects().size(); i++ ) {
+ QRect targetRect = intersectedRects.rects().at(i);
+ if (!targetRect.isValid() || targetRect.isEmpty())
+ continue;
+ int tmpSrcX = srcX + (targetRect.x() - x);
+ int tmpSrcY = srcY + (targetRect.y() - y);
+ QRect srcRect(tmpSrcX,tmpSrcY,targetRect.width(),targetRect.height());
+ d->pmData->blittable()->drawPixmap(targetRect,pm,srcRect);
+ }
+ }
+ x+=blitWidth;
+ if (x>=transformedRect.right()) {
+ x = transformedRect.x();
+ srcX = startX;
+ srcY = 0;
+ y+=blitHeight;
+ if (y>=transformedRect.bottom())
+ rectIsFilled = true;
+ } else
+ srcX = 0;
+ }
+ } else {
+ d->lock();
+ d->pmData->markRasterOverlay(rect);
+ d->raster->fillRect(rect, brush);
+ }
+
+}
+
+void QBlitterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->pmData->markRasterOverlay(path);
+ d->raster->stroke(path, pen);
+}
+
+void QBlitterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->clip(path, op);
+ d->updateClip();
+}
+void QBlitterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op){
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->clip(rect,op);
+ d->updateClip();
+}
+void QBlitterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->clip(region,op);
+ d->updateClip();
+}
+
+void QBlitterPaintEngine::clipEnabledChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->clipEnabledChanged();
+}
+
+void QBlitterPaintEngine::penChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->penChanged();
+ d->capabillities->updateState(STATE_PEN_ENABLED,qpen_style(state()->pen) != Qt::NoPen);
+}
+
+void QBlitterPaintEngine::brushChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->brushChanged();
+
+ bool solid = qbrush_style(state()->brush) == Qt::SolidPattern;
+
+ d->capabillities->updateState(STATE_BRUSH_PATTERN, !solid);
+ d->capabillities->updateState(STATE_BRUSH_ALPHA,
+ qbrush_color(state()->brush).alpha() < 255);
+}
+
+void QBlitterPaintEngine::brushOriginChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->brushOriginChanged();
+}
+
+void QBlitterPaintEngine::opacityChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->opacityChanged();
+
+ bool translucent = state()->opacity < 1;
+ d->capabillities->updateState(STATE_ALPHA,translucent);
+}
+
+void QBlitterPaintEngine::compositionModeChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->compositionModeChanged();
+
+ bool nonTrivial = state()->composition_mode != QPainter::CompositionMode_SourceOver
+ && state()->composition_mode != QPainter::CompositionMode_Source;
+
+ d->capabillities->updateState(STATE_BLENDING_COMPLEX,nonTrivial);
+}
+
+void QBlitterPaintEngine::renderHintsChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->renderHintsChanged();
+
+ bool aa = state()->renderHints & QPainter::Antialiasing;
+ d->capabillities->updateState(STATE_ANTIALIASING, aa);
+
+}
+
+void QBlitterPaintEngine::transformChanged()
+{
+ Q_D(QBlitterPaintEngine);
+ d->raster->transformChanged();
+
+ QTransform::TransformationType type = state()->matrix.type();
+
+ d->capabillities->updateState(STATE_XFORM_COMPLEX, type > QTransform::TxScale);
+ d->capabillities->updateState(STATE_XFORM_SCALE, type > QTransform::TxTranslate);
+
+ d->hasXForm = type >= QTransform::TxTranslate;
+
+}
+
+void QBlitterPaintEngine::drawRects(const QRect *rects, int rectCount)
+{
+ Q_D(QBlitterPaintEngine);
+ if (d->capabillities->canBlitterDrawRectMask()) {
+ for (int i=0; i<rectCount; ++i) {
+ d->fillRect(rects[i], qbrush_color(state()->brush));
+ }
+ } else {
+ d->pmData->markRasterOverlay(rects,rectCount);
+ QPaintEngineEx::drawRects(rects, rectCount);
+ }
+}
+
+void QBlitterPaintEngine::drawRects(const QRectF *rects, int rectCount)
+{
+ Q_D(QBlitterPaintEngine);
+ if (d->capabillities->canBlitterDrawRectMask()) {
+ for (int i=0; i<rectCount; ++i) {
+ d->fillRect(rects[i], qbrush_color(state()->brush));
+ }
+ } else {
+ d->pmData->markRasterOverlay(rects,rectCount);
+ QPaintEngineEx::drawRects(rects, rectCount);
+ }
+}
+
+void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
+{
+ Q_D(QBlitterPaintEngine);
+ if (d->capabillities->canBlitterDrawPixmap(r,pm,sr)) {
+
+ d->unlock();
+ QRectF targetRect = r;
+ if (d->hasXForm) {
+ targetRect = state()->matrix.mapRect(r);
+ }
+ const QClipData *clipData = clip();
+ if (clipData) {
+ if (clipData->hasRectClip) {
+ d->clipAndDrawPixmap(clipData->clipRect,targetRect,pm,sr);
+ }else if (clipData->hasRegionClip) {
+ QVector<QRect>rects = clipData->clipRegion.rects();
+ for (int i = 0; i<rects.size(); i++) {
+ d->clipAndDrawPixmap(rects.at(i),targetRect,pm,sr);
+ }
+ }
+ } else {
+ QRectF deviceRect(0,0,d->raster->paintDevice()->width(), d->raster->paintDevice()->height());
+ d->clipAndDrawPixmap(deviceRect,targetRect,pm,sr);
+ }
+ }else {
+ d->lock();
+ d->pmData->markRasterOverlay(r);
+ d->raster->drawPixmap(r, pm, sr);
+ }
+}
+
+void QBlitterPaintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
+ Qt::ImageConversionFlags flags)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->pmData->markRasterOverlay(r);
+ d->raster->drawImage(r, pm, sr, flags);
+}
+
+
+void QBlitterPaintEngine::drawTextItem(const QPointF &pos, const QTextItem &ti)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->drawTextItem(pos, ti);
+ d->pmData->markRasterOverlay(pos,ti);
+}
+
+void QBlitterPaintEngine::drawStaticTextItem(QStaticTextItem *sti)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->raster->drawStaticTextItem(sti);
+
+//#### d->pmData->markRasterOverlay(sti);
+ qWarning("not implemented: markRasterOverlay for QStaticTextItem");
+
+}
+
+
+void QBlitterPaintEngine::drawEllipse(const QRectF &r)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ d->pmData->markRasterOverlay(r);
+ d->raster->drawEllipse(r);
+}
+
+void QBlitterPaintEngine::setState(QPainterState *s)
+{
+ Q_D(QBlitterPaintEngine);
+ d->lock();
+ QPaintEngineEx::setState(s);
+ d->raster->setState(s);
+
+ clipEnabledChanged();
+ penChanged();
+ brushChanged();
+ brushOriginChanged();
+ opacityChanged();
+ compositionModeChanged();
+ renderHintsChanged();
+ transformChanged();
+
+ d->updateClip();
+}
+
+inline QRasterPaintEngine *QBlitterPaintEngine::raster() const
+{
+ Q_D(const QBlitterPaintEngine);
+ return d->raster;
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+
diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h
new file mode 100644
index 0000000..be8b2bc
--- /dev/null
+++ b/src/gui/painting/qpaintengine_blitter_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QPAINTENGINE_BLITTER_P_H
+#define QPAINTENGINE_BLITTER_P_H
+
+#include "private/qpaintengineex_p.h"
+#include "private/qpaintengine_raster_p.h"
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class QBlitterPaintEnginePrivate;
+class QBlittablePixmapData;
+class QBlittable;
+
+class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx
+{
+ Q_DECLARE_PRIVATE(QBlitterPaintEngine);
+public:
+ QBlitterPaintEngine(QBlittablePixmapData *p);
+ ~QBlitterPaintEngine();
+
+ virtual QPainterState *createState(QPainterState *orig) const;
+
+ virtual QPaintEngine::Type type() const { return Blitter; }
+
+ virtual bool begin(QPaintDevice *pdev);
+ virtual bool end();
+
+ virtual void fill(const QVectorPath &path, const QBrush &brush);
+ virtual void stroke(const QVectorPath &path, const QPen &pen);
+
+ virtual void clip(const QVectorPath &path, Qt::ClipOperation op);
+ virtual void clip(const QRect &rect, Qt::ClipOperation op);
+ virtual void clip(const QRegion &region, Qt::ClipOperation op);
+
+ virtual void clipEnabledChanged();
+ virtual void penChanged();
+ virtual void brushChanged();
+ virtual void brushOriginChanged();
+ virtual void opacityChanged();
+ virtual void compositionModeChanged();
+ virtual void renderHintsChanged();
+ virtual void transformChanged();
+
+ virtual void fillRect(const QRectF &rect, const QBrush &brush);
+ virtual void fillRect(const QRectF &rect, const QColor &color);
+
+ virtual void drawRects(const QRect *rects, int rectCount);
+ virtual void drawRects(const QRectF *rects, int rectCount);
+
+ virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
+
+ virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
+
+ virtual void drawTextItem(const QPointF &pos, const QTextItem &ti);
+ virtual void drawStaticTextItem(QStaticTextItem *);
+
+ virtual void drawEllipse(const QRectF &r);
+
+ virtual void setState(QPainterState *s);
+
+ inline QPainterState *state() { return raster()->state(); }
+ inline const QPainterState *state() const { const QPainterState *state = raster()->state(); return state;}
+ inline const QClipData *clip(){return raster()->d_func()->clip();}
+
+private:
+ QRasterPaintEngine *raster() const;
+};
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+#endif // QPAINTENGINE_BLITTER_P_H
+
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
index b07053e..8aab7c7 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/gui/painting/qpaintengine_mac.cpp
@@ -57,6 +57,8 @@
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
+#include <private/qfontengine_coretext_p.h>
+#include <private/qfontengine_mac_p.h>
#include <private/qnumeric_p.h>
#include <private/qpainter_p.h>
#include <private/qpainterpath_p.h>
@@ -131,8 +133,9 @@ QMacCGContext::QMacCGContext(QPainter *p)
CGContextTranslateCTM(context, native.dx(), native.dy());
}
+ } else {
+ CGContextRetain(context);
}
- CGContextRetain(context);
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index ba618ea..9f3b9b9 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -96,6 +96,8 @@
# include <private/qabstractfontengine_p.h>
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
# include <private/qfontengine_s60_p.h>
+#elif defined(Q_WS_QPA)
+# include <private/qfontengine_ft_p.h>
#endif
#if defined(Q_WS_WIN64)
@@ -124,9 +126,6 @@ void dumpClip(int width, int height, const QClipData *clip);
// 4 pixels.
#define int_dim(pos, dim) (int(pos+dim) - int(pos))
-// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
#ifdef Q_WS_WIN
extern bool qt_cleartype_enabled;
#endif
@@ -444,7 +443,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
if (device->devType() == QInternal::Pixmap) {
QPixmap *pixmap = static_cast<QPixmap *>(device);
QPixmapData *pd = pixmap->pixmapData();
- if (pd->classId() == QPixmapData::RasterClass)
+ if (pd->classId() == QPixmapData::RasterClass || pd->classId() == QPixmapData::BlitterClass)
d->device = pd->buffer();
} else {
d->device = device;
@@ -663,31 +662,23 @@ 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)
+ , fillFlags(s.fillFlags)
+ , pixmapFlags(s.pixmapFlags)
+ , intOpacity(s.intOpacity)
+ , txscale(s.txscale)
+ , clip(s.clip)
+ , dirty(s.dirty)
+ , flag_bits(s.flag_bits)
{
- stroker = s.stroker;
-
- lastBrush = s.lastBrush;
- brushData = s.brushData;
brushData.tempImage = 0;
-
- lastPen = s.lastPen;
- penData = s.penData;
penData.tempImage = 0;
-
- fillFlags = s.fillFlags;
- strokeFlags = s.strokeFlags;
- pixmapFlags = s.pixmapFlags;
-
- intOpacity = s.intOpacity;
-
- txscale = s.txscale;
-
- flag_bits = s.flag_bits;
-
- clip = s.clip;
flags.has_clip_ownership = false;
-
- dirty = s.dirty;
}
/*!
@@ -1769,10 +1760,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
static inline QRect toNormalizedFillRect(const QRectF &rect)
{
- int x1 = qRound(rect.x() + aliasedCoordinateDelta);
- int y1 = qRound(rect.y() + aliasedCoordinateDelta);
- int x2 = qRound(rect.right() + aliasedCoordinateDelta);
- int y2 = qRound(rect.bottom() + aliasedCoordinateDelta);
+ int x1 = qRound(rect.x());
+ int y1 = qRound(rect.y());
+ int x2 = qRound(rect.right());
+ int y2 = qRound(rect.bottom());
if (x2 < x1)
qSwap(x1, x2);
@@ -2041,7 +2032,6 @@ void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, Poly
*/
void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
{
- Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
#ifdef QT_DEBUG_DRAW
@@ -2062,9 +2052,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly
if (mode != PolylineMode) {
// Do the fill...
if (s->brushData.blend) {
- d->outlineMapper->setCoordinateRounding(s->penData.blend && s->flags.fast_pen && s->lastPen.brush().isOpaque());
fillPolygon(points, pointCount, mode);
- d->outlineMapper->setCoordinateRounding(false);
}
}
@@ -2116,7 +2104,6 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
if (s->brushData.blend) {
// Compose polygon fill..,
ensureOutlineMapper();
- d->outlineMapper->setCoordinateRounding(s->penData.blend != 0);
d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill);
d->outlineMapper->moveTo(*points);
const QPoint *p = points;
@@ -2130,7 +2117,6 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect,
&s->brushData);
d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data());
- d->outlineMapper->setCoordinateRounding(false);
}
}
@@ -2178,13 +2164,11 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPointF *points, int pointC
: LineDrawNormal);
int dashOffset = int(s->lastPen.dashOffset());
- const QPointF offs(aliasedCoordinateDelta, aliasedCoordinateDelta);
-
// Draw all the line segments.
for (int i=1; i<pointCount; ++i) {
- QPointF lp1 = points[i-1] * s->matrix + offs;
- QPointF lp2 = points[i] * s->matrix + offs;
+ QPointF lp1 = points[i-1] * s->matrix;
+ QPointF lp2 = points[i] * s->matrix;
const QRectF brect(lp1, lp2);
ProcessSpans penBlend = d->getPenFunc(brect, &s->penData);
@@ -2206,8 +2190,8 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPointF *points, int pointC
// Polygons are implicitly closed.
if (needs_closing) {
- QPointF lp1 = points[pointCount-1] * s->matrix + offs;
- QPointF lp2 = points[0] * s->matrix + offs;
+ QPointF lp1 = points[pointCount-1] * s->matrix;
+ QPointF lp2 = points[0] * s->matrix;
const QRectF brect(lp1, lp2);
ProcessSpans penBlend = d->getPenFunc(brect, &s->penData);
@@ -2506,7 +2490,7 @@ void QRasterPaintEngine::drawImage(const QPointF &p, const QImage &img)
const QClipData *clip = d->clip();
QPointF pt(p.x() + s->matrix.dx(), p.y() + s->matrix.dy());
- if (s->flags.fast_images) {
+ if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()];
if (func) {
if (!clip) {
@@ -2595,10 +2579,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
int sr_b = qCeil(sr.bottom()) - 1;
if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {
- // as fillRect will apply the aliased coordinate delta we need to
- // subtract it here as we don't use it for image drawing
QTransform old = s->matrix;
- s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta);
// Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied.
QRgb color = img.pixel(sr_l, sr_t);
@@ -2690,7 +2671,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
bool exceedsPrecision = targetBounds.width() > 0xffff
|| targetBounds.height() > 0xffff;
- if (s->flags.fast_images && !exceedsPrecision) {
+ if (!exceedsPrecision && d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
if (s->matrix.type() > QTransform::TxScale) {
SrcOverTransformFunc func = qTransformFunctions[d->rasterBuffer->format][img.format()];
if (func && (!clip || clip->hasRectClip)) {
@@ -2742,11 +2723,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
d->initializeRasterizer(&d->image_filler_xform);
d->rasterizer->setAntialiased(s->flags.antialiased);
- const QPointF offs = s->flags.antialiased ? QPointF() : QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
-
const QRectF &rect = r.normalized();
- const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs;
- const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f) - offs;
+ const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f);
+ const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f);
if (s->flags.tx_noshear)
d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width());
@@ -2755,18 +2734,16 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
return;
}
#endif
- const qreal offs = s->flags.antialiased ? qreal(0) : aliasedCoordinateDelta;
QPainterPath path;
path.addRect(r);
QTransform m = s->matrix;
s->matrix = QTransform(m.m11(), m.m12(), m.m13(),
m.m21(), m.m22(), m.m23(),
- m.m31() - offs, m.m32() - offs, m.m33());
+ m.m31(), m.m32(), m.m33());
fillPath(path, &d->image_filler_xform);
s->matrix = m;
} else {
-
- if (s->flags.fast_images) {
+ if (d->canUseFastImageBlending(d->rasterBuffer->compositionMode, img)) {
SrcOverBlendFunc func = qBlendFunctions[d->rasterBuffer->format][img.format()];
if (func) {
QPointF pt(r.x() + s->matrix.dx(), r.y() + s->matrix.dy());
@@ -3099,56 +3076,150 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx
blend(current, spans, &s->penData);
}
-void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
+bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
const QFixedPoint *positions, QFontEngine *fontEngine)
{
Q_D(QRasterPaintEngine);
QRasterPaintEngineState *s = state();
- QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType;
+#if !defined(QT_NO_FREETYPE)
+ if (fontEngine->type() == QFontEngine::Freetype) {
+ QFontEngineFT *fe = static_cast<QFontEngineFT *>(fontEngine);
+ QFontEngineFT::GlyphFormat neededFormat =
+ painter()->device()->devType() == QInternal::Widget
+ ? fe->defaultGlyphFormat()
+ : QFontEngineFT::Format_A8;
+
+ if (d_func()->mono_surface
+ || fe->isBitmapFont() // alphaPenBlt can handle mono, too
+ )
+ neededFormat = QFontEngineFT::Format_Mono;
+
+ if (neededFormat == QFontEngineFT::Format_None)
+ neededFormat = QFontEngineFT::Format_A8;
+
+ QFontEngineFT::QGlyphSet *gset = fe->defaultGlyphs();
+ if (s->matrix.type() >= QTransform::TxScale) {
+ if (s->matrix.isAffine())
+ gset = fe->loadTransformedGlyphSet(s->matrix);
+ else
+ gset = 0;
+ }
- QImageTextureGlyphCache *cache =
- static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
- if (!cache) {
- cache = new QImageTextureGlyphCache(glyphType, s->matrix);
- fontEngine->setGlyphCache(0, cache);
- }
+ if (!gset || gset->outline_drawing
+ || !fe->loadGlyphs(gset, glyphs, numGlyphs, positions, neededFormat))
+ return false;
+
+ FT_Face lockedFace = 0;
+
+ int depth;
+ switch (neededFormat) {
+ case QFontEngineFT::Format_Mono:
+ depth = 1;
+ break;
+ case QFontEngineFT::Format_A8:
+ depth = 8;
+ break;
+ case QFontEngineFT::Format_A32:
+ depth = 32;
+ break;
+ default:
+ Q_ASSERT(false);
+ depth = 0;
+ };
+
+ for (int i = 0; i < numGlyphs; i++) {
+ QFixed spp = fe->subPixelPositionForX(positions[i].x);
+ QFontEngineFT::Glyph *glyph = gset->getGlyph(glyphs[i], spp);
+
+ if (!glyph || glyph->format != neededFormat) {
+ if (!lockedFace)
+ lockedFace = fe->lockFace();
+ glyph = fe->loadGlyph(gset, glyphs[i], spp, neededFormat);
+ }
+
+ if (!glyph || !glyph->data)
+ continue;
+
+ int pitch;
+ switch (neededFormat) {
+ case QFontEngineFT::Format_Mono:
+ pitch = ((glyph->width + 31) & ~31) >> 3;
+ break;
+ case QFontEngineFT::Format_A8:
+ pitch = (glyph->width + 3) & ~3;
+ break;
+ case QFontEngineFT::Format_A32:
+ pitch = glyph->width * 4;
+ break;
+ default:
+ Q_ASSERT(false);
+ pitch = 0;
+ };
+
+ alphaPenBlt(glyph->data, pitch, depth,
+ qFloor(positions[i].x) + glyph->x,
+ qFloor(positions[i].y) - glyph->y,
+ glyph->width, glyph->height);
+ }
+ if (lockedFace)
+ fe->unlockFace();
+ } else
+#endif
+ {
+ QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType;
- cache->populate(fontEngine, numGlyphs, glyphs, positions);
+ QImageTextureGlyphCache *cache =
+ static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix));
+ if (!cache) {
+ cache = new QImageTextureGlyphCache(glyphType, s->matrix);
+ fontEngine->setGlyphCache(0, cache);
+ }
- const QImage &image = cache->image();
- int bpl = image.bytesPerLine();
+ cache->populate(fontEngine, numGlyphs, glyphs, positions);
+ cache->fillInPendingGlyphs();
- int depth = image.depth();
- int rightShift = 0;
- int leftShift = 0;
- if (depth == 32)
- leftShift = 2; // multiply by 4
- else if (depth == 1)
- rightShift = 3; // divide by 8
+ const QImage &image = cache->image();
+ int bpl = image.bytesPerLine();
- int margin = cache->glyphMargin();
+ int depth = image.depth();
+ int rightShift = 0;
+ int leftShift = 0;
+ if (depth == 32)
+ leftShift = 2; // multiply by 4
+ else if (depth == 1)
+ rightShift = 3; // divide by 8
- const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
+ int margin = cache->glyphMargin();
- const uchar *bits = image.bits();
- for (int i=0; i<numGlyphs; ++i) {
- const QTextureGlyphCache::Coord &c = cache->coords.value(glyphs[i]);
- int x = qFloor(positions[i].x + offs) + c.baseLineX - margin;
- int y = qFloor(positions[i].y + offs) - c.baseLineY - margin;
+ bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions();
-// printf("drawing [%d %d %d %d] baseline [%d %d], glyph: %d, to: %d %d, pos: %d %d\n",
-// c.x, c.y,
-// c.w, c.h,
-// c.baseLineX, c.baseLineY,
-// glyphs[i],
-// x, y,
-// positions[i].x.toInt(), positions[i].y.toInt());
+ const uchar *bits = image.bits();
+ for (int i=0; i<numGlyphs; ++i) {
- alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h);
- }
+ QFixed subPixelPosition;
+ if (supportsSubPixelPositions)
+ subPixelPosition = cache->subPixelPositionForX(positions[i].x);
+ QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphs[i], subPixelPosition);
+ const QTextureGlyphCache::Coord &c = cache->coords[glyph];
+ if (c.isNull())
+ continue;
- return;
+ int x = qFloor(positions[i].x) + c.baseLineX - margin;
+ int y = qFloor(positions[i].y) - c.baseLineY - margin;
+
+ // printf("drawing [%d %d %d %d] baseline [%d %d], glyph: %d, to: %d %d, pos: %d %d\n",
+ // c.x, c.y,
+ // c.w, c.h,
+ // c.baseLineX, c.baseLineY,
+ // glyphs[i],
+ // x, y,
+ // positions[i].x.toInt(), positions[i].y.toInt());
+
+ alphaPenBlt(bits + ((c.x << leftShift) >> rightShift) + c.y * bpl, bpl, depth, x, y, c.w, c.h);
+ }
+ }
+ return true;
}
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
@@ -3173,15 +3244,13 @@ void QRasterPaintEngine::drawGlyphsS60(const QPointF &p, const QTextItemInt &ti)
fe->setFontScale(matrix.m11());
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- const QFixed aliasDelta = QFixed::fromReal(aliasedCoordinateDelta);
-
for (int i=0; i<glyphs.size(); ++i) {
TOpenFontCharMetrics tmetrics;
const TUint8 *glyphBitmapBytes;
TSize glyphBitmapSize;
fe->getCharacterData(glyphs[i], tmetrics, glyphBitmapBytes, glyphBitmapSize);
- const int x = qFloor(positions[i].x + tmetrics.HorizBearingX() + aliasDelta);
- const int y = qFloor(positions[i].y - tmetrics.HorizBearingY() + aliasDelta);
+ const int x = qFloor(positions[i].x + tmetrics.HorizBearingX());
+ const int y = qFloor(positions[i].y - tmetrics.HorizBearingY());
alphaPenBlt(glyphBitmapBytes, glyphBitmapSize.iWidth, 8, x, y, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight);
}
@@ -3394,7 +3463,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
#if defined(Q_WS_QWS)
if (fontEngine->type() == QFontEngine::Box) {
- fontEngine->draw(this, qFloor(p.x() + aliasedCoordinateDelta), qFloor(p.y() + aliasedCoordinateDelta), ti);
+ fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
return;
}
@@ -3403,11 +3472,38 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
|| (fontEngine->type() == QFontEngine::Proxy
&& !(static_cast<QProxyFontEngine *>(fontEngine)->drawAsOutline()))
)) {
- fontEngine->draw(this, qFloor(p.x() + aliasedCoordinateDelta), qFloor(p.y() + aliasedCoordinateDelta), ti);
+ fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
return;
}
#endif // Q_WS_QWS
+#ifdef Q_WS_QPA
+ if (s->matrix.type() < QTransform::TxScale) {
+
+ QVarLengthArray<QFixedPoint> positions;
+ QVarLengthArray<glyph_t> glyphs;
+ QTransform matrix = state()->transform();
+
+ qreal _x = qFloor(p.x());
+ qreal _y = qFloor(p.y());
+ matrix.translate(_x, _y);
+
+ fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ if (glyphs.size() == 0)
+ return;
+
+ for(int i = 0; i < glyphs.size(); i++) {
+ QImage img = fontEngine->alphaMapForGlyph(glyphs[i]);
+ glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[i]);
+ alphaPenBlt(img.bits(), img.bytesPerLine(), img.depth(),
+ qRound(positions[i].x + metrics.x),
+ qRound(positions[i].y + metrics.y),
+ img.width(), img.height());
+ }
+ return;
+ }
+#endif //Q_WS_QPA
+
#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2)
@@ -3434,92 +3530,10 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
if (glyphs.size() == 0)
return;
- // only use subpixel antialiasing when drawing to widgets
- QFontEngineFT::GlyphFormat neededFormat =
- painter()->device()->devType() == QInternal::Widget
- ? fe->defaultGlyphFormat()
- : QFontEngineFT::Format_A8;
-
- if (d_func()->mono_surface
- || fe->isBitmapFont() // alphaPenBlt can handle mono, too
- )
- neededFormat = QFontEngineFT::Format_Mono;
-
- if (neededFormat == QFontEngineFT::Format_None)
- neededFormat = QFontEngineFT::Format_A8;
-
- QFontEngineFT::QGlyphSet *gset = fe->defaultGlyphs();
- if (s->matrix.type() >= QTransform::TxScale) {
- if (s->matrix.isAffine())
- gset = fe->loadTransformedGlyphSet(s->matrix);
- else
- gset = 0;
-
- }
-
- if (!gset || gset->outline_drawing
- || !fe->loadGlyphs(gset, glyphs.data(), glyphs.size(), neededFormat))
- {
+ if (!drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), fontEngine))
QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
- FT_Face lockedFace = 0;
-
- int depth;
- switch (neededFormat) {
- case QFontEngineFT::Format_Mono:
- depth = 1;
- break;
- case QFontEngineFT::Format_A8:
- depth = 8;
- break;
- case QFontEngineFT::Format_A32:
- depth = 32;
- break;
- default:
- Q_ASSERT(false);
- depth = 0;
- };
-
- for(int i = 0; i < glyphs.size(); i++) {
- QFontEngineFT::Glyph *glyph = gset->getGlyph(glyphs[i]);
- if (!glyph || glyph->format != neededFormat) {
- if (!lockedFace)
- lockedFace = fe->lockFace();
- glyph = fe->loadGlyph(gset, glyphs[i], neededFormat);
- }
-
- if (!glyph || !glyph->data)
- continue;
-
- int pitch;
- switch (neededFormat) {
- case QFontEngineFT::Format_Mono:
- pitch = ((glyph->width + 31) & ~31) >> 3;
- break;
- case QFontEngineFT::Format_A8:
- pitch = (glyph->width + 3) & ~3;
- break;
- case QFontEngineFT::Format_A32:
- pitch = glyph->width * 4;
- break;
- default:
- Q_ASSERT(false);
- pitch = 0;
- };
-
- alphaPenBlt(glyph->data, pitch, depth,
- qFloor(positions[i].x + offs) + glyph->x,
- qFloor(positions[i].y + offs) - glyph->y,
- glyph->width, glyph->height);
- }
- if (lockedFace)
- fe->unlockFace();
return;
-
#endif
#endif
@@ -3650,8 +3664,8 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount)
int m11 = int(s->matrix.m11());
int m22 = int(s->matrix.m22());
- int dx = qFloor(s->matrix.dx() + aliasedCoordinateDelta);
- int dy = qFloor(s->matrix.dy() + aliasedCoordinateDelta);
+ int dx = qFloor(s->matrix.dx());
+ int dy = qFloor(s->matrix.dy());
for (int i=0; i<lineCount; ++i) {
int dashOffset = int(s->lastPen.dashOffset());
if (s->flags.int_xform) {
@@ -3762,7 +3776,7 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount)
for (int i=0; i<lineCount; ++i) {
int dashOffset = int(s->lastPen.dashOffset());
- QLineF line = (lines[i] * s->matrix).translated(aliasedCoordinateDelta, aliasedCoordinateDelta);
+ QLineF line = lines[i] * s->matrix;
const QRectF brect(QPointF(line.x1(), line.y1()),
QPointF(line.x2(), line.y2()));
ProcessSpans penBlend = d->getPenFunc(brect, &s->penData);
@@ -4296,11 +4310,19 @@ void QRasterPaintEnginePrivate::recalculateFastImages()
QRasterPaintEngineState *s = q->state();
s->flags.fast_images = !(s->renderHints & QPainter::SmoothPixmapTransform)
- && rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver
&& s->matrix.type() <= QTransform::TxShear;
}
+bool QRasterPaintEnginePrivate::canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const
+{
+ Q_Q(const QRasterPaintEngine);
+ const QRasterPaintEngineState *s = q->state();
+ return s->flags.fast_images
+ && (mode == QPainter::CompositionMode_SourceOver
+ || (mode == QPainter::CompositionMode_Source
+ && !image.hasAlphaChannel()));
+}
QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color)
{
@@ -4627,38 +4649,40 @@ void QClipData::fixup()
return;
}
-// qDebug("QClipData::fixup: count=%d",count);
int y = -1;
ymin = m_spans[0].y;
ymax = m_spans[count-1].y + 1;
xmin = INT_MAX;
xmax = 0;
+ const int firstLeft = m_spans[0].x;
+ const int firstRight = m_spans[0].x + m_spans[0].len;
bool isRect = true;
- int left = m_spans[0].x;
- int right = m_spans[0].x + m_spans[0].len;
for (int i = 0; i < count; ++i) {
- if (m_spans[i].y != y) {
- if (m_spans[i].y != y + 1 && y != -1) {
+ QT_FT_Span_& span = m_spans[i];
+
+ if (span.y != y) {
+ if (span.y != y + 1 && y != -1)
isRect = false;
- }
- y = m_spans[i].y;
- m_clipLines[y].spans = m_spans+i;
- m_clipLines[y].count = 0;
-// qDebug() << " new line: y=" << y;
- }
- ++m_clipLines[y].count;
- int sl = (int) m_spans[i].x;
- int sr = sl + m_spans[i].len;
+ y = span.y;
+ m_clipLines[y].spans = &span;
+ m_clipLines[y].count = 1;
+ } else
+ ++m_clipLines[y].count;
+
+ const int spanLeft = span.x;
+ const int spanRight = spanLeft + span.len;
+
+ if (spanLeft < xmin)
+ xmin = spanLeft;
- xmin = qMin(xmin, (int)m_spans[i].x);
- xmax = qMax(xmax, (int)m_spans[i].x + m_spans[i].len);
+ if (spanRight > xmax)
+ xmax = spanRight;
- if (sl != left || sr != right)
+ if (spanLeft != firstLeft || spanRight != firstRight)
isRect = false;
}
-// qDebug("xmin=%d,xmax=%d,ymin=%d,ymax=%d %s", xmin, xmax, ymin, ymax, isRect ? "rectangular" : "");
if (isRect) {
hasRectClip = true;
@@ -4994,8 +5018,8 @@ protected:
int size, int opacity) const;
uint *addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
if (cache.size() == maxCacheSize()) {
- int elem_to_remove = qrand() % maxCacheSize();
- cache.remove(cache.keys()[elem_to_remove]); // may remove more than 1, but OK
+ // may remove more than 1, but OK
+ cache.erase(cache.begin() + (qrand() % maxCacheSize()));
}
CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
generateGradientColorTable(gradient, cache_entry.buffer, paletteSize(), opacity);
@@ -5146,7 +5170,8 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
case Qt::SolidPattern: {
type = Solid;
QColor c = qbrush_color(brush);
- solid.color = PREMUL(ARGB_COMBINE_ALPHA(c.rgba(), alpha));
+ QRgb rgba = c.rgba();
+ solid.color = PREMUL(ARGB_COMBINE_ALPHA(rgba, alpha));
if ((solid.color & 0xff000000) == 0
&& compositionMode == QPainter::CompositionMode_SourceOver) {
type = None;
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 6c2d28d..52f51fa 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -254,12 +254,14 @@ protected:
QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
private:
friend struct QSpanData;
+ friend class QBlitterPaintEngine;
+ friend class QBlitterPaintEnginePrivate;
void init();
void fillRect(const QRectF &rect, QSpanData *data);
void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
- void drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions,
+ bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions,
QFontEngine *fontEngine);
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
@@ -340,6 +342,7 @@ public:
void initializeRasterizer(QSpanData *data);
void recalculateFastImages();
+ bool canUseFastImageBlending(QPainter::CompositionMode mode, const QImage &image) const;
QPaintDevice *device;
QScopedPointer<QOutlineMapper> outlineMapper;
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 8b71b83..94828fb 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -2385,7 +2385,7 @@ void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
set = ft->loadTransformedGlyphSet(d->matrix);
if (!set || set->outline_drawing
- || !ft->loadGlyphs(set, glyphs.data(), glyphs.size(), QFontEngineFT::Format_Render))
+ || !ft->loadGlyphs(set, glyphs.constData(), glyphs.size(), positions.constData(), QFontEngineFT::Format_Render))
{
QPaintEngine::drawTextItem(p, ti);
return;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 76ac7db..14fb772 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -61,6 +61,8 @@
#include "qstyle.h"
#include "qthread.h"
#include "qvarlengtharray.h"
+#include "qstatictext.h"
+#include "qglyphs.h"
#include <private/qfontengine_p.h>
#include <private/qpaintengine_p.h>
@@ -70,8 +72,8 @@
#include <private/qwidget_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
-#include <qstatictext.h>
#include <private/qstatictext_p.h>
+#include <private/qglyphs_p.h>
#include <private/qstylehelper_p.h>
QT_BEGIN_NAMESPACE
@@ -92,7 +94,7 @@ void qt_format_text(const QFont &font,
QPainter *painter);
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe,
QTextCharFormat::UnderlineStyle underlineStyle,
- const QTextItem::RenderFlags flags, qreal width,
+ QTextItem::RenderFlags flags, qreal width,
const QTextCharFormat &charFormat);
// Helper function to calculate left most position, width and flags for decoration drawing
static void drawDecorationForGlyphs(QPainter *painter, const glyph_t *glyphArray,
@@ -149,6 +151,13 @@ static inline uint line_emulation(uint emulation)
| QPaintEngine_OpaqueBackground);
}
+static bool qt_paintengine_supports_transformations(QPaintEngine::Type type)
+{
+ return type == QPaintEngine::OpenGL2
+ || type == QPaintEngine::OpenVG
+ || type == QPaintEngine::OpenGL;
+}
+
#ifndef QT_NO_DEBUG
static bool qt_painter_thread_test(int devType, const char *what, bool extraCondition = false)
{
@@ -162,6 +171,10 @@ static bool qt_painter_thread_test(int devType, const char *what, bool extraCond
#endif
break;
default:
+#ifdef Q_WS_X11
+ if (QApplication::testAttribute(Qt::AA_X11InitThreads))
+ return true;
+#endif
if (!extraCondition && QThread::currentThread() != qApp->thread()) {
qWarning("QPainter: It is not safe to use %s outside the GUI thread", what);
return false;
@@ -2701,6 +2714,63 @@ QPainterPath QPainter::clipPath() const
}
/*!
+ Returns the bounding rectangle of the current clip if there is a clip;
+ otherwise returns an empty rectangle. Note that the clip region is
+ given in logical coordinates.
+
+ The bounding rectangle is not guaranteed to be tight.
+
+ \sa setClipRect(), setClipPath(), setClipRegion()
+
+ \since 4.8
+ */
+
+QRectF QPainter::clipBoundingRect() const
+{
+ Q_D(const QPainter);
+
+ if (!d->engine) {
+ qWarning("QPainter::clipBoundingRect: Painter not active");
+ return QRectF();
+ }
+
+ // Accumulate the bounding box in device space. This is not 100%
+ // precise, but it fits within the guarantee and it is resonably
+ // fast.
+ QRectF bounds;
+ for (int i=0; i<d->state->clipInfo.size(); ++i) {
+ QRectF r;
+ const QPainterClipInfo &info = d->state->clipInfo.at(i);
+
+ if (info.clipType == QPainterClipInfo::RectClip)
+ r = info.rect;
+ else if (info.clipType == QPainterClipInfo::RectFClip)
+ r = info.rectf;
+ else if (info.clipType == QPainterClipInfo::RegionClip)
+ r = info.region.boundingRect();
+ else
+ r = info.path.boundingRect();
+
+ r = info.matrix.mapRect(r);
+
+ if (i == 0)
+ bounds = r;
+ else if (info.operation == Qt::IntersectClip)
+ bounds &= r;
+ else if (info.operation == Qt::UniteClip)
+ bounds |= r;
+ }
+
+
+ // Map the rectangle back into logical space using the inverse
+ // matrix.
+ if (!d->txinv)
+ const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
+
+ return d->invMatrix.mapRect(bounds);
+}
+
+/*!
\fn void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation)
Enables clipping, and sets the clip region to the given \a
@@ -5256,7 +5326,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
return;
#ifndef QT_NO_DEBUG
- qt_painter_thread_test(d->device->devType(), "drawPixmap()");
+ qt_painter_thread_test(d->device->devType(), "drawPixmap()", true);
#endif
if (d->extended) {
@@ -5326,7 +5396,7 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
if (!d->engine || pm.isNull())
return;
#ifndef QT_NO_DEBUG
- qt_painter_thread_test(d->device->devType(), "drawPixmap()");
+ qt_painter_thread_test(d->device->devType(), "drawPixmap()", true);
#endif
qreal x = r.x();
@@ -5711,17 +5781,59 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags);
}
+/*!
+ Draws the glyphs represented by \a glyphs at \a position. The \a position gives the
+ edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font
+ selected on \a glyphs and at offsets given by the positions in \a glyphs.
+
+ \since 4.8
+
+ \sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes()
+*/
+void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs)
+{
+ Q_D(QPainter);
+
+ QFont oldFont = d->state->font;
+ d->state->font = glyphs.font();
+
+ QVector<quint32> glyphIndexes = glyphs.glyphIndexes();
+ QVector<QPointF> glyphPositions = glyphs.positions();
+
+ int count = qMin(glyphIndexes.size(), glyphPositions.size());
+ QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count);
+
+ bool paintEngineSupportsTransformations =
+ d->extended != 0
+ ? qt_paintengine_supports_transformations(d->extended->type())
+ : false;
+ for (int i=0; i<count; ++i) {
+ QPointF processedPosition = position + glyphPositions.at(i);
+ if (!paintEngineSupportsTransformations)
+ processedPosition = d->state->transform().map(processedPosition);
+ fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
+ }
+
+ d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count);
+
+ d->state->font = oldFont;
+}
void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, const QPointF *positionArray,
int glyphCount)
{
+ QVarLengthArray<QFixedPoint, 128> positions(glyphCount);
+ for (int i=0; i<glyphCount; ++i)
+ positions[i] = QFixedPoint::fromPointF(positionArray[i]);
+
QPainterPrivate *painter_d = QPainterPrivate::get(painter);
- painter_d->drawGlyphs(glyphArray, positionArray, glyphCount);
+ painter_d->drawGlyphs(const_cast<quint32 *>(glyphArray), positions.data(), glyphCount);
}
-void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray,
- int glyphCount)
+void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount)
{
+ Q_Q(QPainter);
+
updateState(state);
QFontEngine *fontEngine = state->font.d->engineForScript(QUnicodeTables::Common);
@@ -5736,12 +5848,27 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit
fontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);
}
- QVarLengthArray<QFixedPoint, 128> positions;
+ QFixed leftMost;
+ QFixed rightMost;
+ QFixed baseLine;
for (int i=0; i<glyphCount; ++i) {
- QFixedPoint fp = QFixedPoint::fromPointF(positionArray[i]);
- positions.append(fp);
+ glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]);
+ if (i == 0 || leftMost > positions[i].x)
+ leftMost = positions[i].x;
+
+ // We don't support glyphs that do not share a common baseline. If this turns out to
+ // be a relevant use case, then we need to find clusters of glyphs that share a baseline
+ // and do a drawTextItemDecorations call per cluster.
+ if (i == 0 || baseLine < positions[i].y)
+ baseLine = positions[i].y;
+
+ // We use the advance rather than the actual bounds to match the algorithm in drawText()
+ if (i == 0 || rightMost < positions[i].x + gm.xoff)
+ rightMost = positions[i].x + gm.xoff;
}
+ QFixed width = rightMost - leftMost;
+
if (extended != 0) {
QStaticTextItem staticTextItem;
staticTextItem.color = state->pen.color();
@@ -5749,7 +5876,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit
staticTextItem.setFontEngine(fontEngine);
staticTextItem.numGlyphs = glyphCount;
staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray));
- staticTextItem.glyphPositions = positions.data();
+ staticTextItem.glyphPositions = positions;
extended->drawStaticTextItem(&staticTextItem);
} else {
@@ -5766,7 +5893,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit
textItem.glyphs.numGlyphs = glyphCount;
textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray));
- textItem.glyphs.offsets = positions.data();
+ textItem.glyphs.offsets = positions;
textItem.glyphs.advances_x = advances.data();
textItem.glyphs.advances_y = advances.data();
textItem.glyphs.justifications = glyphJustifications.data();
@@ -5774,6 +5901,21 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit
engine->drawTextItem(QPointF(0, 0), textItem);
}
+
+ QTextItemInt::RenderFlags flags;
+ if (state->font.underline())
+ flags |= QTextItemInt::Underline;
+ if (state->font.overline())
+ flags |= QTextItemInt::Overline;
+ if (state->font.strikeOut())
+ flags |= QTextItemInt::StrikeOut;
+
+ drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()),
+ fontEngine,
+ (state->font.underline()
+ ? QTextCharFormat::SingleUnderline
+ : QTextCharFormat::NoUnderline),
+ flags, width.toReal(), QTextCharFormat());
}
/*!
@@ -5862,10 +6004,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText
return;
}
- bool paintEngineSupportsTransformations = d->extended->type() == QPaintEngine::OpenGL2
- || d->extended->type() == QPaintEngine::OpenVG
- || d->extended->type() == QPaintEngine::OpenGL;
-
+ bool paintEngineSupportsTransformations = qt_paintengine_supports_transformations(d->extended->type());
if (paintEngineSupportsTransformations && !staticText_d->untransformedCoordinates) {
staticText_d->untransformedCoordinates = true;
staticText_d->needsRelayout = true;
@@ -6309,7 +6448,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe,
QTextCharFormat::UnderlineStyle underlineStyle,
- const QTextItem::RenderFlags flags, qreal width,
+ QTextItem::RenderFlags flags, qreal width,
const QTextCharFormat &charFormat)
{
if (underlineStyle == QTextCharFormat::NoUnderline
@@ -6324,7 +6463,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
pen.setWidthF(fe->lineThickness().toReal());
pen.setCapStyle(Qt::FlatCap);
- QLineF line(pos.x(), pos.y(), pos.x() + width, pos.y());
+ QLineF line(pos.x(), pos.y(), pos.x() + qFloor(width), pos.y());
const qreal underlineOffset = fe->underlinePosition().toReal();
// deliberately ceil the offset to avoid the underline coming too close to
@@ -6697,7 +6836,7 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo
return;
#ifndef QT_NO_DEBUG
- qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()");
+ qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()", true);
#endif
qreal sw = pixmap.width();
@@ -7877,7 +8016,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
}
void qt_format_text(const QFont &fnt, const QRectF &_r,
int tf, const QTextOption *option, const QString& str, QRectF *brect,
- int tabstops, int *, int tabarraylen,
+ int tabstops, int *ta, int tabarraylen,
QPainter *painter)
{
@@ -7997,9 +8136,23 @@ start_lengthVariant:
engine.option = *option;
}
+ if (engine.option.tabStop() < 0 && tabstops > 0)
+ engine.option.setTabStop(tabstops);
+
+ if (engine.option.tabs().isEmpty() && ta) {
+ QList<qreal> tabs;
+ for (int i = 0; i < tabarraylen; i++)
+ tabs.append(qreal(ta[i]));
+ engine.option.setTabArray(tabs);
+ }
+
engine.option.setTextDirection(layout_direction);
if (tf & Qt::AlignJustify)
engine.option.setAlignment(Qt::AlignJustify);
+ else if (tf & Qt::AlignRight)
+ engine.option.setAlignment(Qt::AlignRight);
+ else if (tf & Qt::AlignHCenter)
+ engine.option.setAlignment(Qt::AlignHCenter);
else
engine.option.setAlignment(Qt::AlignLeft); // do not do alignment twice
@@ -8095,14 +8248,7 @@ start_lengthVariant:
for (int i = 0; i < textLayout.lineCount(); i++) {
QTextLine line = textLayout.lineAt(i);
-
- qreal advance = line.horizontalAdvance();
- if (tf & Qt::AlignRight)
- xoff = r.width() - advance;
- else if (tf & Qt::AlignHCenter)
- xoff = (r.width() - advance)/2;
-
- line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
+ line.draw(painter, QPointF(r.x(), r.y() + yoff));
}
if (restore) {
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 0d7829e..ae2fdf2 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -79,6 +79,7 @@ class QTextItem;
class QMatrix;
class QTransform;
class QStaticText;
+class QGlyphs;
class QPainterPrivateDeleter;
@@ -221,6 +222,8 @@ public:
void setClipping(bool enable);
bool hasClipping() const;
+ QRectF clipBoundingRect() const;
+
void save();
void restore();
@@ -396,6 +399,8 @@ public:
void setLayoutDirection(Qt::LayoutDirection direction);
Qt::LayoutDirection layoutDirection() const;
+ void drawGlyphs(const QPointF &position, const QGlyphs &glyphs);
+
void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText);
inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText);
inline void drawStaticText(int left, int top, const QStaticText &staticText);
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 0e0c11f..26d8fc3 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE
class QPaintEngine;
class QEmulationPaintEngine;
class QPaintEngineEx;
+struct QFixedPoint;
struct QTLWExtra;
@@ -228,7 +229,7 @@ public:
void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw);
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation);
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation);
- void drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray, int glyphCount);
+ void drawGlyphs(quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount);
void updateMatrix();
void updateInvMatrix();
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 0bb2901..2058040 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -576,6 +576,14 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
}
/*!
+ \fn void QPainterPath::swap(QPainterPath &other)
+ \since 4.8
+
+ Swaps painter path \a other with this painter path. This operation is very
+ fast and never fails.
+*/
+
+/*!
Destroys this QPainterPath object.
*/
QPainterPath::~QPainterPath()
@@ -628,10 +636,14 @@ void QPainterPath::moveTo(const QPointF &p)
#ifdef QPP_DEBUG
printf("QPainterPath::moveTo() (%.2f,%.2f)\n", p.x(), p.y());
#endif
+
+ if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(p.x()) || qt_is_nan(p.y()))
- qWarning("QPainterPath::moveTo: Adding point where x or y is NaN, results are undefined");
+ qWarning("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
ensureData();
detach();
@@ -674,10 +686,14 @@ void QPainterPath::lineTo(const QPointF &p)
#ifdef QPP_DEBUG
printf("QPainterPath::lineTo() (%.2f,%.2f)\n", p.x(), p.y());
#endif
+
+ if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(p.x()) || qt_is_nan(p.y()))
- qWarning("QPainterPath::lineTo: Adding point where x or y is NaN, results are undefined");
+ qWarning("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
ensureData();
detach();
@@ -729,11 +745,15 @@ void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &
printf("QPainterPath::cubicTo() (%.2f,%.2f), (%.2f,%.2f), (%.2f,%.2f)\n",
c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
#endif
+
+ if (!qt_is_finite(c1.x()) || !qt_is_finite(c1.y()) || !qt_is_finite(c2.x()) || !qt_is_finite(c2.y())
+ || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(c1.x()) || qt_is_nan(c1.y()) || qt_is_nan(c2.x()) || qt_is_nan(c2.y())
- || qt_is_nan(e.x()) || qt_is_nan(e.y()))
- qWarning("QPainterPath::cubicTo: Adding point where x or y is NaN, results are undefined");
+ qWarning("QPainterPath::cubicTo: Adding point where x or y is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
ensureData();
detach();
@@ -782,10 +802,14 @@ void QPainterPath::quadTo(const QPointF &c, const QPointF &e)
printf("QPainterPath::quadTo() (%.2f,%.2f), (%.2f,%.2f)\n",
c.x(), c.y(), e.x(), e.y());
#endif
+
+ if (!qt_is_finite(c.x()) || !qt_is_finite(c.y()) || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(c.x()) || qt_is_nan(c.y()) || qt_is_nan(e.x()) || qt_is_nan(e.y()))
- qWarning("QPainterPath::quadTo: Adding point where x or y is NaN, results are undefined");
+ qWarning("QPainterPath::quadTo: Adding point where x or y is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
ensureData();
detach();
@@ -849,11 +873,15 @@ void QPainterPath::arcTo(const QRectF &rect, qreal startAngle, qreal sweepLength
printf("QPainterPath::arcTo() (%.2f, %.2f, %.2f, %.2f, angle=%.2f, sweep=%.2f\n",
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())
+ || !qt_is_finite(startAngle) || !qt_is_finite(sweepLength)) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height())
- || qt_is_nan(startAngle) || qt_is_nan(sweepLength))
- qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined");
+ qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
if (rect.isNull())
return;
@@ -952,10 +980,13 @@ QPointF QPainterPath::currentPosition() const
*/
void QPainterPath::addRect(const QRectF &r)
{
+ if (!qt_is_finite(r.x()) || !qt_is_finite(r.y()) || !qt_is_finite(r.width()) || !qt_is_finite(r.height())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(r.x()) || qt_is_nan(r.y()) || qt_is_nan(r.width()) || qt_is_nan(r.height()))
- qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN, results are undefined");
+ qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
if (r.isNull())
return;
@@ -1032,11 +1063,14 @@ void QPainterPath::addPolygon(const QPolygonF &polygon)
*/
void QPainterPath::addEllipse(const QRectF &boundingRect)
{
+ if (!qt_is_finite(boundingRect.x()) || !qt_is_finite(boundingRect.y())
+ || !qt_is_finite(boundingRect.width()) || !qt_is_finite(boundingRect.height())) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(boundingRect.x()) || qt_is_nan(boundingRect.y())
- || qt_is_nan(boundingRect.width()) || qt_is_nan(boundingRect.height()))
- qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN, results are undefined");
+ qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN or Inf, ignoring call");
#endif
+ return;
+ }
+
if (boundingRect.isNull())
return;
@@ -2358,10 +2392,12 @@ QDataStream &operator>>(QDataStream &s, QPainterPath &p)
s >> x;
s >> y;
Q_ASSERT(type >= 0 && type <= 3);
+ if (!qt_is_finite(x) || !qt_is_finite(y)) {
#ifndef QT_NO_DEBUG
- if (qt_is_nan(x) || qt_is_nan(y))
- qWarning("QDataStream::operator>>: Adding a NaN element to path, results are undefined");
+ qWarning("QDataStream::operator>>: NaN or Inf element found in path, skipping it");
#endif
+ continue;
+ }
QPainterPath::Element elm = { x, y, QPainterPath::ElementType(type) };
p.d_func()->elements.append(elm);
}
@@ -2887,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/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 4d166af..3c23282 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -95,7 +95,12 @@ public:
explicit QPainterPath(const QPointF &startPoint);
QPainterPath(const QPainterPath &other);
QPainterPath &operator=(const QPainterPath &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPainterPath &operator=(QPainterPath &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
~QPainterPath();
+ inline void swap(QPainterPath &other) { d_ptr.swap(other.d_ptr); }
void closeSubpath();
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 4e8408b..bc30038 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -915,7 +915,6 @@ const char *QPdf::paperSizeToString(QPrinter::PaperSize paperSize)
return psToStr[paperSize];
}
-
// -------------------------- base engine, shared code between PS and PDF -----------------------
QPdfBaseEngine::QPdfBaseEngine(QPdfBaseEnginePrivate &dd, PaintEngineFeatures f)
@@ -1157,6 +1156,8 @@ void QPdfBaseEngine::updateState(const QPaintEngineState &state)
}
if (flags & DirtyBrush) {
d->brush = state.brush();
+ if (d->brush.color().alpha() == 0 && d->brush.style() == Qt::SolidPattern)
+ d->brush.setStyle(Qt::NoBrush);
d->hasBrush = d->brush.style() != Qt::NoBrush;
}
if (flags & DirtyBrushOrigin) {
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index 08f9504..b69458d 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -383,6 +383,14 @@ QPen &QPen::operator=(const QPen &p)
}
/*!
+ \fn void QPen::swap(QPen &other)
+ \since 4.8
+
+ Swaps pen \a other with this pen. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the pen as a QVariant.
*/
QPen::operator QVariant() const
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index 4298f81..001cd44 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -74,6 +74,11 @@ public:
~QPen();
QPen &operator=(const QPen &pen);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPen &operator=(QPen &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QPen &other) { qSwap(d, other.d); }
Qt::PenStyle style() const;
void setStyle(Qt::PenStyle);
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index 0cf2ef5..41b686a 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -700,6 +700,22 @@ QPolygon QPolygonF::toPolygon() const
}
/*!
+ \fn void QPolygon::swap(QPolygon &other)
+ \since 4.8
+
+ Swaps polygon \a other with this polygon. This operation is very
+ fast and never fails.
+*/
+
+/*!
+ \fn void QPolygonF::swap(QPolygonF &other)
+ \since 4.8
+
+ Swaps polygon \a other with this polygon. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the polygon as a QVariant
*/
QPolygon::operator QVariant() const
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index b89b2a5..0f4a8b3 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -67,6 +67,8 @@ public:
inline QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
QPolygon(const QRect &r, bool closed=false);
QPolygon(int nPoints, const int *points);
+ inline void swap(QPolygon &other) { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
+
operator QVariant() const;
void translate(int dx, int dy);
@@ -139,6 +141,7 @@ public:
inline QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
QPolygonF(const QRectF &r);
QPolygonF(const QPolygon &a);
+ inline void swap(QPolygonF &other) { QVector<QPointF>::swap(other); } // prevent QVector<QPointF><->QPolygonF swaps
inline void translate(qreal dx, qreal dy);
void translate(const QPointF &offset);
diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp
index f262144..b7f5160 100644
--- a/src/gui/painting/qprintengine_pdf.cpp
+++ b/src/gui/painting/qprintengine_pdf.cpp
@@ -936,7 +936,7 @@ void QPdfEnginePrivate::writeInfo()
xprintf("\n/Creator ");
printString(creator);
xprintf("\n/Producer ");
- printString(QString::fromLatin1("Qt " QT_VERSION_STR " (C) 2010 Nokia Corporation and/or its subsidiary(-ies)"));
+ printString(QString::fromLatin1("Qt " QT_VERSION_STR " (C) 2011 Nokia Corporation and/or its subsidiary(-ies)"));
QDateTime now = QDateTime::currentDateTime().toUTC();
QTime t = now.time();
QDate d = now.date();
diff --git a/src/gui/painting/qprinterinfo.qdoc b/src/gui/painting/qprinterinfo.cpp
index c3c0f83..f680ce1 100644
--- a/src/gui/painting/qprinterinfo.qdoc
+++ b/src/gui/painting/qprinterinfo.cpp
@@ -25,6 +25,16 @@
**
****************************************************************************/
+#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
+
+#ifndef QT_NO_PRINTER
+
+QT_BEGIN_NAMESPACE
+
+QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
+
+
/*!
\class QPrinterInfo
@@ -59,60 +69,94 @@
*/
/*!
- \fn QPrinterInfo::QPrinterInfo()
-
Constructs an empty QPrinterInfo object.
\sa isNull()
*/
+QPrinterInfo::QPrinterInfo()
+ : d_ptr(&QPrinterInfoPrivate::shared_null)
+{
+}
/*!
- \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
-
- Constructs a copy of \a src.
+ Constructs a copy of \a other.
*/
+QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
+ : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
+{
+}
/*!
- \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer)
-
Constructs a QPrinterInfo object from \a printer.
*/
+QPrinterInfo::QPrinterInfo(const QPrinter &printer)
+ : d_ptr(&QPrinterInfoPrivate::shared_null)
+{
+ foreach (const QPrinterInfo &printerInfo, availablePrinters()) {
+ if (printerInfo.printerName() == printer.printerName()) {
+ d_ptr.reset(new QPrinterInfoPrivate(*printerInfo.d_ptr));
+ break;
+ }
+ }
+}
/*!
- \fn QPrinterInfo::~QPrinterInfo()
+ \internal
+*/
+QPrinterInfo::QPrinterInfo(const QString &name)
+ : d_ptr(new QPrinterInfoPrivate(name))
+{
+}
+/*!
Destroys the QPrinterInfo object. References to the values in the
object become invalid.
*/
+QPrinterInfo::~QPrinterInfo()
+{
+}
/*!
- \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-
- Sets the QPrinterInfo object to be equal to \a src.
+ Sets the QPrinterInfo object to be equal to \a other.
*/
+QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
+{
+ Q_ASSERT(d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
+ return *this;
+}
/*!
- \fn QString QPrinterInfo::printerName() const
-
Returns the name of the printer.
\sa QPrinter::setPrinterName()
*/
+QString QPrinterInfo::printerName() const
+{
+ const Q_D(QPrinterInfo);
+ return d->name;
+}
/*!
- \fn bool QPrinterInfo::isNull() const
-
Returns whether this QPrinterInfo object holds a printer definition.
An empty QPrinterInfo object could result for example from calling
defaultPrinter() when there are no printers on the system.
*/
+bool QPrinterInfo::isNull() const
+{
+ const Q_D(QPrinterInfo);
+ return d == &QPrinterInfoPrivate::shared_null;
+}
/*!
- \fn bool QPrinterInfo::isDefault() const
-
Returns whether this printer is the default printer.
*/
+bool QPrinterInfo::isDefault() const
+{
+ const Q_D(QPrinterInfo);
+ return d->isDefault;
+}
/*!
\fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
@@ -123,3 +167,7 @@
Not all printer drivers support this query, so the list may be empty.
On Mac OS X 10.3, this function always returns an empty list.
*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h
index 2ac07a8..3437961 100644
--- a/src/gui/painting/qprinterinfo.h
+++ b/src/gui/painting/qprinterinfo.h
@@ -42,9 +42,10 @@
#ifndef QPRINTERINFO_H
#define QPRINTERINFO_H
-#include <QtGui/QPrinter>
#include <QtCore/QList>
+#include <QtGui/QPrinter>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -56,15 +57,13 @@ class QPrinterInfoPrivate;
class QPrinterInfoPrivateDeleter;
class Q_GUI_EXPORT QPrinterInfo
{
-Q_DECLARE_PRIVATE(QPrinterInfo)
-
public:
QPrinterInfo();
- QPrinterInfo(const QPrinterInfo& src);
- QPrinterInfo(const QPrinter& printer);
+ QPrinterInfo(const QPrinterInfo &other);
+ QPrinterInfo(const QPrinter &printer);
~QPrinterInfo();
- QPrinterInfo& operator=(const QPrinterInfo& src);
+ QPrinterInfo &operator=(const QPrinterInfo &other);
QString printerName() const;
bool isNull() const;
@@ -75,8 +74,10 @@ public:
static QPrinterInfo defaultPrinter();
private:
- QPrinterInfo(const QString& name);
+ QPrinterInfo(const QString &name);
+private:
+ Q_DECLARE_PRIVATE(QPrinterInfo)
QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
};
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index bafe2b2..b24ab70 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include "private/qt_mac_p.h"
@@ -47,189 +48,71 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
-class QPrinterInfoPrivate
-{
-Q_DECLARE_PUBLIC(QPrinterInfo)
-public:
- ~QPrinterInfoPrivate();
- QPrinterInfoPrivate();
- QPrinterInfoPrivate(const QString& name);
-
-private:
- QPrinterInfo* q_ptr;
-
- QString m_name;
- bool m_default;
- bool m_isNull;
-};
-
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
-
-extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size);
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
+extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size);
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
{
QList<QPrinterInfo> printers;
- OSStatus status = noErr;
- QCFType<CFArrayRef> printerList;
- status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
- if (status == noErr) {
- CFIndex count = CFArrayGetCount(printerList);
- for (CFIndex i=0; i<count; ++i) {
- PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
- QString name = QCFString::toQString(PMPrinterGetName(printer));
- printers.append(QPrinterInfo(name));
- if (PMPrinterIsDefault(printer)) {
- printers[i].d_ptr->m_default = true;
- }
+ QCFType<CFArrayRef> array;
+ if (PMServerCreatePrinterList(kPMServerLocal, &array) == noErr) {
+ CFIndex count = CFArrayGetCount(array);
+ for (int i = 0; i < count; ++i) {
+ PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
+ QString printerName = QCFString::toQString(PMPrinterGetName(printer));
+
+ QPrinterInfo printerInfo(printerName);
+ if (PMPrinterIsDefault(printer))
+ printerInfo.d_ptr->isDefault = true;
+ printers.append(printerInfo);
}
}
return printers;
}
-QPrinterInfo QPrinterInfo::defaultPrinter(){
- QList<QPrinterInfo> printers = availablePrinters();
- for (int c = 0; c < printers.size(); ++c) {
- if (printers[c].isDefault()) {
- return printers[c];
- }
- }
- return QPrinterInfo();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfo::QPrinterInfo(const QPrinter& prn)
- : d_ptr(&nullQPrinterInfoPrivate)
+QPrinterInfo QPrinterInfo::defaultPrinter()
{
- QList<QPrinterInfo> list = availablePrinters();
- for (int c = 0; c < list.size(); ++c) {
- if (prn.printerName() == list[c].printerName()) {
- *this = list[c];
- return;
- }
+ QList<QPrinterInfo> printers = availablePrinters();
+ foreach (const QPrinterInfo &printerInfo, printers) {
+ if (printerInfo.isDefault())
+ return printerInfo;
}
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
- d_ptr->q_ptr = this;
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- d_ptr->q_ptr = this;
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
- const Q_D(QPrinterInfo);
- return d->m_name;
-}
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
+ return printers.value(0);
}
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
const Q_D(QPrinterInfo);
- PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->m_name));
+ QList<QPrinter::PaperSize> paperSizes;
+ if (isNull())
+ return paperSizes;
- if (!cfPrn) return QList<QPrinter::PaperSize>();
+ PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
+ if (!cfPrn)
+ return paperSizes;
CFArrayRef array;
- OSStatus status = PMPrinterGetPaperList(cfPrn, &array);
-
- if (status != 0) {
+ if (PMPrinterGetPaperList(cfPrn, &array) != noErr) {
PMRelease(cfPrn);
- return QList<QPrinter::PaperSize>();
+ return paperSizes;
}
- QList<QPrinter::PaperSize> paperList;
int count = CFArrayGetCount(array);
- for (int c = 0; c < count; c++) {
- PMPaper paper = static_cast<PMPaper>(
- const_cast<void*>(
- CFArrayGetValueAtIndex(array, c)));
+ for (int i = 0; i < count; ++i) {
+ PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
double width, height;
- status = PMPaperGetWidth(paper, &width);
- status |= PMPaperGetHeight(paper, &height);
- if (status != 0) continue;
-
- QSizeF size(width * 0.3527, height * 0.3527);
- paperList.append(qSizeFTopaperSize(size));
+ if (PMPaperGetWidth(paper, &width) == noErr && PMPaperGetHeight(paper, &height) == noErr) {
+ QSizeF size(width * 0.3527, height * 0.3527);
+ paperSizes.append(qSizeFTopaperSize(size));
+ }
}
PMRelease(cfPrn);
- return paperList;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate() :
- q_ptr(NULL),
- m_default(false),
- m_isNull(true)
-{
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) :
- q_ptr(NULL),
- m_name(name),
- m_default(false),
- m_isNull(false)
-{
-}
-
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
+ return paperSizes;
}
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h
new file mode 100644
index 0000000..fcc1acb
--- /dev/null
+++ b/src/gui/painting/qprinterinfo_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 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 QPRINTERINFO_P_H
+#define QPRINTERINFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qglobal.h"
+
+#ifndef QT_NO_PRINTER
+
+#include "QtCore/qlist.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPrinterInfoPrivate
+{
+public:
+ QPrinterInfoPrivate(const QString& name = QString()) :
+ name(name), isDefault(false)
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ , cupsPrinterIndex(0), hasPaperSizes(false)
+#endif
+#endif
+ {}
+ ~QPrinterInfoPrivate()
+ {}
+
+ static QPrinterInfoPrivate shared_null;
+
+ QString name;
+ bool isDefault;
+
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ int cupsPrinterIndex;
+ mutable bool hasPaperSizes;
+ mutable QList<QPrinter::PaperSize> paperSizes;
+#endif
+#endif
+};
+
+
+class QPrinterInfoPrivateDeleter
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &QPrinterInfoPrivate::shared_null)
+ delete d;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
+
+#endif // QPRINTERINFO_P_H
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index ed8ce80..38e9590 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include <qfile.h>
#include <qfileinfo.h>
@@ -60,42 +61,66 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
-class QPrinterInfoPrivate
-{
-Q_DECLARE_PUBLIC(QPrinterInfo)
-public:
- QPrinterInfoPrivate();
- QPrinterInfoPrivate(const QString& name);
- ~QPrinterInfoPrivate();
-
- static QPrinter::PaperSize string2PaperSize(const QString& str);
- static QString pageSize2String(QPrinter::PaperSize size);
-
-private:
- QString m_name;
- bool m_isNull;
- bool m_default;
- mutable bool m_mustGetPaperSizes;
- mutable QList<QPrinter::PaperSize> m_paperSizes;
- int m_cupsPrinterIndex;
-
- QPrinterInfo* q_ptr;
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+// preserver names in ascending order for the binary search
+static const struct NamedPaperSize {
+ const char *const name;
+ QPrinter::PaperSize size;
+} named_sizes_map[QPrinter::NPageSize] = {
+ { "A0", QPrinter::A0 },
+ { "A1", QPrinter::A1 },
+ { "A2", QPrinter::A2 },
+ { "A3", QPrinter::A3 },
+ { "A4", QPrinter::A4 },
+ { "A5", QPrinter::A5 },
+ { "A6", QPrinter::A6 },
+ { "A7", QPrinter::A7 },
+ { "A8", QPrinter::A8 },
+ { "A9", QPrinter::A9 },
+ { "B0", QPrinter::B0 },
+ { "B1", QPrinter::B1 },
+ { "B10", QPrinter::B10 },
+ { "B2", QPrinter::B2 },
+ { "B4", QPrinter::B4 },
+ { "B5", QPrinter::B5 },
+ { "B6", QPrinter::B6 },
+ { "B7", QPrinter::B7 },
+ { "B8", QPrinter::B8 },
+ { "B9", QPrinter::B9 },
+ { "C5E", QPrinter::C5E },
+ { "Comm10E", QPrinter::Comm10E },
+ { "Custom", QPrinter::Custom },
+ { "DLE", QPrinter::DLE },
+ { "Executive", QPrinter::Executive },
+ { "Folio", QPrinter::Folio },
+ { "Ledger", QPrinter::Ledger },
+ { "Legal", QPrinter::Legal },
+ { "Letter", QPrinter::Letter },
+ { "Tabloid", QPrinter::Tabloid }
};
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+inline bool operator<(const char *name, const NamedPaperSize &data)
+{ return qstrcmp(name, data.name) < 0; }
+inline bool operator<(const NamedPaperSize &data, const char *name)
+{ return qstrcmp(data.name, name) < 0; }
-class QPrinterInfoPrivateDeleter
+static inline QPrinter::PaperSize string2PaperSize(const char *name)
{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
+ const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name);
+ if (r - named_sizes_map != QPrinter::NPageSize)
+ return r->size;
+ return QPrinter::Custom;
+}
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
+static inline const char *paperSize2String(QPrinter::PaperSize size)
+{
+ for (int i = 0; i < QPrinter::NPageSize; ++i) {
+ if (size == named_sizes_map[i].size)
+ return named_sizes_map[i].name;
+ }
+ return 0;
+}
+#endif
void qt_perhapsAddPrinter(QList<QPrinterDescription> *printers, const QString &name,
QString host, QString comment,
@@ -784,12 +809,12 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
#endif
}
+ QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
+ QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)"));
+
int quality = 0;
int best = 0;
for (int i = 0; i < printers.size(); ++i) {
- QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
- QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)"));
-
QString name = printers.at(i).name;
QString comment = printers.at(i).comment;
if (quality < 5 && name == dollarPrinter) {
@@ -824,331 +849,77 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
{
- QList<QPrinterInfo> list;
+ QList<QPrinterInfo> printers;
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
if (QCUPSSupport::isAvailable()) {
- //const ppd_file_t* cupsPPD = cups.currentPPD();
+ QCUPSSupport cups;
int cupsPrinterCount = cups.availablePrintersCount();
const cups_dest_t* cupsPrinters = cups.availablePrinters();
-
for (int i = 0; i < cupsPrinterCount; ++i) {
QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
if (cupsPrinters[i].instance)
printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
- list.append(QPrinterInfo(printerName));
+
+ QPrinterInfo printerInfo(printerName);
if (cupsPrinters[i].is_default)
- list[i].d_ptr->m_default = true;
- list[i].d_ptr->m_cupsPrinterIndex = i;
+ printerInfo.d_ptr->isDefault = true;
+ printerInfo.d_ptr->cupsPrinterIndex = i;
+ printers.append(printerInfo);
}
- } else {
+ } else
#endif
+ {
QList<QPrinterDescription> lprPrinters;
int defprn = qt_getLprPrinters(lprPrinters);
// populating printer combo
- QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
- for(; i != lprPrinters.constEnd(); ++i) {
- list.append(QPrinterInfo((*i).name));
- }
- if (defprn >= 0 && defprn < lprPrinters.size()) {
- list[defprn].d_ptr->m_default = true;
- }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ foreach (const QPrinterDescription &description, lprPrinters)
+ printers.append(QPrinterInfo(description.name));
+ if (defprn >= 0 && defprn < printers.size())
+ printers[defprn].d_ptr->isDefault = true;
}
-#endif
- return list;
+ return printers;
}
QPrinterInfo QPrinterInfo::defaultPrinter()
{
- QList<QPrinterInfo> prnList = availablePrinters();
- for (int i = 0; i < prnList.size(); ++i) {
- if (prnList[i].isDefault())
- return prnList[i];
+ QList<QPrinterInfo> printers = availablePrinters();
+ foreach (const QPrinterInfo &printerInfo, printers) {
+ if (printerInfo.isDefault())
+ return printerInfo;
}
- return (prnList.size() > 0) ? prnList[0] : QPrinterInfo();
-}
-
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
-{
-}
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
+ return printers.value(0);
}
-QPrinterInfo::QPrinterInfo(const QPrinter& printer)
- : d_ptr(new QPrinterInfoPrivate(printer.printerName()))
+QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
-
- Q_D(QPrinterInfo);
- d->q_ptr = this;
-
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
- if (QCUPSSupport::isAvailable()) {
- int cupsPrinterCount = cups.availablePrintersCount();
- const cups_dest_t* cupsPrinters = cups.availablePrinters();
-
- for (int i = 0; i < cupsPrinterCount; ++i) {
- QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
- if (cupsPrinters[i].instance)
- printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
- if (printerName == printer.printerName()) {
- if (cupsPrinters[i].is_default)
- d->m_default = true;
- d->m_cupsPrinterIndex = i;
- return;
- }
- }
- } else {
-#endif
- QList<QPrinterDescription> lprPrinters;
- int defprn = qt_getLprPrinters(lprPrinters);
- // populating printer combo
- QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
- int c;
- for(c = 0; i != lprPrinters.constEnd(); ++i, ++c) {
- if (i->name == printer.printerName()) {
- if (defprn == c)
- d->m_default = true;
- return;
- }
- }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- }
-#endif
-
- // Printer not found.
- d_ptr.reset(&nullQPrinterInfoPrivate);
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
- d_ptr->q_ptr = this;
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- d_ptr->q_ptr = this;
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
const Q_D(QPrinterInfo);
- return d->m_name;
-}
-
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
-}
+ if (isNull())
+ return d->paperSizes;
-QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-{
- const Q_D(QPrinterInfo);
- if (d->m_mustGetPaperSizes) {
- d->m_mustGetPaperSizes = false;
+ if (!d->hasPaperSizes) {
+ d->hasPaperSizes = true;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
if (QCUPSSupport::isAvailable()) {
// Find paper sizes from CUPS.
- cups.setCurrentPrinter(d->m_cupsPrinterIndex);
+ QCUPSSupport cups;
+ cups.setCurrentPrinter(d->cupsPrinterIndex);
const ppd_option_t* sizes = cups.pageSizes();
if (sizes) {
- for (int j = 0; j < sizes->num_choices; ++j) {
- d->m_paperSizes.append(
- QPrinterInfoPrivate::string2PaperSize(
- QLatin1String(sizes->choices[j].choice)));
- }
+ for (int j = 0; j < sizes->num_choices; ++j)
+ d->paperSizes.append(string2PaperSize(sizes->choices[j].choice));
}
}
-#endif
-
}
- return d->m_paperSizes;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate()
-{
- m_isNull = true;
- m_default = false;
- m_mustGetPaperSizes = true;
- m_cupsPrinterIndex = 0;
- q_ptr = 0;
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name)
-{
- m_name = name;
- m_isNull = false;
- m_default = false;
- m_mustGetPaperSizes = true;
- m_cupsPrinterIndex = 0;
- q_ptr = 0;
-}
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
-}
-
-QPrinter::PaperSize QPrinterInfoPrivate::string2PaperSize(const QString& str)
-{
- if (str == QLatin1String("A4")) {
- return QPrinter::A4;
- } else if (str == QLatin1String("B5")) {
- return QPrinter::B5;
- } else if (str == QLatin1String("Letter")) {
- return QPrinter::Letter;
- } else if (str == QLatin1String("Legal")) {
- return QPrinter::Legal;
- } else if (str == QLatin1String("Executive")) {
- return QPrinter::Executive;
- } else if (str == QLatin1String("A0")) {
- return QPrinter::A0;
- } else if (str == QLatin1String("A1")) {
- return QPrinter::A1;
- } else if (str == QLatin1String("A2")) {
- return QPrinter::A2;
- } else if (str == QLatin1String("A3")) {
- return QPrinter::A3;
- } else if (str == QLatin1String("A5")) {
- return QPrinter::A5;
- } else if (str == QLatin1String("A6")) {
- return QPrinter::A6;
- } else if (str == QLatin1String("A7")) {
- return QPrinter::A7;
- } else if (str == QLatin1String("A8")) {
- return QPrinter::A8;
- } else if (str == QLatin1String("A9")) {
- return QPrinter::A9;
- } else if (str == QLatin1String("B0")) {
- return QPrinter::B0;
- } else if (str == QLatin1String("B1")) {
- return QPrinter::B1;
- } else if (str == QLatin1String("B10")) {
- return QPrinter::B10;
- } else if (str == QLatin1String("B2")) {
- return QPrinter::B2;
- } else if (str == QLatin1String("B3")) {
- return QPrinter::B3;
- } else if (str == QLatin1String("B4")) {
- return QPrinter::B4;
- } else if (str == QLatin1String("B6")) {
- return QPrinter::B6;
- } else if (str == QLatin1String("B7")) {
- return QPrinter::B7;
- } else if (str == QLatin1String("B8")) {
- return QPrinter::B8;
- } else if (str == QLatin1String("B9")) {
- return QPrinter::B9;
- } else if (str == QLatin1String("C5E")) {
- return QPrinter::C5E;
- } else if (str == QLatin1String("Comm10E")) {
- return QPrinter::Comm10E;
- } else if (str == QLatin1String("DLE")) {
- return QPrinter::DLE;
- } else if (str == QLatin1String("Folio")) {
- return QPrinter::Folio;
- } else if (str == QLatin1String("Ledger")) {
- return QPrinter::Ledger;
- } else if (str == QLatin1String("Tabloid")) {
- return QPrinter::Tabloid;
- } else {
- return QPrinter::Custom;
- }
-}
-
-QString QPrinterInfoPrivate::pageSize2String(QPrinter::PaperSize size)
-{
- switch (size) {
- case QPrinter::A4:
- return QLatin1String("A4");
- case QPrinter::B5:
- return QLatin1String("B5");
- case QPrinter::Letter:
- return QLatin1String("Letter");
- case QPrinter::Legal:
- return QLatin1String("Legal");
- case QPrinter::Executive:
- return QLatin1String("Executive");
- case QPrinter::A0:
- return QLatin1String("A0");
- case QPrinter::A1:
- return QLatin1String("A1");
- case QPrinter::A2:
- return QLatin1String("A2");
- case QPrinter::A3:
- return QLatin1String("A3");
- case QPrinter::A5:
- return QLatin1String("A5");
- case QPrinter::A6:
- return QLatin1String("A6");
- case QPrinter::A7:
- return QLatin1String("A7");
- case QPrinter::A8:
- return QLatin1String("A8");
- case QPrinter::A9:
- return QLatin1String("A9");
- case QPrinter::B0:
- return QLatin1String("B0");
- case QPrinter::B1:
- return QLatin1String("B1");
- case QPrinter::B10:
- return QLatin1String("B10");
- case QPrinter::B2:
- return QLatin1String("B2");
- case QPrinter::B3:
- return QLatin1String("B3");
- case QPrinter::B4:
- return QLatin1String("B4");
- case QPrinter::B6:
- return QLatin1String("B6");
- case QPrinter::B7:
- return QLatin1String("B7");
- case QPrinter::B8:
- return QLatin1String("B8");
- case QPrinter::B9:
- return QLatin1String("B9");
- case QPrinter::C5E:
- return QLatin1String("C5E");
- case QPrinter::Comm10E:
- return QLatin1String("Comm10E");
- case QPrinter::DLE:
- return QLatin1String("DLE");
- case QPrinter::Folio:
- return QLatin1String("Folio");
- case QPrinter::Ledger:
- return QLatin1String("Ledger");
- case QPrinter::Tabloid:
- return QLatin1String("Tabloid");
- default:
- return QLatin1String("Custom");
- }
+ return d->paperSizes;
+#else
+ return QList<QPrinter::PaperSize>();
+#endif
}
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 144b715..2c4014d 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include <qstringlist.h>
@@ -51,59 +52,25 @@ QT_BEGIN_NAMESPACE
extern QPrinter::PaperSize mapDevmodePaperSize(int s);
-class QPrinterInfoPrivate
-{
-Q_DECLARE_PUBLIC(QPrinterInfo)
-public:
- ~QPrinterInfoPrivate();
- QPrinterInfoPrivate();
- QPrinterInfoPrivate(const QString& name);
-
-private:
- QString m_name;
- bool m_default;
- bool m_isNull;
-
- QPrinterInfo* q_ptr;
-};
-
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
{
QList<QPrinterInfo> printers;
- LPBYTE buffer;
+
DWORD needed = 0;
DWORD returned = 0;
-
- if ( !EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned))
- {
- buffer = new BYTE[needed];
- if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS , NULL,
- 4, buffer, needed, &needed, &returned))
- {
- delete [] buffer;
- return printers;
- }
- PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
- QPrinterInfo defPrn = defaultPrinter();
- for (uint i = 0; i < returned; ++i) {
- printers.append(QPrinterInfo(QString::fromWCharArray(infoList[i].pPrinterName)));
- if (printers.at(i).printerName() == defPrn.printerName())
- printers[i].d_ptr->m_default = true;
+ if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) {
+ LPBYTE buffer = new BYTE[needed];
+ if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) {
+ PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
+ QPrinterInfo defPrn = defaultPrinter();
+ for (uint i = 0; i < returned; ++i) {
+ QString printerName(QString::fromWCharArray(infoList[i].pPrinterName));
+
+ QPrinterInfo printerInfo(printerName);
+ if (printerInfo.printerName() == defPrn.printerName())
+ printerInfo.d_ptr->isDefault = true;
+ printers.append(printerInfo);
+ }
}
delete [] buffer;
}
@@ -117,127 +84,37 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
wchar_t buffer[256];
GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256);
QString output = QString::fromWCharArray(buffer);
-
- // Filter out the name of the printer, which should be everything
- // before a comma.
- bool noConfiguredPrinters = (output == noPrinters);
- QStringList info = output.split(QLatin1Char(','));
- QString printerName = noConfiguredPrinters ? QString() : info.at(0);
-
- QPrinterInfo prn(printerName);
- prn.d_ptr->m_default = true;
- if (noConfiguredPrinters)
- prn.d_ptr->m_isNull = true;
- return prn;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
- d_ptr->q_ptr = this;
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinter& prn)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- QList<QPrinterInfo> list = availablePrinters();
- for (int c = 0; c < list.size(); ++c) {
- if (prn.printerName() == list[c].printerName()) {
- *this = list[c];
- return;
- }
+ if (output != noPrinters) {
+ // Filter out the name of the printer, which should be everything before a comma.
+ QString printerName = output.split(QLatin1Char(',')).value(0);
+ QPrinterInfo printerInfo(printerName);
+ printerInfo.d_ptr->isDefault = true;
+ return printerInfo;
}
- *this = QPrinterInfo();
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- d_ptr->q_ptr = this;
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
- const Q_D(QPrinterInfo);
- return d->m_name;
-}
-
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
+ return QPrinterInfo();
}
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
const Q_D(QPrinterInfo);
- QList<QPrinter::PaperSize> paperList;
- DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()),
- NULL, DC_PAPERS, NULL, NULL);
- if ((int)size == -1)
- return paperList;
-
- wchar_t *papers = new wchar_t[size];
- size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()),
- NULL, DC_PAPERS, papers, NULL);
+ QList<QPrinter::PaperSize> paperSizes;
+ if (isNull())
+ return paperSizes;
- for (int c = 0; c < (int)size; ++c) {
- paperList.append(mapDevmodePaperSize(papers[c]));
+ DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
+ NULL, DC_PAPERS, NULL, NULL);
+ if ((int)size != -1) {
+ wchar_t *papers = new wchar_t[size];
+ size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
+ NULL, DC_PAPERS, papers, NULL);
+ for (int c = 0; c < (int)size; ++c)
+ paperSizes.append(mapDevmodePaperSize(papers[c]));
+ delete [] papers;
}
- delete [] papers;
-
- return paperList;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate() :
- m_default(false),
- m_isNull(true),
- q_ptr(NULL)
-{
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) :
- m_name(name),
- m_default(false),
- m_isNull(false),
- q_ptr(NULL)
-{
-}
-
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
+ return paperSizes;
}
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index bd38286..75116c2 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -62,8 +62,8 @@ typedef int Q16Dot16;
#define SPAN_BUFFER_SIZE 256
-#define COORD_ROUNDING 1 // 0: round up, 1: round down
-#define COORD_OFFSET 32 // 26.6, 32 is half a pixel
+#define COORD_ROUNDING 0 // 0: round up, 1: round down
+#define COORD_OFFSET 0 // 26.6, 32 is half a pixel
static inline QT_FT_Vector PointToVector(const QPointF &p)
{
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 478a00b..d713346 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -391,6 +391,14 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt
*/
/*!
+ \fn void QRegion::swap(QRegion &other)
+ \since 4.8
+
+ Swaps region \a other with this region. This operation is very
+ fast and never fails.
+*/
+
+/*!
\relates QRegion
Writes the region \a r to the stream \a s and returns a reference
@@ -1620,7 +1628,7 @@ QT_END_INCLUDE_NAMESPACE
QT_BEGIN_INCLUDE_NAMESPACE
# include "qregion_win.cpp"
QT_END_INCLUDE_NAMESPACE
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
static QRegionPrivate qrp;
QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), &qrp};
#endif
@@ -4231,7 +4239,7 @@ QRect QRegion::boundingRect() const
Returns true if \a rect is guaranteed to be fully contained in \a region.
A false return value does not guarantee the opposite.
*/
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
Q_GUI_EXPORT
#endif
bool qt_region_strictContains(const QRegion &region, const QRect &rect)
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index f78ece8..1cd38d4 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -59,7 +59,7 @@ QT_MODULE(Gui)
template <class T> class QVector;
class QVariant;
-#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
struct QRegionPrivate;
#endif
@@ -81,7 +81,11 @@ public:
QRegion(const QBitmap &bitmap);
~QRegion();
QRegion &operator=(const QRegion &);
-
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QRegion &operator=(QRegion &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QRegion &other) { qSwap(d, other.d); }
#ifdef QT3_SUPPORT
inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
#endif
@@ -163,7 +167,7 @@ public:
#endif
HIMutableShapeRef toHIMutableShape() const;
static QRegion fromHIShapeRef(HIShapeRef shape);
-#elif defined(Q_WS_QWS)
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
inline void *handle() const { return d->qt_rgn; }
#endif
#endif
@@ -203,7 +207,7 @@ private:
#elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
mutable RgnHandle unused; // Here for binary compatibility reasons. ### Qt 5 remove.
#endif
-#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
QRegionPrivate *qt_rgn;
#endif
};
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/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 2420f31..f0db805 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -65,8 +65,60 @@ static inline int qt_next_power_of_two(int v)
return v;
}
+int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const
+{
+ // Test 12 different subpixel positions since it factors into 3*4 so it gives
+ // the coverage we need.
+
+ QList<QImage> images;
+ for (int i=0; i<12; ++i) {
+ QImage img = textureMapForGlyph(glyph, QFixed::fromReal(i / 12.0));
+
+ if (images.isEmpty()) {
+ QPainterPath path;
+ QFixedPoint point;
+ m_current_fontengine->addGlyphsToPath(&glyph, &point, 1, &path, QTextItem::RenderFlags());
+
+ // Glyph is space, return 0 to indicate that we need to keep trying
+ if (path.isEmpty())
+ break;
+
+ images.append(img);
+ } else {
+ bool found = false;
+ for (int j=0; j<images.size(); ++j) {
+ if (images.at(j) == img) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ images.append(img);
+ }
+ }
+
+ return images.size();
+}
+
+QFixed QTextureGlyphCache::subPixelPositionForX(QFixed x) const
+{
+ if (m_subPixelPositionCount == 0)
+ return QFixed();
+
+ QFixed subPixelPosition;
+ if (x != 0) {
+ subPixelPosition = x - x.floor();
+ QFixed fraction = (subPixelPosition / QFixed::fromReal(1.0 / m_subPixelPositionCount)).floor();
+
+ // Compensate for precision loss in fixed point to make sure we are always drawing at a subpixel position over
+ // the lower boundary for the selected rasterization by adding 1/64.
+ subPixelPosition = fraction / QFixed(m_subPixelPositionCount) + QFixed::fromReal(0.015625);
+ }
+ return subPixelPosition;
+}
+
bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs,
- const QFixedPoint *)
+ const QFixedPoint *positions)
{
#ifdef CACHE_DEBUG
printf("Populating with %d glyphs\n", numGlyphs);
@@ -77,17 +129,46 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
const int margin = glyphMargin();
const int paddingDoubled = glyphPadding() * 2;
- QHash<glyph_t, Coord> listItemCoordinates;
+ bool supportsSubPixelPositions = fontEngine->supportsSubPixelPositions();
+ if (m_subPixelPositionCount == 0) {
+ if (!supportsSubPixelPositions) {
+ m_subPixelPositionCount = 1;
+ } else {
+#if !defined(Q_WS_X11)
+ int i = 0;
+ while (m_subPixelPositionCount == 0 && i < numGlyphs)
+ m_subPixelPositionCount = calculateSubPixelPositionCount(glyphs[i++]);
+#else
+ m_subPixelPositionCount = 4;
+#endif
+ }
+ }
+
+ QHash<GlyphAndSubPixelPosition, Coord> listItemCoordinates;
int rowHeight = 0;
+ QFontEngine::GlyphFormat format;
+ switch (m_type) {
+ case Raster_A8: format = QFontEngine::Format_A8; break;
+ case Raster_RGBMask: format = QFontEngine::Format_A32; break;
+ default: format = QFontEngine::Format_Mono; break;
+ }
+
// check each glyph for its metrics and get the required rowHeight.
for (int i=0; i < numGlyphs; ++i) {
const glyph_t glyph = glyphs[i];
- if (coords.contains(glyph))
+
+ QFixed subPixelPosition;
+ if (supportsSubPixelPositions) {
+ QFixed x = positions != 0 ? positions[i].x : QFixed();
+ subPixelPosition = subPixelPositionForX(x);
+ }
+
+ if (coords.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition)))
continue;
- if (listItemCoordinates.contains(glyph))
+ if (listItemCoordinates.contains(GlyphAndSubPixelPosition(glyph, subPixelPosition)))
continue;
- glyph_metrics_t metrics = fontEngine->boundingBox(glyph, m_transform);
+ glyph_metrics_t metrics = fontEngine->alphaMapBoundingBox(glyph, m_transform, format);
#ifdef CACHE_DEBUG
printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n",
@@ -98,11 +179,16 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
metrics.yoff.toReal(),
metrics.x.toReal(),
metrics.y.toReal());
-#endif
+#endif
+ GlyphAndSubPixelPosition key(glyph, subPixelPosition);
int glyph_width = metrics.width.ceil().toInt();
int glyph_height = metrics.height.ceil().toInt();
- if (glyph_height == 0 || glyph_width == 0)
+ if (glyph_height == 0 || glyph_width == 0) {
+ // Avoid multiple calls to boundingBox() for non-printable characters
+ Coord c = { 0, 0, 0, 0, 0, 0 };
+ coords.insert(key, c);
continue;
+ }
glyph_width += margin * 2 + 4;
glyph_height += margin * 2 + 4;
// align to 8-bit boundary
@@ -115,30 +201,35 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
metrics.x.round().truncate(),
-metrics.y.truncate() }; // baseline for horizontal scripts
- listItemCoordinates.insert(glyph, c);
+ listItemCoordinates.insert(key, c);
rowHeight = qMax(rowHeight, glyph_height);
}
if (listItemCoordinates.isEmpty())
return true;
rowHeight += margin * 2 + paddingDoubled;
- if (isNull())
- createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, qt_next_power_of_two(rowHeight));
+
+ if (m_w == 0) {
+ if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH)
+ m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH;
+ else
+ m_w = qt_next_power_of_two(fontEngine->maxCharWidth());
+ }
// now actually use the coords and paint the wanted glyps into cache.
- QHash<glyph_t, Coord>::iterator iter = listItemCoordinates.begin();
+ QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = listItemCoordinates.begin();
+ int requiredWidth = m_w;
while (iter != listItemCoordinates.end()) {
Coord c = iter.value();
m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
- if (m_cx + c.w > m_w) {
- int new_width = m_w*2;
+ if (m_cx + c.w > requiredWidth) {
+ int new_width = requiredWidth*2;
while (new_width < m_cx + c.w)
new_width *= 2;
if (new_width <= maxTextureWidth()) {
- resizeTextureData(new_width, m_h);
- m_w = new_width;
+ requiredWidth = new_width;
} else {
// no room on the current line, start new glyph strip
m_cx = 0;
@@ -146,36 +237,63 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
m_currentRowHeight = c.h + margin * 2; // New row
}
}
- if (m_cy + c.h > m_h) {
- int new_height = m_h*2;
- while (new_height < m_cy + c.h)
- new_height *= 2;
-
- if (maxTextureHeight() > 0 && new_height > maxTextureHeight()) {
- // We can't make a new texture of the required size, so
- // bail out
- return false;
- }
- // if no room in the current texture - realloc a larger texture
- resizeTextureData(m_w, new_height);
- m_h = new_height;
+ if (maxTextureHeight() > 0 && m_cy + c.h > maxTextureHeight()) {
+ // We can't make a cache of the required size, so we bail out
+ return false;
}
c.x = m_cx;
c.y = m_cy;
- fillTexture(c, iter.key());
coords.insert(iter.key(), c);
+ m_pendingGlyphs.insert(iter.key(), c);
m_cx += c.w + paddingDoubled;
++iter;
}
-
return true;
+
+}
+
+void QTextureGlyphCache::fillInPendingGlyphs()
+{
+ if (m_pendingGlyphs.isEmpty())
+ return;
+
+ int requiredHeight = m_h;
+ int requiredWidth = m_w; // Use a minimum size to avoid a lot of initial reallocations
+ {
+ QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
+ while (iter != m_pendingGlyphs.end()) {
+ Coord c = iter.value();
+ requiredHeight = qMax(requiredHeight, c.y + c.h);
+ requiredWidth = qMax(requiredWidth, c.x + c.w);
+ ++iter;
+ }
+ }
+
+ if (isNull() || requiredHeight > m_h || requiredWidth > m_w) {
+ if (isNull())
+ createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
+ else
+ resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight));
+ }
+
+ {
+ QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
+ while (iter != m_pendingGlyphs.end()) {
+ GlyphAndSubPixelPosition key = iter.key();
+ fillTexture(iter.value(), key.glyph, key.subPixelPosition);
+
+ ++iter;
+ }
+ }
+
+ m_pendingGlyphs.clear();
}
-QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
+QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const
{
#if defined(Q_WS_X11)
if (m_transform.type() > QTransform::TxTranslate) {
@@ -198,9 +316,11 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
QFontEngineFT *ft = static_cast<QFontEngineFT*> (m_current_fontengine);
QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform);
+ QFixedPoint positions[1];
+ positions[0].x = subPixelPosition;
- if (gset && ft->loadGlyphs(gset, &g, 1, format)) {
- QFontEngineFT::Glyph *glyph = gset->getGlyph(g);
+ if (gset && ft->loadGlyphs(gset, &g, 1, positions, format)) {
+ QFontEngineFT::Glyph *glyph = gset->getGlyph(g, subPixelPosition);
const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3
: (glyph->width + 3) & ~3);
return QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, imageFormat);
@@ -208,9 +328,9 @@ QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const
} else
#endif
if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
- return m_current_fontengine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform);
+ return m_current_fontengine->alphaRGBMapForGlyph(g, subPixelPosition, glyphMargin(), m_transform);
else
- return m_current_fontengine->alphaMapForGlyph(g, m_transform);
+ return m_current_fontengine->alphaMapForGlyph(g, subPixelPosition, m_transform);
return QImage();
}
@@ -247,16 +367,16 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
int QImageTextureGlyphCache::glyphMargin() const
{
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
return 0;
#else
return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
#endif
}
-void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g)
+void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subPixelPosition)
{
- QImage mask = textureMapForGlyph(g);
+ QImage mask = textureMapForGlyph(g, subPixelPosition);
#ifdef CACHE_DEBUG
printf("fillTexture of %dx%d at %d,%d in the cache of %dx%d\n", c.w, c.h, c.x, c.y, m_image.width(), m_image.height());
@@ -341,7 +461,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g)
QPoint base(c.x + glyphMargin(), c.y + glyphMargin() + c.baseLineY-1);
if (m_image.rect().contains(base))
m_image.setPixel(base, 255);
- m_image.save(QString::fromLatin1("cache-%1.png").arg(int(this)));
+ m_image.save(QString::fromLatin1("cache-%1.png").arg(qint64(this)));
#endif
}
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index 17f0d89..922e290 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -81,11 +81,24 @@ class Q_GUI_EXPORT QTextureGlyphCache : public QFontEngineGlyphCache
public:
QTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix)
: QFontEngineGlyphCache(matrix, type), m_current_fontengine(0),
- m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0)
+ m_w(0), m_h(0), m_cx(0), m_cy(0), m_currentRowHeight(0), m_subPixelPositionCount(0)
{ }
virtual ~QTextureGlyphCache() { }
+ struct GlyphAndSubPixelPosition
+ {
+ GlyphAndSubPixelPosition(glyph_t g, QFixed spp) : glyph(g), subPixelPosition(spp) {}
+
+ bool operator==(const GlyphAndSubPixelPosition &other) const
+ {
+ return glyph == other.glyph && subPixelPosition == other.subPixelPosition;
+ }
+
+ glyph_t glyph;
+ QFixed subPixelPosition;
+ };
+
struct Coord {
int x;
int y;
@@ -94,17 +107,23 @@ public:
int baseLineX;
int baseLineY;
+
+ bool isNull() const
+ {
+ return w == 0 || h == 0;
+ }
};
bool populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs,
const QFixedPoint *positions);
+ void fillInPendingGlyphs();
virtual void createTextureData(int width, int height) = 0;
virtual void resizeTextureData(int width, int height) = 0;
virtual int glyphMargin() const { return 0; }
virtual int glyphPadding() const { return 0; }
- virtual void fillTexture(const Coord &coord, glyph_t glyph) = 0;
+ virtual void fillTexture(const Coord &coord, glyph_t glyph, QFixed subPixelPosition) = 0;
inline void createCache(int width, int height) {
m_w = width;
@@ -112,24 +131,42 @@ public:
createTextureData(width, height);
}
- inline bool isNull() const { return m_w <= 0 || m_h <= 0; }
+ inline void resizeCache(int width, int height)
+ {
+ resizeTextureData(width, height);
+ m_w = width;
+ m_h = height;
+ }
- QHash<glyph_t, Coord> coords;
+ inline bool isNull() const { return m_h == 0; }
- QImage textureMapForGlyph(glyph_t g) const;
+ QHash<GlyphAndSubPixelPosition, Coord> coords;
virtual int maxTextureWidth() const { return QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; }
virtual int maxTextureHeight() const { return -1; }
+ QImage textureMapForGlyph(glyph_t g, QFixed subPixelPosition) const;
+
+ QFixed subPixelPositionForX(QFixed x) const;
+
protected:
+ int calculateSubPixelPositionCount(glyph_t) const;
+
QFontEngine *m_current_fontengine;
+ QHash<GlyphAndSubPixelPosition, Coord> m_pendingGlyphs;
int m_w; // image width
int m_h; // image height
int m_cx; // current x
int m_cy; // current y
int m_currentRowHeight; // Height of last row
+ int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
};
+inline uint qHash(const QTextureGlyphCache::GlyphAndSubPixelPosition &g)
+{
+ return (g.glyph << 8) | (g.subPixelPosition * 10).round().toInt();
+}
+
class Q_GUI_EXPORT QImageTextureGlyphCache : public QTextureGlyphCache
{
@@ -139,7 +176,7 @@ public:
virtual int glyphMargin() const;
virtual void createTextureData(int width, int height);
virtual void resizeTextureData(int width, int height);
- virtual void fillTexture(const Coord &c, glyph_t glyph);
+ virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition);
inline const QImage &image() const { return m_image; }
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4441b30..7d11e2f 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1085,8 +1085,11 @@ QDebug operator<<(QDebug dbg, const QTransform &m)
"TxNone",
"TxTranslate",
"TxScale",
+ 0,
"TxRotate",
+ 0, 0, 0,
"TxShear",
+ 0, 0, 0, 0, 0, 0, 0,
"TxProject"
};
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
new file mode 100644
index 0000000..3876c3d
--- /dev/null
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qunifiedtoolbarsurface_mac_p.h"
+#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qbackingstore_p.h>
+#include <private/qmainwindowlayout_p.h>
+
+#include <QDebug>
+
+#ifdef QT_MAC_USE_COCOA
+
+QT_BEGIN_NAMESPACE
+
+QUnifiedToolbarSurface::QUnifiedToolbarSurface(QWidget *widget)
+ : QRasterWindowSurface(widget, false), d_ptr(new QUnifiedToolbarSurfacePrivate)
+{
+ d_ptr->image = 0;
+ d_ptr->inSetGeometry = false;
+
+ setGeometry(QRect(QPoint(0, 0), QSize(widget->width(), 100))); // FIXME: Fix height.
+}
+
+QUnifiedToolbarSurface::~QUnifiedToolbarSurface()
+{
+ if (d_ptr->image)
+ delete d_ptr->image;
+}
+
+QPaintDevice *QUnifiedToolbarSurface::paintDevice()
+{
+ return &d_ptr->image->image;
+}
+
+void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, QWidget *parent_toolbar, const QPoint &offset)
+{
+ if (object != 0) {
+ if (object->isWidgetType()) {
+ QWidget *widget = qobject_cast<QWidget *>(object);
+
+ // We redirect the painting only if the widget is in the same window
+ // and is not a window in itself.
+ if (!(widget->windowType() & Qt::Window)) {
+ widget->d_func()->unifiedSurface = this;
+ widget->d_func()->isInUnifiedToolbar = true;
+ widget->d_func()->toolbar_offset = offset;
+ widget->d_func()->toolbar_ancestor = parent_toolbar;
+
+ for (int i = 0; i < object->children().size(); ++i) {
+ recursiveRedirect(object->children().at(i), parent_toolbar, offset);
+ }
+ }
+ }
+ }
+}
+
+void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offset)
+{
+ setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
+ recursiveRedirect(toolbar, toolbar, offset);
+}
+
+// We basically undo what we set in recursiveRedirect().
+void QUnifiedToolbarSurface::recursiveRemoval(QObject *object)
+{
+ if (object != 0) {
+ if (object->isWidgetType()) {
+ QWidget *widget = qobject_cast<QWidget *>(object);
+
+ // If it's a pop-up or something similar, we don't redirect it.
+ if (widget->windowType() & Qt::Window)
+ return;
+
+ widget->d_func()->unifiedSurface = 0;
+ widget->d_func()->isInUnifiedToolbar = false;
+ widget->d_func()->toolbar_offset = QPoint();
+ widget->d_func()->toolbar_ancestor = 0;
+ }
+
+ for (int i = 0; i < object->children().size(); ++i) {
+ recursiveRemoval(object->children().at(i));
+ }
+ }
+}
+
+void QUnifiedToolbarSurface::removeToolbar(QToolBar *toolbar)
+{
+ recursiveRemoval(toolbar);
+}
+
+void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
+{
+ QWindowSurface::setGeometry(rect);
+ Q_D(QUnifiedToolbarSurface);
+ d->inSetGeometry = true;
+ if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height())
+ prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
+ d->inSetGeometry = false;
+
+ // FIXME: set unified toolbar height.
+}
+
+void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
+{
+ QPainter p(&d_ptr->image->image);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ const QVector<QRect> rects = rgn.rects();
+ const QColor blank = Qt::transparent;
+ for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ p.fillRect(*it, blank);
+ }
+}
+
+void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
+{
+ QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
+ mlayout->updateUnifiedToolbarOffset();
+}
+
+void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ this->flush(widget);
+}
+
+void QUnifiedToolbarSurface::flush(QWidget *widget)
+{
+ Q_D(QUnifiedToolbarSurface);
+
+ if (!d->image)
+ return;
+
+ if (widget->d_func()->flushRequested) {
+ // We call display: directly to avoid flickering in the toolbar.
+ qt_mac_display(widget);
+ }
+}
+
+void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widget)
+{
+ Q_D(QUnifiedToolbarSurface);
+
+ int width = geometry().width();
+ int height = 100; // FIXME
+ if (d->image) {
+ width = qMax(d->image->width(), width);
+ height = qMax(d->image->height(), height);
+ }
+
+ if (width == 0 || height == 0) {
+ delete d->image;
+ d->image = 0;
+ return;
+ }
+
+ QNativeImage *oldImage = d->image;
+
+ d->image = new QNativeImage(width, height, format, false, widget);
+
+ if (oldImage && d->inSetGeometry && hasStaticContents()) {
+ // Make sure we use the const version of bits() (no detach).
+ const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
+ uchar *dst = d->image->image.bits();
+
+ const int srcBytesPerLine = oldImage->image.bytesPerLine();
+ const int dstBytesPerLine = d->image->image.bytesPerLine();
+ const int bytesPerPixel = oldImage->image.depth() >> 3;
+
+ QRegion staticRegion(staticContents());
+ // Make sure we're inside the boundaries of the old image.
+ staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
+ const QVector<QRect> &rects = staticRegion.rects();
+ const QRect *srcRect = rects.constData();
+
+ // Copy the static content of the old image into the new one.
+ int numRectsLeft = rects.size();
+ do {
+ const int bytesOffset = srcRect->x() * bytesPerPixel;
+ const int dy = srcRect->y();
+
+ // Adjust src and dst to point to the right offset.
+ const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
+ uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
+ const int numBytes = srcRect->width() * bytesPerPixel;
+
+ int numScanLinesLeft = srcRect->height();
+ do {
+ ::memcpy(d, s, numBytes);
+ d += dstBytesPerLine;
+ s += srcBytesPerLine;
+ } while (--numScanLinesLeft);
+
+ ++srcRect;
+ } while (--numRectsLeft);
+ }
+
+ delete oldImage;
+}
+
+CGContextRef QUnifiedToolbarSurface::imageContext()
+{
+ Q_D(QUnifiedToolbarSurface);
+ return d->image->cg;
+}
+
+void QUnifiedToolbarSurface::renderToolbar(QWidget *widget, bool forceFlush)
+{
+ QWidget *toolbar = widget->d_func()->toolbar_ancestor;
+
+ updateToolbarOffset(toolbar);
+ QRect beginPaintRect(toolbar->d_func()->toolbar_offset.x(), toolbar->d_func()->toolbar_offset.y(), toolbar->geometry().width(), toolbar->geometry().height());
+ QRegion beginPaintRegion(beginPaintRect);
+
+ beginPaint(beginPaintRegion);
+ toolbar->render(paintDevice(), toolbar->d_func()->toolbar_offset, QRegion(toolbar->geometry()), QWidget::DrawChildren);
+ toolbar->d_func()->flushRequested = true;
+
+ if (forceFlush)
+ flush(toolbar);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_MAC_USE_COCOA
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
new file mode 100644
index 0000000..0a7ebf1
--- /dev/null
+++ b/src/gui/painting/qunifiedtoolbarsurface_mac_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 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 QUNIFIEDTOOLBARSURFACE_MAC_P_H
+#define QUNIFIEDTOOLBARSURFACE_MAC_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qwindowsurface_raster_p.h>
+#include <QWidget>
+#include <QToolBar>
+#include <private/qwidget_p.h>
+#include <private/qnativeimage_p.h>
+
+#ifdef QT_MAC_USE_COCOA
+
+QT_BEGIN_NAMESPACE
+
+class QNativeImage;
+
+
+class QUnifiedToolbarSurfacePrivate
+{
+public:
+ QNativeImage *image;
+ uint inSetGeometry : 1;
+};
+
+class Q_GUI_EXPORT QUnifiedToolbarSurface : public QRasterWindowSurface
+{
+public:
+ QUnifiedToolbarSurface(QWidget *widget);
+ ~QUnifiedToolbarSurface();
+
+ void flush(QWidget *widget);
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void setGeometry(const QRect &rect);
+ void beginPaint(const QRegion &rgn);
+ void insertToolbar(QWidget *toolbar, const QPoint &offset);
+ void removeToolbar(QToolBar *toolbar);
+ void updateToolbarOffset(QWidget *widget);
+ void renderToolbar(QWidget *widget, bool forceFlush = false);
+ void recursiveRedirect(QObject *widget, QWidget *parent_toolbar, const QPoint &offset);
+
+ QPaintDevice *paintDevice();
+ CGContextRef imageContext();
+
+private:
+ void prepareBuffer(QImage::Format format, QWidget *widget);
+ void recursiveRemoval(QObject *object);
+
+ Q_DECLARE_PRIVATE(QUnifiedToolbarSurface)
+ QScopedPointer<QUnifiedToolbarSurfacePrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_MAC_USE_COCOA
+
+#endif // QUNIFIEDTOOLBARSURFACE_MAC_P_H
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index b84f26e..9b71818 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -52,17 +52,17 @@ class QWindowSurfacePrivate
public:
QWindowSurfacePrivate(QWidget *w)
: window(w)
- , staticContentsSupport(0)
- , partialUpdateSupport(1)
{
}
QWidget *window;
+#if !defined(Q_WS_QPA)
QRect geometry;
+#else
+ QSize size;
+#endif //Q_WS_QPA
QRegion staticContents;
QList<QImage*> bufferImages;
- uint staticContentsSupport : 1;
- uint partialUpdateSupport : 1;
};
/*!
@@ -70,7 +70,7 @@ public:
\since 4.3
\internal
\preliminary
- \ingroup qws
+ \ingroup qws qpa
\brief The QWindowSurface class provides the drawing area for top-level
windows.
@@ -114,11 +114,11 @@ public:
/*!
Constructs an empty surface for the given top-level \a window.
*/
-QWindowSurface::QWindowSurface(QWidget *window)
+QWindowSurface::QWindowSurface(QWidget *window, bool setDefaultSurface)
: d_ptr(new QWindowSurfacePrivate(window))
{
if (!QApplicationPrivate::runtime_graphics_system) {
- if(window)
+ if(setDefaultSurface && window)
window->setWindowSurface(this);
}
}
@@ -153,6 +153,7 @@ void QWindowSurface::endPaint(const QRegion &)
d_ptr->bufferImages.clear();
}
+#if !defined(Q_WS_QPA)
/*!
Sets the currently allocated area to be the given \a rect.
@@ -173,6 +174,26 @@ QRect QWindowSurface::geometry() const
{
return d_ptr->geometry;
}
+#else
+
+/*!
+ Sets the size of the windowsurface to be \a size.
+
+ \sa size()
+*/
+void QWindowSurface::resize(const QSize &size)
+{
+ d_ptr->size = size;
+}
+
+/*!
+ Returns the current size of the windowsurface.
+*/
+QSize QWindowSurface::size() const
+{
+ return d_ptr->size;
+}
+#endif //Q_WS_QPA
/*!
Scrolls the given \a area \a dx pixels to the right and \a dy
@@ -288,16 +309,7 @@ QPoint QWindowSurface::offset(const QWidget *widget) const
bool QWindowSurface::hasStaticContentsSupport() const
{
- return d_ptr->staticContentsSupport;
-}
-
-void QWindowSurface::setStaticContentsSupport(bool enable)
-{
- if (enable && !d_ptr->partialUpdateSupport) {
- qWarning("QWindowSurface::setStaticContentsSupport: static contents support requires partial update support");
- return;
- }
- d_ptr->staticContentsSupport = enable;
+ return false;
}
void QWindowSurface::setStaticContents(const QRegion &region)
@@ -312,24 +324,21 @@ QRegion QWindowSurface::staticContents() const
bool QWindowSurface::hasStaticContents() const
{
- return d_ptr->staticContentsSupport && !d_ptr->staticContents.isEmpty();
+ return hasStaticContentsSupport() && !d_ptr->staticContents.isEmpty();
}
bool QWindowSurface::hasPartialUpdateSupport() const
{
- return d_ptr->partialUpdateSupport;
+ return true;
}
-void QWindowSurface::setPartialUpdateSupport(bool enable)
-{
- if (!enable && d_ptr->staticContentsSupport) {
- qWarning("QWindowSurface::setPartialUpdateSupport: static contents support requires partial update support");
- return;
- }
- d_ptr->partialUpdateSupport = enable;
-}
+#ifdef Q_WS_QPA
+#define Q_EXPORT_SCROLLRECT Q_GUI_EXPORT
+#else
+#define Q_EXPORT_SCROLLRECT
+#endif
-void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
+void Q_EXPORT_SCROLLRECT qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
{
// make sure we don't detach
uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
diff --git a/src/gui/painting/qwindowsurface_mac.cpp b/src/gui/painting/qwindowsurface_mac.cpp
index 88d41ba..620a50f 100644
--- a/src/gui/painting/qwindowsurface_mac.cpp
+++ b/src/gui/painting/qwindowsurface_mac.cpp
@@ -82,6 +82,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint
extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
CGContextRef context = qt_mac_graphicsContextFor(widget);
#endif
+ CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
@@ -109,6 +110,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint
#else
CGContextFlush(context);
#endif
+ CGContextRelease(context);
}
void QMacWindowSurface::setGeometry(const QRect &rect)
diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h
index 6275ec0..4a2775f 100644
--- a/src/gui/painting/qwindowsurface_p.h
+++ b/src/gui/painting/qwindowsurface_p.h
@@ -63,11 +63,12 @@ class QRect;
class QPoint;
class QImage;
class QWindowSurfacePrivate;
+class QPlatformWindow;
class Q_GUI_EXPORT QWindowSurface
{
public:
- QWindowSurface(QWidget *window);
+ QWindowSurface(QWidget *window, bool setDefaultSurface = true);
virtual ~QWindowSurface();
QWidget *window() const;
@@ -79,8 +80,14 @@ public:
// can be larger than just the offset from the top-level widget as there may also be window
// decorations which are painted into the window surface.
virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset) = 0;
+#if !defined(Q_WS_QPA)
virtual void setGeometry(const QRect &rect);
QRect geometry() const;
+#else
+ virtual void resize(const QSize &size);
+ QSize size() const;
+ inline QRect geometry() const { return QRect(QPoint(), size()); } //### cleanup before Qt 5
+#endif
virtual bool scroll(const QRegion &area, int dx, int dy);
@@ -93,16 +100,14 @@ public:
virtual QPoint offset(const QWidget *widget) const;
inline QRect rect(const QWidget *widget) const;
- bool hasStaticContentsSupport() const;
- bool hasPartialUpdateSupport() const;
+ virtual bool hasStaticContentsSupport() const;
+ virtual bool hasPartialUpdateSupport() const;
void setStaticContents(const QRegion &region);
QRegion staticContents() const;
protected:
bool hasStaticContents() const;
- void setStaticContentsSupport(bool enable);
- void setPartialUpdateSupport(bool enable);
private:
QWindowSurfacePrivate *d_ptr;
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index ccb10ff..a5c45c0 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -64,6 +64,9 @@
#ifdef Q_WS_MAC
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <QMainWindow>
+#include <private/qmainwindowlayout_p.h>
+#include <QToolBar>
#endif
QT_BEGIN_NAMESPACE
@@ -75,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
@@ -82,8 +88,8 @@ public:
uint inSetGeometry : 1;
};
-QRasterWindowSurface::QRasterWindowSurface(QWidget *window)
- : QWindowSurface(window), d_ptr(new QRasterWindowSurfacePrivate)
+QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurface)
+ : QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate)
{
#ifdef Q_WS_X11
d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0);
@@ -91,10 +97,17 @@ QRasterWindowSurface::QRasterWindowSurface(QWidget *window)
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;
- setStaticContentsSupport(true);
+
+#ifdef QT_MAC_USE_COCOA
+ needsFlush = false;
+ regionToFlush = QRegion();
+#endif // QT_MAC_USE_COCOA
}
@@ -113,8 +126,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)
@@ -214,13 +242,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
{
@@ -248,20 +276,27 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
#ifdef Q_WS_MAC
-// qDebug() << "Flushing" << widget << rgn << offset;
+ Q_UNUSED(offset);
-// d->image->image.save("flush.png");
+ // This is mainly done for native components like native "open file" dialog.
+ if (widget->testAttribute(Qt::WA_DontShowOnScreen)) {
+ return;
+ }
- Q_UNUSED(offset);
+#ifdef QT_MAC_USE_COCOA
+
+ this->needsFlush = true;
+ this->regionToFlush += rgn;
+
+ // The actual flushing will be processed in [view drawRect:rect]
+ qt_mac_setNeedsDisplay(widget);
+
+#else
// Get a context for the widget.
-#ifndef QT_MAC_USE_COCOA
CGContextRef context;
CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
QDBeginCGContext(port, &context);
-#else
- extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
- CGContextRef context = qt_mac_graphicsContextFor(widget);
-#endif
+ CGContextRetain(context);
CGContextSaveGState(context);
// Flip context.
@@ -282,20 +317,17 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
qt_mac_drawCGImage(context, &area, subImage);
+
CGImageRelease(subImage);
CGImageRelease(image);
-// CGSize size = { d->image->image.width(), d->image->image.height() };
-// CGLayerRef layer = CGLayerCreateWithContext(d->image->cg, size, 0);
-// CGPoint pt = { 0, 0 };
-// CGContextDrawLayerAtPoint(context, pt, layer);
-// CGLayerRelease(layer);
+ QDEndCGContext(port, &context);
// Restore context.
CGContextRestoreGState(context);
-#ifndef QT_MAC_USE_COCOA
- QDEndCGContext(port, &context);
-#endif
+ CGContextRelease(context);
+#endif // QT_MAC_USE_COCOA
+
#endif // Q_WS_MAC
#ifdef Q_OS_SYMBIAN
@@ -323,6 +355,25 @@ void QRasterWindowSurface::setGeometry(const QRect &rect)
prepareBuffer(QNativeImage::systemFormat(), window());
}
d->inSetGeometry = false;
+
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ QMainWindow* mWindow = qobject_cast<QMainWindow*>(window());
+ if (mWindow) {
+ QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
+ QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
+
+ for (int i = 0; i < toolbarList.size(); ++i) {
+ QToolBar* toolbar = toolbarList.at(i);
+ if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
+ QWidget* tbWidget = (QWidget*) toolbar;
+ if (tbWidget->d_func()->unifiedSurface) {
+ tbWidget->d_func()->unifiedSurface->setGeometry(rect);
+ }
+ }
+ }
+ }
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+
}
// from qwindowsurface.cpp
@@ -347,6 +398,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));
@@ -355,6 +410,11 @@ bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
#endif
}
+bool QRasterWindowSurface::hasStaticContentsSupport() const
+{
+ return true;
+}
+
void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
{
@@ -417,4 +477,12 @@ void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
delete oldImage;
}
+#ifdef QT_MAC_USE_COCOA
+CGContextRef QRasterWindowSurface::imageContext()
+{
+ Q_D(QRasterWindowSurface);
+ return d->image->cg;
+}
+#endif // QT_MAC_USE_COCOA
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 42f4bb5..669511d 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -56,6 +56,10 @@
#include <qglobal.h>
#include "private/qwindowsurface_p.h"
+#ifdef QT_MAC_USE_COCOA
+# include <private/qt_cocoa_helpers_mac_p.h>
+#endif // QT_MAC_USE_COCOA
+
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WIN
@@ -97,7 +101,7 @@ class QNativeImage;
class Q_GUI_EXPORT QRasterWindowSurface : public QWindowSurface
{
public:
- QRasterWindowSurface(QWidget *widget);
+ QRasterWindowSurface(QWidget *widget, bool setDefaultSurface = true);
~QRasterWindowSurface();
QPaintDevice *paintDevice();
@@ -105,8 +109,19 @@ public:
void beginPaint(const QRegion &rgn);
void setGeometry(const QRect &rect);
bool scroll(const QRegion &area, int dx, int dy);
+ bool hasStaticContentsSupport() const;
+
+#ifdef QT_MAC_USE_COCOA
+ CGContextRef imageContext();
+
+ bool needsFlush;
+ QRegion regionToFlush;
+#endif // QT_MAC_USE_COCOA
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 cb53ea0..4fa25cb 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -88,7 +88,8 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate);
TDisplayMode mode = displayMode(opaque);
// We create empty CFbsBitmap here -> it will be resized in setGeometry
- CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); // CBase derived object needs check on new
+ CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
+ Q_CHECK_PTR(bitmap);
qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
@@ -96,8 +97,6 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget)
data->fromSymbianBitmap(bitmap, true);
d_ptr->device = QPixmap(data);
}
-
- setStaticContentsSupport(true);
}
QS60WindowSurface::~QS60WindowSurface()
@@ -240,6 +239,11 @@ void QS60WindowSurface::setGeometry(const QRect& rect)
QWindowSurface::setGeometry(rect);
}
+bool QS60WindowSurface::hasStaticContentsSupport() const
+{
+ return true;
+}
+
CFbsBitmap* QS60WindowSurface::symbianBitmap() const
{
QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
index d0d4925..f730c87 100644
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ b/src/gui/painting/qwindowsurface_s60_p.h
@@ -79,6 +79,8 @@ public:
void setGeometry(const QRect &rect);
+ bool hasStaticContentsSupport() const;
+
CFbsBitmap *symbianBitmap() const;
private:
diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp
index 8c2c68a..ab4f53e 100644
--- a/src/gui/painting/qwindowsurface_x11.cpp
+++ b/src/gui/painting/qwindowsurface_x11.cpp
@@ -70,9 +70,6 @@ QX11WindowSurface::QX11WindowSurface(QWidget *widget)
#ifndef QT_NO_XRENDER
d_ptr->translucentBackground = X11->use_xrender
&& widget->x11Info().depth() == 32;
- setStaticContentsSupport(!d_ptr->translucentBackground);
-#else
- setStaticContentsSupport(true);
#endif
}
@@ -149,6 +146,8 @@ void QX11WindowSurface::setGeometry(const QRect &rect)
return;
#ifndef QT_NO_XRENDER
if (d_ptr->translucentBackground) {
+ QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());
+
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
data->xinfo = d_ptr->widget->x11Info();
data->resize(size.width(), size.height());
@@ -251,4 +250,13 @@ QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
return px;
}
+bool QX11WindowSurface::hasStaticContentsSupport() const
+{
+#ifndef QT_NO_XRENDER
+ return !d_ptr->translucentBackground;
+#else
+ return true;
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_x11_p.h b/src/gui/painting/qwindowsurface_x11_p.h
index 88753ea..d5179dd 100644
--- a/src/gui/painting/qwindowsurface_x11_p.h
+++ b/src/gui/painting/qwindowsurface_x11_p.h
@@ -80,6 +80,7 @@ public:
bool scroll(const QRegion &area, int dx, int dy);
QPixmap grabWidget(const QWidget *widget,
const QRect& rectangle = QRect()) const;
+ bool hasStaticContentsSupport() const;
private:
QX11WindowSurfacePrivate *d_ptr;
GC gc;
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/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index 2fbec15..8a2a88b 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -3763,6 +3763,7 @@ int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option
break;
case PM_MenuBarItemSpacing:
ret = 6;
+ break;
case PM_MenuBarHMargin:
ret = 0;
break;
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index de5920e..8f99d6a 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -2218,7 +2218,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (vopt->state & QStyle::State_HasFocus) {
QStyleOptionFocusRect o;
o.QStyleOption::operator=(*vopt);
- o.rect = subElementRect(SE_ItemViewItemFocusRect, vopt, widget);
+ o.rect = proxy()->subElementRect(SE_ItemViewItemFocusRect, vopt, widget);
o.state |= QStyle::State_KeyboardFocusChange;
o.state |= QStyle::State_Item;
QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled)
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 83ce5cb..277e302 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -1706,12 +1706,17 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
fakePos = maximum;
else if (scrollBar->sliderPosition > scrollBar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- if (horizontal)
- d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
- else
- d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
+
+ GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
if (scrollBar->subControls & SC_ScrollBarGroove) {
GtkStateType state = GTK_STATE_ACTIVE;
@@ -1990,15 +1995,29 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
style = scaleWidget->style;
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
- GtkObject *adjustment = d->gtk_adjustment_new(slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
+
+ GtkRange *range = (GtkRange*)scaleWidget;
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment,
+ slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
+
int outerSize;
- d->gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
- d->gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
+ d->gtk_range_set_inverted(range, !horizontal);
d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
outerSize++;
@@ -2998,8 +3017,7 @@ void QGtkStyle::drawControl(ControlElement element,
else if (bar->progress > bar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
+ d->gtk_progress_configure((GtkProgress*)gtkProgressBar, fakePos, 0, maximum);
QRect progressBar;
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
index 1e2dd7c..d7c53c9 100644
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -121,7 +121,8 @@ Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
-Ptr_gtk_progress_set_adjustment QGtkStylePrivate::gtk_progress_set_adjustment = 0;
+Ptr_gtk_progress_configure QGtkStylePrivate::gtk_progress_configure = 0;
+Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
Ptr_gtk_icon_factory_lookup_default QGtkStylePrivate::gtk_icon_factory_lookup_default = 0;
@@ -145,6 +146,7 @@ Ptr_gtk_paint_focus QGtkStylePrivate::gtk_paint_focus = 0;
Ptr_gtk_paint_arrow QGtkStylePrivate::gtk_paint_arrow = 0;
Ptr_gtk_paint_handle QGtkStylePrivate::gtk_paint_handle = 0;
Ptr_gtk_paint_expander QGtkStylePrivate::gtk_paint_expander = 0;
+Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
Ptr_gtk_paint_hline QGtkStylePrivate::gtk_paint_hline = 0;
Ptr_gtk_paint_vline QGtkStylePrivate::gtk_paint_vline = 0;
@@ -376,7 +378,8 @@ void QGtkStylePrivate::resolveGtk() const
gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
- gtk_progress_set_adjustment = (Ptr_gtk_progress_set_adjustment)libgtk.resolve("gtk_progress_set_adjustment");
+ gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
+ gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
@@ -405,6 +408,7 @@ void QGtkStylePrivate::resolveGtk() const
gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
+ gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
index 5cf1c59..15a98c8 100644
--- a/src/gui/styles/qgtkstyle_p.h
+++ b/src/gui/styles/qgtkstyle_p.h
@@ -174,8 +174,9 @@ typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
+typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
-typedef void (*Ptr_gtk_progress_set_adjustment)(GtkProgress *, GtkAdjustment *);
+typedef void (*Ptr_gtk_progress_configure)(GtkProgress *, double, double, double);
typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
@@ -198,6 +199,7 @@ typedef void (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkSha
typedef void (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
+typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
@@ -393,7 +395,8 @@ public:
static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
static Ptr_gtk_container_add gtk_container_add;
static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
- static Ptr_gtk_progress_set_adjustment gtk_progress_set_adjustment;
+ static Ptr_gtk_progress_configure gtk_progress_configure;
+ static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
@@ -416,6 +419,7 @@ public:
static Ptr_gtk_paint_arrow gtk_paint_arrow;
static Ptr_gtk_paint_handle gtk_paint_handle;
static Ptr_gtk_paint_expander gtk_paint_expander;
+ static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
static Ptr_gtk_adjustment_new gtk_adjustment_new;
static Ptr_gtk_paint_vline gtk_paint_vline;
static Ptr_gtk_paint_hline gtk_paint_hline;
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 39b0eac..2d21628 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -1566,8 +1566,7 @@ void QMacStylePrivate::timerEvent(QTimerEvent *)
progressBars.removeAt(i);
} else {
if (QProgressBar *pb = qobject_cast<QProgressBar *>(maybeProgress)) {
- if (pb->maximum() == 0 || pb->value() > 0
- && pb->value() < pb->maximum()) {
+ if (pb->maximum() == 0 || (pb->value() > 0 && pb->value() < pb->maximum())) {
if (doAnimate(AquaProgressBar))
pb->update();
}
@@ -1642,7 +1641,7 @@ bool QMacStylePrivate::eventFilter(QObject *o, QEvent *e)
case QEvent::FocusOut:
case QEvent::Show:
case QEvent::WindowActivate: {
- QList<QPushButton *> list = qFindChildren<QPushButton *>(btn->window());
+ QList<QPushButton *> list = btn->window()->findChildren<QPushButton *>();
for (int i = 0; i < list.size(); ++i) {
QPushButton *pBtn = list.at(i);
if ((e->type() == QEvent::FocusOut
@@ -1948,10 +1947,9 @@ void QMacStyle::unpolish(QWidget* w)
rubber->setAttribute(Qt::WA_NoSystemBackground, true);
}
- if (QFocusFrame *frame = qobject_cast<QFocusFrame *>(w)) {
+ if (QFocusFrame *frame = qobject_cast<QFocusFrame *>(w))
frame->setAttribute(Qt::WA_NoSystemBackground, true);
- frame->setAutoFillBackground(true);
- }
+
QWindowsStyle::unpolish(w);
}
@@ -3086,7 +3084,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
}
break;
case PE_PanelScrollAreaCorner: {
- const QBrush brush(qApp->palette().brush(QPalette::Base));
+ const QBrush brush(opt->palette.brush(QPalette::Base));
p->fillRect(opt->rect, brush);
p->setPen(QPen(QColor(217, 217, 217)));
p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
@@ -3609,7 +3607,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
break;
}
}
- bool stretchTabs = (!verticalTabs && tabRect.height() > 22 || verticalTabs && tabRect.width() > 22);
+ bool stretchTabs = (!verticalTabs && tabRect.height() > 22) || (verticalTabs && tabRect.width() > 22);
switch (tp) {
case QStyleOptionTab::Beginning:
@@ -4034,7 +4032,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
bdi.version = qt_mac_hitheme_version;
bdi.state = kThemeMenuBarNormal;
bdi.attributes = 0;
- HIRect hirect = qt_hirectForQRect(mi->rect);
HIThemeDrawMenuBarBackground(&menuRect, &bdi, cg, kHIThemeOrientationNormal);
}
@@ -4624,6 +4621,13 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
tdi.attributes &= ~kThemeTrackShowThumb;
if (scrollBarLength < scrollButtonsCutoffSize(scrollButtonsCutoff, sizePolicy))
tdi.enableState = kThemeTrackNothingToScroll;
+ } else {
+ if (!(slider->subControls & SC_SliderHandle))
+ tdi.attributes &= ~kThemeTrackShowThumb;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ if (!(slider->subControls & SC_SliderGroove))
+ tdi.attributes |= kThemeTrackHideTrack;
+#endif
}
HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg,
@@ -5336,8 +5340,8 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
case SC_GroupBoxCheckBox: {
// Cheat and use the smaller font if we need to
bool checkable = groupBox->subControls & SC_GroupBoxCheckBox;
- bool fontIsSet = (widget && widget->testAttribute(Qt::WA_SetFont)
- || !QApplication::desktopSettingsAware());
+ bool fontIsSet = (widget && widget->testAttribute(Qt::WA_SetFont))
+ || !QApplication::desktopSettingsAware();
int tw;
int h;
int margin = flat || hasNoText ? 0 : 12;
@@ -5540,6 +5544,57 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
// hack to work around horrible sizeHint() code in QAbstractSpinBox
sz.setHeight(sz.height() - 3);
break;
+ case QStyle::CT_TabWidget:
+ // the size between the pane and the "contentsRect" (+4,+4)
+ // (the "contentsRect" is on the inside of the pane)
+ sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget);
+ /**
+ This is supposed to show the relationship between the tabBar and
+ the stack widget of a QTabWidget.
+ Unfortunately ascii is not a good way of representing graphics.....
+ PS: The '=' line is the painted frame.
+
+ top ---+
+ |
+ |
+ |
+ | vvv just outside the painted frame is the "pane"
+ - -|- - - - - - - - - - <-+
+ TAB BAR +=====^============ | +2 pixels
+ - - -|- - -|- - - - - - - <-+
+ | | ^ ^^^ just inside the painted frame is the "contentsRect"
+ | | |
+ | overlap |
+ | | |
+ bottom ------+ <-+ +14 pixels
+ |
+ v
+ ------------------------------ <- top of stack widget
+
+
+ To summarize:
+ * 2 is the distance between the pane and the contentsRect
+ * The 14 and the 1's are the distance from the contentsRect to the stack widget.
+ (same value as used in SE_TabWidgetTabContents)
+ * overlap is how much the pane should overlap the tab bar
+ */
+ // then add the size between the stackwidget and the "contentsRect"
+
+ if (const QStyleOptionTabWidgetFrame *twf
+ = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
+ QSize extra(0,0);
+ const int overlap = pixelMetric(PM_TabBarBaseOverlap, opt, widget);
+ const int gapBetweenTabbarAndStackWidget = 2 + 14 - overlap;
+
+ if (getTabDirection(twf->shape) == kThemeTabNorth || getTabDirection(twf->shape) == kThemeTabSouth) {
+ extra = QSize(2, gapBetweenTabbarAndStackWidget + 1);
+ } else {
+ extra = QSize(gapBetweenTabbarAndStackWidget + 1, 2);
+ }
+ sz+= extra;
+ }
+
+ break;
case QStyle::CT_TabBarTab:
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget);
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index 3698818..02ce60e 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -1054,7 +1054,7 @@ void QPlastiqueStylePrivate::drawPartialFrame(QPainter *painter, const QStyleOpt
bool reverse = option->direction == Qt::RightToLeft;
QStyleOptionFrame frameOpt;
#ifndef QT_NO_LINEEDIT
- if (QLineEdit *lineedit = qFindChild<QLineEdit *>(widget))
+ if (QLineEdit *lineedit = widget->findChild<QLineEdit *>())
frameOpt.initFrom(lineedit);
#else
Q_UNUSED(widget)
@@ -1362,11 +1362,8 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
if (const QStyleOptionFrame *lineEdit = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
// Panel of a line edit inside combo box or spin box is drawn in CC_ComboBox and CC_SpinBox
if (widget) {
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox *>(widget->parentWidget()))
- break;
-#endif
#ifndef QT_NO_SPINBOX
+ // Spinbox doesn't need a separate palette for the lineedit
if (qobject_cast<const QAbstractSpinBox *>(widget->parentWidget()))
break;
#endif
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index da1528e..2d9b6cd 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1410,7 +1410,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
bool isScrollBarVisible = false;
int scrollBarWidth = 0;
- QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget);
+ QList<QScrollBar *> scrollBars = widget->findChildren<QScrollBar *>();
for (int i = 0; i < scrollBars.size(); ++i) {
QScrollBar *scrollBar = scrollBars.at(i);
if (scrollBar && scrollBar->orientation() == Qt::Vertical) {
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index a4e7c38..ecf924c 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -99,14 +99,7 @@ public:
};
-static QHash<const QWidget *, QVector<StyleRule> > *styleRulesCache = 0;
-static QHash<const QWidget *, QHash<int, bool> > *hasStyleRuleCache = 0;
-typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
-static QHash<const QWidget *, QRenderRules> *renderRulesCache = 0;
-static QHash<const QWidget *, QPalette> *customPaletteWidgets = 0; // widgets whose palette we tampered
-static QHash<const void *, StyleSheet> *styleSheetCache = 0; // parsed style sheets
-static QSet<const QWidget *> *autoFillDisabledWidgets = 0;
-
+static QStyleSheetStyleCaches *styleSheetCaches = 0;
/* RECURSION_GUARD:
* the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like:
@@ -1525,8 +1518,8 @@ private:
QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
{
- QHash<const QWidget *, QVector<StyleRule> >::const_iterator cacheIt = styleRulesCache->constFind(w);
- if (cacheIt != styleRulesCache->constEnd())
+ QHash<const QWidget *, QVector<StyleRule> >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(w);
+ if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
return cacheIt.value();
if (!initWidget(w)) {
@@ -1536,12 +1529,12 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
QStyleSheetStyleSelector styleSelector;
StyleSheet defaultSs;
- QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCache->constFind(baseStyle());
- if (defaultCacheIt == styleSheetCache->constEnd()) {
+ QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCaches->styleSheetCache.constFind(baseStyle());
+ if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
defaultSs = getDefaultStyleSheet();
QStyle *bs = baseStyle();
- styleSheetCache->insert(bs, defaultSs);
- QObject::connect(bs, SIGNAL(destroyed(QObject*)), this, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection);
+ styleSheetCaches->styleSheetCache.insert(bs, defaultSs);
+ QObject::connect(bs, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection);
} else {
defaultSs = defaultCacheIt.value();
}
@@ -1549,8 +1542,8 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
if (!qApp->styleSheet().isEmpty()) {
StyleSheet appSs;
- QHash<const void *, StyleSheet>::const_iterator appCacheIt = styleSheetCache->constFind(qApp);
- if (appCacheIt == styleSheetCache->constEnd()) {
+ QHash<const void *, StyleSheet>::const_iterator appCacheIt = styleSheetCaches->styleSheetCache.constFind(qApp);
+ if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
QString ss = qApp->styleSheet();
if (ss.startsWith(QLatin1String("file:///")))
ss.remove(0, 8);
@@ -1559,7 +1552,7 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
qWarning("Could not parse application stylesheet");
appSs.origin = StyleSheetOrigin_Inline;
appSs.depth = 1;
- styleSheetCache->insert(qApp, appSs);
+ styleSheetCaches->styleSheetCache.insert(qApp, appSs);
} else {
appSs = appCacheIt.value();
}
@@ -1571,8 +1564,8 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
if (wid->styleSheet().isEmpty())
continue;
StyleSheet ss;
- QHash<const void *, StyleSheet>::const_iterator widCacheIt = styleSheetCache->constFind(wid);
- if (widCacheIt == styleSheetCache->constEnd()) {
+ QHash<const void *, StyleSheet>::const_iterator widCacheIt = styleSheetCaches->styleSheetCache.constFind(wid);
+ if (widCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
parser.init(wid->styleSheet());
if (!parser.parse(&ss)) {
parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}'));
@@ -1580,7 +1573,7 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
qWarning("Could not parse stylesheet of widget %p", wid);
}
ss.origin = StyleSheetOrigin_Inline;
- styleSheetCache->insert(wid, ss);
+ styleSheetCaches->styleSheetCache.insert(wid, ss);
} else {
ss = widCacheIt.value();
}
@@ -1595,7 +1588,7 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
StyleSelector::NodePtr n;
n.ptr = (void *)w;
QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
- styleRulesCache->insert(w, rules);
+ styleSheetCaches->styleRulesCache.insert(w, rules);
return rules;
}
@@ -1724,7 +1717,7 @@ static void qt_check_if_internal_widget(const QWidget **w, int *element)
QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, int element, quint64 state) const
{
qt_check_if_internal_widget(&w, &element);
- QHash<quint64, QRenderRule> &cache = (*renderRulesCache)[w][element];
+ QHash<quint64, QRenderRule> &cache = styleSheetCaches->renderRulesCache[w][element];
QHash<quint64, QRenderRule>::const_iterator cacheIt = cache.constFind(state);
if (cacheIt != cache.constEnd())
return cacheIt.value();
@@ -2035,7 +2028,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *o
bool QStyleSheetStyle::hasStyleRule(const QWidget *w, int part) const
{
- QHash<int, bool> &cache = (*hasStyleRuleCache)[w];
+ QHash<int, bool> &cache = styleSheetCaches->hasStyleRuleCache[w];
QHash<int, bool>::const_iterator cacheIt = cache.constFind(part);
if (cacheIt != cache.constEnd())
return cacheIt.value();
@@ -2342,7 +2335,7 @@ static QWidget *embeddedWidget(QWidget *w)
#ifndef QT_NO_SPINBOX
if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(w))
- return qFindChild<QLineEdit *>(sb);
+ return sb->findChild<QLineEdit *>();
#endif
#ifndef QT_NO_SCROLLAREA
@@ -2565,7 +2558,7 @@ void QStyleSheetStyle::setPalette(QWidget *w)
rule.configurePalette(&p, map[i].group, ew, ew != w);
}
- customPaletteWidgets->insert(w, w->palette());
+ styleSheetCaches->customPaletteWidgets.insert(w, w->palette());
w->setPalette(p);
if (ew != w)
ew->setPalette(p);
@@ -2573,32 +2566,32 @@ void QStyleSheetStyle::setPalette(QWidget *w)
void QStyleSheetStyle::unsetPalette(QWidget *w)
{
- if (customPaletteWidgets->contains(w)) {
- QPalette p = customPaletteWidgets->value(w);
+ if (styleSheetCaches->customPaletteWidgets.contains(w)) {
+ QPalette p = styleSheetCaches->customPaletteWidgets.value(w);
w->setPalette(p);
QWidget *ew = embeddedWidget(w);
if (ew != w)
ew->setPalette(p);
- customPaletteWidgets->remove(w);
+ styleSheetCaches->customPaletteWidgets.remove(w);
}
QVariant oldFont = w->property("_q_styleSheetWidgetFont");
if (oldFont.isValid()) {
- w->setFont(qVariantValue<QFont>(oldFont));
+ w->setFont(qvariant_cast<QFont>(oldFont));
}
- if (autoFillDisabledWidgets->contains(w)) {
+ if (styleSheetCaches->autoFillDisabledWidgets.contains(w)) {
embeddedWidget(w)->setAutoFillBackground(true);
- autoFillDisabledWidgets->remove(w);
+ styleSheetCaches->autoFillDisabledWidgets.remove(w);
}
}
static void updateWidgets(const QList<const QWidget *>& widgets)
{
- if (!styleRulesCache->isEmpty() || !hasStyleRuleCache->isEmpty() || !renderRulesCache->isEmpty()) {
+ if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
for (int i = 0; i < widgets.size(); ++i) {
const QWidget *widget = widgets.at(i);
- styleRulesCache->remove(widget);
- hasStyleRuleCache->remove(widget);
- renderRulesCache->remove(widget);
+ styleSheetCaches->styleRulesCache.remove(widget);
+ styleSheetCaches->hasStyleRuleCache.remove(widget);
+ styleSheetCaches->renderRulesCache.remove(widget);
}
}
for (int i = 0; i < widgets.size(); ++i) {
@@ -2622,12 +2615,7 @@ QStyleSheetStyle::QStyleSheetStyle(QStyle *base)
{
++numinstances;
if (numinstances == 1) {
- styleRulesCache = new QHash<const QWidget *, QVector<StyleRule> >;
- hasStyleRuleCache = new QHash<const QWidget *, QHash<int, bool> >;
- renderRulesCache = new QHash<const QWidget *, QRenderRules>;
- customPaletteWidgets = new QHash<const QWidget *, QPalette>;
- styleSheetCache = new QHash<const void *, StyleSheet>;
- autoFillDisabledWidgets = new QSet<const QWidget *>;
+ styleSheetCaches = new QStyleSheetStyleCaches;
}
}
@@ -2635,18 +2623,7 @@ QStyleSheetStyle::~QStyleSheetStyle()
{
--numinstances;
if (numinstances == 0) {
- delete styleRulesCache;
- styleRulesCache = 0;
- delete hasStyleRuleCache;
- hasStyleRuleCache = 0;
- delete renderRulesCache;
- renderRulesCache = 0;
- delete customPaletteWidgets;
- customPaletteWidgets = 0;
- delete styleSheetCache;
- styleSheetCache = 0;
- delete autoFillDisabledWidgets;
- autoFillDisabledWidgets = 0;
+ delete styleSheetCaches;
}
}
QStyle *QStyleSheetStyle::baseStyle() const
@@ -2658,19 +2635,19 @@ QStyle *QStyleSheetStyle::baseStyle() const
return QApplication::style();
}
-void QStyleSheetStyle::widgetDestroyed(QObject *o)
+void QStyleSheetStyleCaches::widgetDestroyed(QObject *o)
{
- styleRulesCache->remove((const QWidget *)o);
- hasStyleRuleCache->remove((const QWidget *)o);
- renderRulesCache->remove((const QWidget *)o);
- customPaletteWidgets->remove((const QWidget *)o);
- styleSheetCache->remove((const QWidget *)o);
- autoFillDisabledWidgets->remove((const QWidget *)o);
+ styleRulesCache.remove((const QWidget *)o);
+ hasStyleRuleCache.remove((const QWidget *)o);
+ renderRulesCache.remove((const QWidget *)o);
+ customPaletteWidgets.remove((const QWidget *)o);
+ styleSheetCache.remove((const QWidget *)o);
+ autoFillDisabledWidgets.remove((const QWidget *)o);
}
-void QStyleSheetStyle::styleDestroyed(QObject *o)
+void QStyleSheetStyleCaches::styleDestroyed(QObject *o)
{
- styleSheetCache->remove(o);
+ styleSheetCache.remove(o);
}
/*!
@@ -2688,7 +2665,7 @@ bool QStyleSheetStyle::initWidget(const QWidget *w) const
return false;
const_cast<QWidget *>(w)->setAttribute(Qt::WA_StyleSheet, true);
- QObject::connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(widgetDestroyed(QObject*)));
+ QObject::connect(w, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(widgetDestroyed(QObject*)), Qt::UniqueConnection);
return true;
}
@@ -2700,12 +2677,12 @@ void QStyleSheetStyle::polish(QWidget *w)
if (!initWidget(w))
return;
- if (styleRulesCache->contains(w)) {
+ if (styleSheetCaches->styleRulesCache.contains(w)) {
// the widget accessed its style pointer before polish (or repolish)
// (exemple: the QAbstractSpinBox constructor ask for the stylehint)
- styleRulesCache->remove(w);
- hasStyleRuleCache->remove(w);
- renderRulesCache->remove(w);
+ styleSheetCaches->styleRulesCache.remove(w);
+ styleSheetCaches->hasStyleRuleCache.remove(w);
+ styleSheetCaches->renderRulesCache.remove(w);
}
setGeometry(w);
setProperties(w);
@@ -2771,7 +2748,7 @@ void QStyleSheetStyle::polish(QWidget *w)
QWidget *ew = embeddedWidget(w);
if (ew->autoFillBackground()) {
ew->setAutoFillBackground(false);
- autoFillDisabledWidgets->insert(w);
+ styleSheetCaches->autoFillDisabledWidgets.insert(w);
if (ew != w) { //eg. viewport of a scrollarea
//(in order to draw the background anyway in case we don't.)
ew->setAttribute(Qt::WA_StyledBackground, true);
@@ -2795,20 +2772,20 @@ void QStyleSheetStyle::polish(QPalette &pal)
void QStyleSheetStyle::repolish(QWidget *w)
{
- QList<const QWidget *> children = qFindChildren<const QWidget *>(w, QString());
+ QList<const QWidget *> children = w->findChildren<const QWidget *>(QString());
children.append(w);
- styleSheetCache->remove(w);
+ styleSheetCaches->styleSheetCache.remove(w);
updateWidgets(children);
}
void QStyleSheetStyle::repolish(QApplication *app)
{
Q_UNUSED(app);
- const QList<const QWidget*> allWidgets = styleRulesCache->keys();
- styleSheetCache->remove(qApp);
- styleRulesCache->clear();
- hasStyleRuleCache->clear();
- renderRulesCache->clear();
+ const QList<const QWidget*> allWidgets = styleSheetCaches->styleRulesCache.keys();
+ styleSheetCaches->styleSheetCache.remove(qApp);
+ styleSheetCaches->styleRulesCache.clear();
+ styleSheetCaches->hasStyleRuleCache.clear();
+ styleSheetCaches->renderRulesCache.clear();
updateWidgets(allWidgets);
}
@@ -2819,10 +2796,10 @@ void QStyleSheetStyle::unpolish(QWidget *w)
return;
}
- styleRulesCache->remove(w);
- hasStyleRuleCache->remove(w);
- renderRulesCache->remove(w);
- styleSheetCache->remove(w);
+ styleSheetCaches->styleRulesCache.remove(w);
+ styleSheetCaches->hasStyleRuleCache.remove(w);
+ styleSheetCaches->renderRulesCache.remove(w);
+ styleSheetCaches->styleSheetCache.remove(w);
unsetPalette(w);
w->setProperty("_q_stylesheet_minw", QVariant());
w->setProperty("_q_stylesheet_minh", QVariant());
@@ -2849,10 +2826,10 @@ void QStyleSheetStyle::unpolish(QApplication *app)
{
baseStyle()->unpolish(app);
RECURSION_GUARD(return)
- styleRulesCache->clear();
- hasStyleRuleCache->clear();
- renderRulesCache->clear();
- styleSheetCache->remove(qApp);
+ styleSheetCaches->styleRulesCache.clear();
+ styleSheetCaches->hasStyleRuleCache.clear();
+ styleSheetCaches->renderRulesCache.clear();
+ styleSheetCaches->styleSheetCache.remove(qApp);
}
#ifndef QT_NO_TABBAR
@@ -3048,6 +3025,13 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
titleRule.configurePalette(&pal, QPalette::WindowText, QPalette::Window);
drawItemText(p, labelRect, alignment, pal, gb->state & State_Enabled,
gb->text, QPalette::WindowText);
+
+ if (gb->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*gb);
+ fropt.rect = labelRect;
+ drawPrimitive(PE_FrameFocusRect, &fropt, p, w);
+ }
}
return;
@@ -3717,7 +3701,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
editRect.translate(cb->iconSize.width() + spacing, 0);
}
if (!cb->currentText.isEmpty() && !cb->editable) {
- drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, cb->palette,
+ QPalette styledPalette(cb->palette);
+ rule.configurePalette(&styledPalette, QPalette::Text, QPalette::Base);
+ drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, styledPalette,
cb->state & State_Enabled, cb->currentText, QPalette::Text);
}
p->restore();
@@ -4150,6 +4136,10 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
pseudoElement = PseudoElement_DownArrow;
break;
+ case PE_IndicatorArrowUp:
+ pseudoElement = PseudoElement_UpArrow;
+ break;
+
case PE_IndicatorRadioButton:
pseudoElement = PseudoElement_ExclusiveIndicator;
break;
@@ -4250,7 +4240,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_Widget:
if (w && !rule.hasDrawable()) {
QWidget *container = containerWidget(w);
- if (autoFillDisabledWidgets->contains(container)
+ if (styleSheetCaches->autoFillDisabledWidgets.contains(container)
&& (container == w || !renderRule(container, opt).hasBackground())) {
//we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
// (this may happen if we have rules like :focus)
@@ -5074,7 +5064,7 @@ QIcon QStyleSheetStyle::standardIconImplementation(StandardPixmap standardIcon,
if (!s.isEmpty()) {
QRenderRule rule = renderRule(w, opt);
if (rule.hasStyleHint(s))
- return qVariantValue<QIcon>(rule.styleHint(s));
+ return qvariant_cast<QIcon>(rule.styleHint(s));
}
return baseStyle()->standardIcon(standardIcon, opt, w);
}
@@ -5092,7 +5082,7 @@ QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QS
if (!s.isEmpty()) {
QRenderRule rule = renderRule(w, opt);
if (rule.hasStyleHint(s)) {
- QIcon icon = qVariantValue<QIcon>(rule.styleHint(s));
+ QIcon icon = qvariant_cast<QIcon>(rule.styleHint(s));
return icon.pixmap(16, 16); // ###: unhard-code this if someone complains
}
}
@@ -5186,7 +5176,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
case SH_ComboBox_PopupFrameStyle:
#ifndef QT_NO_COMBOBOX
if (qobject_cast<const QComboBox *>(w)) {
- QAbstractItemView *view = qFindChild<QAbstractItemView *>(w);
+ QAbstractItemView *view = w->findChild<QAbstractItemView *>();
if (view) {
view->ensurePolished();
QRenderRule subRule = renderRule(view, PseudoElement_None);
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/styles/qstylesheetstyle_p.h b/src/gui/styles/qstylesheetstyle_p.h
index 38c51f5..1f331b2 100644
--- a/src/gui/styles/qstylesheetstyle_p.h
+++ b/src/gui/styles/qstylesheetstyle_p.h
@@ -145,10 +145,6 @@ protected Q_SLOTS:
protected:
bool event(QEvent *e);
-private Q_SLOTS:
- void widgetDestroyed(QObject *);
- void styleDestroyed(QObject *);
-
private:
int refcount;
@@ -186,6 +182,22 @@ private:
Q_DECLARE_PRIVATE(QStyleSheetStyle)
};
+class QStyleSheetStyleCaches : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void widgetDestroyed(QObject *);
+ void styleDestroyed(QObject *);
+public:
+ QHash<const QWidget *, QVector<QCss::StyleRule> > styleRulesCache;
+ QHash<const QWidget *, QHash<int, bool> > hasStyleRuleCache;
+ typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
+ QHash<const QWidget *, QRenderRules> renderRulesCache;
+ QHash<const QWidget *, QPalette> customPaletteWidgets; // widgets whose palette we tampered
+ QHash<const void *, QCss::StyleSheet> styleSheetCache; // parsed style sheets
+ QSet<const QWidget *> autoFillDisabledWidgets;
+};
+
QT_END_NAMESPACE
#endif // QT_NO_STYLE_STYLESHEET
diff --git a/src/gui/styles/qwindowscestyle.cpp b/src/gui/styles/qwindowscestyle.cpp
index 7fd9f20..d7947bc 100644
--- a/src/gui/styles/qwindowscestyle.cpp
+++ b/src/gui/styles/qwindowscestyle.cpp
@@ -2294,6 +2294,7 @@ int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QW
break;
case SH_EtchDisabledText:
ret = false;
+ break;
case SH_RequestSoftwareInputPanel:
ret = RSIP_OnMouseClick;
break;
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index e7598a2..44f3f92 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -176,7 +176,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
widget = widget->window();
// Alt has been pressed - find all widgets that care
- QList<QWidget *> l = qFindChildren<QWidget *>(widget);
+ QList<QWidget *> l = widget->findChildren<QWidget *>();
for (int pos=0 ; pos < l.size() ; ++pos) {
QWidget *w = l.at(pos);
if (w->isWindow() || !w->isVisible() ||
@@ -199,7 +199,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
// Update state and repaint the menu bars.
d->alt_down = false;
#ifndef QT_NO_MENUBAR
- QList<QMenuBar *> l = qFindChildren<QMenuBar *>(widget);
+ QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
for (int i = 0; i < l.size(); ++i)
l.at(i)->update();
#endif
@@ -1161,7 +1161,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
if (!menuBar && qobject_cast<const QMenu *>(widget)) {
QWidget *w = QApplication::activeWindow();
if (w && w != widget)
- menuBar = qFindChild<QMenuBar *>(w);
+ menuBar = w->findChild<QMenuBar *>();
}
// If we paint a menu bar draw underlines if is in the keyboardState
if (menuBar) {
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 24d8555..7f1a3ab 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -588,10 +588,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget()))
resolve_mask = spinbox->palette().resolve();
#endif // QT_NO_SPINBOX
-#ifndef QT_NO_COMBOBOX
- if (QComboBox *combobox = qobject_cast<QComboBox*>(widget->parentWidget()))
- resolve_mask = combobox->palette().resolve();
-#endif // QT_NO_COMBOBOX
}
if (resolve_mask & (1 << QPalette::Base)) {
// Base color is set for this widget, so use it
@@ -842,10 +838,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
const QDialogButtonBox *buttonBox = 0;
if (qobject_cast<const QMessageBox *> (widget))
- buttonBox = qFindChild<const QDialogButtonBox *>(widget,QLatin1String("qt_msgbox_buttonbox"));
+ buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
#ifndef QT_NO_INPUTDIALOG
else if (qobject_cast<const QInputDialog *> (widget))
- buttonBox = qFindChild<const QDialogButtonBox *>(widget,QLatin1String("qt_inputdlg_buttonbox"));
+ buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
#endif // QT_NO_INPUTDIALOG
if (buttonBox) {
@@ -2396,14 +2392,14 @@ void QWindowsVistaStyle::polish(QWidget *widget)
}
} else if (qobject_cast<QMessageBox *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox *>(widget,QLatin1String("qt_msgbox_buttonbox"));
+ QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
if (buttonBox)
buttonBox->setContentsMargins(0, 9, 0, 0);
}
#ifndef QT_NO_INPUTDIALOG
else if (qobject_cast<QInputDialog *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox *>(widget,QLatin1String("qt_inputdlg_buttonbox"));
+ QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
if (buttonBox)
buttonBox->setContentsMargins(0, 9, 0, 0);
}
@@ -2435,14 +2431,14 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
widget->setAttribute(Qt::WA_Hover, false);
else if (qobject_cast<QMessageBox *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground, false);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox *>(widget,QLatin1String("qt_msgbox_buttonbox"));
+ QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
if (buttonBox)
buttonBox->setContentsMargins(0, 0, 0, 0);
}
#ifndef QT_NO_INPUTDIALOG
else if (qobject_cast<QInputDialog *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground, false);
- QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox *>(widget,QLatin1String("qt_inputdlg_buttonbox"));
+ QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
if (buttonBox)
buttonBox->setContentsMargins(0, 0, 0, 0);
}
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 629a8c6..74a20fc 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -4054,7 +4054,7 @@ void QWindowsXPStylePrivate::dumpNativeDIB(int w, int h)
bufferPos += sprintf(bufferPos, "\n};\n\n");
printf(bufferDump);
- delete bufferDump;
+ delete[] bufferDump;
++pCount;
}
}
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index b22a908..b6eeec9 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -35,7 +35,7 @@ contains( styles, all ) {
styles = mac windows windowsxp windowsvista
}
-x11|embedded|!macx-*:styles -= mac
+x11|embedded|qpa|!macx-*:styles -= mac
x11{
QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
diff --git a/src/gui/symbian/qsymbianevent.cpp b/src/gui/symbian/qsymbianevent.cpp
index 5c54532..e177d17 100644
--- a/src/gui/symbian/qsymbianevent.cpp
+++ b/src/gui/symbian/qsymbianevent.cpp
@@ -40,6 +40,9 @@
****************************************************************************/
#include "qsymbianevent.h"
+#include <qdebug.h>
+
+#include <w32std.h>
QT_BEGIN_NAMESPACE
@@ -140,4 +143,34 @@ int QSymbianEvent::resourceChangeType() const
return (m_type == ResourceChangeEvent) ? m_eventValue : 0;
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QSymbianEvent *o)
+{
+ if (!o) {
+ dbg << "QSymbianEvent(0x0)";
+ return dbg;
+ }
+ dbg.nospace() << "QSymbianEvent(";
+ switch (o->type()) {
+ case QSymbianEvent::InvalidEvent:
+ dbg << "InvalidEvent";
+ break;
+ case QSymbianEvent::WindowServerEvent:
+ dbg << "WindowServerEvent, Type = " << o->windowServerEvent()->Type();
+ break;
+ case QSymbianEvent::CommandEvent:
+ dbg << "CommandEvent, command = " << o->command();
+ break;
+ case QSymbianEvent::ResourceChangeEvent:
+ dbg << "ResourceChangeEvent, resourceChangeType = " << o->resourceChangeType();
+ break;
+ default:
+ dbg << "Unknown event type";
+ break;
+ }
+ dbg << ")";
+ return dbg.space();
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/gui/symbian/qsymbianevent.h b/src/gui/symbian/qsymbianevent.h
index 5fd5a9e..cf05f63 100644
--- a/src/gui/symbian/qsymbianevent.h
+++ b/src/gui/symbian/qsymbianevent.h
@@ -95,6 +95,10 @@ inline bool QSymbianEvent::isValid() const
return m_type != InvalidEvent;
}
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QSymbianEvent *o);
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 5aac5ea..052dc72 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -68,6 +68,8 @@ static const QCssKnownValue properties[NumProperties - 1] = {
{ "-qt-background-role", QtBackgroundRole },
{ "-qt-block-indent", QtBlockIndent },
{ "-qt-list-indent", QtListIndent },
+ { "-qt-list-number-prefix", QtListNumberPrefix },
+ { "-qt-list-number-suffix", QtListNumberSuffix },
{ "-qt-paragraph-type", QtParagraphType },
{ "-qt-style-features", QtStyleFeatures },
{ "-qt-table-type", QtTableType },
@@ -120,6 +122,7 @@ static const QCssKnownValue properties[NumProperties - 1] = {
{ "image", QtImage },
{ "image-position", QtImageAlignment },
{ "left", Left },
+ { "line-height", LineHeight },
{ "list-style", ListStyle },
{ "list-style-type", ListStyleType },
{ "margin" , Margin },
@@ -403,7 +406,7 @@ int ValueExtractor::lengthValue(const Declaration &decl)
if (decl.d->values.count() < 1)
return 0;
LengthData data = lengthValue(decl.d->values.at(0));
- decl.d->parsed = qVariantFromValue<LengthData>(data);
+ decl.d->parsed = QVariant::fromValue<LengthData>(data);
return lengthValueFromData(data,f);
}
@@ -435,7 +438,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m)
QList<QVariant> v;
for (i = 0; i < 4; i++) {
- v += qVariantFromValue<LengthData>(datas[i]);
+ v += QVariant::fromValue<LengthData>(datas[i]);
m[i] = lengthValueFromData(datas[i], f);
}
decl.d->parsed = v;
@@ -541,7 +544,7 @@ QSize ValueExtractor::sizeValue(const Declaration &decl)
else
x[1] = x[0];
QList<QVariant> v;
- v << qVariantFromValue<LengthData>(x[0]) << qVariantFromValue<LengthData>(x[1]);
+ v << QVariant::fromValue<LengthData>(x[0]) << qVariantFromValue<LengthData>(x[1]);
decl.d->parsed = v;
return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f));
}
@@ -646,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++) {
@@ -669,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);
@@ -703,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();
@@ -735,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) {
@@ -777,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();
@@ -789,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());
@@ -853,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()) {
@@ -916,7 +919,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord
data.width = lengthValue(decl.d->values.at(i));
*width = lengthValueFromData(data.width, f);
if (++i >= decl.d->values.count()) {
- decl.d->parsed = qVariantFromValue<BorderData>(data);
+ decl.d->parsed = QVariant::fromValue<BorderData>(data);
return;
}
}
@@ -925,7 +928,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord
if (data.style != BorderStyle_Unknown) {
*style = data.style;
if (++i >= decl.d->values.count()) {
- decl.d->parsed = qVariantFromValue<BorderData>(data);
+ decl.d->parsed = QVariant::fromValue<BorderData>(data);
return;
}
} else {
@@ -935,10 +938,10 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord
data.color = parseBrushValue(decl.d->values.at(i), pal);
*color = brushFromData(data.color, pal);
if (data.color.type != BrushData::DependsOnThePalette)
- decl.d->parsed = qVariantFromValue<BorderData>(data);
+ 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();
@@ -946,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;
@@ -993,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();
@@ -1032,16 +1035,8 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re
parseShorthandBackgroundProperty(decl.d->values, &brushData, image, repeat, alignment, pal);
*brush = brushFromData(brushData, pal);
if (brushData.type != BrushData::DependsOnThePalette) {
-#if defined Q_CC_MSVC && _MSC_VER <= 1300
- BackgroundData data;
- data.brush = brushData;
- data.image = *image;
- data.repeat = *repeat;
- data.alignment = *alignment;
-#else
BackgroundData data = { brushData, *image, *repeat, *alignment };
-#endif
- decl.d->parsed = qVariantFromValue<BackgroundData>(data);
+ decl.d->parsed = QVariant::fromValue<BackgroundData>(data);
}
}
break;
@@ -1055,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;
@@ -1092,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 ;
@@ -1105,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()) {
@@ -1126,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;
@@ -1151,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)
@@ -1170,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);
@@ -1195,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()) {
@@ -1206,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()) {
@@ -1231,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;
@@ -1319,10 +1314,10 @@ QColor Declaration::colorValue(const QPalette &pal) const
ColorData color = parseColorValue(d->values.at(0));
if(color.type == ColorData::Role) {
- d->parsed = qVariantFromValue<int>(color.role);
+ d->parsed = QVariant::fromValue<int>(color.role);
return pal.color((QPalette::ColorRole)(color.role));
} else {
- d->parsed = qVariantFromValue<QColor>(color.color);
+ d->parsed = QVariant::fromValue<QColor>(color.color);
return color.color;
}
}
@@ -1342,11 +1337,11 @@ QBrush Declaration::brushValue(const QPalette &pal) const
BrushData data = parseBrushValue(d->values.at(0), pal);
if(data.type == BrushData::Role) {
- d->parsed = qVariantFromValue<int>(data.role);
+ d->parsed = QVariant::fromValue<int>(data.role);
return pal.color((QPalette::ColorRole)(data.role));
} else {
if (data.type != BrushData::DependsOnThePalette)
- d->parsed = qVariantFromValue<QBrush>(data.brush);
+ d->parsed = QVariant::fromValue<QBrush>(data.brush);
return data.brush;
}
}
@@ -1376,11 +1371,11 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const
continue;
BrushData data = parseBrushValue(d->values.at(i), pal);
if(data.type == BrushData::Role) {
- v += qVariantFromValue<int>(data.role);
+ v += QVariant::fromValue<int>(data.role);
c[i] = pal.color((QPalette::ColorRole)(data.role));
} else {
if (data.type != BrushData::DependsOnThePalette) {
- v += qVariantFromValue<QBrush>(data.brush);
+ v += QVariant::fromValue<QBrush>(data.brush);
} else {
v += QVariant();
}
@@ -1416,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;
@@ -1453,7 +1448,7 @@ QSize Declaration::sizeValue() const
else
x[1] = x[0];
QSize size(x[0], x[1]);
- d->parsed = qVariantFromValue<QSize>(size);
+ d->parsed = QVariant::fromValue<QSize>(size);
return size;
}
@@ -1465,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();
@@ -1475,7 +1470,7 @@ QRect Declaration::rectValue() const
if (args.count() != 4)
return QRect();
QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());
- d->parsed = qVariantFromValue<QRect>(rect);
+ d->parsed = QVariant::fromValue<QRect>(rect);
return rect;
}
@@ -1496,10 +1491,10 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const
for (i = 0; i < qMin(d->values.count(), 4); i++) {
ColorData color = parseColorValue(d->values.at(i));
if(color.type == ColorData::Role) {
- v += qVariantFromValue<int>(color.role);
+ v += QVariant::fromValue<int>(color.role);
c[i] = pal.color((QPalette::ColorRole)(color.role));
} else {
- v += qVariantFromValue<QColor>(color.color);
+ v += QVariant::fromValue<QColor>(color.color);
c[i] = color.color;
}
}
@@ -1691,7 +1686,7 @@ QIcon Declaration::iconValue() const
i++;
}
- d->parsed = qVariantFromValue<QIcon>(icon);
+ d->parsed = QVariant::fromValue<QIcon>(icon);
return icon;
}
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index cb2cfd3..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
@@ -178,6 +181,9 @@ enum Property {
OutlineBottomRightRadius,
FontVariant,
TextTransform,
+ QtListNumberPrefix,
+ QtListNumberSuffix,
+ LineHeight,
NumProperties
};
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 24d8faf..f77e237 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -75,6 +75,10 @@
#ifdef Q_OS_SYMBIAN
#include <private/qt_s60_p.h>
#endif
+#ifdef Q_WS_QPA
+#include <QtGui/qplatformscreen_qpa.h>
+#include <QtGui/private/qapplication_p.h>
+#endif
#include <QMutexLocker>
@@ -135,6 +139,9 @@ bool QFontDef::exactMatch(const QFontDef &other) const
QFontDatabase::parseFontName(family, this_foundry, this_family);
QFontDatabase::parseFontName(other.family, other_foundry, other_family);
+ this_family = QFontDatabase::resolveFontFamilyAlias(this_family);
+ other_family = QFontDatabase::resolveFontFamilyAlias(other_family);
+
return (styleHint == other.styleHint
&& styleStrategy == other.styleStrategy
&& weight == other.weight
@@ -172,6 +179,17 @@ Q_GUI_EXPORT int qt_defaultDpiX()
if (!subScreens.isEmpty())
screen = subScreens.at(0);
dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
+#elif defined(Q_WS_QPA)
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ if (pi) {
+ QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0);
+ const QSize screenSize = screen->geometry().size();
+ const QSize physicalSize = screen->physicalSize();
+ dpi = qRound(screenSize.width() / (physicalSize.width() / qreal(25.4)));
+ } else {
+ //PI has not been initialised, or it is being initialised. Give a default dpi
+ dpi = 100;
+ }
#elif defined(Q_OS_SYMBIAN)
dpi = S60->defaultDpiX;
#endif // Q_WS_X11
@@ -200,6 +218,17 @@ Q_GUI_EXPORT int qt_defaultDpiY()
if (!subScreens.isEmpty())
screen = subScreens.at(0);
dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
+#elif defined(Q_WS_QPA)
+ QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ if (pi) {
+ QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0);
+ const QSize screenSize = screen->geometry().size();
+ const QSize physicalSize = screen->physicalSize();
+ dpi = qRound(screenSize.height() / (physicalSize.height() / qreal(25.4)));
+ } else {
+ //PI has not been initialised, or it is being initialised. Give a default dpi
+ dpi = 100;
+ }
#elif defined(Q_OS_SYMBIAN)
dpi = S60->defaultDpiY;
#endif // Q_WS_X11
@@ -354,6 +383,9 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other)
if (! (mask & QFont::StretchResolved))
request.stretch = other->request.stretch;
+ if (! (mask & QFont::HintingPreferenceResolved))
+ request.hintingPreference = other->request.hintingPreference;
+
if (! (mask & QFont::UnderlineResolved))
underline = other->underline;
@@ -888,6 +920,105 @@ int QFont::pointSize() const
}
/*!
+ \since 4.8
+
+ \enum QFont::HintingPreference
+
+ This enum describes the different levels of hinting that can be applied
+ to glyphs to improve legibility on displays where it might be warranted
+ by the density of pixels.
+
+ \value PreferDefaultHinting Use the default hinting level for the target platform.
+ \value PreferNoHinting If possible, render text without hinting the outlines
+ of the glyphs. The text layout will be typographically accurate and
+ scalable, using the same metrics as are used e.g. when printing.
+ \value PreferVerticalHinting If possible, render text with no horizontal hinting,
+ but align glyphs to the pixel grid in the vertical direction. The text will appear
+ crisper on displays where the density is too low to give an accurate rendering
+ of the glyphs. But since the horizontal metrics of the glyphs are unhinted, the text's
+ layout will be scalable to higher density devices (such as printers) without impacting
+ details such as line breaks.
+ \value PreferFullHinting If possible, render text with hinting in both horizontal and
+ vertical directions. The text will be altered to optimize legibility on the target
+ device, but since the metrics will depend on the target size of the text, the positions
+ of glyphs, line breaks, and other typographical detail will not scale, meaning that a
+ text layout may look different on devices with different pixel densities.
+
+ Please note that this enum only describes a preference, as the full range of hinting levels
+ are not supported on all of Qt's supported platforms. The following table details the effect
+ of a given hinting preference on a selected set of target platforms.
+
+ \table
+ \header
+ \o
+ \o PreferDefaultHinting
+ \o PreferNoHinting
+ \o PreferVerticalHinting
+ \o PreferFullHinting
+ \row
+ \o Windows Vista (w/o Platform Update) and earlier
+ \o Full hinting
+ \o Full hinting
+ \o Full hinting
+ \o Full hinting
+ \row
+ \o Windows 7 and Windows Vista (w/Platform Update) and DirectWrite enabled in Qt
+ \o Full hinting
+ \o Vertical hinting
+ \o Vertical hinting
+ \o Full hinting
+ \row
+ \o FreeType
+ \o Operating System setting
+ \o No hinting
+ \o Vertical hinting (light)
+ \o Full hinting
+ \row
+ \o Cocoa on Mac OS X
+ \o No hinting
+ \o No hinting
+ \o No hinting
+ \o No hinting
+ \endtable
+
+ \note Please be aware that altering the hinting preference on Windows is available through
+ the DirectWrite font engine. This is available on Windows Vista after installing the platform
+ update, and on Windows 7. In order to use this extension, configure Qt using -directwrite.
+ The target application will then depend on the availability of DirectWrite on the target
+ system.
+
+*/
+
+/*!
+ \since 4.8
+
+ Set the preference for the hinting level of the glyphs to \a hintingPreference. This is a hint
+ to the underlying font rendering system to use a certain level of hinting, and has varying
+ support across platforms. See the table in the documentation for QFont::HintingPreference for
+ more details.
+
+ The default hinting preference is QFont::PreferDefaultHinting.
+*/
+void QFont::setHintingPreference(HintingPreference hintingPreference)
+{
+ detach();
+
+ d->request.hintingPreference = hintingPreference;
+
+ resolve_mask |= QFont::HintingPreferenceResolved;
+}
+
+/*!
+ \since 4.8
+
+ Returns the currently preferred hinting level for glyphs rendered with this font.
+*/
+QFont::HintingPreference QFont::hintingPreference() const
+{
+ return QFont::HintingPreference(d->request.hintingPreference);
+}
+
+/*!
Sets the point size to \a pointSize. The point size must be
greater than zero.
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 178394b..8dbc746 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -93,6 +93,13 @@ public:
NoFontMerging = 0x8000
};
+ enum HintingPreference {
+ PreferDefaultHinting = 0,
+ PreferNoHinting = 1,
+ PreferVerticalHinting = 2,
+ PreferFullHinting = 3
+ };
+
enum Weight {
Light = 25,
Normal = 50,
@@ -133,22 +140,23 @@ public:
};
enum ResolveProperties {
- FamilyResolved = 0x0001,
- SizeResolved = 0x0002,
- StyleHintResolved = 0x0004,
- StyleStrategyResolved = 0x0008,
- WeightResolved = 0x0010,
- StyleResolved = 0x0020,
- UnderlineResolved = 0x0040,
- OverlineResolved = 0x0080,
- StrikeOutResolved = 0x0100,
- FixedPitchResolved = 0x0200,
- StretchResolved = 0x0400,
- KerningResolved = 0x0800,
- CapitalizationResolved = 0x1000,
- LetterSpacingResolved = 0x2000,
- WordSpacingResolved = 0x4000,
- AllPropertiesResolved = 0x7fff
+ FamilyResolved = 0x0001,
+ SizeResolved = 0x0002,
+ StyleHintResolved = 0x0004,
+ StyleStrategyResolved = 0x0008,
+ WeightResolved = 0x0010,
+ StyleResolved = 0x0020,
+ UnderlineResolved = 0x0040,
+ OverlineResolved = 0x0080,
+ StrikeOutResolved = 0x0100,
+ FixedPitchResolved = 0x0200,
+ StretchResolved = 0x0400,
+ KerningResolved = 0x0800,
+ CapitalizationResolved = 0x1000,
+ LetterSpacingResolved = 0x2000,
+ WordSpacingResolved = 0x4000,
+ HintingPreferenceResolved = 0x8000,
+ AllPropertiesResolved = 0xffff
};
QFont();
@@ -213,6 +221,9 @@ public:
void setCapitalization(Capitalization);
Capitalization capitalization() const;
+ void setHintingPreference(HintingPreference hintingPreference);
+ HintingPreference hintingPreference() const;
+
// is raw mode still needed?
bool rawMode() const;
void setRawMode(bool);
@@ -226,7 +237,10 @@ public:
bool operator<(const QFont &) const;
operator QVariant() const;
bool isCopyOf(const QFont &) const;
-
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QFont &operator=(QFont &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
#ifdef Q_WS_WIN
HFONT handle() const;
@@ -315,6 +329,7 @@ private:
friend class QPainterReplayer;
friend class QPaintBufferEngine;
friend class QCommandLinkButtonPrivate;
+ friend class QFontEngine;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &);
diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp
index b2e5f6e..daf68c0 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/gui/text/qfont_mac.cpp
@@ -42,6 +42,7 @@
#include "qfont.h"
#include "qfont_p.h"
#include "qfontengine_p.h"
+#include "qfontengine_mac_p.h"
#include "qfontinfo.h"
#include "qfontmetrics.h"
#include "qpaintdevice.h"
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index bb69aa1..c1a5048 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -72,7 +72,7 @@ struct QFontDef
: pointSize(-1.0), pixelSize(-1),
styleStrategy(QFont::PreferDefault), styleHint(QFont::AnyStyle),
weight(50), fixedPitch(false), style(QFont::StyleNormal), stretch(100),
- ignorePitch(true)
+ ignorePitch(true), hintingPreference(QFont::PreferDefaultHinting)
#ifdef Q_WS_MAC
,fixedPitchComputed(false)
#endif
@@ -97,8 +97,9 @@ struct QFontDef
uint stretch : 12; // 0-400
uint ignorePitch : 1;
+ uint hintingPreference : 2;
uint fixedPitchComputed : 1; // for Mac OS X only
- int reserved : 16; // for future extensions
+ int reserved : 14; // for future extensions
bool exactMatch(const QFontDef &other) const;
bool operator==(const QFontDef &other) const
@@ -111,6 +112,7 @@ struct QFontDef
&& styleStrategy == other.styleStrategy
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
&& family == other.family
+ && hintingPreference == other.hintingPreference
#ifdef Q_WS_X11
&& addStyle == other.addStyle
#endif
@@ -125,6 +127,7 @@ struct QFontDef
if (styleHint != other.styleHint) return styleHint < other.styleHint;
if (styleStrategy != other.styleStrategy) return styleStrategy < other.styleStrategy;
if (family != other.family) return family < other.family;
+ if (hintingPreference != other.hintingPreference) return hintingPreference < other.hintingPreference;
#ifdef Q_WS_X11
if (addStyle != other.addStyle) return addStyle < other.addStyle;
@@ -192,6 +195,11 @@ public:
QFont smallCapsFont() const { return QFont(smallCapsFontPrivate()); }
QFontPrivate *smallCapsFontPrivate() const;
+ static QFontPrivate *get(const QFont &font)
+ {
+ return font.d.data();
+ }
+
void resolve(uint mask, const QFontPrivate *other);
private:
QFontPrivate &operator=(const QFontPrivate &) { return *this; }
diff --git a/src/gui/text/qfont_qpa.cpp b/src/gui/text/qfont_qpa.cpp
new file mode 100644
index 0000000..ff12da8
--- /dev/null
+++ b/src/gui/text/qfont_qpa.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/QPlatformFontDatabase>
+
+QT_BEGIN_NAMESPACE
+
+void QFont::initialize()
+{
+ QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
+}
+
+void QFont::cleanup()
+{
+ QFontCache::cleanup();
+}
+
+
+/*****************************************************************************
+ QFont member functions
+ *****************************************************************************/
+
+Qt::HANDLE QFont::handle() const
+{
+ return 0;
+}
+
+QString QFont::rawName() const
+{
+ return QLatin1String("unknown");
+}
+
+void QFont::setRawName(const QString &)
+{
+}
+
+QString QFont::defaultFamily() const
+{
+ QString familyName;
+ switch(d->request.styleHint) {
+ case QFont::Times:
+ familyName = QString::fromLatin1("times");
+ case QFont::Courier:
+ case QFont::Monospace:
+ familyName = QString::fromLatin1("monospace");
+ case QFont::Decorative:
+ familyName = QString::fromLatin1("old english");
+ case QFont::Helvetica:
+ case QFont::System:
+ default:
+ familyName = QString::fromLatin1("helvetica");
+ }
+
+ QStringList list = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QFont::StyleHint(d->request.styleHint),QUnicodeTables::Common);
+ if (list.size()) {
+ familyName = list.at(0);
+ }
+ return familyName;
+}
+
+QString QFont::lastResortFamily() const
+{
+ return QString::fromLatin1("helvetica");
+}
+
+QString QFont::lastResortFont() const
+{
+ qFatal("QFont::lastResortFont: Cannot find any reasonable font");
+ // Shut compiler up
+ return QString();
+}
+
+
+QT_END_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 6b612eb..cbe0423 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -50,13 +50,19 @@
#include "private/qunicodetables_p.h"
#include "qfontengine_p.h"
+#ifdef Q_WS_QPA
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/qplatformfontdatabase_qpa.h>
+#include "qabstractfileengine.h"
+#endif
+
#ifdef Q_WS_X11
#include <locale.h>
#endif
#include <stdlib.h>
#include <limits.h>
-#if (defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
+#if (defined(Q_WS_QWS)|| defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
# include <ft2build.h>
# include FT_TRUETYPE_TABLES_H
#endif
@@ -75,8 +81,8 @@
# define FM_DEBUG if (false) qDebug
#endif
-#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
-# define for if(0){}else for
+#if defined(Q_WS_WIN) && !defined(QT_NO_DIRECTWRITE)
+# include <dwrite.h>
#endif
QT_BEGIN_NAMESPACE
@@ -143,7 +149,7 @@ struct QtFontEncoding
uchar pitch : 8;
};
-struct QtFontSize
+struct QtFontSize
{
#ifdef Q_WS_X11
QtFontEncoding *encodings;
@@ -151,10 +157,14 @@ struct QtFontSize
uint yres = 0, uint avgwidth = 0, bool add = false);
unsigned short count : 16;
#endif // Q_WS_X11
+
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
QByteArray fileName;
int fileIndex;
-#endif // defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#endif // defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_QPA)
+ void *handle;
+#endif
unsigned short pixelSize : 16;
};
@@ -230,7 +240,7 @@ struct QtFontStyle
delete [] weightName;
delete [] setwidthName;
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
while (count) {
// bitfield count-- in while condition does not work correctly in mwccsym2
count--;
@@ -240,6 +250,12 @@ struct QtFontStyle
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
pixelSizes[count].fileName.~QByteArray();
#endif
+#if defined (Q_WS_QPA)
+ QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
+ if (integration) { //on shut down there will be some that we don't release.
+ integration->fontDatabase()->releaseHandle(pixelSizes[count].handle);
+ }
+#endif
}
#endif
free(pixelSizes);
@@ -255,7 +271,7 @@ struct QtFontStyle
const char *weightName;
const char *setwidthName;
#endif // Q_WS_X11
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
bool antialiased;
#endif
@@ -305,6 +321,9 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
new (&pixelSizes[count].fileName) QByteArray;
pixelSizes[count].fileIndex = 0;
#endif
+#if defined(Q_WS_QPA)
+ pixelSizes[count].handle = 0;
+#endif
return pixelSizes + (count++);
}
@@ -361,7 +380,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create)
}
-struct QtFontFamily
+struct QtFontFamily
{
enum WritingSystemStatus {
Unknown = 0,
@@ -387,9 +406,12 @@ struct QtFontFamily
fixedPitchComputed(false),
#endif
name(n), count(0), foundries(0)
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
, bogusWritingSystems(false)
#endif
+#if defined(Q_WS_QPA)
+ , askedForFallback(false)
+#endif
{
memset(writingSystems, 0, sizeof(writingSystems));
}
@@ -427,10 +449,13 @@ struct QtFontFamily
int count;
QtFontFoundry **foundries;
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
bool bogusWritingSystems;
QStringList fallbackFamilies;
#endif
+#if defined (Q_WS_QPA)
+ bool askedForFallback;
+#endif
unsigned char writingSystems[QFontDatabase::WritingSystemsCount];
QtFontFoundry *foundry(const QString &f, bool = false);
@@ -475,6 +500,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
// ### copied to tools/makeqpf/qpf2.cpp
#if (defined(Q_WS_QWS) && !defined(QT_NO_FREETYPE)) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
+
// see the Unicode subset bitfields in the MSDN docs
static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
// Any,
@@ -621,13 +647,24 @@ public:
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
, symbianExtras(0)
#endif
+#if defined(Q_WS_WIN) && !defined(QT_NO_DIRECTWRITE)
+ , directWriteFactory(0)
+ , directWriteGdiInterop(0)
+#endif
{ }
+
~QFontDatabasePrivate() {
free();
#if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
if (symbianExtras)
delete symbianExtras;
#endif
+#if defined(Q_WS_WIN) && !defined(QT_NO_DIRECTWRITE)
+ if (directWriteGdiInterop)
+ directWriteGdiInterop->Release();
+ if (directWriteFactory != 0)
+ directWriteFactory->Release();
+#endif
}
QtFontFamily *family(const QString &f, bool = false);
void free() {
@@ -640,8 +677,17 @@ public:
}
int count;
+#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
+ QString systemLang;
+#endif
QtFontFamily **families;
+#if defined(Q_WS_WIN) && !defined(QT_NO_DIRECTWRITE)
+ IDWriteFactory *directWriteFactory;
+ IDWriteGdiInterop *directWriteGdiInterop;
+#endif
+
+
struct ApplicationFont {
QString fileName;
QByteArray data;
@@ -669,7 +715,7 @@ public:
bool loadFromCache(const QString &fontPath);
void addQPF2File(const QByteArray &file);
#endif // Q_WS_QWS
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
void addFont(const QString &familyname, const char *foundryname, int weight,
bool italic, int pixelSize, const QByteArray &file, int fileIndex,
bool antialiased,
@@ -680,10 +726,12 @@ public:
#endif
#if defined(Q_WS_QWS)
QDataStream *stream;
- QStringList fallbackFamilies;
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
QSymbianFontDatabaseExtras *symbianExtras;
#endif
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ QStringList fallbackFamilies;
+#endif
};
void QFontDatabasePrivate::invalidate()
@@ -732,7 +780,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
return families[pos];
}
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
+#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) && !defined(QT_NO_FREETYPE)
void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundryname, int weight, bool italic, int pixelSize,
const QByteArray &file, int fileIndex, bool antialiased,
const QList<QFontDatabase::WritingSystem> &writingSystems)
@@ -965,7 +1013,7 @@ static void match(int script, const QFontDef &request,
const QString &family_name, const QString &foundry_name, int force_encoding_id,
QtFontDesc *desc, const QList<int> &blacklistedFamilies = QList<int>(), bool forceXLFD=false);
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
+#if defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA)
static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef)
{
fontDef->family = desc.family->name;
@@ -994,7 +1042,7 @@ static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDe
#endif
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) || defined(Q_WS_QPA)
static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
{
// look for the requested font in the engine data cache
@@ -1055,9 +1103,17 @@ QT_BEGIN_INCLUDE_NAMESPACE
# include "qfontdatabase_win.cpp"
#elif defined(Q_WS_QWS)
# include "qfontdatabase_qws.cpp"
+#elif defined(Q_WS_QPA)
+# include "qfontdatabase_qpa.cpp"
#elif defined(Q_OS_SYMBIAN)
# include "qfontdatabase_s60.cpp"
#endif
+#if !defined(Q_WS_X11)
+QString QFontDatabase::resolveFontFamilyAlias(const QString &family)
+{
+ return family;
+}
+#endif
QT_END_INCLUDE_NAMESPACE
static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey)
@@ -1340,6 +1396,7 @@ static void match(int script, const QFontDef &request,
styleKey.stretch = request.stretch;
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
+
FM_DEBUG("QFontDatabase::match\n"
" request:\n"
" family: %s [%s], script: %d\n"
@@ -2429,10 +2486,12 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem)
sample += QChar(0x4f8b);
break;
case Japanese:
- sample += QChar(0x3050);
- sample += QChar(0x3060);
- sample += QChar(0x30b0);
- sample += QChar(0x30c0);
+ sample += QChar(0x30b5);
+ sample += QChar(0x30f3);
+ sample += QChar(0x30d7);
+ sample += QChar(0x30eb);
+ sample += QChar(0x3067);
+ sample += QChar(0x3059);
break;
case Korean:
sample += QChar(0xac00);
@@ -2485,7 +2544,7 @@ void QFontDatabase::createDatabase()
{ initializeDb(); }
// used from qfontengine_ft.cpp
-QByteArray qt_fontdata_from_index(int index)
+Q_GUI_EXPORT QByteArray qt_fontdata_from_index(int index)
{
QMutexLocker locker(fontDatabaseMutex());
return privateDb()->applicationFonts.value(index).data;
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 69a2484..ae1130e 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -152,7 +152,8 @@ public:
private:
static void createDatabase();
static void parseFontName(const QString &name, QString &foundry, QString &family);
-#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+ static QString resolveFontFamilyAlias(const QString &family);
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
static QFontEngine *findFont(int script, const QFontPrivate *fp, const QFontDef &request);
#endif
static void load(const QFontPrivate *d, int script);
@@ -167,6 +168,7 @@ private:
friend class QFontEngineMultiXLFD;
friend class QFontEngineMultiQWS;
friend class QFontEngineMultiS60;
+ friend class QFontEngineMultiQPA;
QFontDatabasePrivate *d;
};
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index 6dfec28..ad2c1b2 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -45,6 +45,8 @@
#include <qabstractfileengine.h>
#include <stdlib.h>
#include <qendian.h>
+#include <private/qfontengine_coretext_p.h>
+#include <private/qfontengine_mac_p.h>
QT_BEGIN_NAMESPACE
@@ -293,8 +295,12 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
// previous versions
family_list << QApplication::font().defaultFamily();
+#if defined(QT_MAC_USE_COCOA)
+ QCFString fontName = NULL, familyName = NULL;
+#else
ATSFontFamilyRef familyRef = 0;
ATSFontRef fontRef = 0;
+#endif
QMutexLocker locker(fontDatabaseMutex());
QFontDatabasePrivate *db = privateDb();
@@ -304,26 +310,20 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
for (int k = 0; k < db->count; ++k) {
if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
QByteArray family_name = db->families[k]->name.toUtf8();
+#if defined(QT_MAC_USE_COCOA)
+ QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL);
+ if (ctFont) {
+ fontName = CTFontCopyFullName(ctFont);
+ familyName = CTFontCopyFamilyName(ctFont);
+ goto FamilyFound;
+ }
+#else
familyRef = ATSFontFamilyFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
if (familyRef) {
fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
goto FamilyFound;
- } else {
-#if defined(QT_MAC_USE_COCOA)
- // ATS and CT disagrees on what the family name should be,
- // use CT to look up the font if ATS fails.
- QCFString familyName = QString::fromAscii(family_name);
- QCFType<CTFontRef> CTfontRef = CTFontCreateWithName(familyName, 12, NULL);
- QCFType<CTFontDescriptorRef> fontDescriptor = CTFontCopyFontDescriptor(CTfontRef);
- QCFString displayName = (CFStringRef)CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontDisplayNameAttribute);
-
- familyRef = ATSFontFamilyFindFromName(displayName, kATSOptionFlagsDefault);
- if (familyRef) {
- fontRef = ATSFontFindFromName(displayName, kATSOptionFlagsDefault);
- goto FamilyFound;
- }
-#endif
}
+#endif
}
}
}
@@ -331,92 +331,18 @@ FamilyFound:
//fill in the engine's font definition
QFontDef fontDef = d->request; //copy..
if(fontDef.pointSize < 0)
- fontDef.pointSize = qt_mac_pointsize(fontDef, d->dpi);
+ fontDef.pointSize = qt_mac_pointsize(fontDef, d->dpi);
else
- fontDef.pixelSize = qt_mac_pixelsize(fontDef, d->dpi);
-#if 0
- ItemCount name_count;
- if(ATSUCountFontNames(fontID, &name_count) == noErr && name_count) {
- ItemCount actualName_size;
- if(ATSUGetIndFontName(fontID, 0, 0, 0, &actualName_size, 0, 0, 0, 0) == noErr && actualName_size) {
- QByteArray actualName(actualName_size);
- if(ATSUGetIndFontName(fontID, 0, actualName_size, actualName.data(), &actualName_size, 0, 0, 0, 0) == noErr && actualName_size)
- fontDef.family = QString::fromUtf8(actualName);
- }
- }
-#else
- {
- QCFString actualName;
- if(ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr)
- fontDef.family = actualName;
- }
-#endif
+ fontDef.pixelSize = qt_mac_pixelsize(fontDef, d->dpi);
#ifdef QT_MAC_USE_COCOA
- QFontEngine *engine = new QCoreTextFontEngineMulti(familyRef, fontRef, fontDef, d->kerning);
-#elif 1
- QFontEngine *engine = new QFontEngineMacMulti(familyRef, fontRef, fontDef, d->kerning);
+ fontDef.family = familyName;
+ QFontEngine *engine = new QCoreTextFontEngineMulti(fontName, fontDef, d->kerning);
#else
- ATSFontFamilyRef atsFamily = familyRef;
- ATSFontFamilyRef atsFontRef = fontRef;
-
- FMFont fontID;
- FMFontFamily fmFamily;
- FMFontStyle fntStyle = 0;
- fmFamily = FMGetFontFamilyFromATSFontFamilyRef(atsFamily);
- if (fmFamily == kInvalidFontFamily) {
- // Use the ATSFont then...
- fontID = FMGetFontFromATSFontRef(atsFontRef);
- } else {
- if (fontDef.weight >= QFont::Bold)
- fntStyle |= ::bold;
- if (fontDef.style != QFont::StyleNormal)
- fntStyle |= ::italic;
-
- FMFontStyle intrinsicStyle;
- FMFont fnt = 0;
- if (FMGetFontFromFontFamilyInstance(fmFamily, fntStyle, &fnt, &intrinsicStyle) == noErr)
- fontID = FMGetATSFontRefFromFont(fnt);
- }
-
- OSStatus status;
-
- const int maxAttributeCount = 5;
- ATSUAttributeTag tags[maxAttributeCount + 1];
- ByteCount sizes[maxAttributeCount + 1];
- ATSUAttributeValuePtr values[maxAttributeCount + 1];
- int attributeCount = 0;
-
- Fixed size = FixRatio(fontDef.pixelSize, 1);
- tags[attributeCount] = kATSUSizeTag;
- sizes[attributeCount] = sizeof(size);
- values[attributeCount] = &size;
- ++attributeCount;
-
- tags[attributeCount] = kATSUFontTag;
- sizes[attributeCount] = sizeof(fontID);
- values[attributeCount] = &fontID;
- ++attributeCount;
-
- CGAffineTransform transform = CGAffineTransformIdentity;
- if (fontDef.stretch != 100) {
- transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
- tags[attributeCount] = kATSUFontMatrixTag;
- sizes[attributeCount] = sizeof(transform);
- values[attributeCount] = &transform;
- ++attributeCount;
- }
-
- ATSUStyle style;
- status = ATSUCreateStyle(&style);
- Q_ASSERT(status == noErr);
-
- Q_ASSERT(attributeCount < maxAttributeCount + 1);
- status = ATSUSetAttributes(style, attributeCount, tags, sizes, values);
- Q_ASSERT(status == noErr);
-
- QFontEngine *engine = new QFontEngineMac(style, fontID, fontDef, /*multiEngine*/ 0);
- ATSUDisposeStyle(style);
+ QCFString actualName;
+ if (ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr)
+ fontDef.family = actualName;
+ QFontEngine *engine = new QFontEngineMacMulti(familyRef, fontRef, fontDef, d->kerning);
#endif
d->engineData->engine = engine;
engine->ref.ref(); //a ref for the engineData->engine
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
new file mode 100644
index 0000000..7bcce56
--- /dev/null
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -0,0 +1,394 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlibraryinfo.h"
+#include <QtCore/qsettings.h>
+
+#include "qfontengine_qpa_p.h"
+#include "qplatformdefs.h"
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/qplatformfontdatabase_qpa.h>
+
+#include <QtCore/qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &foundryname, int weight,
+ QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize,
+ const QSupportedWritingSystems &writingSystems, void *handle)
+{
+ QFontDatabasePrivate *d = privateDb();
+ // qDebug() << "Adding font" << familyname << weight << italic << pixelSize << file << fileIndex << antialiased;
+ QtFontStyle::Key styleKey;
+ styleKey.style = style;
+ styleKey.weight = weight;
+ styleKey.stretch = stretch;
+ QtFontFamily *f = d->family(familyName, true);
+
+ for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
+ if (writingSystems.supported(QFontDatabase::WritingSystem(i))) {
+ f->writingSystems[i] = QtFontFamily::Supported;
+ } else {
+ f->writingSystems[i] = QtFontFamily::Unsupported;
+ }
+ }
+
+ QtFontFoundry *foundry = f->foundry(foundryname, true);
+ QtFontStyle *fontStyle = foundry->style(styleKey, true);
+ fontStyle->smoothScalable = scalable;
+ fontStyle->antialiased = antialiased;
+ QtFontSize *size = fontStyle->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true);
+ size->handle = handle;
+}
+
+static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script)
+{
+ QStringList retList = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
+ QFontDatabasePrivate *db = privateDb();
+
+ QStringList::iterator i;
+ for (i = retList.begin(); i != retList.end(); ++i) {
+ bool contains = false;
+ for (int j = 0; j < db->count; j++) {
+ QtFontFamily *qtFamily = db->families[j];
+ if (!(i->compare(qtFamily->name,Qt::CaseInsensitive))) {
+ contains = true;
+ break;
+ }
+ }
+ if (!contains) {
+ i = retList.erase(i);
+ i--;
+ }
+ }
+ return retList;
+}
+
+static void initializeDb()
+{
+ static int initialized = false;
+
+ if (!initialized) {
+ //init by asking for the platformfontdb for the first time :)
+ QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
+ initialized = true;
+ }
+}
+
+#ifndef QT_NO_SETTINGS
+// called from qapplication_qws.cpp
+void qt_applyFontDatabaseSettings(const QSettings &settings)
+{
+ initializeDb();
+ QFontDatabasePrivate *db = privateDb();
+ for (int i = 0; i < db->count; ++i) {
+ QtFontFamily *family = db->families[i];
+ if (settings.contains(family->name))
+ family->fallbackFamilies = settings.value(family->name).toStringList();
+ }
+
+ if (settings.contains(QLatin1String("Global Fallbacks")))
+ db->fallbackFamilies = settings.value(QLatin1String("Global Fallbacks")).toStringList();
+}
+#endif // QT_NO_SETTINGS
+
+static inline void load(const QString & = QString(), int = -1)
+{
+ initializeDb();
+}
+
+static
+QFontEngine *loadSingleEngine(int script,
+ const QFontDef &request,
+ QtFontFoundry *foundry,
+ QtFontStyle *style, QtFontSize *size)
+{
+ Q_UNUSED(foundry);
+
+ Q_ASSERT(size);
+ int pixelSize = size->pixelSize;
+ if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE))
+ pixelSize = request.pixelSize;
+
+ QFontDef def = request;
+ def.pixelSize = pixelSize;
+
+ QFontCache::Key key(def,script);
+ QFontEngine *engine = QFontCache::instance()->findEngine(key);
+ if (!engine) {
+ QPlatformFontDatabase *pfdb = QApplicationPrivate::platformIntegration()->fontDatabase();
+ engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle);
+ if (engine) {
+ QFontCache::Key key(def,script);
+ QFontCache::instance()->instance()->insertEngine(key,engine);
+ }
+ }
+ return engine;
+}
+
+static
+QFontEngine *loadEngine(int script, const QFontDef &request,
+ QtFontFamily *family, QtFontFoundry *foundry,
+ QtFontStyle *style, QtFontSize *size)
+{
+
+ QFontEngine *engine = loadSingleEngine(script, request, foundry, style, size);
+ //make sure that the db has all fallback families
+ if (engine
+ && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol ) {
+
+ if (family && !family->askedForFallback) {
+ QFont::Style fontStyle = QFont::Style(style->key.style);
+ QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
+ if (styleHint == QFont::AnyStyle && request.fixedPitch)
+ styleHint = QFont::TypeWriter;
+ family->fallbackFamilies = fallbackFamilies(family->name,fontStyle,styleHint,QUnicodeTables::Script(script));
+
+ family->askedForFallback = true;
+ }
+
+ QStringList fallbacks = privateDb()->fallbackFamilies;
+ if (family && !family->fallbackFamilies.isEmpty())
+ fallbacks = family->fallbackFamilies;
+
+ engine = new QFontEngineMultiQPA(engine, script, fallbacks);
+ }
+
+ return engine;
+}
+
+static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
+{
+ QFontDatabasePrivate *db = privateDb();
+
+ fnt->families = QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName);
+
+ db->reregisterAppFonts = true;
+}
+
+bool QFontDatabase::removeApplicationFont(int handle)
+{
+ QMutexLocker locker(fontDatabaseMutex());
+
+ QFontDatabasePrivate *db = privateDb();
+ if (handle < 0 || handle >= db->applicationFonts.count())
+ return false;
+
+ db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont();
+
+ db->reregisterAppFonts = true;
+ db->invalidate();
+ return true;
+}
+
+bool QFontDatabase::removeAllApplicationFonts()
+{
+ QMutexLocker locker(fontDatabaseMutex());
+
+ QFontDatabasePrivate *db = privateDb();
+ if (db->applicationFonts.isEmpty())
+ return false;
+
+ db->applicationFonts.clear();
+ db->invalidate();
+ return true;
+}
+
+bool QFontDatabase::supportsThreadedFontRendering()
+{
+ return true;
+}
+
+/*!
+ \internal
+*/
+QFontEngine *
+QFontDatabase::findFont(int script, const QFontPrivate *fp,
+ const QFontDef &request)
+{
+ QMutexLocker locker(fontDatabaseMutex());
+
+ const int force_encoding_id = -1;
+
+ if (!privateDb()->count)
+ initializeDb();
+
+ QFontEngine *engine;
+ QFontCache::Key key(request, script);
+ engine = QFontCache::instance()->findEngine(key);
+ if (engine) {
+ qDebug() << "Cache hit level 1";
+ return engine;
+ }
+
+ QString family_name, foundry_name;
+
+ parseFontName(request.family, foundry_name, family_name);
+
+ if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
+ engine =new QTestFontEngine(request.pixelSize);
+ engine->fontDef = request;
+ }
+
+ QtFontDesc desc;
+ match(script, request, family_name, foundry_name, force_encoding_id, &desc);
+ if (desc.family != 0 && desc.foundry != 0 && desc.style != 0) {
+ engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
+ } else {
+ FM_DEBUG(" NO MATCH FOUND\n");
+ }
+
+ if (engine) {
+ initFontDef(desc, request, &engine->fontDef);
+
+ if (fp) {
+ QFontDef def = request;
+ if (def.family.isEmpty()) {
+ def.family = fp->request.family;
+ def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
+ }
+ }
+ }
+
+ if (!engine) {
+ if (!request.family.isEmpty()) {
+ QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QFont::StyleHint(request.styleHint),QUnicodeTables::Script(script));
+ for (int i = 0; i < fallbacks.size(); i++) {
+ QFontDef def = request;
+ def.family = fallbacks.at(i);
+ QFontCache::Key key(def,script);
+ engine = QFontCache::instance()->findEngine(key);
+ if (!engine) {
+ QtFontDesc desc;
+ match(script, def, def.family, QLatin1String(""), 0, &desc);
+ if (desc.family == 0 && desc.foundry == 0 && desc.style == 0) {
+ continue;
+ }
+ engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size);
+ if (engine) {
+ initFontDef(desc, def, &engine->fontDef);
+ break;
+ }
+ }
+ }
+ }
+
+ if (!engine)
+ engine = new QFontEngineBox(request.pixelSize);
+
+ FM_DEBUG("returning box engine");
+ }
+
+ if (fp && fp->dpi > 0) {
+ engine->fontDef.pointSize = qreal(double((engine->fontDef.pixelSize * 72) / fp->dpi));
+ } else {
+ engine->fontDef.pointSize = request.pointSize;
+ }
+
+ return engine;
+}
+
+void QFontDatabase::load(const QFontPrivate *d, int script)
+{
+ QFontDef req = d->request;
+
+ if (req.pixelSize == -1) {
+ req.pixelSize = floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100;
+ req.pixelSize = qRound(req.pixelSize);
+ }
+ if (req.pointSize < 0)
+ req.pointSize = req.pixelSize*72.0/d->dpi;
+ if (req.weight == 0)
+ req.weight = QFont::Normal;
+ if (req.stretch == 0)
+ req.stretch = 100;
+
+ QFontCache::Key key(req, script);
+
+ if (!d->engineData)
+ getEngineData(d, key);
+
+ // the cached engineData could have already loaded the engine we want
+ if (d->engineData->engines[script])
+ return;
+
+ QFontEngine *fe = QFontCache::instance()->findEngine(key);
+
+ // list of families to try
+ QStringList family_list;
+
+ if (!req.family.isEmpty()) {
+ family_list = familyList(req);
+
+ // add the default family
+ QString defaultFamily = QApplication::font().family();
+ if (! family_list.contains(defaultFamily))
+ family_list << defaultFamily;
+
+ }
+
+ // null family means find the first font matching the specified script
+ family_list << QString();
+
+ QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
+ for (; !fe && it != end; ++it) {
+ req.family = *it;
+
+ fe = QFontDatabase::findFont(script, d, req);
+ if (fe && (fe->type()==QFontEngine::Box) && !req.family.isEmpty())
+ fe = 0;
+ }
+
+ if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) {
+ for (int i = 0; i < QUnicodeTables::ScriptCount; ++i) {
+ if (!d->engineData->engines[i]) {
+ d->engineData->engines[i] = fe;
+ fe->ref.ref();
+ }
+ }
+ } else {
+ d->engineData->engines[script] = fe;
+ fe->ref.ref();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index a0126f1..d076de0 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -40,8 +40,10 @@
****************************************************************************/
#include "qdir.h"
+#if defined(Q_WS_QWS)
#include "qscreen_qws.h" //so we can check for rotation
#include "qwindowsystem_qws.h"
+#endif
#include "qlibraryinfo.h"
#include "qabstractfileengine.h"
#include <QtCore/qsettings.h>
@@ -153,7 +155,11 @@ extern QString qws_fontCacheDir();
#ifndef QT_FONTS_ARE_RESOURCES
bool QFontDatabasePrivate::loadFromCache(const QString &fontPath)
{
+#ifdef Q_WS_QWS
const bool weAreTheServer = QWSServer::instance();
+#else
+ const bool weAreTheServer = true; // assume single-process
+#endif
QString fontDirFile = fontPath + QLatin1String("/fontdir");
@@ -382,12 +388,14 @@ static void initializeDb()
}
#endif
+#ifndef QT_NO_QWS_QPF2
QDir dir(fontpath, QLatin1String("*.qpf2"));
for (int i = 0; i < int(dir.count()); ++i) {
const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
//qDebug() << "looking at" << file;
db->addQPF2File(file);
}
+#endif
#endif //QT_FONTS_ARE_RESOURCES
@@ -688,6 +696,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp,
{
QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
style, size));
+#ifndef QT_NO_QWS_QPF
if (!engine.isNull()
&& script == QUnicodeTables::Common
&& !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
@@ -701,6 +710,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp,
engine.take();
engine.reset(fe);
}
+#endif
return engine.take();
}
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 97426a8..6d3970e 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -464,6 +464,7 @@ void QFontEngineMultiS60::loadEngine(int at)
Q_ASSERT(engines[at]);
}
+#ifdef QT_NO_FREETYPE
static bool registerScreenDeviceFont(int screenDeviceFontIndex,
const QSymbianFontDatabaseExtrasImplementation *dbExtras)
{
@@ -525,6 +526,7 @@ static bool registerScreenDeviceFont(int screenDeviceFontIndex,
family->writingSystems[system] = QtFontFamily::Supported;
return true;
}
+#endif
static void initializeDb()
{
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index e2c5116..8279195 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -49,6 +49,11 @@
#include "qabstractfileengine.h"
#include "qendian.h"
+#if !defined(QT_NO_DIRECTWRITE)
+# include "qsettings.h"
+# include "qfontenginedirectwrite_p.h"
+#endif
+
#ifdef Q_OS_WINCE
# include <QTemporaryFile>
#endif
@@ -542,6 +547,65 @@ static void initFontInfo(QFontEngineWin *fe, const QFontDef &request, const QFon
}
}
+#if !defined(QT_NO_DIRECTWRITE)
+static void initFontInfo(QFontEngineDirectWrite *fe, const QFontDef &request,
+ const QFontPrivate *fp, IDWriteFont *font)
+{
+ fe->fontDef = request;
+
+ IDWriteFontFamily *fontFamily = NULL;
+ HRESULT hr = font->GetFontFamily(&fontFamily);
+
+ IDWriteLocalizedStrings *familyNames = NULL;
+ if (SUCCEEDED(hr))
+ hr = fontFamily->GetFamilyNames(&familyNames);
+
+ UINT32 index = 0;
+ BOOL exists = false;
+
+ wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
+
+ if (SUCCEEDED(hr)) {
+ int defaultLocaleSuccess = GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH);
+
+ if (defaultLocaleSuccess)
+ hr = familyNames->FindLocaleName(localeName, &index, &exists);
+
+ if (SUCCEEDED(hr) && !exists)
+ hr = familyNames->FindLocaleName(L"en-us", &index, &exists);
+ }
+
+ if (!exists)
+ index = 0;
+
+ UINT32 length = 0;
+ if (SUCCEEDED(hr))
+ hr = familyNames->GetStringLength(index, &length);
+
+ wchar_t *name = new (std::nothrow) wchar_t[length+1];
+ if (name == NULL)
+ hr = E_OUTOFMEMORY;
+
+ // Get the family name.
+ if (SUCCEEDED(hr))
+ hr = familyNames->GetString(index, name, length + 1);
+
+ if (SUCCEEDED(hr))
+ fe->fontDef.family = QString::fromWCharArray(name);
+
+ delete[] name;
+ if (familyNames != NULL)
+ familyNames->Release();
+
+ if (FAILED(hr))
+ qErrnoWarning(hr, "initFontInfo: Failed to get family name");
+
+ if (fe->fontDef.pointSize < 0)
+ fe->fontDef.pointSize = fe->fontDef.pixelSize * 72. / fp->dpi;
+ else if (fe->fontDef.pixelSize == -1)
+ fe->fontDef.pixelSize = qRound(fe->fontDef.pointSize * fp->dpi / 72.);
+}
+#endif
static const char *other_tryFonts[] = {
"Arial",
@@ -595,6 +659,14 @@ static const char *kr_tryFonts[] = {
static const char **tryFonts = 0;
+#if !defined(QT_NO_DIRECTWRITE)
+static QString fontNameSubstitute(const QString &familyName)
+{
+ QLatin1String key("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\"
+ "FontSubstitutes");
+ return QSettings(key, QSettings::NativeFormat).value(familyName, familyName).toString();
+}
+#endif
static inline HFONT systemFont()
{
@@ -629,6 +701,15 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
HFONT hfont = 0;
+
+#if !defined(QT_NO_DIRECTWRITE)
+ bool useDirectWrite = (request.hintingPreference == QFont::PreferNoHinting)
+ || (request.hintingPreference == QFont::PreferVerticalHinting);
+ IDWriteFont *directWriteFont = 0;
+#else
+ bool useDirectWrite = false;
+#endif
+
if (fp->rawMode) { // will choose a stock font
int f, deffnt = SYSTEM_FONT;
QString fam = desc->family->name.toLower();
@@ -745,6 +826,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
fam = QLatin1String("Courier New");
memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded
+
hfont = CreateFontIndirect(&lf);
if (!hfont)
qErrnoWarning("QFontEngine::loadEngine: CreateFontIndirect failed");
@@ -759,52 +841,120 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
res = GetTextMetrics(hdc, &tm);
avWidth = tm.tmAveCharWidth;
ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE;
-
SelectObject(hdc, oldObj);
- if (hfont && (!ttf || request.stretch != 100)) {
- DeleteObject(hfont);
- if (!res)
- qErrnoWarning("QFontEngine::loadEngine: GetTextMetrics failed");
- lf.lfWidth = avWidth * request.stretch/100;
- hfont = CreateFontIndirect(&lf);
- if (!hfont)
- qErrnoWarning("QFontEngine::loadEngine: CreateFontIndirect with stretch failed");
- }
+ if (!ttf || !useDirectWrite) {
+ useDirectWrite = false;
+
+ if (hfont && (!ttf || request.stretch != 100)) {
+ DeleteObject(hfont);
+ if (!res)
+ qErrnoWarning("QFontEngine::loadEngine: GetTextMetrics failed");
+ lf.lfWidth = avWidth * request.stretch/100;
+ hfont = CreateFontIndirect(&lf);
+ if (!hfont)
+ qErrnoWarning("QFontEngine::loadEngine: CreateFontIndirect with stretch failed");
+ }
#ifndef Q_WS_WINCE
- if (hfont == 0) {
- hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- stockFont = true;
- }
+ if (hfont == 0) {
+ hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
+ stockFont = true;
+ }
#else
- if (hfont == 0) {
- hfont = (HFONT)GetStockObject(SYSTEM_FONT);
- stockFont = true;
+ if (hfont == 0) {
+ hfont = (HFONT)GetStockObject(SYSTEM_FONT);
+ stockFont = true;
+ }
+#endif
+
+ }
+
+#if !defined(QT_NO_DIRECTWRITE)
+ else {
+ // Default to false for DirectWrite (and re-enable once/if everything
+ // turns out okay)
+ useDirectWrite = false;
+
+ QFontDatabasePrivate *db = privateDb();
+ if (db->directWriteFactory == 0) {
+ HRESULT hr = DWriteCreateFactory(
+ DWRITE_FACTORY_TYPE_SHARED,
+ __uuidof(IDWriteFactory),
+ reinterpret_cast<IUnknown **>(&db->directWriteFactory)
+ );
+ if (FAILED(hr)) {
+ qErrnoWarning("QFontEngine::loadEngine: DWriteCreateFactory failed");
+ } else {
+ hr = db->directWriteFactory->GetGdiInterop(&db->directWriteGdiInterop);
+ if (FAILED(hr))
+ qErrnoWarning("QFontEngine::loadEngine: GetGdiInterop failed");
+ }
+ }
+
+ if (db->directWriteGdiInterop != 0) {
+ QString nameSubstitute = fontNameSubstitute(QString::fromWCharArray(lf.lfFaceName));
+ memcpy(lf.lfFaceName, nameSubstitute.utf16(),
+ sizeof(wchar_t) * qMin(nameSubstitute.length() + 1, LF_FACESIZE));
+
+ HRESULT hr = db->directWriteGdiInterop->CreateFontFromLOGFONT(
+ &lf,
+ &directWriteFont);
+ if (FAILED(hr)) {
+ qErrnoWarning("QFontEngine::loadEngine: CreateFontFromLOGFONT failed "
+ "for %ls (0x%lx)",
+ lf.lfFaceName, hr);
+ } else {
+ DeleteObject(hfont);
+ useDirectWrite = true;
+ }
+ }
}
#endif
}
- QFontEngineWin *few = new QFontEngineWin(font_name, hfont, stockFont, lf);
-
- if (preferClearTypeAA)
- few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
-
- // Also check for OpenType tables when using complex scripts
- // ### TODO: This only works for scripts that require OpenType. More generally
- // for scripts that do not require OpenType we should just look at the list of
- // supported writing systems in the font's OS/2 table.
- if (scriptRequiresOpenType(script)) {
- HB_Face hbFace = few->harfbuzzFace();
- if (!hbFace || !hbFace->supported_scripts[script]) {
- FM_DEBUG(" OpenType support missing for script\n");
- delete few;
- return 0;
+
+ QFontEngine *fe = 0;
+ if (!useDirectWrite) {
+ QFontEngineWin *few = new QFontEngineWin(font_name, hfont, stockFont, lf);
+ if (preferClearTypeAA)
+ few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
+
+ // Also check for OpenType tables when using complex scripts
+ // ### TODO: This only works for scripts that require OpenType. More generally
+ // for scripts that do not require OpenType we should just look at the list of
+ // supported writing systems in the font's OS/2 table.
+ if (scriptRequiresOpenType(script)) {
+ HB_Face hbFace = few->harfbuzzFace();
+ if (!hbFace || !hbFace->supported_scripts[script]) {
+ FM_DEBUG(" OpenType support missing for script\n");
+ delete few;
+ return 0;
+ }
}
+
+ initFontInfo(few, request, fp);
+ fe = few;
}
- QFontEngine *fe = few;
- initFontInfo(few, request, fp);
+#if !defined(QT_NO_DIRECTWRITE)
+ else {
+ QFontDatabasePrivate *db = privateDb();
+ QFontEngineDirectWrite *fedw = new QFontEngineDirectWrite(font_name,
+ db->directWriteFactory,
+ db->directWriteGdiInterop,
+ directWriteFont,
+ request.pixelSize);
+
+ initFontInfo(fedw, request, fp, directWriteFont);
+
+ fe = fedw;
+ }
+
+ if (directWriteFont != 0)
+ directWriteFont->Release();
+#endif
+
if(script == QUnicodeTables::Common
&& !(request.styleStrategy & QFont::NoFontMerging)
&& !(desc->family->writingSystems[QFontDatabase::Symbol] & QtFontFamily::Supported)) {
@@ -836,7 +986,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
list << QLatin1String(*tf);
++tf;
}
- QFontEngine *mfe = new QFontEngineMultiWin(few, list);
+ QFontEngine *mfe = new QFontEngineMultiWin(fe, list);
mfe->fontDef = fe->fontDef;
fe = mfe;
}
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index a4a5665..0c0c4c8 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -746,6 +746,7 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
QFontDef fontDef;
fontDef.styleStrategy = request.styleStrategy;
+ fontDef.hintingPreference = request.hintingPreference;
FcChar8 *value = 0;
if (FcPatternGetString(pattern, FC_FAMILY, 0, &value) == FcResultMatch) {
fontDef.family = QString::fromUtf8(reinterpret_cast<const char *>(value));
@@ -1018,6 +1019,13 @@ static void loadFontConfig()
QFontDatabasePrivate *db = privateDb();
FcFontSet *fonts;
+ FcPattern *pattern = FcPatternCreate();
+ FcDefaultSubstitute(pattern);
+ FcChar8 *lang = 0;
+ if (FcPatternGetString(pattern, FC_LANG, 0, &lang) == FcResultMatch)
+ db->systemLang = QString::fromUtf8((const char *) lang);
+ FcPatternDestroy(pattern);
+
QString familyName;
FcChar8 *value = 0;
int weight_value;
@@ -1455,6 +1463,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
weight_value = FC_WEIGHT_DEMIBOLD;
else if (request.weight < (QFont::Bold + QFont::Black) / 2)
weight_value = FC_WEIGHT_BOLD;
+ FcPatternDel(pattern, FC_WEIGHT);
FcPatternAddInteger(pattern, FC_WEIGHT, weight_value);
int slant_value = FC_SLANT_ROMAN;
@@ -1462,20 +1471,25 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
slant_value = FC_SLANT_ITALIC;
else if (request.style == QFont::StyleOblique)
slant_value = FC_SLANT_OBLIQUE;
+ FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, slant_value);
double size_value = qMax(qreal(1.), request.pixelSize);
+ FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value);
int stretch = request.stretch;
if (!stretch)
stretch = 100;
+ FcPatternDel(pattern, FC_WIDTH);
FcPatternAddInteger(pattern, FC_WIDTH, stretch);
if (X11->display && QX11Info::appDepth(screen) <= 8) {
+ FcPatternDel(pattern, FC_ANTIALIAS);
// can't do antialiasing on 8bpp
FcPatternAddBool(pattern, FC_ANTIALIAS, false);
} else if (request.styleStrategy & (QFont::PreferAntialias|QFont::NoAntialias)) {
+ FcPatternDel(pattern, FC_ANTIALIAS);
FcPatternAddBool(pattern, FC_ANTIALIAS,
!(request.styleStrategy & QFont::NoAntialias));
}
@@ -1484,6 +1498,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD
Q_ASSERT(script < QUnicodeTables::ScriptCount);
FcLangSet *ls = FcLangSetCreate();
FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
+ FcPatternDel(pattern, FC_LANG);
FcPatternAddLangSet(pattern, FC_LANG, ls);
FcLangSetDestroy(ls);
}
@@ -1958,17 +1973,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);
@@ -2030,6 +2034,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
int count = 0;
QStringList families;
+ QFontDatabasePrivate *db = privateDb();
FcPattern *pattern = 0;
do {
@@ -2041,8 +2046,19 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
FcPatternDel(pattern, FC_FILE);
FcPatternAddString(pattern, FC_FILE, (const FcChar8 *)fnt->fileName.toUtf8().constData());
- FcChar8 *fam = 0;
- if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) {
+ FcChar8 *fam = 0, *familylang = 0;
+ int i, n = 0;
+ for (i = 0; ; i++) {
+ if (FcPatternGetString(pattern, FC_FAMILYLANG, i, &familylang) != FcResultMatch)
+ break;
+ QString familyLang = QString::fromUtf8((const char *) familylang);
+ if (familyLang.compare(db->systemLang, Qt::CaseInsensitive) == 0) {
+ n = i;
+ break;
+ }
+ }
+
+ if (FcPatternGetString(pattern, FC_FAMILY, n, &fam) == FcResultMatch) {
QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam));
families << family;
}
@@ -2105,4 +2121,26 @@ bool QFontDatabase::supportsThreadedFontRendering()
#endif
}
+QString QFontDatabase::resolveFontFamilyAlias(const QString &family)
+{
+#if defined(QT_NO_FONTCONFIG)
+ return family;
+#else
+ FcPattern *pattern = FcPatternCreate();
+ if (!pattern)
+ return family;
+
+ FcPatternAddString(pattern, FC_FAMILY, (const FcChar8 *) family.toUtf8().data());
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ FcChar8 *familyAfterSubstitution;
+ FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution);
+ QString resolved = QString::fromUtf8((const char *) familyAfterSubstitution);
+ FcPatternDestroy(pattern);
+
+ return resolved;
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 44346d1..3adf4eb 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -184,10 +184,6 @@ QFontEngine::QFontEngine()
QFontEngine::~QFontEngine()
{
- for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(),
- end = m_glyphCaches.constEnd(); it != end; ++it) {
- delete it->cache;
- }
m_glyphCaches.clear();
qHBFreeFace(hbFace);
}
@@ -241,6 +237,24 @@ glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix
return metrics;
}
+QFont QFontEngine::createExplicitFont() const
+{
+ return createExplicitFontWithName(fontDef.family);
+}
+
+QFont QFontEngine::createExplicitFontWithName(const QString &familyName) const
+{
+ QFont font(familyName);
+ font.setStyleStrategy(QFont::NoFontMerging);
+ font.setWeight(fontDef.weight);
+ font.setItalic(fontDef.style == QFont::StyleItalic);
+ if (fontDef.pointSize < 0)
+ font.setPixelSize(fontDef.pixelSize);
+ else
+ font.setPointSizeF(fontDef.pointSize);
+ return font;
+}
+
QFixed QFontEngine::xHeight() const
{
QGlyphLayoutArray<8> glyphs;
@@ -480,7 +494,7 @@ static void collectSingleContour(qreal x0, qreal y0, uint *grid, int x, int y, i
path->closeSubpath();
}
-void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path)
+Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path)
{
uint *grid = new uint[(w+1)*(h+1)];
// set up edges
@@ -591,6 +605,12 @@ void QFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int n
addBitmapFontToPath(x, y, g, path, flags);
}
+QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/)
+{
+ // For font engines don't support subpixel positioning
+ return alphaMapForGlyph(glyph);
+}
+
QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
{
QImage i = alphaMapForGlyph(glyph);
@@ -601,7 +621,20 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
return i;
}
-QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int /* margin */, const QTransform &t)
+QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
+{
+ if (! supportsSubPixelPositions())
+ return alphaMapForGlyph(glyph, t);
+
+ QImage i = alphaMapForGlyph(glyph, subPixelPosition);
+ if (t.type() > QTransform::TxTranslate)
+ i = i.transformed(t).convertToFormat(QImage::Format_Indexed8);
+ Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
+
+ return i;
+}
+
+QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, int /* margin */, const QTransform &t)
{
QImage alphaMask = alphaMapForGlyph(glyph, t);
QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
@@ -711,14 +744,16 @@ void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data)
{
Q_ASSERT(data);
- GlyphCacheEntry entry = { key, data };
+ GlyphCacheEntry entry;
+ entry.context = key;
+ entry.cache = data;
if (m_glyphCaches.contains(entry))
return;
// Limit the glyph caches to 4. This covers all 90 degree rotations and limits
// memory use when there is continuous or random rotation
if (m_glyphCaches.size() == 4)
- delete m_glyphCaches.takeLast().cache;
+ m_glyphCaches.removeLast();
m_glyphCaches.push_front(entry);
@@ -727,7 +762,7 @@ void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data)
QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const
{
for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
- QFontEngineGlyphCache *c = it->cache;
+ QFontEngineGlyphCache *c = it->cache.data();
if (key == it->context
&& type == c->cacheType()
&& qtransform_equals_no_translate(c->m_transform, transform)) {
@@ -737,7 +772,7 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, QFontEngineGlyphCache:
return 0;
}
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
{
uint left_right = (left << 16) + right;
@@ -1181,7 +1216,7 @@ glyph_metrics_t QFontEngineBox::boundingBox(const QGlyphLayout &glyphs)
return overall;
}
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
void QFontEngineBox::draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &ti)
{
if (!ti.glyphs.numGlyphs)
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
new file mode 100644
index 0000000..4d9192e
--- /dev/null
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -0,0 +1,747 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfontengine_coretext_p.h"
+
+#include <QtCore/qendian.h>
+#include <QtCore/qsettings.h>
+
+#include <private/qimage_p.h>
+
+#if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+
+QT_BEGIN_NAMESPACE
+
+static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
+
+QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const QFontDef &fontDef, bool kerning)
+ : QFontEngineMulti(0)
+{
+ this->fontDef = fontDef;
+ CTFontSymbolicTraits symbolicTraits = 0;
+ if (fontDef.weight >= QFont::Bold)
+ symbolicTraits |= kCTFontBoldTrait;
+ switch (fontDef.style) {
+ case QFont::StyleNormal:
+ break;
+ case QFont::StyleItalic:
+ case QFont::StyleOblique:
+ symbolicTraits |= kCTFontItalicTrait;
+ break;
+ }
+
+ transform = CGAffineTransformIdentity;
+ if (fontDef.stretch != 100) {
+ transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
+ }
+
+ QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
+ QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform);
+ ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits);
+
+ // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does
+ // not exist for the given font. (for example italic)
+ if (ctfont == 0) {
+ ctfont = baseFont;
+ CFRetain(ctfont);
+ }
+
+ attributeDict = CFDictionaryCreateMutable(0, 2,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont);
+ if (!kerning) {
+ float zero = 0.0;
+ QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
+ CFDictionaryAddValue(attributeDict, kCTKernAttributeName, noKern);
+ }
+
+ QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
+ fe->ref.ref();
+ engines.append(fe);
+
+}
+
+QCoreTextFontEngineMulti::~QCoreTextFontEngineMulti()
+{
+ CFRelease(ctfont);
+}
+
+uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef id) const
+{
+ for (int i = 0; i < engines.count(); ++i) {
+ if (CFEqual(engineAt(i)->ctfont, id))
+ return i;
+ }
+
+ QCoreTextFontEngineMulti *that = const_cast<QCoreTextFontEngineMulti *>(this);
+ QCoreTextFontEngine *fe = new QCoreTextFontEngine(id, fontDef, that);
+ fe->ref.ref();
+ that->engines.append(fe);
+ return engines.count() - 1;
+}
+
+bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
+ unsigned short *logClusters, const HB_CharAttributes *) const
+{
+ QCFType<CFStringRef> cfstring = CFStringCreateWithCharactersNoCopy(0,
+ reinterpret_cast<const UniChar *>(str),
+ len, kCFAllocatorNull);
+ QCFType<CFAttributedStringRef> attributedString = CFAttributedStringCreate(0, cfstring, attributeDict);
+ QCFType<CTTypesetterRef> typeSetter;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ if (flags & QTextEngine::RightToLeft) {
+ const void *optionKeys[] = { kCTTypesetterOptionForcedEmbeddingLevel };
+ const short rtlForcedEmbeddingLevelValue = 1;
+ const void *rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) };
+ QCFType<CFDictionaryRef> options = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, 1,
+ &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ typeSetter = CTTypesetterCreateWithAttributedStringAndOptions(attributedString, options);
+ } else
+#endif
+ typeSetter = CTTypesetterCreateWithAttributedString(attributedString);
+
+ CFRange range = {0, 0};
+ QCFType<CTLineRef> line = CTTypesetterCreateLine(typeSetter, range);
+ CFArrayRef array = CTLineGetGlyphRuns(line);
+ uint arraySize = CFArrayGetCount(array);
+ glyph_t *outGlyphs = glyphs->glyphs;
+ HB_GlyphAttributes *outAttributes = glyphs->attributes;
+ QFixed *outAdvances_x = glyphs->advances_x;
+ QFixed *outAdvances_y = glyphs->advances_y;
+ glyph_t *initialGlyph = outGlyphs;
+
+ if (arraySize == 0) {
+ // CoreText failed to shape the text we gave it, so we assume one glyph
+ // per character and build a list of invalid glyphs with zero advance
+ *nglyphs = len;
+ for (int i = 0; i < len; ++i) {
+ outGlyphs[i] = 0;
+ if (logClusters)
+ logClusters[i] = i;
+ outAdvances_x[i] = QFixed();
+ outAdvances_y[i] = QFixed();
+ outAttributes[i].clusterStart = true;
+ }
+ return true;
+ }
+
+ const bool rtl = (CTRunGetStatus(static_cast<CTRunRef>(CFArrayGetValueAtIndex(array, 0))) & kCTRunStatusRightToLeft);
+
+ bool outOBounds = false;
+ for (uint i = 0; i < arraySize; ++i) {
+ CTRunRef run = static_cast<CTRunRef>(CFArrayGetValueAtIndex(array, rtl ? (arraySize - 1 - i) : i));
+ CFIndex glyphCount = CTRunGetGlyphCount(run);
+ if (glyphCount == 0)
+ continue;
+
+ Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
+ CFRange stringRange = CTRunGetStringRange(run);
+ UniChar endGlyph = CFStringGetCharacterAtIndex(cfstring, stringRange.location + stringRange.length - 1);
+ bool endWithPDF = QChar::direction(endGlyph) == QChar::DirPDF;
+ if (endWithPDF)
+ glyphCount++;
+
+ if (!outOBounds && outGlyphs + glyphCount - initialGlyph > *nglyphs) {
+ outOBounds = true;
+ }
+ if (!outOBounds) {
+ CFDictionaryRef runAttribs = CTRunGetAttributes(run);
+ //NSLog(@"Dictionary %@", runAttribs);
+ if (!runAttribs)
+ runAttribs = attributeDict;
+ CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
+ const uint fontIndex = (fontIndexForFont(runFont) << 24);
+ //NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
+ if (endWithPDF)
+ glyphCount--;
+
+ QVarLengthArray<CGGlyph, 512> cgglyphs(0);
+ const CGGlyph *tmpGlyphs = CTRunGetGlyphsPtr(run);
+ if (!tmpGlyphs) {
+ cgglyphs.resize(glyphCount);
+ CTRunGetGlyphs(run, range, cgglyphs.data());
+ tmpGlyphs = cgglyphs.constData();
+ }
+ QVarLengthArray<CGPoint, 512> cgpoints(0);
+ const CGPoint *tmpPoints = CTRunGetPositionsPtr(run);
+ if (!tmpPoints) {
+ cgpoints.resize(glyphCount);
+ CTRunGetPositions(run, range, cgpoints.data());
+ tmpPoints = cgpoints.constData();
+ }
+
+ const int rtlOffset = rtl ? (glyphCount - 1) : 0;
+ const int rtlSign = rtl ? -1 : 1;
+
+ if (logClusters) {
+ CFRange stringRange = CTRunGetStringRange(run);
+ QVarLengthArray<CFIndex, 512> stringIndices(0);
+ const CFIndex *tmpIndices = CTRunGetStringIndicesPtr(run);
+ if (!tmpIndices) {
+ stringIndices.resize(glyphCount);
+ CTRunGetStringIndices(run, range, stringIndices.data());
+ tmpIndices = stringIndices.constData();
+ }
+
+ const int firstGlyphIndex = outGlyphs - initialGlyph;
+ outAttributes[0].clusterStart = true;
+
+ CFIndex k = 0;
+ CFIndex i = 0;
+ for (i = stringRange.location;
+ (i < stringRange.location + stringRange.length) && (k < glyphCount); ++i) {
+ if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location) {
+ logClusters[i] = k + firstGlyphIndex;
+ outAttributes[k].clusterStart = true;
+ ++k;
+ } else {
+ logClusters[i] = k + firstGlyphIndex - 1;
+ }
+ }
+ // in case of a ligature at the end, fill the remaining logcluster entries
+ for (;i < stringRange.location + stringRange.length; i++) {
+ logClusters[i] = k + firstGlyphIndex - 1;
+ }
+ }
+ for (CFIndex i = 0; i < glyphCount - 1; ++i) {
+ int idx = rtlOffset + rtlSign * i;
+ outGlyphs[idx] = tmpGlyphs[i] | fontIndex;
+ outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
+ // Use negative y advance for flipped coordinate system
+ outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y);
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ outAdvances_x[idx] = outAdvances_x[idx].round();
+ outAdvances_y[idx] = outAdvances_y[idx].round();
+ }
+ }
+ CGSize lastGlyphAdvance;
+ CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1);
+
+ outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex;
+ outAdvances_x[rtl ? 0 : (glyphCount - 1)] =
+ (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ ? QFixed::fromReal(lastGlyphAdvance.width).round()
+ : QFixed::fromReal(lastGlyphAdvance.width);
+
+ if (endWithPDF) {
+ logClusters[stringRange.location + stringRange.length - 1] = glyphCount;
+ outGlyphs[glyphCount] = 0xFFFF;
+ outAdvances_x[glyphCount] = 0;
+ outAdvances_y[glyphCount] = 0;
+ outAttributes[glyphCount].clusterStart = true;
+ outAttributes[glyphCount].dontPrint = true;
+ glyphCount++;
+ }
+ }
+ outGlyphs += glyphCount;
+ outAttributes += glyphCount;
+ outAdvances_x += glyphCount;
+ outAdvances_y += glyphCount;
+ }
+ *nglyphs = (outGlyphs - initialGlyph);
+ return !outOBounds;
+}
+
+bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
+ int *nglyphs, QTextEngine::ShaperFlags flags) const
+{
+ *nglyphs = len;
+ QCFType<CFStringRef> cfstring;
+
+ QVarLengthArray<CGGlyph> cgGlyphs(len);
+ CTFontGetGlyphsForCharacters(ctfont, (const UniChar*)str, cgGlyphs.data(), len);
+
+ for (int i = 0; i < len; ++i) {
+ if (cgGlyphs[i]) {
+ glyphs->glyphs[i] = cgGlyphs[i];
+ } else {
+ if (!cfstring)
+ cfstring = CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar *>(str), len, kCFAllocatorNull);
+ QCFType<CTFontRef> substituteFont = CTFontCreateForString(ctfont, cfstring, CFRangeMake(i, 1));
+ CGGlyph substituteGlyph = 0;
+ CTFontGetGlyphsForCharacters(substituteFont, (const UniChar*)str + i, &substituteGlyph, 1);
+ if (substituteGlyph) {
+ const uint fontIndex = (fontIndexForFont(substituteFont) << 24);
+ glyphs->glyphs[i] = substituteGlyph | fontIndex;
+ if (!(flags & QTextEngine::GlyphIndicesOnly)) {
+ CGSize advance;
+ CTFontGetAdvancesForGlyphs(substituteFont, kCTFontHorizontalOrientation, &substituteGlyph, &advance, 1);
+ glyphs->advances_x[i] = QFixed::fromReal(advance.width);
+ glyphs->advances_y[i] = QFixed::fromReal(advance.height);
+ }
+ }
+ }
+ }
+
+ if (flags & QTextEngine::GlyphIndicesOnly)
+ return true;
+
+ QVarLengthArray<CGSize> advances(len);
+ CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), len);
+
+ for (int i = 0; i < len; ++i) {
+ if (glyphs->glyphs[i] & 0xff000000)
+ continue;
+ glyphs->advances_x[i] = QFixed::fromReal(advances[i].width);
+ glyphs->advances_y[i] = QFixed::fromReal(advances[i].height);
+ }
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ for (int i = 0; i < len; ++i) {
+ glyphs->advances_x[i] = glyphs->advances_x[i].round();
+ glyphs->advances_y[i] = glyphs->advances_y[i].round();
+ }
+ }
+
+ return true;
+}
+
+void QCoreTextFontEngineMulti::recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const
+{
+}
+void QCoreTextFontEngineMulti::doKerning(int , QGlyphLayout *, QTextEngine::ShaperFlags) const
+{
+}
+
+void QCoreTextFontEngineMulti::loadEngine(int)
+{
+ // Do nothing
+ Q_ASSERT(false);
+}
+
+
+
+QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def,
+ QCoreTextFontEngineMulti *multiEngine)
+{
+ fontDef = def;
+ parentEngine = multiEngine;
+ synthesisFlags = 0;
+ ctfont = font;
+ CFRetain(ctfont);
+ cgFont = CTFontCopyGraphicsFont(ctfont, NULL);
+ CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont);
+ if (fontDef.weight >= QFont::Bold && !(traits & kCTFontBoldTrait)) {
+ synthesisFlags |= SynthesizedBold;
+ }
+
+ if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait)) {
+ synthesisFlags |= SynthesizedItalic;
+ }
+ transform = CGAffineTransformIdentity;
+ if (fontDef.stretch != 100) {
+ transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
+ }
+ QByteArray os2Table = getSfntTable(MAKE_TAG('O', 'S', '/', '2'));
+ if (os2Table.size() >= 10)
+ fsType = qFromBigEndian<quint16>(reinterpret_cast<const uchar *>(os2Table.constData() + 8));
+
+ QSettings appleSettings(QLatin1String("apple.com"));
+ QVariant appleValue = appleSettings.value(QLatin1String("AppleAntiAliasingThreshold"));
+ if (appleValue.isValid())
+ antialiasing_threshold = appleValue.toInt();
+ else
+ antialiasing_threshold = -1;
+}
+
+QCoreTextFontEngine::~QCoreTextFontEngine()
+{
+ CFRelease(cgFont);
+ CFRelease(ctfont);
+}
+
+bool QCoreTextFontEngine::stringToCMap(const QChar *, int, QGlyphLayout *, int *, QTextEngine::ShaperFlags) const
+{
+ return false;
+}
+
+glyph_metrics_t QCoreTextFontEngine::boundingBox(const QGlyphLayout &glyphs)
+{
+ QFixed w;
+ bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
+
+ for (int i = 0; i < glyphs.numGlyphs; ++i) {
+ w += round ? glyphs.effectiveAdvance(i).round()
+ : glyphs.effectiveAdvance(i);
+ }
+ return glyph_metrics_t(0, -(ascent()), w - lastRightBearing(glyphs, round), ascent()+descent(), w, 0);
+}
+glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
+{
+ glyph_metrics_t ret;
+ CGGlyph g = glyph;
+ CGRect rect = CTFontGetBoundingRectsForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, 0, 1);
+ if (synthesisFlags & QFontEngine::SynthesizedItalic) {
+ rect.size.width += rect.size.height * SYNTHETIC_ITALIC_SKEW;
+ }
+ ret.width = QFixed::fromReal(rect.size.width);
+ ret.height = QFixed::fromReal(rect.size.height);
+ ret.x = QFixed::fromReal(rect.origin.x);
+ ret.y = -QFixed::fromReal(rect.origin.y) - ret.height;
+ CGSize advances[1];
+ CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1);
+ ret.xoff = QFixed::fromReal(advances[0].width);
+ ret.yoff = QFixed::fromReal(advances[0].height);
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ ret.xoff = ret.xoff.round();
+ ret.yoff = ret.yoff.round();
+ }
+
+ return ret;
+}
+
+QFixed QCoreTextFontEngine::ascent() const
+{
+ return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ ? QFixed::fromReal(CTFontGetAscent(ctfont)).round()
+ : QFixed::fromReal(CTFontGetAscent(ctfont));
+}
+QFixed QCoreTextFontEngine::descent() const
+{
+ QFixed d = QFixed::fromReal(CTFontGetDescent(ctfont));
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ d = d.round();
+
+ // subtract a pixel to even out the historical +1 in QFontMetrics::height().
+ // Fix in Qt 5.
+ return d - 1;
+}
+QFixed QCoreTextFontEngine::leading() const
+{
+ return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ ? QFixed::fromReal(CTFontGetLeading(ctfont)).round()
+ : QFixed::fromReal(CTFontGetLeading(ctfont));
+}
+QFixed QCoreTextFontEngine::xHeight() const
+{
+ return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ ? QFixed::fromReal(CTFontGetXHeight(ctfont)).round()
+ : QFixed::fromReal(CTFontGetXHeight(ctfont));
+}
+QFixed QCoreTextFontEngine::averageCharWidth() const
+{
+ // ### Need to implement properly and get the information from the OS/2 Table.
+ return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ ? QFontEngine::averageCharWidth().round()
+ : QFontEngine::averageCharWidth();
+}
+
+qreal QCoreTextFontEngine::maxCharWidth() const
+{
+ // ### Max Help!
+ return 0;
+
+}
+qreal QCoreTextFontEngine::minLeftBearing() const
+{
+ // ### Min Help!
+ return 0;
+
+}
+qreal QCoreTextFontEngine::minRightBearing() const
+{
+ // ### Max Help! (even thought it's right)
+ return 0;
+
+}
+
+void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight)
+{
+ QVarLengthArray<QFixedPoint> positions;
+ QVarLengthArray<glyph_t> glyphs;
+ QTransform matrix;
+ matrix.translate(x, y);
+ getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ if (glyphs.size() == 0)
+ return;
+
+ CGContextSetFontSize(ctx, fontDef.pixelSize);
+
+ CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
+
+ CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight);
+
+ CGAffineTransformConcat(cgMatrix, oldTextMatrix);
+
+ if (synthesisFlags & QFontEngine::SynthesizedItalic)
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
+
+ cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
+
+ CGContextSetTextMatrix(ctx, cgMatrix);
+
+ CGContextSetTextDrawingMode(ctx, kCGTextFill);
+
+
+ QVarLengthArray<CGSize> advances(glyphs.size());
+ QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
+
+ for (int i = 0; i < glyphs.size() - 1; ++i) {
+ advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
+ advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
+ cgGlyphs[i] = glyphs[i];
+ }
+ advances[glyphs.size() - 1].width = 0;
+ advances[glyphs.size() - 1].height = 0;
+ cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
+
+ CGContextSetFont(ctx, cgFont);
+ //NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
+
+ CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
+
+ CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+
+ if (synthesisFlags & QFontEngine::SynthesizedBold) {
+ CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
+ positions[0].y.toReal());
+
+ CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+ }
+
+ CGContextSetTextMatrix(ctx, oldTextMatrix);
+}
+
+struct ConvertPathInfo
+{
+ ConvertPathInfo(QPainterPath *newPath, const QPointF &newPos) : path(newPath), pos(newPos) {}
+ QPainterPath *path;
+ QPointF pos;
+};
+
+static void convertCGPathToQPainterPath(void *info, const CGPathElement *element)
+{
+ ConvertPathInfo *myInfo = static_cast<ConvertPathInfo *>(info);
+ switch(element->type) {
+ case kCGPathElementMoveToPoint:
+ myInfo->path->moveTo(element->points[0].x + myInfo->pos.x(),
+ element->points[0].y + myInfo->pos.y());
+ break;
+ case kCGPathElementAddLineToPoint:
+ myInfo->path->lineTo(element->points[0].x + myInfo->pos.x(),
+ element->points[0].y + myInfo->pos.y());
+ break;
+ case kCGPathElementAddQuadCurveToPoint:
+ myInfo->path->quadTo(element->points[0].x + myInfo->pos.x(),
+ element->points[0].y + myInfo->pos.y(),
+ element->points[1].x + myInfo->pos.x(),
+ element->points[1].y + myInfo->pos.y());
+ break;
+ case kCGPathElementAddCurveToPoint:
+ myInfo->path->cubicTo(element->points[0].x + myInfo->pos.x(),
+ element->points[0].y + myInfo->pos.y(),
+ element->points[1].x + myInfo->pos.x(),
+ element->points[1].y + myInfo->pos.y(),
+ element->points[2].x + myInfo->pos.x(),
+ element->points[2].y + myInfo->pos.y());
+ break;
+ case kCGPathElementCloseSubpath:
+ myInfo->path->closeSubpath();
+ break;
+ default:
+ qDebug() << "Unhandled path transform type: " << element->type;
+ }
+
+}
+
+void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
+ QPainterPath *path, QTextItem::RenderFlags)
+{
+ CGAffineTransform cgMatrix = CGAffineTransformIdentity;
+ cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
+
+ if (synthesisFlags & QFontEngine::SynthesizedItalic)
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
+
+ for (int i = 0; i < nGlyphs; ++i) {
+ QCFType<CGPathRef> cgpath = CTFontCreatePathForGlyph(ctfont, glyphs[i], &cgMatrix);
+ ConvertPathInfo info(path, positions[i].toPointF());
+ CGPathApply(cgpath, &info, convertCGPathToQPainterPath);
+ }
+}
+
+QFont QCoreTextFontEngine::createExplicitFont() const
+{
+ QString familyName = QCFString::toQString(CTFontCopyFamilyName(ctfont));
+ return createExplicitFontWithName(familyName);
+}
+
+QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int /*margin*/, bool aa)
+{
+ const glyph_metrics_t br = boundingBox(glyph);
+ QImage im(qRound(br.width)+2, qRound(br.height)+2, QImage::Format_RGB32);
+ im.fill(0);
+
+ CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ uint cgflags = kCGImageAlphaNoneSkipFirst;
+#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
+ cgflags |= kCGBitmapByteOrder32Host;
+#endif
+ CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(),
+ 8, im.bytesPerLine(), colorspace,
+ cgflags);
+ CGContextSetFontSize(ctx, fontDef.pixelSize);
+ CGContextSetShouldAntialias(ctx, aa ||
+ (fontDef.pointSize > antialiasing_threshold
+ && !(fontDef.styleStrategy & QFont::NoAntialias)));
+ CGContextSetShouldSmoothFonts(ctx, aa);
+ CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
+ CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
+
+ CGAffineTransformConcat(cgMatrix, oldTextMatrix);
+
+ if (synthesisFlags & QFontEngine::SynthesizedItalic)
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
+
+ cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
+
+ CGContextSetTextMatrix(ctx, cgMatrix);
+ CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
+ CGContextSetTextDrawingMode(ctx, kCGTextFill);
+
+ CGContextSetFont(ctx, cgFont);
+
+ qreal pos_x = -br.x.toReal() + subPixelPosition.toReal();
+ qreal pos_y = im.height() + br.y.toReal() - 1;
+ CGContextSetTextPosition(ctx, pos_x, pos_y);
+
+ CGSize advance;
+ advance.width = 0;
+ advance.height = 0;
+ CGGlyph cgGlyph = glyph;
+ CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
+
+ if (synthesisFlags & QFontEngine::SynthesizedBold) {
+ CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
+ CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
+ }
+
+ CGContextRelease(ctx);
+
+ return im;
+}
+
+QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
+{
+ QImage im = imageForGlyph(glyph, subPixelPosition, 0, false);
+
+ QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
+ QVector<QRgb> colors(256);
+ for (int i=0; i<256; ++i)
+ colors[i] = qRgba(0, 0, 0, i);
+ indexed.setColorTable(colors);
+
+ for (int y=0; y<im.height(); ++y) {
+ uint *src = (uint*) im.scanLine(y);
+ uchar *dst = indexed.scanLine(y);
+ for (int x=0; x<im.width(); ++x) {
+ *dst = qGray(*src);
+ ++dst;
+ ++src;
+ }
+ }
+
+ return indexed;
+}
+
+QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, const QTransform &x)
+{
+ if (x.type() >= QTransform::TxScale)
+ return QFontEngine::alphaRGBMapForGlyph(glyph, subPixelPosition, margin, x);
+
+ QImage im = imageForGlyph(glyph, subPixelPosition, margin, true);
+ qGamma_correct_back_to_linear_cs(&im);
+ return im;
+}
+
+void QCoreTextFontEngine::recalcAdvances(int numGlyphs, QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
+{
+ Q_ASSERT(false);
+ Q_UNUSED(numGlyphs);
+ Q_UNUSED(glyphs);
+ Q_UNUSED(flags);
+}
+
+QFontEngine::FaceId QCoreTextFontEngine::faceId() const
+{
+ return QFontEngine::FaceId();
+}
+
+bool QCoreTextFontEngine::canRender(const QChar *string, int len)
+{
+ QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
+ QCFType<CFStringRef>(CFStringCreateWithCharactersNoCopy(0,
+ reinterpret_cast<const UniChar *>(string),
+ len, kCFAllocatorNull)),
+ CFRangeMake(0, len));
+ return retFont != 0;
+ return false;
+}
+
+ bool QCoreTextFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const
+ {
+ QCFType<CFDataRef> table = CTFontCopyTable(ctfont, tag, 0);
+ if (!table || !length)
+ return false;
+ CFIndex tableLength = CFDataGetLength(table);
+ int availableLength = *length;
+ *length = tableLength;
+ if (buffer) {
+ if (tableLength > availableLength)
+ return false;
+ CFDataGetBytes(table, CFRangeMake(0, tableLength), buffer);
+ }
+ return true;
+ }
+
+void QCoreTextFontEngine::getUnscaledGlyph(glyph_t, QPainterPath *, glyph_metrics_t *)
+{
+ // ###
+}
+
+QT_END_NAMESPACE
+
+#endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
new file mode 100644
index 0000000..7d17aef
--- /dev/null
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** 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 QFONTENGINE_CORETEXT_P_H
+#define QFONTENGINE_CORETEXT_P_H
+
+#include <private/qfontengine_p.h>
+
+#if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+
+class QCoreTextFontEngineMulti;
+class QCoreTextFontEngine : public QFontEngine
+{
+public:
+ QCoreTextFontEngine(CTFontRef font, const QFontDef &def,
+ QCoreTextFontEngineMulti *multiEngine = 0);
+ ~QCoreTextFontEngine();
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
+ virtual void recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
+
+ virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
+ virtual glyph_metrics_t boundingBox(glyph_t glyph);
+
+ virtual QFixed ascent() const;
+ virtual QFixed descent() const;
+ virtual QFixed leading() const;
+ virtual QFixed xHeight() const;
+ virtual qreal maxCharWidth() const;
+ virtual QFixed averageCharWidth() const;
+
+ virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
+ QPainterPath *path, QTextItem::RenderFlags);
+
+ virtual const char *name() const { return "QCoreTextFontEngine"; }
+
+ virtual bool canRender(const QChar *string, int len);
+
+ virtual int synthesized() const { return synthesisFlags; }
+ virtual bool supportsSubPixelPositions() const { return true; }
+
+ virtual Type type() const { return QFontEngine::Mac; }
+
+ void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
+
+ virtual FaceId faceId() const;
+ virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const;
+ virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
+ virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+ virtual qreal minRightBearing() const;
+ virtual qreal minLeftBearing() const;
+ virtual QFont createExplicitFont() const;
+
+private:
+ QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool colorful);
+ CTFontRef ctfont;
+ CGFontRef cgFont;
+ QCoreTextFontEngineMulti *parentEngine;
+ int synthesisFlags;
+ CGAffineTransform transform;
+ friend class QCoreTextFontEngineMulti;
+ int antialiasing_threshold;
+};
+
+class QCoreTextFontEngineMulti : public QFontEngineMulti
+{
+public:
+ QCoreTextFontEngineMulti(const QCFString &name, const QFontDef &fontDef, bool kerning);
+ ~QCoreTextFontEngineMulti();
+
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
+ QTextEngine::ShaperFlags flags) const;
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
+ QTextEngine::ShaperFlags flags,
+ unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
+
+
+ virtual void recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
+ virtual void doKerning(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
+
+ virtual const char *name() const { return "CoreText"; }
+protected:
+ virtual void loadEngine(int at);
+
+private:
+ inline const QCoreTextFontEngine *engineAt(int i) const
+ { return static_cast<const QCoreTextFontEngine *>(engines.at(i)); }
+
+ uint fontIndexForFont(CTFontRef id) const;
+ CTFontRef ctfont;
+ mutable QCFType<CFMutableDictionaryRef> attributeDict;
+ CGAffineTransform transform;
+ friend class QFontDialogPrivate;
+};
+
+#endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+
+#endif // QFONTENGINE_CORETEXT_P_H
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index e89b508..db0156a 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -174,9 +174,7 @@ int QFreetypeFace::fsType() const
HB_Error QFreetypeFace::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints)
{
- int load_flags = (flags & HB_ShaperFlag_UseDesignMetrics) ? FT_LOAD_NO_HINTING : FT_LOAD_DEFAULT;
-
- if (HB_Error error = (HB_Error)FT_Load_Glyph(face, glyph, load_flags))
+ if (HB_Error error = (HB_Error)FT_Load_Glyph(face, glyph, flags))
return error;
if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
@@ -723,7 +721,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
metrics = face->size->metrics;
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
/*
TrueType fonts with embedded bitmaps may have a bitmap font specific
ascent/descent in the EBLC table. There is no direct public API
@@ -755,16 +753,54 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format)
return true;
}
-QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph) const
+void QFontEngineFT::setDefaultHintStyle(HintStyle style)
{
- Glyph *g = set->getGlyph(glyph);
- if (g)
- return g;
+ default_hint_style = style;
+}
+int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
+ bool &hsubpixel, int &vfactor) const
+{
int load_flags = FT_LOAD_DEFAULT | default_load_flags;
- if (set->outline_drawing)
+ int load_target = default_hint_style == HintLight
+ ? FT_LOAD_TARGET_LIGHT
+ : FT_LOAD_TARGET_NORMAL;
+
+ if (format == Format_Mono) {
+ load_target = FT_LOAD_TARGET_MONO;
+ } else if (format == Format_A32) {
+ if (subpixelType == QFontEngineFT::Subpixel_RGB || subpixelType == QFontEngineFT::Subpixel_BGR) {
+ if (default_hint_style == HintFull)
+ load_target = FT_LOAD_TARGET_LCD;
+ hsubpixel = true;
+ } else if (subpixelType == QFontEngineFT::Subpixel_VRGB || subpixelType == QFontEngineFT::Subpixel_VBGR) {
+ if (default_hint_style == HintFull)
+ load_target = FT_LOAD_TARGET_LCD_V;
+ vfactor = 3;
+ }
+ }
+
+ if (set && set->outline_drawing)
load_flags = FT_LOAD_NO_BITMAP;
+ if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics))
+ load_flags |= FT_LOAD_NO_HINTING;
+ else
+ load_flags |= load_target;
+
+ return load_flags;
+}
+
+QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph, GlyphFormat format) const
+{
+ Glyph *g = set->getGlyph(glyph);
+ if (g && g->format == format)
+ return g;
+
+ bool hsubpixel = false;
+ int vfactor = 1;
+ int load_flags = loadFlags(set, format, 0, hsubpixel, vfactor);
+
// apply our matrix to this, but note that the metrics will not be affected by this.
FT_Face face = lockFace();
FT_Matrix matrix = this->matrix;
@@ -855,7 +891,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph
return g;
}
-QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, GlyphFormat format, bool fetchMetricsOnly) const
+QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
+ QFixed subPixelPosition,
+ GlyphFormat format,
+ bool fetchMetricsOnly) const
{
// Q_ASSERT(freetype->lock == 1);
@@ -870,10 +909,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
}
}
- Glyph *g = set->getGlyph(glyph);
+ Glyph *g = set->getGlyph(glyph, subPixelPosition);
if (g && g->format == format) {
if (uploadToServer && !g->uploadedToServer) {
- set->setGlyph(glyph, 0);
+ set->setGlyph(glyph, subPixelPosition, 0);
delete g;
g = 0;
} else {
@@ -886,33 +925,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
Q_ASSERT(format != Format_None);
bool hsubpixel = false;
int vfactor = 1;
- int load_flags = FT_LOAD_DEFAULT | default_load_flags;
-
- int load_target = default_hint_style == HintLight
- ? FT_LOAD_TARGET_LIGHT
- : FT_LOAD_TARGET_NORMAL;
-
- if (set->outline_drawing)
- load_flags |= FT_LOAD_NO_BITMAP;
-
- if (format == Format_Mono) {
- load_target = FT_LOAD_TARGET_MONO;
- } else if (format == Format_A32) {
- if (subpixelType == QFontEngineFT::Subpixel_RGB || subpixelType == QFontEngineFT::Subpixel_BGR) {
- if (default_hint_style == HintFull)
- load_target = FT_LOAD_TARGET_LCD;
- hsubpixel = true;
- } else if (subpixelType == QFontEngineFT::Subpixel_VRGB || subpixelType == QFontEngineFT::Subpixel_VBGR) {
- if (default_hint_style == HintFull)
- load_target = FT_LOAD_TARGET_LCD_V;
- vfactor = 3;
- }
- }
-
- if (default_hint_style == HintNone)
- load_flags |= FT_LOAD_NO_HINTING;
- else
- load_flags |= load_target;
+ int load_flags = loadFlags(set, format, 0, hsubpixel, vfactor);
#ifndef Q_WS_QWS
if (format != Format_Mono && !embeddedbitmap)
@@ -929,6 +942,12 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
load_flags |= FT_LOAD_NO_BITMAP;
FT_Face face = freetype->face;
+
+ FT_Vector v;
+ v.x = format == Format_Mono ? 0 : FT_Pos(subPixelPosition.toReal() * 64);
+ v.y = 0;
+ FT_Set_Transform(face, &freetype->matrix, &v);
+
FT_Error err = FT_Load_Glyph(face, glyph, load_flags);
if (err && (load_flags & FT_LOAD_NO_BITMAP)) {
load_flags &= ~FT_LOAD_NO_BITMAP;
@@ -1029,6 +1048,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
top = CEIL(top);
int hpixels = TRUNC(right - left);
+ // subpixel position requires one more pixel
+ if (subPixelPosition > 0 && format != Format_Mono)
+ hpixels++;
+
if (hsubpixel)
hpixels = hpixels*3 + 8;
info.width = hpixels;
@@ -1171,7 +1194,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
uploadGlyphToServer(set, glyph, g, &info, glyph_buffer_size);
}
- set->setGlyph(glyph, g);
+ set->setGlyph(glyph, subPixelPosition, g);
return g;
}
@@ -1404,12 +1427,28 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadTransformedGlyphSet(const QTransfor
return gs;
}
-bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format)
+QFixed QFontEngineFT::subPixelPositionForX(QFixed x)
+{
+ int m_subPixelPositionCount = 4;
+
+ QFixed subPixelPosition;
+ if (x != 0) {
+ subPixelPosition = x - x.floor();
+ QFixed fraction = (subPixelPosition / QFixed::fromReal(1.0 / m_subPixelPositionCount)).floor();
+ subPixelPosition = fraction / QFixed(m_subPixelPositionCount);
+ }
+ return subPixelPosition;
+}
+
+bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs,
+ const QFixedPoint *positions,
+ GlyphFormat format)
{
FT_Face face = 0;
for (int i = 0; i < num_glyphs; ++i) {
- Glyph *glyph = gs->getGlyph(glyphs[i]);
+ QFixed spp = subPixelPositionForX(positions[i].x);
+ Glyph *glyph = gs->getGlyph(glyphs[i], spp);
if (glyph == 0 || glyph->format != format) {
if (!face) {
face = lockFace();
@@ -1418,7 +1457,7 @@ bool QFontEngineFT::loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, G
FT_Set_Transform(face, &m, 0);
freetype->matrix = m;
}
- if (!loadGlyph(gs, glyphs[i], format)) {
+ if (!loadGlyph(gs, glyphs[i], spp, format)) {
unlockFace();
return false;
}
@@ -1642,32 +1681,23 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
{
FT_Face face = 0;
- if (flags & QTextEngine::DesignMetrics) {
- for (int i = 0; i < glyphs->numGlyphs; i++) {
- Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
- if (g) {
- glyphs->advances_x[i] = QFixed::fromFixed(g->linearAdvance);
- } else {
- if (!face)
- face = lockFace();
- g = loadGlyph(glyphs->glyphs[i], Format_None, true);
- glyphs->advances_x[i] = QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10);
- }
- glyphs->advances_y[i] = 0;
- }
- } else {
- for (int i = 0; i < glyphs->numGlyphs; i++) {
- Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
- if (g) {
- glyphs->advances_x[i] = QFixed(g->advance);
- } else {
- if (!face)
- face = lockFace();
- g = loadGlyph(glyphs->glyphs[i], Format_None, true);
- glyphs->advances_x[i] = QFixed::fromFixed(face->glyph->metrics.horiAdvance).round();
- }
- glyphs->advances_y[i] = 0;
+ bool design = (default_hint_style == HintNone ||
+ default_hint_style == HintLight ||
+ (flags & HB_ShaperFlag_UseDesignMetrics));
+ for (int i = 0; i < glyphs->numGlyphs; i++) {
+ Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]);
+ if (g) {
+ glyphs->advances_x[i] = design ? QFixed::fromFixed(g->linearAdvance) : QFixed(g->advance);
+ } else {
+ if (!face)
+ face = lockFace();
+ g = loadGlyph(glyphs->glyphs[i], 0, Format_None, true);
+ glyphs->advances_x[i] = design ? QFixed::fromFixed(face->glyph->linearHoriAdvance >> 10)
+ : QFixed::fromFixed(face->glyph->metrics.horiAdvance).round();
}
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ glyphs->advances_x[i] = glyphs->advances_x[i].round();
+ glyphs->advances_y[i] = 0;
}
if (face)
unlockFace();
@@ -1690,7 +1720,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs)
if (!g) {
if (!face)
face = lockFace();
- g = loadGlyph(glyphs.glyphs[i], Format_None, true);
+ g = loadGlyph(glyphs.glyphs[i], 0, Format_None, true);
}
if (g) {
QFixed x = overall.xoff + glyphs.offsets[i].x + g->x;
@@ -1731,7 +1761,7 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph)
Glyph *g = defaultGlyphSet.getGlyph(glyph);
if (!g) {
face = lockFace();
- g = loadGlyph(glyph, Format_None, true);
+ g = loadGlyph(glyph, 0, Format_None, true);
}
if (g) {
overall.x = g->x;
@@ -1739,6 +1769,8 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph)
overall.width = g->width;
overall.height = g->height;
overall.xoff = g->advance;
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ overall.xoff = overall.xoff.round();
} else {
int left = FLOOR(face->glyph->metrics.horiBearingX);
int right = CEIL(face->glyph->metrics.horiBearingX + face->glyph->metrics.width);
@@ -1758,6 +1790,11 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph)
glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matrix)
{
+ return alphaMapBoundingBox(glyph, matrix, QFontEngine::Format_None);
+}
+
+glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, const QTransform &matrix, QFontEngine::GlyphFormat format)
+{
FT_Face face = 0;
glyph_metrics_t overall;
QGlyphSet *glyphSet = 0;
@@ -1801,9 +1838,9 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr
glyphSet = &defaultGlyphSet;
}
Glyph * g = glyphSet->getGlyph(glyph);
- if (!g) {
+ if (!g || g->format != format) {
face = lockFace();
- g = loadGlyphMetrics(glyphSet, glyph);
+ g = loadGlyphMetrics(glyphSet, glyph, format);
}
if (g) {
@@ -1829,13 +1866,13 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr
return overall;
}
-QImage QFontEngineFT::alphaMapForGlyph(glyph_t g)
+QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition)
{
lockFace();
GlyphFormat glyph_format = antialias ? Format_A8 : Format_Mono;
- Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, glyph_format);
+ Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, subPixelPosition, glyph_format);
if (!glyph) {
unlockFace();
return QFontEngine::alphaMapForGlyph(g);
@@ -1865,19 +1902,19 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g)
return img;
}
-QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransform &t)
+QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, int margin, const QTransform &t)
{
if (t.type() > QTransform::TxTranslate)
- return QFontEngine::alphaRGBMapForGlyph(g, margin, t);
+ return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, margin, t);
lockFace();
GlyphFormat glyph_format = Format_A32;
- Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, glyph_format);
+ Glyph *glyph = defaultGlyphSet.outline_drawing ? 0 : loadGlyph(g, subPixelPosition, glyph_format);
if (!glyph) {
unlockFace();
- return QFontEngine::alphaRGBMapForGlyph(g, margin, t);
+ return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, margin, t);
}
QImage img(glyph->width, glyph->height, QImage::Format_RGB32);
@@ -1889,7 +1926,7 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, int margin, const QTransfor
void QFontEngineFT::removeGlyphFromCache(glyph_t glyph)
{
- defaultGlyphSet.removeGlyphFromCache(glyph);
+ defaultGlyphSet.removeGlyphFromCache(glyph, 0);
}
int QFontEngineFT::glyphCount() const
@@ -1969,9 +2006,9 @@ void QFontEngineFT::QGlyphSet::clear()
glyph_data.clear();
}
-void QFontEngineFT::QGlyphSet::removeGlyphFromCache(int index)
+void QFontEngineFT::QGlyphSet::removeGlyphFromCache(glyph_t index, QFixed subPixelPosition)
{
- if (index < 256) {
+ if (useFastGlyphData(index, subPixelPosition)) {
if (fast_glyph_data[index]) {
delete fast_glyph_data[index];
fast_glyph_data[index] = 0;
@@ -1979,18 +2016,18 @@ void QFontEngineFT::QGlyphSet::removeGlyphFromCache(int index)
--fast_glyph_count;
}
} else {
- delete glyph_data.take(index);
+ delete glyph_data.take(GlyphAndSubPixelPosition(index, subPixelPosition));
}
}
-void QFontEngineFT::QGlyphSet::setGlyph(int index, Glyph *glyph)
+void QFontEngineFT::QGlyphSet::setGlyph(glyph_t index, QFixed subPixelPosition, Glyph *glyph)
{
- if (index < 256) {
+ if (useFastGlyphData(index, subPixelPosition)) {
if (!fast_glyph_data[index])
++fast_glyph_count;
fast_glyph_data[index] = glyph;
} else {
- glyph_data.insert(index, glyph);
+ glyph_data.insert(GlyphAndSubPixelPosition(index, subPixelPosition), glyph);
}
}
@@ -2007,7 +2044,10 @@ void QFontEngineFT::freeServerGlyphSet(unsigned long id)
HB_Error QFontEngineFT::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints)
{
lockFace();
- HB_Error result = freetype->getPointInOutline(glyph, flags, point, xpos, ypos, nPoints);
+ bool hsubpixel = true;
+ int vfactor = 1;
+ int load_flags = loadFlags(0, Format_A8, flags, hsubpixel, vfactor);
+ HB_Error result = freetype->getPointInOutline(glyph, load_flags, point, xpos, ypos, nPoints);
unlockFace();
return result;
}
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 93a6d16..fc3ac82 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -130,13 +130,6 @@ private:
class Q_GUI_EXPORT QFontEngineFT : public QFontEngine
{
public:
- enum GlyphFormat {
- Format_None,
- Format_Render = Format_None,
- Format_Mono,
- Format_A8,
- Format_A32
- };
/* we don't cache glyphs that are too large anyway, so we can make this struct rather small */
struct Glyph {
@@ -173,6 +166,19 @@ public:
};
#endif
+ struct GlyphAndSubPixelPosition
+ {
+ GlyphAndSubPixelPosition(glyph_t g, QFixed spp) : glyph(g), subPixelPosition(spp) {}
+
+ bool operator==(const GlyphAndSubPixelPosition &other) const
+ {
+ return glyph == other.glyph && subPixelPosition == other.subPixelPosition;
+ }
+
+ glyph_t glyph;
+ QFixed subPixelPosition;
+ };
+
struct QGlyphSet
{
QGlyphSet();
@@ -181,18 +187,21 @@ public:
unsigned long id; // server sided id, GlyphSet for X11
bool outline_drawing;
- void removeGlyphFromCache(int index);
+ void removeGlyphFromCache(glyph_t index, QFixed subPixelPosition);
void clear();
- inline Glyph *getGlyph(int index) const
+ inline bool useFastGlyphData(glyph_t index, QFixed subPixelPosition) const {
+ return (index < 256 && subPixelPosition == 0);
+ }
+ inline Glyph *getGlyph(glyph_t index, QFixed subPixelPosition = 0) const
{
- if (index < 256)
+ if (useFastGlyphData(index, subPixelPosition))
return fast_glyph_data[index];
- return glyph_data.value(index);
+ return glyph_data.value(GlyphAndSubPixelPosition(index, subPixelPosition));
}
- void setGlyph(int index, Glyph *glyph);
+ void setGlyph(glyph_t index, QFixed spp, Glyph *glyph);
private:
- mutable QHash<int, Glyph *> glyph_data; // maps from glyph index to glyph data
+ mutable QHash<GlyphAndSubPixelPosition, Glyph *> glyph_data; // maps from glyph index to glyph data
mutable Glyph *fast_glyph_data[256]; // for fast lookup of glyphs < 256
mutable int fast_glyph_count;
};
@@ -200,6 +209,11 @@ private:
virtual QFontEngine::FaceId faceId() const;
virtual QFontEngine::Properties properties() const;
virtual QFixed emSquareSize() const;
+ virtual bool supportsSubPixelPositions() const
+ {
+ return default_hint_style == HintLight ||
+ default_hint_style == HintNone;
+ }
virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
virtual int synthesized() const;
@@ -240,8 +254,11 @@ private:
virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix);
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
- virtual QImage alphaMapForGlyph(glyph_t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
+ virtual QImage alphaMapForGlyph(glyph_t g) { return alphaMapForGlyph(g, 0); }
+ virtual QImage alphaMapForGlyph(glyph_t, QFixed);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+ virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QTransform &matrix,
+ QFontEngine::GlyphFormat format);
virtual void removeGlyphFromCache(glyph_t glyph);
virtual int glyphCount() const;
@@ -259,17 +276,20 @@ private:
inline bool invalid() const { return xsize == 0 && ysize == 0; }
inline bool isBitmapFont() const { return defaultFormat == Format_Mono; }
- inline Glyph *loadGlyph(uint glyph, GlyphFormat format = Format_None, bool fetchMetricsOnly = false) const
- { return loadGlyph(&defaultGlyphSet, glyph, format, fetchMetricsOnly); }
- Glyph *loadGlyph(QGlyphSet *set, uint glyph, GlyphFormat = Format_None, bool fetchMetricsOnly = false) const;
+ inline Glyph *loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format = Format_None, bool fetchMetricsOnly = false) const
+ { return loadGlyph(&defaultGlyphSet, glyph, subPixelPosition, format, fetchMetricsOnly); }
+ Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false) const;
QGlyphSet *defaultGlyphs() { return &defaultGlyphSet; }
GlyphFormat defaultGlyphFormat() const { return defaultFormat; }
- inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.getGlyph(g); }
+ inline Glyph *cachedGlyph(glyph_t g) const { return defaultGlyphSet.getGlyph(g, 0); }
QGlyphSet *loadTransformedGlyphSet(const QTransform &matrix);
- bool loadGlyphs(QGlyphSet *gs, glyph_t *glyphs, int num_glyphs, GlyphFormat format = Format_Render);
+ QFixed subPixelPositionForX(QFixed x);
+ bool loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs,
+ const QFixedPoint *positions,
+ GlyphFormat format = Format_Render);
#if defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
virtual void draw(QPaintEngine * /*p*/, qreal /*x*/, qreal /*y*/, const QTextItemInt & /*si*/) {}
@@ -282,6 +302,14 @@ private:
virtual HB_Error getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
+ enum HintStyle {
+ HintNone,
+ HintLight,
+ HintMedium,
+ HintFull
+ };
+
+ void setDefaultHintStyle(HintStyle style);
protected:
void freeGlyphSets();
@@ -293,12 +321,6 @@ protected:
QFreetypeFace *freetype;
int default_load_flags;
- enum HintStyle {
- HintNone,
- HintLight,
- HintMedium,
- HintFull
- };
HintStyle default_hint_style;
@@ -311,7 +333,8 @@ protected:
bool embeddedbitmap;
private:
- QFontEngineFT::Glyph *loadGlyphMetrics(QGlyphSet *set, uint glyph) const;
+ QFontEngineFT::Glyph *loadGlyphMetrics(QGlyphSet *set, uint glyph, GlyphFormat format) const;
+ int loadFlags(QGlyphSet *set, GlyphFormat format, int flags, bool &hsubpixel, int &vfactor) const;
GlyphFormat defaultFormat;
FT_Matrix matrix;
@@ -333,6 +356,11 @@ private:
mutable bool kerning_pairs_loaded;
};
+inline uint qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g)
+{
+ return (g.glyph << 8) | (g.subPixelPosition * 10).round().toInt();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_FREETYPE
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 42b9402..7751bbe 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include "qfontengine_mac_p.h"
+
#include <private/qapplication_p.h>
#include <private/qfontengine_p.h>
#include <private/qpainter_p.h>
@@ -53,14 +55,13 @@
#include <qdebug.h>
#include <qendian.h>
#include <qmath.h>
+#include <private/qimage_p.h>
#include <ApplicationServices/ApplicationServices.h>
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
-static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
-
/*****************************************************************************
QFontEngine debug facilities
*****************************************************************************/
@@ -121,682 +122,6 @@ OSStatus QMacFontPath::closePath(void *data)
}
-
-void qmacfontengine_gamma_correct(QImage *image)
-{
- extern uchar qt_pow_rgb_gamma[256];
-
- // gamma correct the pixels back to linear color space...
- int h = image->height();
- int w = image->width();
-
- for (int y=0; y<h; ++y) {
- uint *pixels = (uint *) image->scanLine(y);
- for (int x=0; x<w; ++x) {
- uint p = pixels[x];
- uint r = qt_pow_rgb_gamma[qRed(p)];
- uint g = qt_pow_rgb_gamma[qGreen(p)];
- uint b = qt_pow_rgb_gamma[qBlue(p)];
- pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
- }
- }
-}
-
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
- : QFontEngineMulti(0)
-{
- this->fontDef = fontDef;
- CTFontSymbolicTraits symbolicTraits = 0;
- if (fontDef.weight >= QFont::Bold)
- symbolicTraits |= kCTFontBoldTrait;
- switch (fontDef.style) {
- case QFont::StyleNormal:
- break;
- case QFont::StyleItalic:
- case QFont::StyleOblique:
- symbolicTraits |= kCTFontItalicTrait;
- break;
- }
-
- QCFString name;
- ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name);
-
- transform = CGAffineTransformIdentity;
- if (fontDef.stretch != 100) {
- transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
- }
-
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
- QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, &transform);
- ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, &transform, symbolicTraits, symbolicTraits);
-
- // CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does
- // not exist for the given font. (for example italic)
- if (ctfont == 0) {
- ctfont = baseFont;
- CFRetain(ctfont);
- }
-
- attributeDict = CFDictionaryCreateMutable(0, 2,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont);
- if (!kerning) {
- float zero = 0.0;
- QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
- CFDictionaryAddValue(attributeDict, kCTKernAttributeName, noKern);
- }
-
- QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
- fe->ref.ref();
- engines.append(fe);
-
-}
-
-QCoreTextFontEngineMulti::~QCoreTextFontEngineMulti()
-{
- CFRelease(ctfont);
-}
-
-uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef id) const
-{
- for (int i = 0; i < engines.count(); ++i) {
- if (CFEqual(engineAt(i)->ctfont, id))
- return i;
- }
-
- QCoreTextFontEngineMulti *that = const_cast<QCoreTextFontEngineMulti *>(this);
- QCoreTextFontEngine *fe = new QCoreTextFontEngine(id, fontDef, that);
- fe->ref.ref();
- that->engines.append(fe);
- return engines.count() - 1;
-}
-
-bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags,
- unsigned short *logClusters, const HB_CharAttributes *) const
-{
- QCFType<CFStringRef> cfstring = CFStringCreateWithCharactersNoCopy(0,
- reinterpret_cast<const UniChar *>(str),
- len, kCFAllocatorNull);
- QCFType<CFAttributedStringRef> attributedString = CFAttributedStringCreate(0, cfstring, attributeDict);
- QCFType<CTTypesetterRef> typeSetter = CTTypesetterCreateWithAttributedString(attributedString);
- CFRange range = {0, 0};
- QCFType<CTLineRef> line = CTTypesetterCreateLine(typeSetter, range);
- CFArrayRef array = CTLineGetGlyphRuns(line);
- uint arraySize = CFArrayGetCount(array);
- glyph_t *outGlyphs = glyphs->glyphs;
- HB_GlyphAttributes *outAttributes = glyphs->attributes;
- QFixed *outAdvances_x = glyphs->advances_x;
- QFixed *outAdvances_y = glyphs->advances_y;
- glyph_t *initialGlyph = outGlyphs;
-
- if (arraySize == 0) {
- // CoreText failed to shape the text we gave it, so we assume one glyph
- // per character and build a list of invalid glyphs with zero advance
- *nglyphs = len;
- for (int i = 0; i < len; ++i) {
- outGlyphs[i] = 0;
- if (logClusters)
- logClusters[i] = i;
- outAdvances_x[i] = QFixed();
- outAdvances_y[i] = QFixed();
- outAttributes[i].clusterStart = true;
- }
- return true;
- }
-
- const bool rtl = (CTRunGetStatus(static_cast<CTRunRef>(CFArrayGetValueAtIndex(array, 0))) & kCTRunStatusRightToLeft);
-
- bool outOBounds = false;
- for (uint i = 0; i < arraySize; ++i) {
- CTRunRef run = static_cast<CTRunRef>(CFArrayGetValueAtIndex(array, rtl ? (arraySize - 1 - i) : i));
- CFIndex glyphCount = CTRunGetGlyphCount(run);
- if (glyphCount == 0)
- continue;
-
- Q_ASSERT((CTRunGetStatus(run) & kCTRunStatusRightToLeft) == rtl);
-
- if (!outOBounds && outGlyphs + glyphCount - initialGlyph > *nglyphs) {
- outOBounds = true;
- }
- if (!outOBounds) {
- CFDictionaryRef runAttribs = CTRunGetAttributes(run);
- //NSLog(@"Dictionary %@", runAttribs);
- if (!runAttribs)
- runAttribs = attributeDict;
- CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
- const uint fontIndex = (fontIndexForFont(runFont) << 24);
- //NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
- QVarLengthArray<CGGlyph, 512> cgglyphs(0);
- const CGGlyph *tmpGlyphs = CTRunGetGlyphsPtr(run);
- if (!tmpGlyphs) {
- cgglyphs.resize(glyphCount);
- CTRunGetGlyphs(run, range, cgglyphs.data());
- tmpGlyphs = cgglyphs.constData();
- }
- QVarLengthArray<CGPoint, 512> cgpoints(0);
- const CGPoint *tmpPoints = CTRunGetPositionsPtr(run);
- if (!tmpPoints) {
- cgpoints.resize(glyphCount);
- CTRunGetPositions(run, range, cgpoints.data());
- tmpPoints = cgpoints.constData();
- }
-
- const int rtlOffset = rtl ? (glyphCount - 1) : 0;
- const int rtlSign = rtl ? -1 : 1;
-
- if (logClusters) {
- CFRange stringRange = CTRunGetStringRange(run);
- QVarLengthArray<CFIndex, 512> stringIndices(0);
- const CFIndex *tmpIndices = CTRunGetStringIndicesPtr(run);
- if (!tmpIndices) {
- stringIndices.resize(glyphCount);
- CTRunGetStringIndices(run, range, stringIndices.data());
- tmpIndices = stringIndices.constData();
- }
-
- const int firstGlyphIndex = outGlyphs - initialGlyph;
- outAttributes[0].clusterStart = true;
-
- CFIndex k = 0;
- CFIndex i = 0;
- for (i = stringRange.location;
- (i < stringRange.location + stringRange.length) && (k < glyphCount); ++i) {
- if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location) {
- logClusters[i] = k + firstGlyphIndex;
- outAttributes[k].clusterStart = true;
- ++k;
- } else {
- logClusters[i] = k + firstGlyphIndex - 1;
- }
- }
- // in case of a ligature at the end, fill the remaining logcluster entries
- for (;i < stringRange.location + stringRange.length; i++) {
- logClusters[i] = k + firstGlyphIndex - 1;
- }
- }
- for (CFIndex i = 0; i < glyphCount - 1; ++i) {
- int idx = rtlOffset + rtlSign * i;
- outGlyphs[idx] = tmpGlyphs[i] | fontIndex;
- outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
- outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y);
-
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
- outAdvances_x[idx] = outAdvances_x[idx].round();
- outAdvances_y[idx] = outAdvances_y[idx].round();
- }
- }
- CGSize lastGlyphAdvance;
- CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1);
-
- outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex;
- outAdvances_x[rtl ? 0 : (glyphCount - 1)] =
- (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? QFixed::fromReal(lastGlyphAdvance.width).round()
- : QFixed::fromReal(lastGlyphAdvance.width);
- }
- outGlyphs += glyphCount;
- outAttributes += glyphCount;
- outAdvances_x += glyphCount;
- outAdvances_y += glyphCount;
- }
- *nglyphs = (outGlyphs - initialGlyph);
- return !outOBounds;
-}
-
-bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
- int *nglyphs, QTextEngine::ShaperFlags flags) const
-{
- *nglyphs = len;
- QCFType<CFStringRef> cfstring;
-
- QVarLengthArray<CGGlyph> cgGlyphs(len);
- CTFontGetGlyphsForCharacters(ctfont, (const UniChar*)str, cgGlyphs.data(), len);
-
- for (int i = 0; i < len; ++i) {
- if (cgGlyphs[i]) {
- glyphs->glyphs[i] = cgGlyphs[i];
- } else {
- if (!cfstring)
- cfstring = CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar *>(str), len, kCFAllocatorNull);
- QCFType<CTFontRef> substituteFont = CTFontCreateForString(ctfont, cfstring, CFRangeMake(i, 1));
- CGGlyph substituteGlyph = 0;
- CTFontGetGlyphsForCharacters(substituteFont, (const UniChar*)str + i, &substituteGlyph, 1);
- if (substituteGlyph) {
- const uint fontIndex = (fontIndexForFont(substituteFont) << 24);
- glyphs->glyphs[i] = substituteGlyph | fontIndex;
- if (!(flags & QTextEngine::GlyphIndicesOnly)) {
- CGSize advance;
- CTFontGetAdvancesForGlyphs(substituteFont, kCTFontHorizontalOrientation, &substituteGlyph, &advance, 1);
- glyphs->advances_x[i] = QFixed::fromReal(advance.width);
- glyphs->advances_y[i] = QFixed::fromReal(advance.height);
- }
- }
- }
- }
-
- if (flags & QTextEngine::GlyphIndicesOnly)
- return true;
-
- QVarLengthArray<CGSize> advances(len);
- CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), len);
-
- for (int i = 0; i < len; ++i) {
- if (glyphs->glyphs[i] & 0xff000000)
- continue;
- glyphs->advances_x[i] = QFixed::fromReal(advances[i].width);
- glyphs->advances_y[i] = QFixed::fromReal(advances[i].height);
- }
-
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
- for (int i = 0; i < len; ++i) {
- glyphs->advances_x[i] = glyphs->advances_x[i].round();
- glyphs->advances_y[i] = glyphs->advances_y[i].round();
- }
- }
-
- return true;
-}
-
-void QCoreTextFontEngineMulti::recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const
-{
-}
-void QCoreTextFontEngineMulti::doKerning(int , QGlyphLayout *, QTextEngine::ShaperFlags) const
-{
-}
-
-void QCoreTextFontEngineMulti::loadEngine(int)
-{
- // Do nothing
- Q_ASSERT(false);
-}
-
-
-
-QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def,
- QCoreTextFontEngineMulti *multiEngine)
-{
- fontDef = def;
- parentEngine = multiEngine;
- synthesisFlags = 0;
- ctfont = font;
- CFRetain(ctfont);
- ATSFontRef atsfont = CTFontGetPlatformFont(ctfont, 0);
- cgFont = CGFontCreateWithPlatformFont(&atsfont);
- CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont);
- if (fontDef.weight >= QFont::Bold && !(traits & kCTFontBoldTrait)) {
- synthesisFlags |= SynthesizedBold;
- }
-
- if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait)) {
- synthesisFlags |= SynthesizedItalic;
- }
- transform = CGAffineTransformIdentity;
- if (fontDef.stretch != 100) {
- transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
- }
- QByteArray os2Table = getSfntTable(MAKE_TAG('O', 'S', '/', '2'));
- if (os2Table.size() >= 10)
- fsType = qFromBigEndian<quint16>(reinterpret_cast<const uchar *>(os2Table.constData() + 8));
-}
-
-QCoreTextFontEngine::~QCoreTextFontEngine()
-{
- CFRelease(ctfont);
- CFRelease(cgFont);
-}
-
-bool QCoreTextFontEngine::stringToCMap(const QChar *, int, QGlyphLayout *, int *, QTextEngine::ShaperFlags) const
-{
- return false;
-}
-
-glyph_metrics_t QCoreTextFontEngine::boundingBox(const QGlyphLayout &glyphs)
-{
- QFixed w;
- bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
-
- for (int i = 0; i < glyphs.numGlyphs; ++i) {
- w += round ? glyphs.effectiveAdvance(i).round()
- : glyphs.effectiveAdvance(i);
- }
- return glyph_metrics_t(0, -(ascent()), w - lastRightBearing(glyphs, round), ascent()+descent(), w, 0);
-}
-glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
-{
- glyph_metrics_t ret;
- CGGlyph g = glyph;
- CGRect rect = CTFontGetBoundingRectsForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, 0, 1);
- if (synthesisFlags & QFontEngine::SynthesizedItalic) {
- rect.size.width += rect.size.height * SYNTHETIC_ITALIC_SKEW;
- }
- ret.width = QFixed::fromReal(rect.size.width);
- ret.height = QFixed::fromReal(rect.size.height);
- ret.x = QFixed::fromReal(rect.origin.x);
- ret.y = -QFixed::fromReal(rect.origin.y) - ret.height;
- CGSize advances[1];
- CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1);
- ret.xoff = QFixed::fromReal(advances[0].width);
- ret.yoff = QFixed::fromReal(advances[0].height);
-
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
- ret.xoff = ret.xoff.round();
- ret.yoff = ret.yoff.round();
- }
-
- return ret;
-}
-
-QFixed QCoreTextFontEngine::ascent() const
-{
- return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? QFixed::fromReal(CTFontGetAscent(ctfont)).round()
- : QFixed::fromReal(CTFontGetAscent(ctfont));
-}
-QFixed QCoreTextFontEngine::descent() const
-{
- QFixed d = QFixed::fromReal(CTFontGetDescent(ctfont));
- if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- d = d.round();
-
- // subtract a pixel to even out the historical +1 in QFontMetrics::height().
- // Fix in Qt 5.
- return d - 1;
-}
-QFixed QCoreTextFontEngine::leading() const
-{
- return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? QFixed::fromReal(CTFontGetLeading(ctfont)).round()
- : QFixed::fromReal(CTFontGetLeading(ctfont));
-}
-QFixed QCoreTextFontEngine::xHeight() const
-{
- return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? QFixed::fromReal(CTFontGetXHeight(ctfont)).round()
- : QFixed::fromReal(CTFontGetXHeight(ctfont));
-}
-QFixed QCoreTextFontEngine::averageCharWidth() const
-{
- // ### Need to implement properly and get the information from the OS/2 Table.
- return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
- ? QFontEngine::averageCharWidth().round()
- : QFontEngine::averageCharWidth();
-}
-
-qreal QCoreTextFontEngine::maxCharWidth() const
-{
- // ### Max Help!
- return 0;
-
-}
-qreal QCoreTextFontEngine::minLeftBearing() const
-{
- // ### Min Help!
- return 0;
-
-}
-qreal QCoreTextFontEngine::minRightBearing() const
-{
- // ### Max Help! (even thought it's right)
- return 0;
-
-}
-
-void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight)
-{
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix;
- matrix.translate(x, y);
- getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- if (glyphs.size() == 0)
- return;
-
- CGContextSetFontSize(ctx, fontDef.pixelSize);
-
- CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
-
- CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight);
-
- CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
- if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
-
- cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
- CGContextSetTextMatrix(ctx, cgMatrix);
-
- CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
-
- QVarLengthArray<CGSize> advances(glyphs.size());
- QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
- for (int i = 0; i < glyphs.size() - 1; ++i) {
- advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
- advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
- cgGlyphs[i] = glyphs[i];
- }
- advances[glyphs.size() - 1].width = 0;
- advances[glyphs.size() - 1].height = 0;
- cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
-
- CGContextSetFont(ctx, cgFont);
- //NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
-
- CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
-
- if (synthesisFlags & QFontEngine::SynthesizedBold) {
- CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
- positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
- }
-
- CGContextSetTextMatrix(ctx, oldTextMatrix);
-}
-
-struct ConvertPathInfo
-{
- ConvertPathInfo(QPainterPath *newPath, const QPointF &newPos) : path(newPath), pos(newPos) {}
- QPainterPath *path;
- QPointF pos;
-};
-
-static void convertCGPathToQPainterPath(void *info, const CGPathElement *element)
-{
- ConvertPathInfo *myInfo = static_cast<ConvertPathInfo *>(info);
- switch(element->type) {
- case kCGPathElementMoveToPoint:
- myInfo->path->moveTo(element->points[0].x + myInfo->pos.x(),
- element->points[0].y + myInfo->pos.y());
- break;
- case kCGPathElementAddLineToPoint:
- myInfo->path->lineTo(element->points[0].x + myInfo->pos.x(),
- element->points[0].y + myInfo->pos.y());
- break;
- case kCGPathElementAddQuadCurveToPoint:
- myInfo->path->quadTo(element->points[0].x + myInfo->pos.x(),
- element->points[0].y + myInfo->pos.y(),
- element->points[1].x + myInfo->pos.x(),
- element->points[1].y + myInfo->pos.y());
- break;
- case kCGPathElementAddCurveToPoint:
- myInfo->path->cubicTo(element->points[0].x + myInfo->pos.x(),
- element->points[0].y + myInfo->pos.y(),
- element->points[1].x + myInfo->pos.x(),
- element->points[1].y + myInfo->pos.y(),
- element->points[2].x + myInfo->pos.x(),
- element->points[2].y + myInfo->pos.y());
- break;
- case kCGPathElementCloseSubpath:
- myInfo->path->closeSubpath();
- break;
- default:
- qDebug() << "Unhandled path transform type: " << element->type;
- }
-
-}
-
-void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
- QPainterPath *path, QTextItem::RenderFlags)
-{
-
- CGAffineTransform cgMatrix = CGAffineTransformIdentity;
- cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
-
- if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
-
-
- for (int i = 0; i < nGlyphs; ++i) {
- QCFType<CGPathRef> cgpath = CTFontCreatePathForGlyph(ctfont, glyphs[i], &cgMatrix);
- ConvertPathInfo info(path, positions[i].toPointF());
- CGPathApply(cgpath, &info, convertCGPathToQPainterPath);
- }
-}
-
-QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa)
-{
- const glyph_metrics_t br = boundingBox(glyph);
- QImage im(qRound(br.width)+2, qRound(br.height)+2, QImage::Format_RGB32);
- im.fill(0);
-
- CGColorSpaceRef colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
- uint cgflags = kCGImageAlphaNoneSkipFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
- cgflags |= kCGBitmapByteOrder32Host;
-#endif
- CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(),
- 8, im.bytesPerLine(), colorspace,
- cgflags);
- CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, aa ||
- (fontDef.pointSize > qt_antialiasing_threshold
- && !(fontDef.styleStrategy & QFont::NoAntialias)));
- CGContextSetShouldSmoothFonts(ctx, aa);
- CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
- CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
-
- CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
- if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
-
- cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
- CGContextSetTextMatrix(ctx, cgMatrix);
- CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
- CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
- ATSFontRef atsfont = CTFontGetPlatformFont(ctfont, 0);
- QCFType<CGFontRef> cgFont = CGFontCreateWithPlatformFont(&atsfont);
- CGContextSetFont(ctx, cgFont);
-
- qreal pos_x = -br.x.toReal()+1, pos_y = im.height()+br.y.toReal();
- CGContextSetTextPosition(ctx, pos_x, pos_y);
-
- CGSize advance;
- advance.width = 0;
- advance.height = 0;
- CGGlyph cgGlyph = glyph;
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
-
- if (synthesisFlags & QFontEngine::SynthesizedBold) {
- CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
- }
-
- CGContextRelease(ctx);
-
- return im;
-}
-
-QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
-{
- QImage im = imageForGlyph(glyph, 0, false);
-
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
-
- for (int y=0; y<im.height(); ++y) {
- uint *src = (uint*) im.scanLine(y);
- uchar *dst = indexed.scanLine(y);
- for (int x=0; x<im.width(); ++x) {
- *dst = qGray(*src);
- ++dst;
- ++src;
- }
- }
-
- return indexed;
-}
-
-QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &x)
-{
- if (x.type() >= QTransform::TxScale)
- return QFontEngine::alphaRGBMapForGlyph(glyph, margin, x);
-
- QImage im = imageForGlyph(glyph, margin, true);
- qmacfontengine_gamma_correct(&im);
- return im;
-}
-
-void QCoreTextFontEngine::recalcAdvances(int numGlyphs, QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
-{
- Q_ASSERT(false);
- Q_UNUSED(numGlyphs);
- Q_UNUSED(glyphs);
- Q_UNUSED(flags);
-}
-
-QFontEngine::FaceId QCoreTextFontEngine::faceId() const
-{
- return QFontEngine::FaceId();
-}
-
-bool QCoreTextFontEngine::canRender(const QChar *string, int len)
-{
- QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
- QCFType<CFStringRef>(CFStringCreateWithCharactersNoCopy(0,
- reinterpret_cast<const UniChar *>(string),
- len, kCFAllocatorNull)),
- CFRangeMake(0, len));
- return retFont != 0;
- return false;
-}
-
- bool QCoreTextFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const
- {
- QCFType<CFDataRef> table = CTFontCopyTable(ctfont, tag, 0);
- if (!table || !length)
- return false;
- CFIndex tableLength = CFDataGetLength(table);
- int availableLength = *length;
- *length = tableLength;
- if (buffer) {
- if (tableLength > availableLength)
- return false;
- CFDataGetBytes(table, CFRangeMake(0, tableLength), buffer);
- }
- return true;
- }
-
-void QCoreTextFontEngine::getUnscaledGlyph(glyph_t, QPainterPath *, glyph_metrics_t *)
-{
- // ###
-}
-
-#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-
#ifndef QT_MAC_USE_COCOA
QFontEngineMacMulti::QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
: QFontEngineMulti(0)
@@ -1424,6 +749,7 @@ static inline unsigned int getChar(const QChar *str, int &i, const int len)
return uc;
}
+// Not used directly for shaping, only used to calculate m_averageCharWidth
bool QFontEngineMac::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
{
if (!cmap) {
@@ -1596,6 +922,27 @@ static void addGlyphsToPathHelper(ATSUStyle style, glyph_t *glyphs, QFixedPoint
DisposeATSCubicClosePathUPP(closePath);
}
+QFont QFontEngineMac::createExplicitFont() const
+{
+ FMFont fmFont = FMGetFontFromATSFontRef(fontID);
+
+ FMFontFamily fmFamily;
+ FMFontStyle fmStyle;
+ QString familyName;
+ if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) {
+ ATSFontFamilyRef familyRef = FMGetATSFontFamilyRefFromFontFamily(fmFamily);
+ QCFString cfFamilyName;;
+ ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &cfFamilyName);
+ familyName = cfFamilyName;
+ } else {
+ QCFString cfFontName;
+ ATSFontGetName(fontID, kATSOptionFlagsDefault, &cfFontName);
+ familyName = cfFontName;
+ }
+
+ return createExplicitFontWithName(familyName);
+}
+
void QFontEngineMac::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path,
QTextItem::RenderFlags)
{
@@ -1630,7 +977,7 @@ QImage QFontEngineMac::imageForGlyph(glyph_t glyph, int margin, bool colorful)
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0));
cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
@@ -1682,7 +1029,7 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
return indexed;
}
-QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t)
+QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, QFixed, int margin, const QTransform &t)
{
QImage im = imageForGlyph(glyph, margin, true);
@@ -1690,7 +1037,7 @@ QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
im = im.transformed(t);
}
- qmacfontengine_gamma_correct(&im);
+ qGamma_correct_back_to_linear_cs(&im);
return im;
}
@@ -1723,7 +1070,7 @@ void QFontEngineMac::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
diff --git a/src/gui/text/qfontengine_mac_p.h b/src/gui/text/qfontengine_mac_p.h
new file mode 100644
index 0000000..6967348
--- /dev/null
+++ b/src/gui/text/qfontengine_mac_p.h
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** 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 QFONTENGINE_MAC_P_H
+#define QFONTENGINE_MAC_P_H
+
+#include <private/qfontengine_p.h>
+
+#ifndef QT_MAC_USE_COCOA
+class QFontEngineMacMulti;
+class QFontEngineMac : public QFontEngine
+{
+ friend class QFontEngineMacMulti;
+public:
+ QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine = 0);
+ virtual ~QFontEngineMac();
+
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const;
+ virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
+
+ virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
+ virtual glyph_metrics_t boundingBox(glyph_t glyph);
+
+ virtual QFixed ascent() const;
+ virtual QFixed descent() const;
+ virtual QFixed leading() const;
+ virtual QFixed xHeight() const;
+ virtual qreal maxCharWidth() const;
+ virtual QFixed averageCharWidth() const;
+
+ virtual QFont createExplicitFont() const;
+
+ virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
+ QPainterPath *path, QTextItem::RenderFlags);
+
+ virtual const char *name() const { return "QFontEngineMac"; }
+
+ virtual bool canRender(const QChar *string, int len);
+
+ virtual int synthesized() const { return synthesisFlags; }
+
+ virtual Type type() const { return QFontEngine::Mac; }
+
+ void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
+
+ virtual FaceId faceId() const;
+ virtual QByteArray getSfntTable(uint tag) const;
+ virtual Properties properties() const;
+ virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
+ virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+
+private:
+ QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
+
+ ATSUFontID fontID;
+ QCFType<CGFontRef> cgFont;
+ ATSUStyle style;
+ int synthesisFlags;
+ mutable QGlyphLayout kashidaGlyph;
+ QFontEngineMacMulti *multiEngine;
+ mutable const unsigned char *cmap;
+ mutable bool symbolCMap;
+ mutable QByteArray cmapTable;
+ CGAffineTransform transform;
+ QFixed m_ascent;
+ QFixed m_descent;
+ QFixed m_leading;
+ qreal m_maxCharWidth;
+ QFixed m_xHeight;
+ QFixed m_averageCharWidth;
+};
+
+class QFontEngineMacMulti : public QFontEngineMulti
+{
+ friend class QFontEngineMac;
+public:
+ // internal
+ struct ShaperItem
+ {
+ inline ShaperItem() : string(0), from(0), length(0),
+ log_clusters(0), charAttributes(0) {}
+
+ const QChar *string;
+ int from;
+ int length;
+ QGlyphLayout glyphs;
+ unsigned short *log_clusters;
+ const HB_CharAttributes *charAttributes;
+ QTextEngine::ShaperFlags flags;
+ };
+
+ QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning);
+ virtual ~QFontEngineMacMulti();
+
+ virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
+ unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
+
+ virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
+ virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
+
+ virtual const char *name() const { return "ATSUI"; }
+
+ virtual bool canRender(const QChar *string, int len);
+
+ inline ATSUFontID macFontID() const { return fontID; }
+
+protected:
+ virtual void loadEngine(int at);
+
+private:
+ inline const QFontEngineMac *engineAt(int i) const
+ { return static_cast<const QFontEngineMac *>(engines.at(i)); }
+
+ bool stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags, ShaperItem *item) const;
+
+ int fontIndexForFontID(ATSUFontID id) const;
+
+ ATSUFontID fontID;
+ uint kerning : 1;
+
+ mutable ATSUTextLayout textLayout;
+ mutable ATSUStyle style;
+ CGAffineTransform transform;
+};
+#endif //!QT_MAC_USE_COCOA
+
+#endif // QFONTENGINE_MAC_P_H
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index ea2d925..f501141 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -117,9 +117,19 @@ public:
// S60 types
S60FontEngine, // Cannot be simply called "S60". Reason is qt_s60Data.h
+ DirectWrite,
+
TestFontEngine = 0x1000
};
+ enum GlyphFormat {
+ Format_None,
+ Format_Render = Format_None,
+ Format_Mono,
+ Format_A8,
+ Format_A32
+ };
+
QFontEngine();
virtual ~QFontEngine();
@@ -155,6 +165,7 @@ public:
SynthesizedStretch = 0x4
};
virtual int synthesized() const { return 0; }
+ virtual bool supportsSubPixelPositions() const { return false; }
virtual QFixed emSquareSize() const { return ascent(); }
@@ -168,11 +179,15 @@ public:
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const {}
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
+#if !defined(Q_WS_X11) && !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN) && !defined(Q_WS_QPA)
virtual void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si) = 0;
#endif
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
QPainterPath *path, QTextItem::RenderFlags flags);
+
+ /* Creates a QFont object to represent this particular QFontEngine */
+ virtual QFont createExplicitFont() const;
+
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags,
QVarLengthArray<glyph_t> &glyphs_out, QVarLengthArray<QFixedPoint> &positions);
@@ -183,8 +198,15 @@ public:
* Returns an image indexed_8 with index values ranging from 0=fully transparent to 255=opaque
*/
virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
+ virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+
+ virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, const QTransform &matrix, GlyphFormat /*format*/)
+ {
+ return boundingBox(glyph, matrix);
+ }
virtual void removeGlyphFromCache(glyph_t);
@@ -237,7 +259,7 @@ public:
bool symbol;
mutable HB_FontRec hbFont;
mutable HB_Face hbFace;
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
struct KernPair {
uint left_right;
QFixed adjust;
@@ -254,13 +276,14 @@ public:
int glyphFormat;
protected:
+ QFont createExplicitFontWithName(const QString &familyName) const;
static const QVector<QRgb> &grayPalette();
QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false);
private:
struct GlyphCacheEntry {
void *context;
- QFontEngineGlyphCache *cache;
+ QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache;
bool operator==(const GlyphCacheEntry &other) { return context == other.context && cache == other.cache; }
};
@@ -412,214 +435,6 @@ protected:
QVector<QFontEngine *> engines;
};
-#if defined(Q_WS_MAC)
-
-struct QCharAttributes;
-class QFontEngineMacMulti;
-# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-class QCoreTextFontEngineMulti;
-class QCoreTextFontEngine : public QFontEngine
-{
-public:
- QCoreTextFontEngine(CTFontRef font, const QFontDef &def,
- QCoreTextFontEngineMulti *multiEngine = 0);
- ~QCoreTextFontEngine();
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
- virtual void recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
-
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual QFixed xHeight() const;
- virtual qreal maxCharWidth() const;
- virtual QFixed averageCharWidth() const;
-
- virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
- QPainterPath *path, QTextItem::RenderFlags);
-
- virtual const char *name() const { return "QCoreTextFontEngine"; }
-
- virtual bool canRender(const QChar *string, int len);
-
- virtual int synthesized() const { return synthesisFlags; }
-
- virtual Type type() const { return QFontEngine::Mac; }
-
- void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
-
- virtual FaceId faceId() const;
- virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const;
- virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
- virtual QImage alphaMapForGlyph(glyph_t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
- virtual qreal minRightBearing() const;
- virtual qreal minLeftBearing() const;
-
-
-private:
- QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
- CTFontRef ctfont;
- CGFontRef cgFont;
- QCoreTextFontEngineMulti *parentEngine;
- int synthesisFlags;
- CGAffineTransform transform;
- friend class QCoreTextFontEngineMulti;
-};
-
-class QCoreTextFontEngineMulti : public QFontEngineMulti
-{
-public:
- QCoreTextFontEngineMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef,
- const QFontDef &fontDef, bool kerning);
- ~QCoreTextFontEngineMulti();
-
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
- QTextEngine::ShaperFlags flags) const;
- bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
- QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
-
-
- virtual void recalcAdvances(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
- virtual void doKerning(int , QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
- virtual const char *name() const { return "CoreText"; }
-protected:
- virtual void loadEngine(int at);
-
-private:
- inline const QCoreTextFontEngine *engineAt(int i) const
- { return static_cast<const QCoreTextFontEngine *>(engines.at(i)); }
-
- uint fontIndexForFont(CTFontRef id) const;
- CTFontRef ctfont;
- mutable QCFType<CFMutableDictionaryRef> attributeDict;
- CGAffineTransform transform;
- friend class QFontDialogPrivate;
-};
-# endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-
-#ifndef QT_MAC_USE_COCOA
-class QFontEngineMac : public QFontEngine
-{
- friend class QFontEngineMacMulti;
-public:
- QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine = 0);
- virtual ~QFontEngineMac();
-
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const;
- virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
- virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
- virtual glyph_metrics_t boundingBox(glyph_t glyph);
-
- virtual QFixed ascent() const;
- virtual QFixed descent() const;
- virtual QFixed leading() const;
- virtual QFixed xHeight() const;
- virtual qreal maxCharWidth() const;
- virtual QFixed averageCharWidth() const;
-
- virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
- QPainterPath *path, QTextItem::RenderFlags);
-
- virtual const char *name() const { return "QFontEngineMac"; }
-
- virtual bool canRender(const QChar *string, int len);
-
- virtual int synthesized() const { return synthesisFlags; }
-
- virtual Type type() const { return QFontEngine::Mac; }
-
- void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
-
- virtual FaceId faceId() const;
- virtual QByteArray getSfntTable(uint tag) const;
- virtual Properties properties() const;
- virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
- virtual QImage alphaMapForGlyph(glyph_t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
-
-private:
- QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
-
- ATSUFontID fontID;
- QCFType<CGFontRef> cgFont;
- ATSUStyle style;
- int synthesisFlags;
- mutable QGlyphLayout kashidaGlyph;
- QFontEngineMacMulti *multiEngine;
- mutable const unsigned char *cmap;
- mutable bool symbolCMap;
- mutable QByteArray cmapTable;
- CGAffineTransform transform;
- QFixed m_ascent;
- QFixed m_descent;
- QFixed m_leading;
- qreal m_maxCharWidth;
- QFixed m_xHeight;
- QFixed m_averageCharWidth;
-};
-
-class QFontEngineMacMulti : public QFontEngineMulti
-{
- friend class QFontEngineMac;
-public:
- // internal
- struct ShaperItem
- {
- inline ShaperItem() : string(0), from(0), length(0),
- log_clusters(0), charAttributes(0) {}
-
- const QChar *string;
- int from;
- int length;
- QGlyphLayout glyphs;
- unsigned short *log_clusters;
- const HB_CharAttributes *charAttributes;
- QTextEngine::ShaperFlags flags;
- };
-
- QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning);
- virtual ~QFontEngineMacMulti();
-
- virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
- bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
- unsigned short *logClusters, const HB_CharAttributes *charAttributes) const;
-
- virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
- virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
- virtual const char *name() const { return "ATSUI"; }
-
- virtual bool canRender(const QChar *string, int len);
-
- inline ATSUFontID macFontID() const { return fontID; }
-
-protected:
- virtual void loadEngine(int at);
-
-private:
- inline const QFontEngineMac *engineAt(int i) const
- { return static_cast<const QFontEngineMac *>(engines.at(i)); }
-
- bool stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags, ShaperItem *item) const;
-
- int fontIndexForFontID(ATSUFontID id) const;
-
- ATSUFontID fontID;
- uint kerning : 1;
-
- mutable ATSUTextLayout textLayout;
- mutable ATSUStyle style;
- CGAffineTransform transform;
-};
-#endif //!QT_MAC_USE_COCOA
-#endif
-
class QTestFontEngine : public QFontEngineBox
{
public:
diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp
new file mode 100644
index 0000000..851bb59
--- /dev/null
+++ b/src/gui/text/qfontengine_qpa.cpp
@@ -0,0 +1,691 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfontengine_qpa_p.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QBuffer>
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/QPlatformFontDatabase>
+#include <QtGui/private/qpaintengine_raster_p.h>
+
+QT_BEGIN_NAMESPACE
+
+//#define DEBUG_HEADER
+//#define DEBUG_FONTENGINE
+
+static QFontEngineQPA::TagType tagTypes[QFontEngineQPA::NumTags] = {
+ QFontEngineQPA::StringType, // FontName
+ QFontEngineQPA::StringType, // FileName
+ QFontEngineQPA::UInt32Type, // FileIndex
+ QFontEngineQPA::UInt32Type, // FontRevision
+ QFontEngineQPA::StringType, // FreeText
+ QFontEngineQPA::FixedType, // Ascent
+ QFontEngineQPA::FixedType, // Descent
+ QFontEngineQPA::FixedType, // Leading
+ QFontEngineQPA::FixedType, // XHeight
+ QFontEngineQPA::FixedType, // AverageCharWidth
+ QFontEngineQPA::FixedType, // MaxCharWidth
+ QFontEngineQPA::FixedType, // LineThickness
+ QFontEngineQPA::FixedType, // MinLeftBearing
+ QFontEngineQPA::FixedType, // MinRightBearing
+ QFontEngineQPA::FixedType, // UnderlinePosition
+ QFontEngineQPA::UInt8Type, // GlyphFormat
+ QFontEngineQPA::UInt8Type, // PixelSize
+ QFontEngineQPA::UInt8Type, // Weight
+ QFontEngineQPA::UInt8Type, // Style
+ QFontEngineQPA::StringType, // EndOfHeader
+ QFontEngineQPA::BitFieldType// WritingSystems
+};
+
+
+#if defined(DEBUG_HEADER)
+# define DEBUG_VERIFY qDebug
+#else
+# define DEBUG_VERIFY if (0) qDebug
+#endif
+
+#define READ_VERIFY(type, variable) \
+ if (tagPtr + sizeof(type) > endPtr) { \
+ DEBUG_VERIFY() << "read verify failed in line" << __LINE__; \
+ return 0; \
+ } \
+ variable = qFromBigEndian<type>(tagPtr); \
+ DEBUG_VERIFY() << "read value" << variable << "of type " #type; \
+ tagPtr += sizeof(type)
+
+template <typename T>
+T readValue(const uchar *&data)
+{
+ T value = qFromBigEndian<T>(data);
+ data += sizeof(T);
+ return value;
+}
+
+#define VERIFY(condition) \
+ if (!(condition)) { \
+ DEBUG_VERIFY() << "condition " #condition " failed in line" << __LINE__; \
+ return 0; \
+ }
+
+#define VERIFY_TAG(condition) \
+ if (!(condition)) { \
+ DEBUG_VERIFY() << "verifying tag condition " #condition " failed in line" << __LINE__ << "with tag" << tag; \
+ return 0; \
+ }
+
+static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr)
+{
+ quint16 tag, length;
+ READ_VERIFY(quint16, tag);
+ READ_VERIFY(quint16, length);
+ if (tag == QFontEngineQPA::Tag_EndOfHeader)
+ return endPtr;
+ if (tag < QFontEngineQPA::NumTags) {
+ switch (tagTypes[tag]) {
+ case QFontEngineQPA::BitFieldType:
+ case QFontEngineQPA::StringType:
+ // can't do anything...
+ break;
+ case QFontEngineQPA::UInt32Type:
+ VERIFY_TAG(length == sizeof(quint32));
+ break;
+ case QFontEngineQPA::FixedType:
+ VERIFY_TAG(length == sizeof(quint32));
+ break;
+ case QFontEngineQPA::UInt8Type:
+ VERIFY_TAG(length == sizeof(quint8));
+ break;
+ }
+#if defined(DEBUG_HEADER)
+ if (length == 1)
+ qDebug() << "tag data" << hex << *tagPtr;
+ else if (length == 4)
+ qDebug() << "tag data" << hex << tagPtr[0] << tagPtr[1] << tagPtr[2] << tagPtr[3];
+#endif
+ }
+ return tagPtr + length;
+}
+
+const QFontEngineQPA::Glyph *QFontEngineQPA::findGlyph(glyph_t g) const
+{
+ if (!g || g >= glyphMapEntries)
+ return 0;
+ const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset);
+ quint32 glyphPos = qFromBigEndian<quint32>(gmapPtr[g]);
+ if (glyphPos > glyphDataSize) {
+ if (glyphPos == 0xffffffff)
+ return 0;
+#if defined(DEBUG_FONTENGINE)
+ qDebug() << "glyph" << g << "outside of glyphData, remapping font file";
+#endif
+ if (glyphPos > glyphDataSize)
+ return 0;
+ }
+ return reinterpret_cast<const Glyph *>(fontData + glyphDataOffset + glyphPos);
+}
+
+bool QFontEngineQPA::verifyHeader(const uchar *data, int size)
+{
+ VERIFY(size >= int(sizeof(Header)));
+ const Header *header = reinterpret_cast<const Header *>(data);
+ if (header->magic[0] != 'Q'
+ || header->magic[1] != 'P'
+ || header->magic[2] != 'F'
+ || header->magic[3] != '2')
+ return false;
+
+ VERIFY(header->majorVersion <= CurrentMajorVersion);
+ const quint16 dataSize = qFromBigEndian<quint16>(header->dataSize);
+ VERIFY(size >= int(sizeof(Header)) + dataSize);
+
+ const uchar *tagPtr = data + sizeof(Header);
+ const uchar *tagEndPtr = tagPtr + dataSize;
+ while (tagPtr < tagEndPtr - 3) {
+ tagPtr = verifyTag(tagPtr, tagEndPtr);
+ VERIFY(tagPtr);
+ }
+
+ VERIFY(tagPtr <= tagEndPtr);
+ return true;
+}
+
+QVariant QFontEngineQPA::extractHeaderField(const uchar *data, HeaderTag requestedTag)
+{
+ const Header *header = reinterpret_cast<const Header *>(data);
+ const uchar *tagPtr = data + sizeof(Header);
+ const uchar *endPtr = tagPtr + qFromBigEndian<quint16>(header->dataSize);
+ while (tagPtr < endPtr - 3) {
+ quint16 tag = readValue<quint16>(tagPtr);
+ quint16 length = readValue<quint16>(tagPtr);
+ if (tag == requestedTag) {
+ switch (tagTypes[requestedTag]) {
+ case StringType:
+ return QVariant(QString::fromUtf8(reinterpret_cast<const char *>(tagPtr), length));
+ case UInt32Type:
+ return QVariant(readValue<quint32>(tagPtr));
+ case UInt8Type:
+ return QVariant(uint(*tagPtr));
+ case FixedType:
+ return QVariant(QFixed::fromFixed(readValue<quint32>(tagPtr)).toReal());
+ case BitFieldType:
+ return QVariant(QByteArray(reinterpret_cast<const char *>(tagPtr), length));
+ }
+ return QVariant();
+ } else if (tag == Tag_EndOfHeader) {
+ break;
+ }
+ tagPtr += length;
+ }
+
+ return QVariant();
+}
+
+
+
+static inline unsigned int getChar(const QChar *str, int &i, const int len)
+{
+ unsigned int uc = str[i].unicode();
+ if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) {
+ uint low = str[i+1].unicode();
+ if (low >= 0xdc00 && low < 0xe000) {
+ uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
+ ++i;
+ }
+ }
+ return uc;
+}
+
+QFontEngineQPA::QFontEngineQPA(const QFontDef &def, const QByteArray &data)
+ : fontData(reinterpret_cast<const uchar *>(data.constData())), dataSize(data.size())
+{
+ fontDef = def;
+ cache_cost = 100;
+ externalCMap = 0;
+ cmapOffset = 0;
+ cmapSize = 0;
+ glyphMapOffset = 0;
+ glyphMapEntries = 0;
+ glyphDataOffset = 0;
+ glyphDataSize = 0;
+ kerning_pairs_loaded = false;
+ readOnly = true;
+
+#if defined(DEBUG_FONTENGINE)
+ qDebug() << "QFontEngineQPA::QFontEngineQPA( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ')';
+#endif
+
+ if (!verifyHeader(fontData, dataSize)) {
+#if defined(DEBUG_FONTENGINE)
+ qDebug() << "verifyHeader failed!";
+#endif
+ return;
+ }
+
+ const Header *header = reinterpret_cast<const Header *>(fontData);
+
+ readOnly = (header->lock == 0xffffffff);
+
+ const uchar *imgData = fontData + sizeof(Header) + qFromBigEndian<quint16>(header->dataSize);
+ const uchar *endPtr = fontData + dataSize;
+ while (imgData <= endPtr - 8) {
+ quint16 blockTag = readValue<quint16>(imgData);
+ imgData += 2; // skip padding
+ quint32 blockSize = readValue<quint32>(imgData);
+
+ if (blockTag == CMapBlock) {
+ cmapOffset = imgData - fontData;
+ cmapSize = blockSize;
+ } else if (blockTag == GMapBlock) {
+ glyphMapOffset = imgData - fontData;
+ glyphMapEntries = blockSize / 4;
+ } else if (blockTag == GlyphBlock) {
+ glyphDataOffset = imgData - fontData;
+ glyphDataSize = blockSize;
+ }
+
+ imgData += blockSize;
+ }
+
+ face_id.filename = QFile::encodeName(extractHeaderField(fontData, Tag_FileName).toString());
+ face_id.index = extractHeaderField(fontData, Tag_FileIndex).toInt();
+
+ // get the real cmap
+ if (cmapOffset) {
+ int tableSize = cmapSize;
+ const uchar *cmapPtr = getCMap(fontData + cmapOffset, tableSize, &symbol, &cmapSize);
+ if (cmapPtr)
+ cmapOffset = cmapPtr - fontData;
+ else
+ cmapOffset = 0;
+ } else if (externalCMap) {
+ int tableSize = cmapSize;
+ externalCMap = getCMap(externalCMap, tableSize, &symbol, &cmapSize);
+ }
+
+ // verify all the positions in the glyphMap
+ if (glyphMapOffset) {
+ const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset);
+ for (uint i = 0; i < glyphMapEntries; ++i) {
+ quint32 glyphDataPos = qFromBigEndian<quint32>(gmapPtr[i]);
+ if (glyphDataPos == 0xffffffff)
+ continue;
+ if (glyphDataPos >= glyphDataSize) {
+ // error
+ glyphMapOffset = 0;
+ glyphMapEntries = 0;
+ break;
+ }
+ }
+ }
+
+#if defined(DEBUG_FONTENGINE)
+ if (!isValid())
+ qDebug() << "fontData" << fontData << "dataSize" << dataSize
+ << "externalCMap" << externalCMap << "cmapOffset" << cmapOffset
+ << "glyphMapOffset" << glyphMapOffset << "glyphDataOffset" << glyphDataOffset
+ << "fd" << fd << "glyphDataSize" << glyphDataSize;
+#endif
+}
+
+QFontEngineQPA::~QFontEngineQPA()
+{
+}
+
+bool QFontEngineQPA::getSfntTableData(uint tag, uchar *buffer, uint *length) const
+{
+ Q_UNUSED(tag);
+ Q_UNUSED(buffer);
+ *length = 0;
+ return false;
+}
+
+bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
+{
+ if (*nglyphs < len) {
+ *nglyphs = len;
+ return false;
+ }
+
+#if defined(DEBUG_FONTENGINE)
+ QSet<QChar> seenGlyphs;
+#endif
+
+ const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset);
+
+ bool mirrored = flags & QTextEngine::RightToLeft;
+ int glyph_pos = 0;
+ if (symbol) {
+ for (int i = 0; i < len; ++i) {
+ unsigned int uc = getChar(str, i, len);
+ if (mirrored)
+ uc = QChar::mirroredChar(uc);
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
+ if(!glyphs->glyphs[glyph_pos] && uc < 0x100)
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc + 0xf000);
+ ++glyph_pos;
+ }
+ } else {
+ for (int i = 0; i < len; ++i) {
+ unsigned int uc = getChar(str, i, len);
+ if (mirrored)
+ uc = QChar::mirroredChar(uc);
+ glyphs->glyphs[glyph_pos] = getTrueTypeGlyphIndex(cmap, uc);
+#if 0 && defined(DEBUG_FONTENGINE)
+ QChar c(uc);
+ if (!findGlyph(glyphs[glyph_pos].glyph) && !seenGlyphs.contains(c))
+ qDebug() << "glyph for character" << c << '/' << hex << uc << "is" << dec << glyphs[glyph_pos].glyph;
+
+ seenGlyphs.insert(c);
+#endif
+ ++glyph_pos;
+ }
+ }
+
+ *nglyphs = glyph_pos;
+ glyphs->numGlyphs = glyph_pos;
+ recalcAdvances(glyphs, flags);
+ return true;
+}
+
+void QFontEngineQPA::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
+{
+ for (int i = 0; i < glyphs->numGlyphs; ++i) {
+ const Glyph *g = findGlyph(glyphs->glyphs[i]);
+ if (!g) {
+ glyphs->glyphs[i] = 0;
+ continue;
+ }
+ glyphs->advances_x[i] = g->advance;
+ glyphs->advances_y[i] = 0;
+ }
+}
+
+QImage QFontEngineQPA::alphaMapForGlyph(glyph_t g)
+{
+ const Glyph *glyph = findGlyph(g);
+ if (!glyph)
+ return QImage();
+
+ const uchar *bits = ((const uchar *) glyph) + sizeof(Glyph);
+
+ QImage image(bits,glyph->width, glyph->height, glyph->bytesPerLine, QImage::Format_Indexed8);
+
+ return image;
+}
+
+void QFontEngineQPA::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)
+{
+ addBitmapFontToPath(x, y, glyphs, path, flags);
+}
+
+glyph_metrics_t QFontEngineQPA::boundingBox(const QGlyphLayout &glyphs)
+{
+ glyph_metrics_t overall;
+ // initialize with line height, we get the same behaviour on all platforms
+ overall.y = -ascent();
+ overall.height = ascent() + descent() + 1;
+
+ QFixed ymax = 0;
+ QFixed xmax = 0;
+ for (int i = 0; i < glyphs.numGlyphs; i++) {
+ const Glyph *g = findGlyph(glyphs.glyphs[i]);
+ if (!g)
+ continue;
+
+ QFixed x = overall.xoff + glyphs.offsets[i].x + g->x;
+ QFixed y = overall.yoff + glyphs.offsets[i].y + g->y;
+ overall.x = qMin(overall.x, x);
+ overall.y = qMin(overall.y, y);
+ xmax = qMax(xmax, x + g->width);
+ ymax = qMax(ymax, y + g->height);
+ overall.xoff += g->advance;
+ }
+ overall.height = qMax(overall.height, ymax - overall.y);
+ overall.width = xmax - overall.x;
+
+ return overall;
+}
+
+glyph_metrics_t QFontEngineQPA::boundingBox(glyph_t glyph)
+{
+ glyph_metrics_t overall;
+ const Glyph *g = findGlyph(glyph);
+ if (!g)
+ return overall;
+ overall.x = g->x;
+ overall.y = g->y;
+ overall.width = g->width;
+ overall.height = g->height;
+ overall.xoff = g->advance;
+ return overall;
+}
+
+QFixed QFontEngineQPA::ascent() const
+{
+ return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>());
+}
+
+QFixed QFontEngineQPA::descent() const
+{
+ return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>());
+}
+
+QFixed QFontEngineQPA::leading() const
+{
+ return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value<qreal>());
+}
+
+qreal QFontEngineQPA::maxCharWidth() const
+{
+ return extractHeaderField(fontData, Tag_MaxCharWidth).value<qreal>();
+}
+
+qreal QFontEngineQPA::minLeftBearing() const
+{
+ return extractHeaderField(fontData, Tag_MinLeftBearing).value<qreal>();
+}
+
+qreal QFontEngineQPA::minRightBearing() const
+{
+ return extractHeaderField(fontData, Tag_MinRightBearing).value<qreal>();
+}
+
+QFixed QFontEngineQPA::underlinePosition() const
+{
+ return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value<qreal>());
+}
+
+QFixed QFontEngineQPA::lineThickness() const
+{
+ return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value<qreal>());
+}
+
+QFontEngine::Type QFontEngineQPA::type() const
+{
+ return QFontEngine::QPF2;
+}
+
+bool QFontEngineQPA::canRender(const QChar *string, int len)
+{
+ const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset);
+
+ if (symbol) {
+ for (int i = 0; i < len; ++i) {
+ unsigned int uc = getChar(string, i, len);
+ glyph_t g = getTrueTypeGlyphIndex(cmap, uc);
+ if(!g && uc < 0x100)
+ g = getTrueTypeGlyphIndex(cmap, uc + 0xf000);
+ if (!g)
+ return false;
+ }
+ } else {
+ for (int i = 0; i < len; ++i) {
+ unsigned int uc = getChar(string, i, len);
+ if (!getTrueTypeGlyphIndex(cmap, uc))
+ return false;
+ }
+ }
+ return true;
+}
+
+bool QFontEngineQPA::isValid() const
+{
+ return fontData && dataSize && (cmapOffset || externalCMap)
+ && glyphMapOffset && glyphDataOffset && glyphDataSize > 0;
+}
+
+void QPAGenerator::generate()
+{
+ writeHeader();
+ writeGMap();
+ writeBlock(QFontEngineQPA::GlyphBlock, QByteArray());
+
+ dev->seek(4); // position of header.lock
+ writeUInt32(0);
+}
+
+void QPAGenerator::writeHeader()
+{
+ QFontEngineQPA::Header header;
+
+ header.magic[0] = 'Q';
+ header.magic[1] = 'P';
+ header.magic[2] = 'F';
+ header.magic[3] = '2';
+ header.lock = 1;
+ header.majorVersion = QFontEngineQPA::CurrentMajorVersion;
+ header.minorVersion = QFontEngineQPA::CurrentMinorVersion;
+ header.dataSize = 0;
+ dev->write((const char *)&header, sizeof(header));
+
+ writeTaggedString(QFontEngineQPA::Tag_FontName, fe->fontDef.family.toUtf8());
+
+ QFontEngine::FaceId face = fe->faceId();
+ writeTaggedString(QFontEngineQPA::Tag_FileName, face.filename);
+ writeTaggedUInt32(QFontEngineQPA::Tag_FileIndex, face.index);
+
+ {
+ uchar data[4];
+ uint len = 4;
+ bool ok = fe->getSfntTableData(MAKE_TAG('h', 'e', 'a', 'd'), data, &len);
+ if (ok) {
+ const quint32 revision = qFromBigEndian<quint32>(data);
+ writeTaggedUInt32(QFontEngineQPA::Tag_FontRevision, revision);
+ }
+ }
+
+ writeTaggedQFixed(QFontEngineQPA::Tag_Ascent, fe->ascent());
+ writeTaggedQFixed(QFontEngineQPA::Tag_Descent, fe->descent());
+ writeTaggedQFixed(QFontEngineQPA::Tag_Leading, fe->leading());
+ writeTaggedQFixed(QFontEngineQPA::Tag_XHeight, fe->xHeight());
+ writeTaggedQFixed(QFontEngineQPA::Tag_AverageCharWidth, fe->averageCharWidth());
+ writeTaggedQFixed(QFontEngineQPA::Tag_MaxCharWidth, QFixed::fromReal(fe->maxCharWidth()));
+ writeTaggedQFixed(QFontEngineQPA::Tag_LineThickness, fe->lineThickness());
+ writeTaggedQFixed(QFontEngineQPA::Tag_MinLeftBearing, QFixed::fromReal(fe->minLeftBearing()));
+ writeTaggedQFixed(QFontEngineQPA::Tag_MinRightBearing, QFixed::fromReal(fe->minRightBearing()));
+ writeTaggedQFixed(QFontEngineQPA::Tag_UnderlinePosition, fe->underlinePosition());
+ writeTaggedUInt8(QFontEngineQPA::Tag_PixelSize, fe->fontDef.pixelSize);
+ writeTaggedUInt8(QFontEngineQPA::Tag_Weight, fe->fontDef.weight);
+ writeTaggedUInt8(QFontEngineQPA::Tag_Style, fe->fontDef.style);
+
+ writeTaggedUInt8(QFontEngineQPA::Tag_GlyphFormat, QFontEngineQPA::AlphamapGlyphs);
+
+ writeTaggedString(QFontEngineQPA::Tag_EndOfHeader, QByteArray());
+ align4();
+
+ const quint64 size = dev->pos();
+ header.dataSize = qToBigEndian<quint16>(size - sizeof(header));
+ dev->seek(0);
+ dev->write((const char *)&header, sizeof(header));
+ dev->seek(size);
+}
+
+void QPAGenerator::writeGMap()
+{
+ const quint16 glyphCount = fe->glyphCount();
+
+ writeUInt16(QFontEngineQPA::GMapBlock);
+ writeUInt16(0); // padding
+ writeUInt32(glyphCount * 4);
+
+ QByteArray &buffer = dev->buffer();
+ const int numBytes = glyphCount * sizeof(quint32);
+ qint64 pos = buffer.size();
+ buffer.resize(pos + numBytes);
+ qMemSet(buffer.data() + pos, 0xff, numBytes);
+ dev->seek(pos + numBytes);
+}
+
+void QPAGenerator::writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data)
+{
+ writeUInt16(tag);
+ writeUInt16(0); // padding
+ const int padSize = ((data.size() + 3) / 4) * 4 - data.size();
+ writeUInt32(data.size() + padSize);
+ dev->write(data);
+ for (int i = 0; i < padSize; ++i)
+ writeUInt8(0);
+}
+
+void QPAGenerator::writeTaggedString(QFontEngineQPA::HeaderTag tag, const QByteArray &string)
+{
+ writeUInt16(tag);
+ writeUInt16(string.length());
+ dev->write(string);
+}
+
+void QPAGenerator::writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value)
+{
+ writeUInt16(tag);
+ writeUInt16(sizeof(value));
+ writeUInt32(value);
+}
+
+void QPAGenerator::writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value)
+{
+ writeUInt16(tag);
+ writeUInt16(sizeof(value));
+ writeUInt8(value);
+}
+
+void QPAGenerator::writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value)
+{
+ writeUInt16(tag);
+ writeUInt16(sizeof(quint32));
+ writeUInt32(value.value());
+}
+
+
+/*
+ Creates a new multi QPA engine.
+
+ This function takes ownership of the QFontEngine, increasing it's refcount.
+*/
+QFontEngineMultiQPA::QFontEngineMultiQPA(QFontEngine *fe, int _script, const QStringList &fallbacks)
+ : QFontEngineMulti(fallbacks.size() + 1),
+ fallbackFamilies(fallbacks), script(_script)
+{
+ engines[0] = fe;
+ fe->ref.ref();
+ fontDef = engines[0]->fontDef;
+}
+
+void QFontEngineMultiQPA::loadEngine(int at)
+{
+ Q_ASSERT(at < engines.size());
+ Q_ASSERT(engines.at(at) == 0);
+
+ QFontDef request = fontDef;
+ request.styleStrategy |= QFont::NoFontMerging;
+ request.family = fallbackFamilies.at(at-1);
+ engines[at] = QFontDatabase::findFont(script,
+ /*fontprivate*/0,
+ request);
+ Q_ASSERT(engines[at]);
+ engines[at]->ref.ref();
+ engines[at]->fontDef = request;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_qpa_p.h b/src/gui/text/qfontengine_qpa_p.h
new file mode 100644
index 0000000..e15beae
--- /dev/null
+++ b/src/gui/text/qfontengine_qpa_p.h
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** 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 QFONTENGINE_QPA_P_H
+#define QFONTENGINE_QPA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+#include <QtCore/qconfig.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qendian.h>
+#include <QtCore/QBuffer>
+
+#include "qfontengine_p.h"
+
+#include <QtCore/QFile>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QFontEngine;
+class QFreetypeFace;
+class QBuffer;
+
+class Q_GUI_EXPORT QFontEngineQPA : public QFontEngine
+{
+public:
+ // if you add new tags please make sure to update the tables in
+ // qpfutil.cpp and tools/makeqpf/qpf2.cpp
+ enum HeaderTag {
+ Tag_FontName, // 0 string
+ Tag_FileName, // 1 string
+ Tag_FileIndex, // 2 quint32
+ Tag_FontRevision, // 3 quint32
+ Tag_FreeText, // 4 string
+ Tag_Ascent, // 5 QFixed
+ Tag_Descent, // 6 QFixed
+ Tag_Leading, // 7 QFixed
+ Tag_XHeight, // 8 QFixed
+ Tag_AverageCharWidth, // 9 QFixed
+ Tag_MaxCharWidth, // 10 QFixed
+ Tag_LineThickness, // 11 QFixed
+ Tag_MinLeftBearing, // 12 QFixed
+ Tag_MinRightBearing, // 13 QFixed
+ Tag_UnderlinePosition, // 14 QFixed
+ Tag_GlyphFormat, // 15 quint8
+ Tag_PixelSize, // 16 quint8
+ Tag_Weight, // 17 quint8
+ Tag_Style, // 18 quint8
+ Tag_EndOfHeader, // 19 string
+ Tag_WritingSystems, // 20 bitfield
+
+ NumTags
+ };
+
+ enum TagType {
+ StringType,
+ FixedType,
+ UInt8Type,
+ UInt32Type,
+ BitFieldType
+ };
+
+ struct Tag
+ {
+ quint16 tag;
+ quint16 size;
+ };
+
+ enum GlyphFormat {
+ BitmapGlyphs = 1,
+ AlphamapGlyphs = 8
+ };
+
+ enum {
+ CurrentMajorVersion = 2,
+ CurrentMinorVersion = 0
+ };
+
+ // The CMap is identical to the TrueType CMap table format
+ // The GMap table is a normal array with the total number of
+ // covered glyphs in the TrueType font
+ enum BlockTag {
+ CMapBlock,
+ GMapBlock,
+ GlyphBlock
+ };
+
+ struct Q_PACKED Header
+ {
+ char magic[4]; // 'QPF2'
+ quint32 lock; // values: 0 = unlocked, 0xffffffff = read-only, otherwise qws client id of locking process
+ quint8 majorVersion;
+ quint8 minorVersion;
+ quint16 dataSize;
+ };
+
+ struct Q_PACKED Block
+ {
+ quint16 tag;
+ quint16 pad;
+ quint32 dataSize;
+ };
+
+ struct Q_PACKED Glyph
+ {
+ quint8 width;
+ quint8 height;
+ quint8 bytesPerLine;
+ qint8 x;
+ qint8 y;
+ qint8 advance;
+ };
+
+ QFontEngineQPA(const QFontDef &def, const QByteArray &data);
+ ~QFontEngineQPA();
+
+ FaceId faceId() const { return face_id; }
+ bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
+
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
+ void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
+
+ void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
+ QImage alphaMapForGlyph(glyph_t t);
+
+ glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
+ glyph_metrics_t boundingBox(glyph_t glyph);
+
+ QFixed ascent() const;
+ QFixed descent() const;
+ QFixed leading() const;
+ qreal maxCharWidth() const;
+ qreal minLeftBearing() const;
+ qreal minRightBearing() const;
+ QFixed underlinePosition() const;
+ QFixed lineThickness() const;
+
+ Type type() const;
+
+ bool canRender(const QChar *string, int len);
+ inline const char *name() const { return "QPF2"; }
+
+ virtual int glyphCount() const { return glyphMapEntries; }
+
+ bool isValid() const;
+
+ const Glyph *findGlyph(glyph_t g) const;
+
+ static bool verifyHeader(const uchar *data, int size);
+ static QVariant extractHeaderField(const uchar *data, HeaderTag tag);
+
+private:
+
+ const uchar *fontData;
+ int dataSize;
+ const uchar *externalCMap;
+ quint32 cmapOffset;
+ int cmapSize;
+ quint32 glyphMapOffset;
+ quint32 glyphMapEntries;
+ quint32 glyphDataOffset;
+ quint32 glyphDataSize;
+ QString internalFileName;
+ QString encodedFileName;
+ bool readOnly;
+
+ FaceId face_id;
+ QByteArray freetypeCMapTable;
+ mutable bool kerning_pairs_loaded;
+};
+
+struct QPAGenerator
+{
+ QPAGenerator(QBuffer *device, QFontEngine *engine)
+ : dev(device), fe(engine) {}
+
+ void generate();
+ void writeHeader();
+ void writeGMap();
+ void writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data);
+
+ void writeTaggedString(QFontEngineQPA::HeaderTag tag, const QByteArray &string);
+ void writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value);
+ void writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value);
+ void writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value);
+
+ void writeUInt16(quint16 value) { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); }
+ void writeUInt32(quint32 value) { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); }
+ void writeUInt8(quint8 value) { dev->write((const char *)&value, sizeof(value)); }
+ void writeInt8(qint8 value) { dev->write((const char *)&value, sizeof(value)); }
+
+ void align4() { while (dev->pos() & 3) { dev->putChar('\0'); } }
+
+ QBuffer *dev;
+ QFontEngine *fe;
+};
+
+class QFontEngineMultiQPA : public QFontEngineMulti
+{
+public:
+ QFontEngineMultiQPA(QFontEngine *fe, int script, const QStringList &fallbacks);
+
+ void loadEngine(int at);
+
+private:
+ QStringList fallbackFamilies;
+ int script;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFONTENGINE_QPA_P_H
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index 2fd4716..d35bbe5 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -306,6 +306,8 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
glyphMapEntries = 0;
glyphDataOffset = 0;
glyphDataSize = 0;
+ if (renderingFontEngine)
+ glyphFormat = renderingFontEngine->glyphFormat;
kerning_pairs_loaded = false;
readOnly = true;
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 f2b6f5c..e9b54e3 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -108,7 +108,8 @@ QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const
Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag));
TInt error = KErrNone;
TInt tableByteLength = 0;
- TAny *table = q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength));
+ TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
+ Q_CHECK_PTR(table);
const QByteArray result(static_cast<const char*>(table), tableByteLength);
m_trueTypeExtension->ReleaseTrueTypeTable(table);
return result;
@@ -138,8 +139,8 @@ bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *len
TInt error = KErrNone;
TInt tableByteLength;
- TAny *table =
- q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength));
+ TAny *table = m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength);
+ Q_CHECK_PTR(table);
if (error != KErrNone) {
return false;
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 167e19a..82d9da0 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1251,7 +1251,7 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C
#define SPI_SETFONTSMOOTHINGCONTRAST 0x200D
-QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t)
+QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, QFixed, int margin, const QTransform &t)
{
HFONT font = hfont;
@@ -1286,7 +1286,7 @@ QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
// -------------------------------------- Multi font engine
-QFontEngineMultiWin::QFontEngineMultiWin(QFontEngineWin *first, const QStringList &fallbacks)
+QFontEngineMultiWin::QFontEngineMultiWin(QFontEngine *first, const QStringList &fallbacks)
: QFontEngineMulti(fallbacks.size()+1),
fallbacks(fallbacks)
{
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index f60a5c3..28d8000 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -104,7 +104,7 @@ public:
virtual QImage alphaMapForGlyph(glyph_t t) { return alphaMapForGlyph(t, QTransform()); }
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
- virtual QImage alphaRGBMapForGlyph(glyph_t t, int margin, const QTransform &xform);
+ virtual QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
#ifndef Q_CC_MINGW
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
@@ -150,7 +150,7 @@ private:
class QFontEngineMultiWin : public QFontEngineMulti
{
public:
- QFontEngineMultiWin(QFontEngineWin *first, const QStringList &fallbacks);
+ QFontEngineMultiWin(QFontEngine *first, const QStringList &fallbacks);
void loadEngine(int at);
QStringList fallbacks;
diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp
index 1b0fbf1..9f3f8d3 100644
--- a/src/gui/text/qfontengine_x11.cpp
+++ b/src/gui/text/qfontengine_x11.cpp
@@ -992,7 +992,7 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
face_id.filename = file_name;
face_id.index = face_index;
- canUploadGlyphsToServer = qApp->thread() == QThread::currentThread();
+ canUploadGlyphsToServer = QApplication::testAttribute(Qt::AA_X11InitThreads) || (qApp->thread() == QThread::currentThread());
subpixelType = Subpixel_None;
if (antialias) {
@@ -1012,10 +1012,29 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s
}
}
+ if (fd.hintingPreference != QFont::PreferDefaultHinting) {
+ switch (fd.hintingPreference) {
+ case QFont::PreferNoHinting:
+ default_hint_style = HintNone;
+ break;
+ case QFont::PreferVerticalHinting:
+ default_hint_style = HintLight;
+ break;
+ case QFont::PreferFullHinting:
+ default:
+ default_hint_style = HintFull;
+ break;
+ }
+ }
#ifdef FC_HINT_STYLE
- {
+ else {
int hint_style = 0;
- if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
+ // Try to use Xft.hintstyle from XDefaults first if running in GNOME, to match
+ // the behavior of cairo
+ if (X11->fc_hint_style > -1 && X11->desktopEnvironment == DE_GNOME)
+ hint_style = X11->fc_hint_style;
+ else if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch
+ && X11->fc_hint_style > -1)
hint_style = X11->fc_hint_style;
switch (hint_style) {
diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp
new file mode 100644
index 0000000..af5bab2
--- /dev/null
+++ b/src/gui/text/qfontenginedirectwrite.cpp
@@ -0,0 +1,641 @@
+/****************************************************************************
+**
+** 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_DIRECTWRITE
+
+#include "qfontenginedirectwrite_p.h"
+
+#include <qendian.h>
+#include <dwrite.h>
+#include <private/qnativeimage_p.h>
+
+#include <d2d1.h>
+
+QT_BEGIN_NAMESPACE
+
+// Convert from design units to logical pixels
+#define DESIGN_TO_LOGICAL(DESIGN_UNIT_VALUE) \
+ QFixed::fromReal((qreal(DESIGN_UNIT_VALUE) / qreal(m_unitsPerEm)) * fontDef.pixelSize)
+
+namespace {
+
+ class GeometrySink: public IDWriteGeometrySink
+ {
+ public:
+ GeometrySink(QPainterPath *path) : m_path(path), m_refCount(0)
+ {
+ Q_ASSERT(m_path != 0);
+ }
+
+ IFACEMETHOD_(void, AddBeziers)(const D2D1_BEZIER_SEGMENT *beziers, UINT bezierCount);
+ IFACEMETHOD_(void, AddLines)(const D2D1_POINT_2F *points, UINT pointCount);
+ IFACEMETHOD_(void, BeginFigure)(D2D1_POINT_2F startPoint, D2D1_FIGURE_BEGIN figureBegin);
+ IFACEMETHOD(Close)();
+ IFACEMETHOD_(void, EndFigure)(D2D1_FIGURE_END figureEnd);
+ IFACEMETHOD_(void, SetFillMode)(D2D1_FILL_MODE fillMode);
+ IFACEMETHOD_(void, SetSegmentFlags)(D2D1_PATH_SEGMENT vertexFlags);
+
+ IFACEMETHOD_(unsigned long, AddRef)();
+ IFACEMETHOD_(unsigned long, Release)();
+ IFACEMETHOD(QueryInterface)(IID const &riid, void **ppvObject);
+
+ private:
+ inline static QPointF fromD2D1_POINT_2F(const D2D1_POINT_2F &inp)
+ {
+ return QPointF(inp.x, inp.y);
+ }
+
+ unsigned long m_refCount;
+ QPointF m_startPoint;
+ QPainterPath *m_path;
+ };
+
+ void GeometrySink::AddBeziers(const D2D1_BEZIER_SEGMENT *beziers,
+ UINT bezierCount)
+ {
+ for (uint i=0; i<bezierCount; ++i) {
+ QPointF c1 = fromD2D1_POINT_2F(beziers[i].point1);
+ QPointF c2 = fromD2D1_POINT_2F(beziers[i].point2);
+ QPointF p2 = fromD2D1_POINT_2F(beziers[i].point3);
+
+ m_path->cubicTo(c1, c2, p2);
+ }
+ }
+
+ void GeometrySink::AddLines(const D2D1_POINT_2F *points, UINT pointsCount)
+ {
+ for (uint i=0; i<pointsCount; ++i)
+ m_path->lineTo(fromD2D1_POINT_2F(points[i]));
+ }
+
+ void GeometrySink::BeginFigure(D2D1_POINT_2F startPoint,
+ D2D1_FIGURE_BEGIN /*figureBegin*/)
+ {
+ m_startPoint = fromD2D1_POINT_2F(startPoint);
+ m_path->moveTo(m_startPoint);
+ }
+
+ IFACEMETHODIMP GeometrySink::Close()
+ {
+ return E_NOTIMPL;
+ }
+
+ void GeometrySink::EndFigure(D2D1_FIGURE_END figureEnd)
+ {
+ if (figureEnd == D2D1_FIGURE_END_CLOSED)
+ m_path->closeSubpath();
+ }
+
+ void GeometrySink::SetFillMode(D2D1_FILL_MODE fillMode)
+ {
+ m_path->setFillRule(fillMode == D2D1_FILL_MODE_ALTERNATE
+ ? Qt::OddEvenFill
+ : Qt::WindingFill);
+ }
+
+ void GeometrySink::SetSegmentFlags(D2D1_PATH_SEGMENT /*vertexFlags*/)
+ {
+ /* Not implemented */
+ }
+
+ IFACEMETHODIMP_(unsigned long) GeometrySink::AddRef()
+ {
+ return InterlockedIncrement(&m_refCount);
+ }
+
+ IFACEMETHODIMP_(unsigned long) GeometrySink::Release()
+ {
+ unsigned long newCount = InterlockedDecrement(&m_refCount);
+ if (newCount == 0)
+ {
+ delete this;
+ return 0;
+ }
+
+ return newCount;
+ }
+
+ IFACEMETHODIMP GeometrySink::QueryInterface(IID const &riid, void **ppvObject)
+ {
+ if (__uuidof(IDWriteGeometrySink) == riid) {
+ *ppvObject = this;
+ } else if (__uuidof(IUnknown) == riid) {
+ *ppvObject = this;
+ } else {
+ *ppvObject = NULL;
+ return E_FAIL;
+ }
+
+ AddRef();
+ return S_OK;
+ }
+
+}
+
+QFontEngineDirectWrite::QFontEngineDirectWrite(const QString &name,
+ IDWriteFactory *directWriteFactory,
+ IDWriteGdiInterop *directWriteGdiInterop,
+ IDWriteFont *directWriteFont,
+ qreal pixelSize)
+ : m_name(name)
+ , m_directWriteFont(directWriteFont)
+ , m_directWriteFontFace(0)
+ , m_directWriteFactory(directWriteFactory)
+ , m_directWriteBitmapRenderTarget(0)
+ , m_directWriteGdiInterop(directWriteGdiInterop)
+ , m_lineThickness(-1)
+ , m_unitsPerEm(-1)
+ , m_ascent(-1)
+ , m_descent(-1)
+ , m_xHeight(-1)
+ , m_lineGap(-1)
+{
+ m_directWriteFont->AddRef();
+ m_directWriteFactory->AddRef();
+ m_directWriteGdiInterop->AddRef();
+
+ fontDef.pixelSize = pixelSize;
+
+ HRESULT hr = m_directWriteFont->CreateFontFace(&m_directWriteFontFace);
+ if (FAILED(hr))
+ qErrnoWarning("QFontEngineDirectWrite: CreateFontFace failed");
+
+ collectMetrics();
+}
+
+QFontEngineDirectWrite::~QFontEngineDirectWrite()
+{
+ m_directWriteFont->Release();
+ m_directWriteFactory->Release();
+ m_directWriteGdiInterop->Release();
+
+ if (m_directWriteBitmapRenderTarget != 0)
+ m_directWriteBitmapRenderTarget->Release();
+}
+
+void QFontEngineDirectWrite::collectMetrics()
+{
+ if (m_directWriteFont != 0) {
+ DWRITE_FONT_METRICS metrics;
+
+ m_directWriteFont->GetMetrics(&metrics);
+ m_unitsPerEm = metrics.designUnitsPerEm;
+
+ m_lineThickness = DESIGN_TO_LOGICAL(metrics.underlineThickness);
+ m_ascent = DESIGN_TO_LOGICAL(metrics.ascent);
+ m_descent = DESIGN_TO_LOGICAL(metrics.descent);
+ m_xHeight = DESIGN_TO_LOGICAL(metrics.xHeight);
+ m_lineGap = DESIGN_TO_LOGICAL(metrics.lineGap);
+ }
+}
+
+QFixed QFontEngineDirectWrite::lineThickness() const
+{
+ if (m_lineThickness > 0)
+ return m_lineThickness;
+ else
+ return QFontEngine::lineThickness();
+}
+
+bool QFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, uint *length) const
+{
+ if (m_directWriteFontFace) {
+ DWORD t = qbswap<quint32>(tag);
+
+ const void *tableData = 0;
+ void *tableContext = 0;
+ UINT32 tableSize;
+ BOOL exists;
+ HRESULT hr = m_directWriteFontFace->TryGetFontTable(
+ t, &tableData, &tableSize, &tableContext, &exists
+ );
+
+ if (SUCCEEDED(hr)) {
+ if (!exists)
+ return false;
+
+ if (buffer == 0) {
+ *length = tableSize;
+ return true;
+ } else if (*length < tableSize) {
+ return false;
+ }
+
+ qMemCopy(buffer, tableData, tableSize);
+ m_directWriteFontFace->ReleaseFontTable(tableContext);
+
+ return true;
+ } else {
+ qErrnoWarning("QFontEngineDirectWrite::getSfntTableData: TryGetFontTable failed");
+ }
+ }
+
+ return false;
+}
+
+QFixed QFontEngineDirectWrite::emSquareSize() const
+{
+ if (m_unitsPerEm > 0)
+ return m_unitsPerEm;
+ else
+ return QFontEngine::emSquareSize();
+}
+
+inline unsigned int getChar(const QChar *str, int &i, const int len)
+{
+ unsigned int uc = str[i].unicode();
+ if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) {
+ uint low = str[i+1].unicode();
+ if (low >= 0xdc00 && low < 0xe000) {
+ uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
+ ++i;
+ }
+ }
+ return uc;
+}
+
+bool QFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
+ int *nglyphs, QTextEngine::ShaperFlags flags) const
+{
+ if (m_directWriteFontFace != 0) {
+ QVarLengthArray<UINT32> codePoints(len);
+ for (int i=0; i<len; ++i) {
+ codePoints[i] = getChar(str, i, len);
+ if (flags & QTextEngine::RightToLeft)
+ codePoints[i] = QChar::mirroredChar(codePoints[i]);
+ }
+
+ QVarLengthArray<UINT16> glyphIndices(len);
+ HRESULT hr = m_directWriteFontFace->GetGlyphIndicesW(codePoints.data(),
+ len,
+ glyphIndices.data());
+
+ if (SUCCEEDED(hr)) {
+ for (int i=0; i<len; ++i)
+ glyphs->glyphs[i] = glyphIndices[i];
+
+ *nglyphs = len;
+
+ if (!(flags & QTextEngine::GlyphIndicesOnly))
+ recalcAdvances(glyphs, 0);
+
+ return true;
+ } else {
+ qErrnoWarning("QFontEngineDirectWrite::stringToCMap: GetGlyphIndicesW failed");
+ }
+ }
+
+ return false;
+}
+
+void QFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
+{
+ if (m_directWriteFontFace == 0)
+ return;
+
+ QVarLengthArray<UINT16> glyphIndices(glyphs->numGlyphs);
+
+ // ### Caching?
+ for(int i=0; i<glyphs->numGlyphs; i++)
+ glyphIndices[i] = UINT16(glyphs->glyphs[i]);
+
+ QVarLengthArray<DWRITE_GLYPH_METRICS> glyphMetrics(glyphIndices.size());
+ HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(glyphIndices.data(),
+ glyphIndices.size(),
+ glyphMetrics.data());
+ if (SUCCEEDED(hr)) {
+ for (int i=0; i<glyphs->numGlyphs; ++i) {
+ glyphs->advances_x[i] = DESIGN_TO_LOGICAL(glyphMetrics[i].advanceWidth);
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ glyphs->advances_x[i] = glyphs->advances_x[i].round();
+ glyphs->advances_y[i] = 0;
+ }
+ } else {
+ qErrnoWarning("QFontEngineDirectWrite::recalcAdvances: GetDesignGlyphMetrics failed");
+ }
+}
+
+void QFontEngineDirectWrite::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
+ QPainterPath *path, QTextItem::RenderFlags flags)
+{
+ if (m_directWriteFontFace == 0)
+ return;
+
+ QVarLengthArray<UINT16> glyphIndices(nglyphs);
+ QVarLengthArray<DWRITE_GLYPH_OFFSET> glyphOffsets(nglyphs);
+ QVarLengthArray<FLOAT> glyphAdvances(nglyphs);
+
+ for (int i=0; i<nglyphs; ++i) {
+ glyphIndices[i] = glyphs[i];
+ glyphOffsets[i].advanceOffset = positions[i].x.toReal();
+ glyphOffsets[i].ascenderOffset = -positions[i].y.toReal();
+ glyphAdvances[i] = 0.0;
+ }
+
+ GeometrySink geometrySink(path);
+ HRESULT hr = m_directWriteFontFace->GetGlyphRunOutline(
+ fontDef.pixelSize,
+ glyphIndices.data(),
+ glyphAdvances.data(),
+ glyphOffsets.data(),
+ nglyphs,
+ false,
+ flags & QTextItem::RightToLeft,
+ &geometrySink
+ );
+
+ if (FAILED(hr))
+ qErrnoWarning("QFontEngineDirectWrite::addGlyphsToPath: GetGlyphRunOutline failed");
+}
+
+glyph_metrics_t QFontEngineDirectWrite::boundingBox(const QGlyphLayout &glyphs)
+{
+ if (glyphs.numGlyphs == 0)
+ return glyph_metrics_t();
+
+ bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
+
+ QFixed w = 0;
+ for (int i = 0; i < glyphs.numGlyphs; ++i) {
+ w += round ? glyphs.effectiveAdvance(i).round() : glyphs.effectiveAdvance(i);
+
+ }
+
+ return glyph_metrics_t(0, -m_ascent, w - lastRightBearing(glyphs), m_ascent + m_descent, w, 0);
+}
+
+glyph_metrics_t QFontEngineDirectWrite::boundingBox(glyph_t g)
+{
+ if (m_directWriteFontFace == 0)
+ return glyph_metrics_t();
+
+ UINT16 glyphIndex = g;
+
+ DWRITE_GLYPH_METRICS glyphMetrics;
+ HRESULT hr = m_directWriteFontFace->GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetrics);
+ if (SUCCEEDED(hr)) {
+ QFixed advanceWidth = DESIGN_TO_LOGICAL(glyphMetrics.advanceWidth);
+ QFixed leftSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.leftSideBearing);
+ QFixed rightSideBearing = DESIGN_TO_LOGICAL(glyphMetrics.rightSideBearing);
+ QFixed advanceHeight = DESIGN_TO_LOGICAL(glyphMetrics.advanceHeight);
+ QFixed verticalOriginY = DESIGN_TO_LOGICAL(glyphMetrics.verticalOriginY);
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
+ advanceWidth = advanceWidth.round();
+ advanceHeight = advanceHeight.round();
+ }
+
+ QFixed width = advanceWidth - leftSideBearing - rightSideBearing;
+
+ return glyph_metrics_t(-leftSideBearing, -verticalOriginY,
+ width, m_ascent + m_descent,
+ advanceWidth, advanceHeight);
+ } else {
+ qErrnoWarning("QFontEngineDirectWrite::boundingBox: GetDesignGlyphMetrics failed");
+ }
+
+ return glyph_metrics_t();
+}
+
+QFixed QFontEngineDirectWrite::ascent() const
+{
+ return fontDef.styleStrategy & QFont::ForceIntegerMetrics
+ ? m_ascent.round()
+ : m_ascent;
+}
+
+QFixed QFontEngineDirectWrite::descent() const
+{
+ return fontDef.styleStrategy & QFont::ForceIntegerMetrics
+ ? (m_descent - 1).round()
+ : (m_descent - 1);
+}
+
+QFixed QFontEngineDirectWrite::leading() const
+{
+ return fontDef.styleStrategy & QFont::ForceIntegerMetrics
+ ? m_lineGap.round()
+ : m_lineGap;
+}
+
+QFixed QFontEngineDirectWrite::xHeight() const
+{
+ return fontDef.styleStrategy & QFont::ForceIntegerMetrics
+ ? m_xHeight.round()
+ : m_xHeight;
+}
+
+qreal QFontEngineDirectWrite::maxCharWidth() const
+{
+ // ###
+ return 0;
+}
+
+extern uint qt_pow_gamma[256];
+
+QImage QFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
+{
+ QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform());
+
+ QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
+ QVector<QRgb> colors(256);
+ for (int i=0; i<256; ++i)
+ colors[i] = qRgba(0, 0, 0, i);
+ indexed.setColorTable(colors);
+
+ for (int y=0; y<im.height(); ++y) {
+ uint *src = (uint*) im.scanLine(y);
+ uchar *dst = indexed.scanLine(y);
+ for (int x=0; x<im.width(); ++x) {
+ *dst = 255 - (qt_pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
+ ++dst;
+ ++src;
+ }
+ }
+
+ return indexed;
+}
+
+bool QFontEngineDirectWrite::supportsSubPixelPositions() const
+{
+ return true;
+}
+
+QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t,
+ QFixed subPixelPosition,
+ int margin,
+ const QTransform &xform)
+{
+ glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform);
+ int width = (metrics.width + margin * 2 + 4).ceil().toInt() ;
+ int height = (metrics.height + margin * 2 + 4).ceil().toInt();
+
+ UINT16 glyphIndex = t;
+ FLOAT glyphAdvance = metrics.xoff.toReal();
+
+ DWRITE_GLYPH_OFFSET glyphOffset;
+ glyphOffset.advanceOffset = 0;
+ glyphOffset.ascenderOffset = 0;
+
+ DWRITE_GLYPH_RUN glyphRun;
+ glyphRun.fontFace = m_directWriteFontFace;
+ glyphRun.fontEmSize = fontDef.pixelSize;
+ glyphRun.glyphCount = 1;
+ glyphRun.glyphIndices = &glyphIndex;
+ glyphRun.glyphAdvances = &glyphAdvance;
+ glyphRun.isSideways = false;
+ glyphRun.bidiLevel = 0;
+ glyphRun.glyphOffsets = &glyphOffset;
+
+ QFixed x = margin - metrics.x.round() + subPixelPosition;
+ QFixed y = margin - metrics.y.floor();
+
+ DWRITE_MATRIX transform;
+ transform.dx = x.toReal();
+ transform.dy = y.toReal();
+ transform.m11 = xform.m11();
+ transform.m12 = xform.m12();
+ transform.m21 = xform.m21();
+ transform.m22 = xform.m22();
+
+ IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
+ HRESULT hr = m_directWriteFactory->CreateGlyphRunAnalysis(
+ &glyphRun,
+ 1.0f,
+ &transform,
+ DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
+ DWRITE_MEASURING_MODE_NATURAL,
+ 0.0, 0.0,
+ &glyphAnalysis
+ );
+
+ if (SUCCEEDED(hr)) {
+ RECT rect;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = width;
+ rect.bottom = height;
+
+ int size = width * height * 3;
+ BYTE *alphaValues = new BYTE[size];
+ qMemSet(alphaValues, size, 0);
+
+ hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
+ &rect,
+ alphaValues,
+ size);
+
+ if (SUCCEEDED(hr)) {
+ QImage img(width, height, QImage::Format_RGB32);
+ img.fill(0xffffffff);
+
+ for (int y=0; y<height; ++y) {
+ uint *dest = reinterpret_cast<uint *>(img.scanLine(y));
+ BYTE *src = alphaValues + width * 3 * y;
+
+ for (int x=0; x<width; ++x) {
+ dest[x] = *(src) << 16
+ | *(src + 1) << 8
+ | *(src + 2);
+
+ src += 3;
+ }
+ }
+
+ delete[] alphaValues;
+ glyphAnalysis->Release();
+
+ return img;
+ } else {
+ delete[] alphaValues;
+ glyphAnalysis->Release();
+
+ qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed");
+ }
+
+ } else {
+ qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateGlyphRunAnalysis failed");
+ }
+
+ return QImage();
+}
+
+QImage QFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
+ QFixed subPixelPosition,
+ int margin,
+ const QTransform &xform)
+{
+ QImage mask = imageForGlyph(t, subPixelPosition, margin, xform);
+ return mask.depth() == 32
+ ? mask
+ : mask.convertToFormat(QImage::Format_RGB32);
+}
+
+const char *QFontEngineDirectWrite::name() const
+{
+ return 0;
+}
+
+bool QFontEngineDirectWrite::canRender(const QChar *string, int len)
+{
+ for (int i=0; i<len; ++i) {
+ BOOL exists;
+ UINT32 codePoint = getChar(string, i, len);
+ HRESULT hr = m_directWriteFont->HasCharacter(codePoint, &exists);
+ if (FAILED(hr)) {
+ qErrnoWarning("QFontEngineDirectWrite::canRender: HasCharacter failed");
+ return false;
+ } else if (!exists) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QFontEngine::Type QFontEngineDirectWrite::type() const
+{
+ return QFontEngine::DirectWrite;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DIRECTWRITE
diff --git a/src/gui/text/qfontenginedirectwrite_p.h b/src/gui/text/qfontenginedirectwrite_p.h
new file mode 100644
index 0000000..80f90b8
--- /dev/null
+++ b/src/gui/text/qfontenginedirectwrite_p.h
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** 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 QFONTENGINEDIRECTWRITE_H
+#define QFONTENGINEDIRECTWRITE_H
+
+#ifndef QT_NO_DIRECTWRITE
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qfontengine_p.h"
+
+struct IDWriteFont ;
+struct IDWriteFontFace ;
+struct IDWriteFactory ;
+struct IDWriteBitmapRenderTarget ;
+struct IDWriteGdiInterop ;
+
+QT_BEGIN_NAMESPACE
+
+class QFontEngineDirectWrite : public QFontEngine
+{
+ Q_OBJECT
+public:
+ explicit QFontEngineDirectWrite(const QString &name,
+ IDWriteFactory *directWriteFactory,
+ IDWriteGdiInterop *directWriteGdiInterop,
+ IDWriteFont *directWriteFont,
+ qreal pixelSize);
+ ~QFontEngineDirectWrite();
+
+ QFixed lineThickness() const;
+ bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
+ QFixed emSquareSize() const;
+
+ bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
+ void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const;
+
+ void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
+ QPainterPath *path, QTextItem::RenderFlags flags);
+
+ glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
+ glyph_metrics_t boundingBox(glyph_t g);
+
+ QFixed ascent() const;
+ QFixed descent() const;
+ QFixed leading() const;
+ QFixed xHeight() const;
+ qreal maxCharWidth() const;
+
+ const char *name() const;
+
+ bool supportsSubPixelPositions() const;
+
+ QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
+ QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin,
+ const QTransform &xform);
+
+ bool canRender(const QChar *string, int len);
+ Type type() const;
+
+private:
+ QImage imageForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform);
+ void collectMetrics();
+
+ QString m_name;
+ IDWriteFont *m_directWriteFont;
+ IDWriteFontFace *m_directWriteFontFace;
+ IDWriteFactory *m_directWriteFactory;
+ IDWriteBitmapRenderTarget *m_directWriteBitmapRenderTarget;
+ IDWriteGdiInterop *m_directWriteGdiInterop;
+
+ QFixed m_lineThickness;
+ int m_unitsPerEm;
+ QFixed m_ascent;
+ QFixed m_descent;
+ QFixed m_xHeight;
+ QFixed m_lineGap;
+ FaceId m_faceId;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DIRECTWRITE
+
+#endif // QFONTENGINEDIRECTWRITE_H
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index f85f4b9..8f8d93d 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -72,7 +72,7 @@
QT_BEGIN_NAMESPACE
-class QFontEngineGlyphCache
+class QFontEngineGlyphCache: public QSharedData
{
public:
enum Type {
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index ca8500b..5cd85fb 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -443,6 +443,21 @@ bool QFontMetrics::inFont(QChar ch) const
}
/*!
+ Returns true if the character encoded in UCS-4/UTF-32 is a valid
+ character in the font; otherwise returns false.
+*/
+bool QFontMetrics::inFontUcs4(uint ucs4) const
+{
+ const int script = QUnicodeTables::script(ucs4);
+ QFontEngine *engine = d->engineForScript(script);
+ Q_ASSERT(engine != 0);
+ if (engine->type() == QFontEngine::Box)
+ return false;
+ QString utf16 = QString::fromUcs4(&ucs4, 1);
+ return engine->canRender(utf16.data(), utf16.length());
+}
+
+/*!
Returns the left bearing of character \a ch in the font.
The left bearing is the right-ward distance of the left-most pixel
@@ -1315,6 +1330,21 @@ bool QFontMetricsF::inFont(QChar ch) const
}
/*!
+ Returns true if the character encoded in UCS-4/UTF-32 is a valid
+ character in the font; otherwise returns false.
+*/
+bool QFontMetricsF::inFontUcs4(uint ucs4) const
+{
+ const int script = QUnicodeTables::script(ucs4);
+ QFontEngine *engine = d->engineForScript(script);
+ Q_ASSERT(engine != 0);
+ if (engine->type() == QFontEngine::Box)
+ return false;
+ QString utf16 = QString::fromUcs4(&ucs4, 1);
+ return engine->canRender(utf16.data(), utf16.length());
+}
+
+/*!
Returns the left bearing of character \a ch in the font.
The left bearing is the right-ward distance of the left-most pixel
@@ -1779,7 +1809,7 @@ qreal QFontMetricsF::lineWidth() const
Use the boundingRect() function in combination with
QString::left() instead.
-
+
\oldcode
QRect rect = boundingRect(text, len);
\newcode
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 71b7abe..5fe8676 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -71,6 +71,10 @@ public:
~QFontMetrics();
QFontMetrics &operator=(const QFontMetrics &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QFontMetrics &operator=(QFontMetrics &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
int ascent() const;
int descent() const;
@@ -85,6 +89,7 @@ public:
int averageCharWidth() const;
bool inFont(QChar) const;
+ bool inFontUcs4(uint ucs4) const;
int leftBearing(QChar) const;
int rightBearing(QChar) const;
@@ -148,7 +153,10 @@ public:
QFontMetricsF &operator=(const QFontMetricsF &);
QFontMetricsF &operator=(const QFontMetrics &);
-
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QFontMetricsF &operator=(QFontMetricsF &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
qreal ascent() const;
qreal descent() const;
qreal height() const;
@@ -162,6 +170,7 @@ public:
qreal averageCharWidth() const;
bool inFont(QChar) const;
+ bool inFontUcs4(uint ucs4) const;
qreal leftBearing(QChar) const;
qreal rightBearing(QChar) const;
diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphs.cpp
new file mode 100644
index 0000000..affa08a
--- /dev/null
+++ b/src/gui/text/qglyphs.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglyphs.h"
+#include "qglyphs_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QGlyphs
+ \brief the QGlyphs class provides direct access to the internal glyphs in a font
+ \since 4.8
+
+ \ingroup text
+ \mainclass
+
+ When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points
+ into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode
+ representation of the text and the QFont object will in this case serve as a convenient
+ abstraction that hides the details of what actually takes place when displaying the text
+ on-screen. For instance, by the time the text actually reaches the screen, it may be represented
+ by a set of fonts in addition to the one specified by the user, e.g. in case the originally
+ selected font did not support all the writing systems contained in the text.
+
+ Under certain circumstances, it can be useful as an application developer to have more low-level
+ control over which glyphs in a specific font are drawn to the screen. This could for instance
+ be the case in applications that use an external font engine and text shaper together with Qt.
+ QGlyphs provides an interface to the raw data needed to get text on the screen. It
+ contains a list of glyph indexes, a position for each glyph and a font.
+
+ It is the user's responsibility to ensure that the selected font actually contains the
+ provided glyph indexes.
+
+ QTextLayout::glyphs() can be used to convert unicode encoded text into a list of QGlyphs
+ objects, and QPainter::drawGlyphs() can be used to draw the glyphs.
+*/
+
+
+/*!
+ Constructs an empty QGlyphs object.
+*/
+QGlyphs::QGlyphs() : d(new QGlyphsPrivate)
+{
+}
+
+/*!
+ Constructs a QGlyphs object which is a copy of \a other.
+*/
+QGlyphs::QGlyphs(const QGlyphs &other)
+{
+ d = other.d;
+}
+
+/*!
+ Destroys the QGlyphs.
+*/
+QGlyphs::~QGlyphs()
+{
+ // Required for QExplicitlySharedDataPointer
+}
+
+/*!
+ \internal
+*/
+void QGlyphs::detach()
+{
+ if (d->ref != 1)
+ d.detach();
+}
+
+/*!
+ Assigns \a other to this QGlyphs object.
+*/
+QGlyphs &QGlyphs::operator=(const QGlyphs &other)
+{
+ d = other.d;
+ return *this;
+}
+
+/*!
+ Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes,
+ the list of positions and the font are all equal, otherwise returns false.
+*/
+bool QGlyphs::operator==(const QGlyphs &other) const
+{
+ return ((d == other.d)
+ || (d->glyphIndexes == other.d->glyphIndexes
+ && d->glyphPositions == other.d->glyphPositions
+ && d->font == other.d->font));
+}
+
+/*!
+ Compares \a other to this QGlyphs object. Returns true if any of the list of glyph
+ indexes, the list of positions or the font are different, otherwise returns false.
+*/
+bool QGlyphs::operator!=(const QGlyphs &other) const
+{
+ return !(*this == other);
+}
+
+/*!
+ \internal
+
+ Adds together the lists of glyph indexes and positions in \a other and this QGlyphs
+ object and returns the result. The font in the returned QGlyphs will be the same as in
+ this QGlyphs object.
+*/
+QGlyphs QGlyphs::operator+(const QGlyphs &other) const
+{
+ QGlyphs ret(*this);
+ ret += other;
+ return ret;
+}
+
+/*!
+ \internal
+
+ Appends the glyph indexes and positions in \a other to this QGlyphs object and returns
+ a reference to the current object.
+*/
+QGlyphs &QGlyphs::operator+=(const QGlyphs &other)
+{
+ detach();
+
+ d->glyphIndexes += other.d->glyphIndexes;
+ d->glyphPositions += other.d->glyphPositions;
+
+ return *this;
+}
+
+/*!
+ Returns the font selected for this QGlyphs object.
+
+ \sa setFont()
+*/
+QFont QGlyphs::font() const
+{
+ return d->font;
+}
+
+/*!
+ Sets the font in which to look up the glyph indexes to \a font. This must be an explicitly
+ resolvable font which defines glyphs for the specified glyph indexes.
+
+ \sa font(), setGlyphIndexes()
+*/
+void QGlyphs::setFont(const QFont &font)
+{
+ detach();
+ d->font = font;
+}
+
+/*!
+ Returns the glyph indexes for this QGlyphs object.
+
+ \sa setGlyphIndexes(), setPositions()
+*/
+QVector<quint32> QGlyphs::glyphIndexes() const
+{
+ return d->glyphIndexes;
+}
+
+/*!
+ Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must
+ be valid for the selected font.
+*/
+void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes)
+{
+ detach();
+ d->glyphIndexes = glyphIndexes;
+}
+
+/*!
+ Returns the position of the edge of the baseline for each glyph in this set of glyph indexes.
+*/
+QVector<QPointF> QGlyphs::positions() const
+{
+ return d->glyphPositions;
+}
+
+/*!
+ Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to
+ \a positions.
+*/
+void QGlyphs::setPositions(const QVector<QPointF> &positions)
+{
+ detach();
+ d->glyphPositions = positions;
+}
+
+/*!
+ Clears all data in the QGlyphs object.
+*/
+void QGlyphs::clear()
+{
+ detach();
+ d->glyphPositions = QVector<QPointF>();
+ d->glyphIndexes = QVector<quint32>();
+ d->font = QFont();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphs.h
new file mode 100644
index 0000000..5f37136
--- /dev/null
+++ b/src/gui/text/qglyphs.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** 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 QGLYPHS_H
+#define QGLYPHS_H
+
+#include <QtCore/qsharedpointer.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qpoint.h>
+#include <QtGui/qfont.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGlyphsPrivate;
+class Q_GUI_EXPORT QGlyphs
+{
+public:
+ QGlyphs();
+ QGlyphs(const QGlyphs &other);
+ ~QGlyphs();
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QVector<quint32> glyphIndexes() const;
+ void setGlyphIndexes(const QVector<quint32> &glyphIndexes);
+
+ QVector<QPointF> positions() const;
+ void setPositions(const QVector<QPointF> &positions);
+
+ void clear();
+
+ QGlyphs &operator=(const QGlyphs &other);
+ bool operator==(const QGlyphs &other) const;
+ bool operator!=(const QGlyphs &other) const;
+
+private:
+ friend class QGlyphsPrivate;
+ friend class QTextLine;
+
+ QGlyphs operator+(const QGlyphs &other) const;
+ QGlyphs &operator+=(const QGlyphs &other);
+
+ void detach();
+ QExplicitlySharedDataPointer<QGlyphsPrivate> d;
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QGLYPHS_H
diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphs_p.h
new file mode 100644
index 0000000..c632e2f
--- /dev/null
+++ b/src/gui/text/qglyphs_p.h
@@ -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 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 QGLYPHS_P_H
+#define QGLYPHS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qfont.h>
+#include "qglyphs.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QGlyphsPrivate: public QSharedData
+{
+public:
+ QGlyphsPrivate()
+ {
+ }
+
+ QGlyphsPrivate(const QGlyphsPrivate &other)
+ : QSharedData(other), glyphIndexes(other.glyphIndexes), glyphPositions(other.glyphPositions), font(other.font)
+ {
+ }
+
+ QVector<quint32> glyphIndexes;
+ QVector<QPointF> glyphPositions;
+ QFont font;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGLYPHS_P_H
diff --git a/src/gui/text/qpfutil.cpp b/src/gui/text/qpfutil.cpp
index 4a0e29f..734d4c3 100644
--- a/src/gui/text/qpfutil.cpp
+++ b/src/gui/text/qpfutil.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-static QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = {
+static const QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = {
QFontEngineQPF::StringType, // FontName
QFontEngineQPF::StringType, // FileName
QFontEngineQPF::UInt32Type, // FileIndex
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
new file mode 100644
index 0000000..6fa25e7
--- /dev/null
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -0,0 +1,291 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformfontdatabase_qpa.h"
+#include <QtGui/private/qfontengine_p.h>
+#include <QtGui/private/qfontengine_qpa_p.h>
+#include <QtCore/QLibraryInfo>
+#include <QtCore/QDir>
+
+QT_BEGIN_NAMESPACE
+
+extern void qt_registerFont(const QString &familyname, const QString &foundryname, int weight,
+ QFont::Style style, int stretch, bool antialiased,bool scalable, int pixelSize,
+ const QSupportedWritingSystems &writingSystems, void *hanlde);
+
+void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle)
+{
+ if (dataArray.size() == 0)
+ return;
+
+ const uchar *data = reinterpret_cast<const uchar *>(dataArray.constData());
+ if (QFontEngineQPA::verifyHeader(data, dataArray.size())) {
+ QString fontName = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_FontName).toString();
+ int pixelSize = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_PixelSize).toInt();
+ QVariant weight = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Weight);
+ QVariant style = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_Style);
+ QByteArray writingSystemBits = QFontEngineQPA::extractHeaderField(data, QFontEngineQPA::Tag_WritingSystems).toByteArray();
+
+ if (!fontName.isEmpty() && pixelSize) {
+ QFont::Weight fontWeight = QFont::Normal;
+ if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
+ fontWeight = QFont::Weight(weight.toInt());
+
+ QFont::Style fontStyle = static_cast<QFont::Style>(style.toInt());
+
+ QSupportedWritingSystems writingSystems;
+ for (int i = 0; i < writingSystemBits.count(); ++i) {
+ uchar currentByte = writingSystemBits.at(i);
+ for (int j = 0; j < 8; ++j) {
+ if (currentByte & 1)
+ writingSystems.setSupported(QFontDatabase::WritingSystem(i * 8 + j));
+ currentByte >>= 1;
+ }
+ }
+ QFont::Stretch stretch = QFont::Unstretched;
+ registerFont(fontName,QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,writingSystems,handle);
+ }
+ } else {
+ qDebug() << "header verification of QPF2 font failed. maybe it is corrupt?";
+ }
+}
+
+void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight,
+ QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize,
+ const QSupportedWritingSystems &writingSystems, void *usrPtr)
+{
+ if (scalable)
+ pixelSize = 0;
+ qt_registerFont(familyname,foundryname,weight,style,stretch,antialiased,scalable,pixelSize,writingSystems,usrPtr);
+}
+
+class QWritingSystemsPrivate
+{
+public:
+ QWritingSystemsPrivate()
+ : ref(1)
+ , vector(QFontDatabase::WritingSystemsCount,false)
+ {
+ }
+
+ QWritingSystemsPrivate(const QWritingSystemsPrivate *other)
+ : ref(1)
+ , vector(other->vector)
+ {
+ }
+
+ QAtomicInt ref;
+ QVector<bool> vector;
+};
+
+QSupportedWritingSystems::QSupportedWritingSystems()
+{
+ d = new QWritingSystemsPrivate;
+}
+
+QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystems &other)
+{
+ d = other.d;
+ d->ref.ref();
+}
+
+QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other)
+{
+ if (d != other.d) {
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ }
+ return *this;
+}
+
+QSupportedWritingSystems::~QSupportedWritingSystems()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+void QSupportedWritingSystems::detach()
+{
+ if (d->ref != 1) {
+ QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d);
+ if (!d->ref.deref())
+ delete d;
+ d = newd;
+ }
+}
+
+void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support)
+{
+ detach();
+ d->vector[writingSystem] = support;
+}
+
+bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const
+{
+ return d->vector.at(writingSystem);
+}
+
+/*!
+ \class QSupportedWritingSystems
+ \brief The QSupportedWritingSystems class is used when registering fonts with the internal Qt
+ fontdatabase
+ \ingroup painting
+
+ Its to provide an easy to use interface for indicating what writing systems a specific font
+ supports.
+
+*/
+
+/*!
+ This function is called once at startup by Qts internal fontdatabase. Reimplement this function
+ in a subclass for a convenient place to initialise the internal fontdatabase.
+
+ The default implementation looks in the fontDir() location and registers all qpf2 fonts.
+*/
+void QPlatformFontDatabase::populateFontDatabase()
+{
+ QString fontpath = fontDir();
+
+ if(!QFile::exists(fontpath)) {
+ qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
+ qPrintable(fontpath));
+ }
+
+ QDir dir(fontpath);
+ dir.setNameFilters(QStringList() << QLatin1String("*.qpf2"));
+ dir.refresh();
+ for (int i = 0; i < int(dir.count()); ++i) {
+ const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i]));
+ QFile file(QString::fromLocal8Bit(fileName));
+ if (file.open(QFile::ReadOnly)) {
+ const QByteArray fileData = file.readAll();
+ QByteArray *fileDataPtr = new QByteArray(fileData);
+ registerQPF2Font(fileData, fileDataPtr);
+ }
+ }
+}
+
+/*!
+
+*/
+QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle)
+{
+ Q_UNUSED(script);
+ Q_UNUSED(handle);
+ QByteArray *fileDataPtr = static_cast<QByteArray *>(handle);
+ QFontEngineQPA *engine = new QFontEngineQPA(fontDef,*fileDataPtr);
+ //qDebug() << fontDef.pixelSize << fontDef.weight << fontDef.style << fontDef.stretch << fontDef.styleHint << fontDef.styleStrategy << fontDef.family << script;
+ return engine;
+}
+
+/*!
+
+*/
+QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
+{
+ Q_UNUSED(family);
+ Q_UNUSED(style);
+ Q_UNUSED(styleHint);
+ Q_UNUSED(script);
+ return QStringList();
+}
+
+/*!
+ Adds an application font. Returns a list of family names, or an empty list if the font could
+ not be added
+*/
+QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
+{
+ Q_UNUSED(fontData);
+ Q_UNUSED(fileName);
+
+ qWarning("This plugin does not support application fonts");
+ return QStringList();
+}
+
+/*!
+
+*/
+void QPlatformFontDatabase::releaseHandle(void *handle)
+{
+ QByteArray *fileDataPtr = static_cast<QByteArray *>(handle);
+ delete fileDataPtr;
+}
+
+/*!
+
+*/
+QString QPlatformFontDatabase::fontDir() const
+{
+ QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QPA_FONTDIR"));
+ if (fontpath.isEmpty()) {
+#ifndef QT_NO_SETTINGS
+ fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath);
+ fontpath += QLatin1String("/fonts");
+#endif
+ }
+
+ return fontpath;
+}
+
+/*!
+ \class QPlatformFontDatabase
+ \brief The QPlatformFontDatabase makes it possible to customize how fonts are picked up, and
+ and how they are rendered
+
+ \ingroup painting
+
+ QPlatformFontDatabase is the superclass which is intended to let platform implementations use
+ native font handling.
+
+ Qt has its internal fontdatabase which it uses to pick up available fonts. To be able
+ to populate this database subclass this class, and reimplement populateFontDatabase().
+
+ Use the function registerFont to populate the internal fontdatabase.
+
+ Sometimes a specified font does not have the required glyphs, then the fallbackForFamily
+ function is called.
+
+ \sa QSupportedWritingSystems
+*/
+QT_END_NAMESPACE
diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h
new file mode 100644
index 0000000..e0e4f04
--- /dev/null
+++ b/src/gui/text/qplatformfontdatabase_qpa.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** 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 QPLATFORMFONTDATABASE_QPA_H
+#define QPLATFORMFONTDATABASE_QPA_H
+
+#include <QtCore/qconfig.h>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QList>
+#include <QtGui/QFontDatabase>
+#include <QtGui/private/qfont_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWritingSystemsPrivate;
+
+class Q_GUI_EXPORT QSupportedWritingSystems
+{
+public:
+
+ QSupportedWritingSystems();
+ QSupportedWritingSystems(const QSupportedWritingSystems &other);
+ QSupportedWritingSystems &operator=(const QSupportedWritingSystems &other);
+ ~QSupportedWritingSystems();
+
+ void setSupported(QFontDatabase::WritingSystem, bool supported = true);
+ bool supported(QFontDatabase::WritingSystem) const;
+
+private:
+ void detach();
+
+ QWritingSystemsPrivate *d;
+
+ friend Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
+ friend Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
+};
+
+Q_GUI_EXPORT bool operator==(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
+Q_GUI_EXPORT bool operator!=(const QSupportedWritingSystems &, const QSupportedWritingSystems &);
+
+class QFontRequestPrivate;
+
+class Q_GUI_EXPORT QPlatformFontDatabase
+{
+public:
+ virtual void populateFontDatabase();
+ virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
+ virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
+ virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
+ virtual void releaseHandle(void *handle);
+
+ virtual QString fontDir() const;
+
+ //callback
+ static void registerQPF2Font(const QByteArray &dataArray, void *handle);
+ static void registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight,
+ QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize,
+ const QSupportedWritingSystems &writingSystems, void *handle);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMFONTDATABASE_QPA_H
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 1a81394..66ce64b 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -64,6 +64,7 @@
#include "qgraphicssceneevent.h"
#include "qprinter.h"
#include "qtextdocumentwriter.h"
+#include "private/qtextcursor_p.h"
#include <qtextformat.h>
#include <qdatetime.h>
@@ -1970,6 +1971,8 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
layout->setAdditionalFormats(overrides);
cursor.endEditBlock();
+ if (cursor.d)
+ cursor.d->setX();
}
QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
@@ -2985,7 +2988,7 @@ QAbstractTextDocumentLayout::PaintContext QTextControl::getPaintContext(QWidget
if (widget)
style = widget->style();
style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret);
- selection.format = qVariantValue<QTextFormat>(ret.variant).toCharFormat();
+ selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat();
} else {
QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive;
selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight));
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index dc55e0e..4eaeb41 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -230,6 +230,7 @@ private:
QSharedDataPointer<QTextCursorPrivate> d;
friend class QTextDocumentFragmentPrivate;
friend class QTextCopyHelper;
+ friend class QTextControlPrivate;
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 673ae46..be67279 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1985,6 +1985,8 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
if (fi.exists()) {
resourceUrl =
QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name);
+ } else if (currentURL.isEmpty()) {
+ resourceUrl.setScheme(QLatin1String("file"));
}
}
@@ -2602,14 +2604,40 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
default: html += QLatin1String("<ul"); // ### should not happen
}
- html += QLatin1String(" style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");
+ QString styleString = QString::fromLatin1("margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");
if (format.hasProperty(QTextFormat::ListIndent)) {
- html += QLatin1String(" -qt-list-indent: ");
- html += QString::number(format.indent());
- html += QLatin1Char(';');
+ styleString += QLatin1String(" -qt-list-indent: ");
+ styleString += QString::number(format.indent());
+ styleString += QLatin1Char(';');
+ }
+
+ if (format.hasProperty(QTextFormat::ListNumberPrefix)) {
+ QString numberPrefix = format.numberPrefix();
+ numberPrefix.replace(QLatin1Char('"'), QLatin1String("\\22"));
+ numberPrefix.replace(QLatin1Char('\''), QLatin1String("\\27")); // FIXME: There's a problem in the CSS parser the prevents this from being correctly restored
+ styleString += QLatin1String(" -qt-list-number-prefix: ");
+ styleString += QLatin1Char('\'');
+ styleString += numberPrefix;
+ styleString += QLatin1Char('\'');
+ styleString += QLatin1Char(';');
}
+ if (format.hasProperty(QTextFormat::ListNumberSuffix)) {
+ if (format.numberSuffix() != QLatin1String(".")) { // this is our default
+ QString numberSuffix = format.numberSuffix();
+ numberSuffix.replace(QLatin1Char('"'), QLatin1String("\\22"));
+ numberSuffix.replace(QLatin1Char('\''), QLatin1String("\\27")); // see above
+ styleString += QLatin1String(" -qt-list-number-suffix: ");
+ styleString += QLatin1Char('\'');
+ styleString += numberSuffix;
+ styleString += QLatin1Char('\'');
+ styleString += QLatin1Char(';');
+ }
+ }
+
+ html += QLatin1String(" style=\"");
+ html += styleString;
html += QLatin1String("\">");
}
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index b4bd858..7890b38 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -682,6 +682,10 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes()
QTextListFormat listFmt;
listFmt.setStyle(style);
+ if (!currentNode->textListNumberPrefix.isNull())
+ listFmt.setNumberPrefix(currentNode->textListNumberPrefix);
+ if (!currentNode->textListNumberSuffix.isNull())
+ listFmt.setNumberSuffix(currentNode->textListNumberSuffix);
++indent;
if (currentNode->hasCssListIndent)
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 5e59341..684de00 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -513,9 +513,6 @@ public:
qreal scaleToDevice(qreal value) const;
QFixed scaleToDevice(QFixed value) const;
-
- qreal lineH;
- QTextDocumentLayout::LineHeightMode lineHeightMode;
};
QTextDocumentLayoutPrivate::QTextDocumentLayoutPrivate()
@@ -523,9 +520,7 @@ QTextDocumentLayoutPrivate::QTextDocumentLayoutPrivate()
cursorWidth(1),
currentLazyLayoutPosition(-1),
lazyLayoutStepSize(1000),
- lastPageCount(-1),
- lineH(1),
- lineHeightMode(QTextDocumentLayout::ProportionalHeight)
+ lastPageCount(-1)
{
showLayoutProgress = true;
insideDocumentChange = false;
@@ -2511,6 +2506,24 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
fd->currentLayoutStruct = 0;
}
+static inline void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling,
+ 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)
+ *lineAdjustment = QFixed::fromReal(line.ascent() + qMax(line.leading(), qreal(0.0))) - ((*lineHeight * 4) / 5);
+ else
+ *lineAdjustment = QFixed::fromReal(line.height()) - *lineHeight;
+ }
+ else {
+ *lineBreakHeight = QFixed::fromReal(line.height());
+ *lineAdjustment = 0;
+ }
+}
+
void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosition, const QTextBlockFormat &blockFormat,
QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, const QTextBlockFormat *previousBlockFormat)
{
@@ -2644,11 +2657,12 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
}
- // TODO: replace with proper line height support in 4.8
- QFixed lineHeight = (lineHeightMode == QTextDocumentLayout::FixedHeight)
- ? QFixed::fromReal(lineH) : QFixed::fromReal(line.height() * lineH);
+ QFixed lineBreakHeight, lineHeight, lineAdjustment;
+ qreal scaling = (q->paintDevice() && q->paintDevice()->logicalDpiY() != qt_defaultDpi()) ?
+ qreal(q->paintDevice()->logicalDpiY()) / qreal(qt_defaultDpi()) : 1;
+ getLineHeightParams(blockFormat, line, scaling, &lineAdjustment, &lineBreakHeight, &lineHeight);
- if (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineHeight > layoutStruct->pageBottom) {
+ if (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom) {
layoutStruct->newPage();
floatMargins(layoutStruct->y, layoutStruct, &left, &right);
@@ -2660,7 +2674,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
right -= text_indent;
}
- line.setPosition(QPointF((left - layoutStruct->x_left).toReal(), (layoutStruct->y - cy).toReal()));
+ line.setPosition(QPointF((left - layoutStruct->x_left).toReal(), (layoutStruct->y - cy - lineAdjustment).toReal()));
layoutStruct->y += lineHeight;
layoutStruct->contentsWidth
= qMax<QFixed>(layoutStruct->contentsWidth, QFixed::fromReal(line.x() + line.naturalTextWidth()) + totalRightMargin);
@@ -2680,11 +2694,16 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
QTextLine line = tl->lineAt(i);
layoutStruct->contentsWidth
= qMax(layoutStruct->contentsWidth, QFixed::fromReal(line.x() + tl->lineAt(i).naturalTextWidth()) + totalRightMargin);
- const QFixed lineHeight = QFixed::fromReal(line.height());
+
+ QFixed lineBreakHeight, lineHeight, lineAdjustment;
+ qreal scaling = (q->paintDevice() && q->paintDevice()->logicalDpiY() != qt_defaultDpi()) ?
+ qreal(q->paintDevice()->logicalDpiY()) / qreal(qt_defaultDpi()) : 1;
+ getLineHeightParams(blockFormat, line, scaling, &lineAdjustment, &lineBreakHeight, &lineHeight);
+
if (layoutStruct->pageHeight != QFIXED_MAX) {
- if (layoutStruct->absoluteY() + lineHeight > layoutStruct->pageBottom)
+ if (layoutStruct->absoluteY() + lineBreakHeight > layoutStruct->pageBottom)
layoutStruct->newPage();
- line.setPosition(QPointF(line.position().x(), layoutStruct->y.toReal() - tl->position().y()));
+ line.setPosition(QPointF(line.position().x(), (layoutStruct->y - lineAdjustment).toReal() - tl->position().y()));
}
layoutStruct->y += lineHeight;
}
@@ -2722,13 +2741,6 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
}
}
-void QTextDocumentLayout::setLineHeight(qreal lineH, QTextDocumentLayout::LineHeightMode mode = QTextDocumentLayout::ProportionalHeight)
-{
- Q_D(QTextDocumentLayout);
- d->lineH = lineH;
- d->lineHeightMode = mode;
-}
-
void QTextDocumentLayoutPrivate::floatMargins(const QFixed &y, const QTextLayoutStruct *layoutStruct,
QFixed *left, QFixed *right) const
{
diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h
index 3e3e485..3c0383c 100644
--- a/src/gui/text/qtextdocumentlayout_p.h
+++ b/src/gui/text/qtextdocumentlayout_p.h
@@ -63,7 +63,7 @@ class QTextListFormat;
class QTextDocumentLayoutPrivate;
-class Q_GUI_EXPORT QTextDocumentLayout : public QAbstractTextDocumentLayout
+class Q_AUTOTEST_EXPORT QTextDocumentLayout : public QAbstractTextDocumentLayout
{
Q_DECLARE_PRIVATE(QTextDocumentLayout)
Q_OBJECT
@@ -109,11 +109,6 @@ protected:
void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item,
int posInDocument, const QTextFormat &format);
virtual void timerEvent(QTimerEvent *e);
-
- // TODO: remove when we support line height properly in 4.8
- enum LineHeightMode { ProportionalHeight, FixedHeight };
- void setLineHeight(qreal lineHeight, QTextDocumentLayout::LineHeightMode mode);
-
private:
QRectF doLayout(int from, int oldLength, int length);
void layoutFinished();
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 4378c62..a63fdbf 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -612,7 +612,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon
} else {
eor = current;
}
- dir = QChar::DirON; status.eor = QChar::DirAN;
+ dir = QChar::DirAN; status.eor = QChar::DirAN;
break;
case QChar::DirCS:
if(status.eor == QChar::DirAN) {
@@ -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,10 @@ void QTextEngine::invalidate()
maxWidth = 0;
if (specialData)
specialData->resolvedFormatIndices.clear();
+
+ releaseCachedFontEngine(feCache.prevFontEngine);
+ releaseCachedFontEngine(feCache.prevScaledFontEngine);
+ feCache.reset();
}
void QTextEngine::clearLineData()
@@ -1783,6 +1796,13 @@ QFont QTextEngine::font(const QScriptItem &si) const
return font;
}
+QTextEngine::FontEngineCache::FontEngineCache()
+{
+ reset();
+}
+
+//we cache the previous results of this function, as calling it numerous times with the same effective
+//input is common (and hard to cache at a higher level)
QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const
{
QFontEngine *engine = 0;
@@ -1791,28 +1811,53 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
QFont font = fnt;
if (hasFormats()) {
- QTextCharFormat f = format(&si);
- font = f.font();
-
- if (block.docHandle() && block.docHandle()->layout()) {
- // Make sure we get the right dpi on printers
- QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();
- if (pdev)
- font = QFont(font, pdev);
+ if (feCache.prevFontEngine && feCache.prevPosition == si.position && feCache.prevLength == length(&si) && feCache.prevScript == script) {
+ engine = feCache.prevFontEngine;
+ scaledEngine = feCache.prevScaledFontEngine;
} else {
- font = font.resolve(fnt);
- }
- engine = font.d->engineForScript(script);
- QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();
- if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) {
- if (font.pointSize() != -1)
- font.setPointSize((font.pointSize() * 2) / 3);
- else
- font.setPixelSize((font.pixelSize() * 2) / 3);
- scaledEngine = font.d->engineForScript(script);
+ QTextCharFormat f = format(&si);
+ font = f.font();
+
+ if (block.docHandle() && block.docHandle()->layout()) {
+ // Make sure we get the right dpi on printers
+ QPaintDevice *pdev = block.docHandle()->layout()->paintDevice();
+ if (pdev)
+ font = QFont(font, pdev);
+ } else {
+ font = font.resolve(fnt);
+ }
+ engine = font.d->engineForScript(script);
+ QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();
+ if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) {
+ if (font.pointSize() != -1)
+ font.setPointSize((font.pointSize() * 2) / 3);
+ else
+ font.setPixelSize((font.pixelSize() * 2) / 3);
+ 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);
}
} else {
- engine = font.d->engineForScript(script);
+ if (feCache.prevFontEngine && feCache.prevScript == script && feCache.prevPosition == -1)
+ engine = feCache.prevFontEngine;
+ else {
+ engine = font.d->engineForScript(script);
+ feCache.prevFontEngine = engine;
+ if (engine)
+ engine->ref.ref();
+ feCache.prevScript = script;
+ feCache.prevPosition = -1;
+ feCache.prevLength = -1;
+ feCache.prevScaledFontEngine = 0;
+ }
}
if (si.analysis.flags == QScriptAnalysis::SmallCaps) {
@@ -2356,30 +2401,29 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
if (flags & Qt::TextShowMnemonic) {
itemize();
+ HB_CharAttributes *attributes = const_cast<HB_CharAttributes *>(this->attributes());
+ if (!attributes)
+ return QString();
for (int i = 0; i < layoutData->items.size(); ++i) {
QScriptItem &si = layoutData->items[i];
if (!si.num_glyphs)
shape(i);
- HB_CharAttributes *attributes = const_cast<HB_CharAttributes *>(this->attributes());
- if (!attributes)
- return QString();
-
unsigned short *logClusters = this->logClusters(&si);
QGlyphLayout glyphs = shapedGlyphs(&si);
const int end = si.position + length(&si);
- for (int i = si.position; i < end - 1; ++i)
+ for (int i = si.position; i < end - 1; ++i) {
if (layoutData->string.at(i) == QLatin1Char('&')) {
const int gp = logClusters[i - si.position];
glyphs.attributes[gp].dontPrint = true;
attributes[i + 1].charStop = false;
attributes[i + 1].whiteSpace = false;
attributes[i + 1].lineBreakType = HB_NoBreak;
- if (i < end - 1
- && layoutData->string.at(i + 1) == QLatin1Char('&'))
+ if (layoutData->string.at(i + 1) == QLatin1Char('&'))
++i;
}
+ }
}
}
@@ -2441,7 +2485,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
if (mode == Qt::ElideRight) {
QFixed currentWidth;
- int pos = 0;
+ int pos;
int nextBreak = 0;
do {
@@ -2461,7 +2505,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
return layoutData->string.left(pos) + ellipsisText;
} else if (mode == Qt::ElideLeft) {
QFixed currentWidth;
- int pos = layoutData->string.length();
+ int pos;
int nextBreak = layoutData->string.length();
do {
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp
index c34bdb3..97e8c5b 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/gui/text/qtextengine_mac.cpp
@@ -41,6 +41,9 @@
#include "qtextengine_p.h"
+#include <private/qfontengine_coretext_p.h>
+#include <private/qfontengine_mac_p.h>
+
QT_BEGIN_NAMESPACE
// set the glyph attributes heuristically. Assumes a 1 to 1 relationship between chars and glyphs
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 34723ab..50d1ff8 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -128,7 +128,7 @@ struct Q_AUTOTEST_EXPORT QScriptAnalysis
TabOrObject = Tab,
Object = 7
};
- unsigned short script : 8;
+ unsigned short script : 7;
unsigned short bidiLevel : 6; // Unicode Bidi algorithm embedding level (0-61)
unsigned short flags : 3;
inline bool operator == (const QScriptAnalysis &other) const {
@@ -385,7 +385,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine
QFixed textWidth;
QFixed textAdvance;
int from;
- signed int length : 29;
+ signed int length : 28;
mutable uint justified : 1;
mutable uint gridfitted : 1;
uint hasTrailingSpaces : 1;
@@ -435,7 +435,7 @@ public:
uint hasBidi : 1;
uint layoutState : 2;
uint memory_on_stack : 1;
- bool haveCharAttributes;
+ uint haveCharAttributes : 1;
QString string;
bool reallocate(int totalGlyphs);
};
@@ -556,6 +556,23 @@ public:
mutable QScriptLineArray lines;
+ struct FontEngineCache {
+ FontEngineCache();
+ mutable QFontEngine *prevFontEngine;
+ mutable QFontEngine *prevScaledFontEngine;
+ mutable int prevScript;
+ mutable int prevPosition;
+ mutable int prevLength;
+ inline void reset() {
+ prevFontEngine = 0;
+ prevScaledFontEngine = 0;
+ prevScript = -1;
+ prevPosition = -1;
+ prevLength = -1;
+ }
+ };
+ mutable FontEngineCache feCache;
+
QString text;
QFont fnt;
QTextBlock block;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index c009ce7..a02ea49 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -411,6 +411,9 @@ void QTextFormatPrivate::recalcFont() const
case QTextFormat::FontStyleHint:
f.setStyleHint(static_cast<QFont::StyleHint>(props.at(i).value.toInt()), f.styleStrategy());
break;
+ case QTextFormat::FontHintingPreference:
+ f.setHintingPreference(static_cast<QFont::HintingPreference>(props.at(i).value.toInt()));
+ break;
case QTextFormat::FontStyleStrategy:
f.setStyleStrategy(static_cast<QFont::StyleStrategy>(props.at(i).value.toInt()));
break;
@@ -541,6 +544,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\value TabPositions Specifies the tab positions. The tab positions are structs of QTextOption::Tab which are stored in
a QList (internally, in a QList<QVariant>).
\value BlockIndent
+ \value LineHeight
+ \value LineHeightType
\value BlockNonBreakableLines
\value BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element.
@@ -933,7 +938,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const
const QVariant prop = d->property(propertyId);
if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float)
return 0.;
- return qVariantValue<qreal>(prop);
+ return qvariant_cast<qreal>(prop);
}
/*!
@@ -1563,6 +1568,25 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)
\sa font()
*/
+/*!
+ \since 4.8
+
+ \fn void QTextCharFormat::setFontHintingPreference(QFont::HintingPreference hintingPreference)
+
+ Sets the hinting preference of the text format's font to be \a hintingPreference.
+
+ \sa setFont(), QFont::setHintingPreference()
+*/
+
+/*!
+ \since 4.8
+
+ \fn QFont::HintingPreference QTextCharFormat::fontHintingPreference() const
+
+ Returns the hinting preference set for this text format.
+
+ \sa font(), QFont::hintingPreference()
+*/
/*!
\fn QPen QTextCharFormat::textOutline() const
@@ -1856,6 +1880,10 @@ QFont QTextCharFormat::font() const
indentation is set with setIndent(), the indentation of the first
line with setTextIndent().
+ Line spacing is set with setLineHeight() and retrieved via lineHeight()
+ and lineHeightType(). The types of line spacing available are in the
+ LineHeightTypes enum.
+
Line breaking can be enabled and disabled with setNonBreakableLines().
The brush used to paint the paragraph's background
@@ -1872,6 +1900,22 @@ QFont QTextCharFormat::font() const
*/
/*!
+ \since 4.8
+ \enum QTextBlockFormat::LineHeightTypes
+
+ This enum describes the various types of line spacing support paragraphs can have.
+
+ \value SingleHeight This is the default line height: single spacing.
+ \value ProportionalHeight This sets the spacing proportional to the line (in percentage).
+ For example, set to 200 for double spacing.
+ \value FixedHeight This sets the line height to a fixed line height (in pixels).
+ \value MinimumHeight This sets the minimum line height (in pixels).
+ \value LineDistanceHeight This adds the specified height between lines (in pixels).
+
+ \sa lineHeight(), lineHeightType(), setLineHeight()
+*/
+
+/*!
\fn QTextBlockFormat::QTextBlockFormat()
Constructs a new QTextBlockFormat.
@@ -1903,7 +1947,7 @@ void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs)
QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin();
while (iter != tabs.constEnd()) {
QVariant v;
- qVariantSetValue<QTextOption::Tab>(v, *iter);
+ v.setValue<QTextOption::Tab>(*iter);
list.append(v);
++iter;
}
@@ -1925,7 +1969,7 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant);
QList<QVariant>::Iterator iter = variantsList.begin();
while(iter != variantsList.end()) {
- answer.append( qVariantValue<QTextOption::Tab>(*iter));
+ answer.append( qvariant_cast<QTextOption::Tab>(*iter));
++iter;
}
return answer;
@@ -2089,6 +2133,51 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
/*!
+ \fn void QTextBlockFormat::setLineHeight(qreal height, int heightType)
+ \since 4.8
+
+ This sets the line height for the paragraph to the value in height
+ which is dependant on heightType, described by the LineHeightTypes enum.
+
+ \sa LineHeightTypes, lineHeight(), lineHeightType()
+*/
+
+
+/*!
+ \fn qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling) const
+ \since 4.8
+
+ This returns what the height of the lines in the paragraph will be depending
+ on the given height of the script line and the scaling. The value that is returned
+ is also dependant on the given LineHeightType of the paragraph as well as the LineHeight
+ setting that has been set for the paragraph. The scaling is needed for the heights
+ that include a fixed number of pixels, to scale them appropriately for printing.
+
+ \sa LineHeightTypes, setLineHeight(), lineHeightType()
+*/
+
+
+/*!
+ \fn qreal QTextBlockFormat::lineHeight() const
+ \since 4.8
+
+ This returns the LineHeight property for the paragraph.
+
+ \sa LineHeightTypes, setLineHeight(), lineHeightType()
+*/
+
+
+/*!
+ \fn qreal QTextBlockFormat::lineHeightType() const
+ \since 4.8
+
+ This returns the LineHeightType property of the paragraph.
+
+ \sa LineHeightTypes, setLineHeight(), lineHeight()
+*/
+
+
+/*!
\fn void QTextBlockFormat::setNonBreakableLines(bool b)
If \a b is true, the lines in the paragraph are treated as
@@ -2235,6 +2324,44 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt)
\sa setIndent()
*/
+/*!
+ \fn void QTextListFormat::setNumberPrefix(const QString &numberPrefix)
+ \since 4.8
+
+ Sets the list format's number prefix. This can be used with all
+ sorted list types. It does not have any effect on unsorted list types.
+
+ \sa numberPrefix()
+*/
+
+/*!
+ \fn int QTextListFormat::numberPrefix() const
+ \since 4.8
+
+ Returns the list format's number prefix.
+
+ \sa setNumberPrefix()
+*/
+
+/*!
+ \fn void QTextListFormat::setNumberSuffix(const QString &numberSuffix)
+ \since 4.8
+
+ Sets the list format's number suffix. This can be used with all
+ sorted list types. It does not have any effect on unsorted list types.
+ The default suffix is ".".
+
+ \sa numberSuffix()
+*/
+
+/*!
+ \fn int QTextListFormat::numberSuffix() const
+ \since 4.8
+
+ Returns the list format's number suffix.
+
+ \sa setNumberSuffix()
+*/
/*!
\class QTextFrameFormat
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index eb9146f..ff28eaa 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -164,6 +164,8 @@ public:
TextIndent = 0x1034,
TabPositions = 0x1035,
BlockIndent = 0x1040,
+ LineHeight = 0x1048,
+ LineHeightType = 0x1049,
BlockNonBreakableLines = 0x1050,
BlockTrailingHorizontalRulerWidth = 0x1060,
@@ -175,6 +177,7 @@ public:
FontStyleHint = 0x1FE3,
FontStyleStrategy = 0x1FE4,
FontKerning = 0x1FE5,
+ FontHintingPreference = 0x1FE6,
FontFamily = 0x2000,
FontPointSize = 0x2001,
FontSizeAdjustment = 0x2002,
@@ -202,6 +205,8 @@ public:
// list properties
ListStyle = 0x3000,
ListIndent = 0x3001,
+ ListNumberPrefix = 0x3002,
+ ListNumberSuffix = 0x3003,
// table and frame properties
FrameBorder = 0x4000,
@@ -456,6 +461,16 @@ public:
QFont::StyleStrategy fontStyleStrategy() const
{ return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
+ inline void setFontHintingPreference(QFont::HintingPreference hintingPreference)
+ {
+ setProperty(FontHintingPreference, hintingPreference);
+ }
+
+ inline QFont::HintingPreference fontHintingPreference() const
+ {
+ return static_cast<QFont::HintingPreference>(intProperty(FontHintingPreference));
+ }
+
inline void setFontKerning(bool enable)
{ setProperty(FontKerning, enable); }
inline bool fontKerning() const
@@ -529,6 +544,14 @@ inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan)
class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
{
public:
+ enum LineHeightTypes {
+ SingleHeight = 0,
+ ProportionalHeight = 1,
+ FixedHeight = 2,
+ MinimumHeight = 3,
+ LineDistanceHeight = 4
+ };
+
QTextBlockFormat();
bool isValid() const { return isBlockFormat(); }
@@ -566,6 +589,14 @@ public:
inline int indent() const
{ return intProperty(BlockIndent); }
+ inline void setLineHeight(qreal height, int heightType)
+ { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); }
+ inline qreal lineHeight(qreal scriptLineHeight, qreal scaling) const;
+ inline qreal lineHeight() const
+ { return doubleProperty(LineHeight); }
+ inline int lineHeightType() const
+ { return intProperty(LineHeightType); }
+
inline void setNonBreakableLines(bool b)
{ setProperty(BlockNonBreakableLines, b); }
inline bool nonBreakableLines() const
@@ -590,6 +621,23 @@ inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
inline void QTextBlockFormat::setIndent(int aindent)
{ setProperty(BlockIndent, aindent); }
+inline qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const
+{
+ switch(intProperty(LineHeightType)) {
+ case SingleHeight:
+ return(scriptLineHeight);
+ case ProportionalHeight:
+ return(scriptLineHeight * doubleProperty(LineHeight) / 100.0);
+ case FixedHeight:
+ return(doubleProperty(LineHeight) * scaling);
+ case MinimumHeight:
+ return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling));
+ case LineDistanceHeight:
+ return(scriptLineHeight + doubleProperty(LineHeight) * scaling);
+ }
+ return(0);
+}
+
class Q_GUI_EXPORT QTextListFormat : public QTextFormat
{
public:
@@ -617,6 +665,14 @@ public:
inline int indent() const
{ return intProperty(ListIndent); }
+ inline void setNumberPrefix(const QString &numberPrefix);
+ inline QString numberPrefix() const
+ { return stringProperty(ListNumberPrefix); }
+
+ inline void setNumberSuffix(const QString &numberSuffix);
+ inline QString numberSuffix() const
+ { return stringProperty(ListNumberSuffix); }
+
protected:
explicit QTextListFormat(const QTextFormat &fmt);
friend class QTextFormat;
@@ -628,6 +684,12 @@ inline void QTextListFormat::setStyle(Style astyle)
inline void QTextListFormat::setIndent(int aindent)
{ setProperty(ListIndent, aindent); }
+inline void QTextListFormat::setNumberPrefix(const QString &np)
+{ setProperty(ListNumberPrefix, np); }
+
+inline void QTextListFormat::setNumberSuffix(const QString &ns)
+{ setProperty(ListNumberSuffix, ns); }
+
class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
{
public:
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index e685197..3513a28 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1250,6 +1250,20 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
case QCss::QtBlockIndent:
blockFormat.setIndent(decl.d->values.first().variant.toInt());
break;
+ case QCss::LineHeight: {
+ qreal lineHeight;
+ if (decl.realValue(&lineHeight, "px")) {
+ blockFormat.setLineHeight(lineHeight, QTextBlockFormat::FixedHeight);
+ } else {
+ bool ok;
+ QString value = decl.d->values.first().toString();
+ lineHeight = value.toDouble(&ok);
+ if (ok)
+ blockFormat.setLineHeight(lineHeight, QTextBlockFormat::ProportionalHeight);
+ else
+ blockFormat.setLineHeight(0, QTextBlockFormat::SingleHeight);
+ }
+ break; }
case QCss::TextIndent: {
qreal indent = 0;
if (decl.realValue(&indent, "px"))
@@ -1323,6 +1337,12 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
case QCss::ListStyle:
setListStyle(decl.d->values);
break;
+ case QCss::QtListNumberPrefix:
+ textListNumberPrefix = decl.d->values.first().variant.toString();
+ break;
+ case QCss::QtListNumberSuffix:
+ textListNumberSuffix = decl.d->values.first().variant.toString();
+ break;
default: break;
}
}
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index 5e2b456..4c44efd 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -180,6 +180,8 @@ struct QTextHtmlParserNode {
uint displayMode : 3; // QTextHtmlElement::DisplayMode
uint hasHref : 1;
QTextListFormat::Style listStyle;
+ QString textListNumberPrefix;
+ QString textListNumberSuffix;
QString imageName;
qreal imageWidth;
qreal imageHeight;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 905f81b..8eff7d2 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -52,6 +52,8 @@
#include "qtextformat_p.h"
#include "qstyleoption.h"
#include "qpainterpath.h"
+#include "qglyphs.h"
+#include "qglyphs_p.h"
#include <limits.h>
#include <qdebug.h>
@@ -165,7 +167,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line)
/*!
Returns the inline object's rectangle.
- \sa ascent() descent() width()
+ \sa ascent(), descent(), width()
*/
QRectF QTextInlineObject::rect() const
{
@@ -176,7 +178,7 @@ QRectF QTextInlineObject::rect() const
/*!
Returns the inline object's width.
- \sa ascent() descent() rect()
+ \sa ascent(), descent(), rect()
*/
qreal QTextInlineObject::width() const
{
@@ -186,7 +188,7 @@ qreal QTextInlineObject::width() const
/*!
Returns the inline object's ascent.
- \sa descent() width() rect()
+ \sa descent(), width(), rect()
*/
qreal QTextInlineObject::ascent() const
{
@@ -196,7 +198,7 @@ qreal QTextInlineObject::ascent() const
/*!
Returns the inline object's descent.
- \sa ascent() width() rect()
+ \sa ascent(), width(), rect()
*/
qreal QTextInlineObject::descent() const
{
@@ -207,18 +209,17 @@ qreal QTextInlineObject::descent() const
Returns the inline object's total height. This is equal to
ascent() + descent() + 1.
- \sa ascent() descent() width() rect()
+ \sa ascent(), descent(), width(), rect()
*/
qreal QTextInlineObject::height() const
{
return eng->layoutData->items[itm].height().toReal();
}
-
/*!
Sets the inline object's width to \a w.
- \sa width() ascent() descent() rect()
+ \sa width(), ascent(), descent(), rect()
*/
void QTextInlineObject::setWidth(qreal w)
{
@@ -228,7 +229,7 @@ void QTextInlineObject::setWidth(qreal w)
/*!
Sets the inline object's ascent to \a a.
- \sa ascent() setDescent() width() rect()
+ \sa ascent(), setDescent(), width(), rect()
*/
void QTextInlineObject::setAscent(qreal a)
{
@@ -238,7 +239,7 @@ void QTextInlineObject::setAscent(qreal a)
/*!
Sets the inline object's decent to \a d.
- \sa descent() setAscent() width() rect()
+ \sa descent(), setAscent(), width(), rect()
*/
void QTextInlineObject::setDescent(qreal d)
{
@@ -246,7 +247,7 @@ void QTextInlineObject::setDescent(qreal d)
}
/*!
- The position of the inline object within the text layout.
+ The position of the inline object within the text layout.
*/
int QTextInlineObject::textPosition() const
{
@@ -254,8 +255,8 @@ int QTextInlineObject::textPosition() const
}
/*!
- Returns an integer describing the format of the inline object
- within the text layout.
+ Returns an integer describing the format of the inline object
+ within the text layout.
*/
int QTextInlineObject::formatIndex() const
{
@@ -263,7 +264,7 @@ int QTextInlineObject::formatIndex() const
}
/*!
- Returns format of the inline object within the text layout.
+ Returns format of the inline object within the text layout.
*/
QTextFormat QTextInlineObject::format() const
{
@@ -273,7 +274,7 @@ QTextFormat QTextInlineObject::format() const
}
/*!
- Returns if the object should be laid out right-to-left or left-to-right.
+ Returns if the object should be laid out right-to-left or left-to-right.
*/
Qt::LayoutDirection QTextInlineObject::textDirection() const
{
@@ -325,7 +326,6 @@ Qt::LayoutDirection QTextInlineObject::textDirection() const
boundingRect(), and a minimumWidth() and a maximumWidth().
\sa QStaticText
-
*/
/*!
@@ -398,16 +398,19 @@ QTextLayout::~QTextLayout()
Sets the layout's font to the given \a font. The layout is
invalidated and must be laid out again.
- \sa text()
+ \sa font()
*/
void QTextLayout::setFont(const QFont &font)
{
d->fnt = font;
+ d->feCache.reset();
}
/*!
Returns the current font that is used for the layout, or a default
font if none is set.
+
+ \sa setFont()
*/
QFont QTextLayout::font() const
{
@@ -441,10 +444,10 @@ QString QTextLayout::text() const
}
/*!
- Sets the text option structure that controls the layout process to the
- given \a option.
+ Sets the text option structure that controls the layout process to the
+ given \a option.
- \sa textOption() QTextOption
+ \sa textOption()
*/
void QTextLayout::setTextOption(const QTextOption &option)
{
@@ -452,9 +455,9 @@ void QTextLayout::setTextOption(const QTextOption &option)
}
/*!
- Returns the current text option used to control the layout process.
+ Returns the current text option used to control the layout process.
- \sa setTextOption() QTextOption
+ \sa setTextOption()
*/
QTextOption QTextLayout::textOption() const
{
@@ -464,6 +467,8 @@ QTextOption QTextLayout::textOption() const
/*!
Sets the \a position and \a text of the area in the layout that is
processed before editing occurs.
+
+ \sa preeditAreaPosition(), preeditAreaText()
*/
void QTextLayout::setPreeditArea(int position, const QString &text)
{
@@ -492,6 +497,8 @@ void QTextLayout::setPreeditArea(int position, const QString &text)
/*!
Returns the position of the area in the text layout that will be
processed before editing occurs.
+
+ \sa preeditAreaText()
*/
int QTextLayout::preeditAreaPosition() const
{
@@ -500,6 +507,8 @@ int QTextLayout::preeditAreaPosition() const
/*!
Returns the text that is inserted in the layout before editing occurs.
+
+ \sa preeditAreaPosition()
*/
QString QTextLayout::preeditAreaText() const
{
@@ -508,8 +517,7 @@ QString QTextLayout::preeditAreaText() const
/*!
- Sets the additional formats supported by the text layout to \a
- formatList.
+ Sets the additional formats supported by the text layout to \a formatList.
\sa additionalFormats(), clearAdditionalFormats()
*/
@@ -535,6 +543,7 @@ void QTextLayout::setAdditionalFormats(const QList<FormatRange> &formatList)
}
if (d->block.docHandle())
d->block.docHandle()->documentChange(d->block.position(), d->block.length());
+ d->feCache.reset();
}
/*!
@@ -599,6 +608,8 @@ bool QTextLayout::cacheEnabled() const
/*!
Begins the layout process.
+
+ \sa endLayout()
*/
void QTextLayout::beginLayout()
{
@@ -616,6 +627,8 @@ void QTextLayout::beginLayout()
/*!
Ends the layout process.
+
+ \sa beginLayout()
*/
void QTextLayout::endLayout()
{
@@ -634,35 +647,33 @@ void QTextLayout::endLayout()
d->freeMemory();
}
-/*! \since 4.4
+/*!
+ \since 4.4
-Clears the line information in the layout. After having called
-this function, lineCount() returns 0.
- */
+ Clears the line information in the layout. After having called
+ this function, lineCount() returns 0.
+*/
void QTextLayout::clearLayout()
{
d->clearLineData();
}
-
/*!
Returns the next valid cursor position after \a oldPos that
respects the given cursor \a mode.
+ Returns value of \a oldPos, if \a oldPos is not a valid cursor position.
- \sa isValidCursorPosition() previousCursorPosition()
+ \sa isValidCursorPosition(), previousCursorPosition()
*/
int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
{
-// qDebug("looking for next cursor pos for %d", oldPos);
const HB_CharAttributes *attributes = d->attributes();
- if (!attributes)
- return 0;
- int len = d->block.isValid() ?
- (d->block.length() - 1)
- : d->layoutData->string.length();
-
- if (oldPos >= len)
+ int len = d->block.isValid() ? d->block.length() - 1
+ : d->layoutData->string.length();
+ Q_ASSERT(len <= d->layoutData->string.length());
+ if (!attributes || oldPos < 0 || oldPos >= len)
return oldPos;
+
if (mode == SkipCharacters) {
oldPos++;
while (oldPos < len && !attributes[oldPos].charStop)
@@ -679,22 +690,23 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
while (oldPos < len && d->atSpace(oldPos))
oldPos++;
}
-// qDebug(" -> %d", oldPos);
+
return oldPos;
}
/*!
Returns the first valid cursor position before \a oldPos that
respects the given cursor \a mode.
+ Returns value of \a oldPos, if \a oldPos is not a valid cursor position.
- \sa isValidCursorPosition() nextCursorPosition()
+ \sa isValidCursorPosition(), nextCursorPosition()
*/
int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const
{
-// qDebug("looking for previous cursor pos for %d", oldPos);
const HB_CharAttributes *attributes = d->attributes();
- if (!attributes || oldPos <= 0)
- return 0;
+ if (!attributes || oldPos <= 0 || oldPos > d->layoutData->string.length())
+ return oldPos;
+
if (mode == SkipCharacters) {
oldPos--;
while (oldPos && !attributes[oldPos].charStop)
@@ -712,7 +724,7 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const
oldPos--;
}
}
-// qDebug(" -> %d", oldPos);
+
return oldPos;
}
@@ -739,7 +751,6 @@ bool QTextLayout::isValidCursorPosition(int pos) const
return attributes[pos].charStop;
}
-
/*!
Returns a new text line to be laid out if there is text to be
inserted into the layout; otherwise returns an invalid text line.
@@ -801,7 +812,7 @@ int QTextLayout::lineCount() const
/*!
Returns the \a{i}-th line of text in this text layout.
- \sa lineCount() lineForTextPosition()
+ \sa lineCount(), lineForTextPosition()
*/
QTextLine QTextLayout::lineAt(int i) const
{
@@ -811,7 +822,7 @@ QTextLine QTextLayout::lineAt(int i) const
/*!
Returns the line that contains the cursor position specified by \a pos.
- \sa isValidCursorPosition() lineAt()
+ \sa isValidCursorPosition(), lineAt()
*/
QTextLine QTextLayout::lineForTextPosition(int pos) const
{
@@ -902,8 +913,9 @@ qreal QTextLayout::maximumWidth() const
return d->maxWidth.toReal();
}
+
/*!
- \internal
+ \internal
*/
void QTextLayout::setFlags(int flags)
{
@@ -1028,6 +1040,35 @@ QScriptItem &QTextLineItemIterator::next()
return *si;
}
+static QFixed offsetInLigature(const unsigned short *logClusters,
+ const QGlyphLayout &glyphs,
+ int pos, int max, int glyph_pos)
+{
+ int offsetInCluster = 0;
+ for (int i = pos - 1; i >= 0; i--) {
+ if (logClusters[i] == glyph_pos)
+ offsetInCluster++;
+ else
+ break;
+ }
+
+ // in the case that the offset is inside a (multi-character) glyph,
+ // interpolate the position.
+ if (offsetInCluster > 0) {
+ int clusterLength = 0;
+ for (int i = pos - offsetInCluster; i < max; i++) {
+ if (logClusters[i] == glyph_pos)
+ clusterLength++;
+ else
+ break;
+ }
+ if (clusterLength)
+ return glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength;
+ }
+
+ return 0;
+}
+
bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const
{
*selectionX = *selectionWidth = 0;
@@ -1067,8 +1108,19 @@ bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selec
swidth += glyphs.effectiveAdvance(g);
}
- *selectionX = x + soff;
- *selectionWidth = swidth;
+ // If the starting character is in the middle of a ligature,
+ // selection should only contain the right part of that ligature
+ // glyph, so we need to get the width of the left part here and
+ // add it to *selectionX
+ QFixed leftOffsetInLigature = offsetInLigature(logClusters, glyphs, from,
+ to, start_glyph);
+ *selectionX = x + soff + leftOffsetInLigature;
+ *selectionWidth = swidth - leftOffsetInLigature;
+ // If the ending character is also part of a ligature, swidth does
+ // not contain that part yet, we also need to find out the width of
+ // that left part
+ *selectionWidth += offsetInLigature(logClusters, glyphs, to,
+ eng->length(item), end_glyph);
}
return true;
}
@@ -1114,9 +1166,26 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip)
return clip.isValid() ? (rect & clip) : rect;
}
+
+/*!
+ Returns the glyph indexes and positions for all glyphs in this QTextLayout. This is an
+ expensive function, and should not be called in a time sensitive context.
+
+ \since 4.8
+
+ \sa draw(), QPainter::drawGlyphs()
+*/
+QList<QGlyphs> QTextLayout::glyphs() const
+{
+ QList<QGlyphs> glyphs;
+ for (int i=0; i<d->lines.size(); ++i)
+ glyphs += QTextLine(i, d).glyphs(-1, -1);
+
+ return glyphs;
+}
+
/*!
- Draws the whole layout on the painter \a p at the position specified by
- \a pos.
+ Draws the whole layout on the painter \a p at the position specified by \a pos.
The rendered layout includes the given \a selections and is clipped within
the rectangle specified by \a clip.
*/
@@ -1290,12 +1359,12 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVector<FormatRang
}
/*!
- \fn void QTextLayout::drawCursor(QPainter *painter, const QPointF &position, int cursorPosition) const
- \overload
+ \fn void QTextLayout::drawCursor(QPainter *painter, const QPointF &position, int cursorPosition) const
+ \overload
- Draws a text cursor with the current pen at the given \a position using the
- \a painter specified.
- The corresponding position within the text is specified by \a cursorPosition.
+ Draws a text cursor with the current pen at the given \a position using the
+ \a painter specified.
+ The corresponding position within the text is specified by \a cursorPosition.
*/
void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const
{
@@ -1303,11 +1372,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
}
/*!
- \fn void QTextLayout::drawCursor(QPainter *painter, const QPointF &position, int cursorPosition, int width) const
+ \fn void QTextLayout::drawCursor(QPainter *painter, const QPointF &position, int cursorPosition, int width) const
- Draws a text cursor with the current pen and the specified \a width at the given \a position using the
- \a painter specified.
- The corresponding position within the text is specified by \a cursorPosition.
+ Draws a text cursor with the current pen and the specified \a width at the given \a position using the
+ \a painter specified.
+ The corresponding position within the text is specified by \a cursorPosition.
*/
void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition, int width) const
{
@@ -1438,7 +1507,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
/*!
Returns the line's bounding rectangle.
- \sa x() y() textLength() width()
+ \sa x(), y(), textLength(), width()
*/
QRectF QTextLine::rect() const
{
@@ -1464,7 +1533,7 @@ QRectF QTextLine::naturalTextRect() const
/*!
Returns the line's x position.
- \sa rect() y() textLength() width()
+ \sa rect(), y(), textLength(), width()
*/
qreal QTextLine::x() const
{
@@ -1474,7 +1543,7 @@ qreal QTextLine::x() const
/*!
Returns the line's y position.
- \sa x() rect() textLength() width()
+ \sa x(), rect(), textLength(), width()
*/
qreal QTextLine::y() const
{
@@ -1484,7 +1553,7 @@ qreal QTextLine::y() const
/*!
Returns the line's width as specified by the layout() function.
- \sa naturalTextWidth() x() y() textLength() rect()
+ \sa naturalTextWidth(), x(), y(), textLength(), rect()
*/
qreal QTextLine::width() const
{
@@ -1495,7 +1564,7 @@ qreal QTextLine::width() const
/*!
Returns the line's ascent.
- \sa descent() height()
+ \sa descent(), height()
*/
qreal QTextLine::ascent() const
{
@@ -1505,7 +1574,7 @@ qreal QTextLine::ascent() const
/*!
Returns the line's descent.
- \sa ascent() height()
+ \sa ascent(), height()
*/
qreal QTextLine::descent() const
{
@@ -1517,7 +1586,7 @@ qreal QTextLine::descent() const
if leading is not included. If leading is included, this equals to
ascent() + descent() + leading() + 1.
- \sa ascent() descent() leading() setLeadingIncluded()
+ \sa ascent(), descent(), leading(), setLeadingIncluded()
*/
qreal QTextLine::height() const
{
@@ -1529,24 +1598,25 @@ qreal QTextLine::height() const
Returns the line's leading.
- \sa ascent() descent() height()
+ \sa ascent(), descent(), height()
*/
qreal QTextLine::leading() const
{
return eng->lines[i].leading.toReal();
}
-/*! \since 4.6
+/*!
+ \since 4.6
- Includes positive leading into the line's height if \a included is true;
- otherwise does not include leading.
+ Includes positive leading into the line's height if \a included is true;
+ otherwise does not include leading.
- By default, leading is not included.
+ By default, leading is not included.
- Note that negative leading is ignored, it must be handled
- in the code using the text lines by letting the lines overlap.
+ Note that negative leading is ignored, it must be handled
+ in the code using the text lines by letting the lines overlap.
- \sa leadingIncluded()
+ \sa leadingIncluded()
*/
void QTextLine::setLeadingIncluded(bool included)
@@ -1555,20 +1625,21 @@ void QTextLine::setLeadingIncluded(bool included)
}
-/*! \since 4.6
+/*!
+ \since 4.6
- Returns true if positive leading is included into the line's height; otherwise returns false.
+ Returns true if positive leading is included into the line's height;
+ otherwise returns false.
- By default, leading is not included.
+ By default, leading is not included.
- \sa setLeadingIncluded()
+ \sa setLeadingIncluded()
*/
bool QTextLine::leadingIncluded() const
{
return eng->lines[i].leadingIncluded;
}
-
/*!
Returns the width of the line that is occupied by text. This is
always \<= to width(), and is the minimum width that could be used
@@ -1579,14 +1650,15 @@ qreal QTextLine::naturalTextWidth() const
return eng->lines[i].textWidth.toReal();
}
-/*! \since 4.7
- Returns the horizontal advance of the text. The advance of the text
- is the distance from its position to the next position at which
- text would naturally be drawn.
+/*!
+ \since 4.7
+ Returns the horizontal advance of the text. The advance of the text
+ is the distance from its position to the next position at which
+ text would naturally be drawn.
- By adding the advance to the position of the text line and using this
- as the position of a second text line, you will be able to position
- the two lines side-by-side without gaps in-between.
+ By adding the advance to the position of the text line and using this
+ as the position of a second text line, you will be able to position
+ the two lines side-by-side without gaps in-between.
*/
qreal QTextLine::horizontalAdvance() const
{
@@ -1780,7 +1852,8 @@ static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &gly
++line.length;
} while (pos < end && logClusters[pos] == glyphPosition);
do { // calculate the textWidth for the rest of the current cluster.
- line.textWidth += glyphs.advances_x[glyphPosition] * !glyphs.attributes[glyphPosition].dontPrint;
+ if (!glyphs.attributes[glyphPosition].dontPrint)
+ line.textWidth += glyphs.advances_x[glyphPosition];
++glyphPosition;
} while (glyphPosition < current.num_glyphs && !glyphs.attributes[glyphPosition].clusterStart);
@@ -1844,14 +1917,14 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.currentPosition = qMax(line.from, current.position);
end = current.position + eng->length(item);
lbh.glyphs = eng->shapedGlyphs(&current);
+ QFontEngine *fontEngine = eng->fontEngine(current);
+ if (lbh.fontEngine != fontEngine) {
+ lbh.fontEngine = fontEngine;
+ lbh.minimumRightBearing = qMin(QFixed(),
+ QFixed::fromReal(fontEngine->minRightBearing()));
+ }
}
const QScriptItem &current = eng->layoutData->items[item];
- QFontEngine *fontEngine = eng->fontEngine(current);
- if (lbh.fontEngine != fontEngine) {
- lbh.fontEngine = fontEngine;
- lbh.minimumRightBearing = qMin(QFixed(),
- QFixed::fromReal(fontEngine->minRightBearing()));
- }
lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent,
current.leading + current.ascent) - qMax(lbh.tmpData.ascent,
@@ -2017,9 +2090,10 @@ found:
eng->maxWidth += lbh.spaceData.textWidth;
if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
line.textWidth += lbh.spaceData.textWidth;
- line.length += lbh.spaceData.length;
- if (lbh.spaceData.length)
+ if (lbh.spaceData.length) {
+ line.length += lbh.spaceData.length;
line.hasTrailingSpaces = true;
+ }
line.justified = false;
line.gridfitted = false;
@@ -2173,6 +2247,151 @@ static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const Q
}
+namespace {
+ struct GlyphInfo
+ {
+ GlyphInfo(const QGlyphLayout &layout, const QPointF &position,
+ const QTextItemInt::RenderFlags &renderFlags)
+ : glyphLayout(layout), itemPosition(position), flags(renderFlags)
+ {
+ }
+
+ QGlyphLayout glyphLayout;
+ QPointF itemPosition;
+ QTextItem::RenderFlags flags;
+ };
+}
+
+/*!
+ \internal
+
+ Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in
+ QScriptItems that overlap with the range defined by \a from and \a length. The arguments
+ specify characters, relative to the text in the layout. Note that it is not possible to
+ use this function to retrieve a subset of the glyphs in a QScriptItem.
+
+ \since 4.8
+
+ \sa QTextLayout::glyphs()
+*/
+QList<QGlyphs> QTextLine::glyphs(int from, int length) const
+{
+ const QScriptLine &line = eng->lines[i];
+
+ if (line.length == 0)
+ return QList<QGlyphs>();
+
+ QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
+
+ QTextLineItemIterator iterator(eng, i);
+ qreal y = line.y.toReal() + line.base().toReal();
+ while (!iterator.atEnd()) {
+ QScriptItem &si = iterator.next();
+ if (si.analysis.flags >= QScriptAnalysis::TabOrObject)
+ continue;
+
+ QPointF pos(iterator.x.toReal(), y);
+ if (from >= 0 && length >= 0 &&
+ (from >= si.position + eng->length(&si) || from + length <= si.position))
+ continue;
+
+ QFont font = eng->font(si);
+
+ QTextItem::RenderFlags flags;
+ if (font.overline())
+ flags |= QTextItem::Overline;
+ if (font.underline())
+ flags |= QTextItem::Underline;
+ if (font.strikeOut())
+ flags |= QTextItem::StrikeOut;
+ if (si.analysis.bidiLevel % 2)
+ flags |= QTextItem::RightToLeft;
+
+ QGlyphLayout glyphLayout = eng->shapedGlyphs(&si).mid(iterator.glyphsStart,
+ iterator.glyphsEnd - iterator.glyphsStart);
+
+ if (glyphLayout.numGlyphs > 0) {
+ QFontEngine *mainFontEngine = font.d->engineForScript(si.analysis.script);
+ if (mainFontEngine->type() == QFontEngine::Multi) {
+ QFontEngineMulti *multiFontEngine = static_cast<QFontEngineMulti *>(mainFontEngine);
+ int start = 0;
+ int end;
+ int which = glyphLayout.glyphs[0] >> 24;
+ for (end = 0; end < glyphLayout.numGlyphs; ++end) {
+ const int e = glyphLayout.glyphs[end] >> 24;
+ if (e == which)
+ continue;
+
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
+ GlyphInfo(subLayout, pos, flags));
+
+ start = end;
+ which = e;
+ }
+
+ QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
+ glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
+ GlyphInfo(subLayout, pos, flags));
+
+ } else {
+ glyphLayoutHash.insertMulti(mainFontEngine,
+ GlyphInfo(glyphLayout, pos, flags));
+ }
+ }
+ }
+
+ QHash<QPair<QFontEngine *, int>, QGlyphs> glyphsHash;
+
+ QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys();
+ for (int i=0; i<keys.size(); ++i) {
+ QFontEngine *fontEngine = keys.at(i);
+
+ // Make a font for this particular engine
+ QFont font = fontEngine->createExplicitFont();
+
+ QList<GlyphInfo> glyphLayouts = glyphLayoutHash.values(fontEngine);
+ for (int j=0; j<glyphLayouts.size(); ++j) {
+ const QPointF &pos = glyphLayouts.at(j).itemPosition;
+ const QGlyphLayout &glyphLayout = glyphLayouts.at(j).glyphLayout;
+ const QTextItem::RenderFlags &flags = glyphLayouts.at(j).flags;
+
+ font.setOverline(flags.testFlag(QTextItem::Overline));
+ font.setUnderline(flags.testFlag(QTextItem::Underline));
+ font.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
+
+ QVarLengthArray<glyph_t> glyphsArray;
+ QVarLengthArray<QFixedPoint> positionsArray;
+
+ fontEngine->getGlyphPositions(glyphLayout, QTransform(), flags, glyphsArray,
+ positionsArray);
+ Q_ASSERT(glyphsArray.size() == positionsArray.size());
+
+ QVector<quint32> glyphs;
+ QVector<QPointF> positions;
+ for (int i=0; i<glyphsArray.size(); ++i) {
+ glyphs.append(glyphsArray.at(i) & 0xffffff);
+ positions.append(positionsArray.at(i).toPointF() + pos);
+ }
+
+ QGlyphs glyphIndexes;
+ glyphIndexes.setGlyphIndexes(glyphs);
+ glyphIndexes.setPositions(positions);
+
+ QPair<QFontEngine *, int> key(fontEngine, int(flags));
+
+ if (!glyphsHash.contains(key))
+ glyphsHash.insert(key, QGlyphs());
+
+ QGlyphs &target = glyphsHash[key];
+ target += glyphIndexes;
+ target.setFont(font);
+ }
+ }
+
+ return glyphsHash.values();
+}
+
/*!
\fn void QTextLine::draw(QPainter *painter, const QPointF &position, const QTextLayout::FormatRange *selection) const
@@ -2222,8 +2441,12 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
QTextCharFormat format;
if (eng->hasFormats() || selection) {
- if (!suppressColors)
- format = eng->format(&si);
+ format = eng->format(&si);
+ if (suppressColors) {
+ format.clearForeground();
+ format.clearBackground();
+ format.clearProperty(QTextFormat::TextUnderlineColor);
+ }
if (selection)
format.merge(selection->format);
@@ -2369,21 +2592,20 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
}
/*!
- \fn int QTextLine::cursorToX(int cursorPos, Edge edge) const
+ \fn int QTextLine::cursorToX(int cursorPos, Edge edge) const
- \overload
+ \overload
*/
-
/*!
- Converts the cursor position \a cursorPos to the corresponding x position
- inside the line, taking account of the \a edge.
+ Converts the cursor position \a cursorPos to the corresponding x position
+ inside the line, taking account of the \a edge.
- If \a cursorPos is not a valid cursor position, the nearest valid
- cursor position will be used instead, and cpos will be modified to
- point to this valid cursor position.
+ If \a cursorPos is not a valid cursor position, the nearest valid
+ cursor position will be used instead, and cpos will be modified to
+ point to this valid cursor position.
- \sa xToCursor()
+ \sa xToCursor()
*/
qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
{
@@ -2482,14 +2704,6 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
if(pos == l)
x += si->width;
} else {
- int offsetInCluster = 0;
- for (int i=pos-1; i >= 0; i--) {
- if (logClusters[i] == glyph_pos)
- offsetInCluster++;
- else
- break;
- }
-
if (reverse) {
int end = qMin(lineEnd, si->position + l) - si->position;
int glyph_end = end == l ? si->num_glyphs : logClusters[end];
@@ -2501,17 +2715,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
for (int i = glyph_start; i < glyph_pos; i++)
x += glyphs.effectiveAdvance(i);
}
- if (offsetInCluster > 0) { // in the case that the offset is inside a (multi-character) glyph, interpolate the position.
- int clusterLength = 0;
- for (int i=pos - offsetInCluster; i < line.length; i++) {
- if (logClusters[i] == glyph_pos)
- clusterLength++;
- else
- break;
- }
- if (clusterLength)
- x+= glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength;
- }
+ x += offsetInLigature(logClusters, glyphs, pos, line.length, glyph_pos);
}
*cursorPos = pos + si->position;
@@ -2519,12 +2723,12 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
}
/*!
- \fn int QTextLine::xToCursor(qreal x, CursorPosition cpos) const
+ \fn int QTextLine::xToCursor(qreal x, CursorPosition cpos) const
- Converts the x-coordinate \a x, to the nearest matching cursor
- position, depending on the cursor position type, \a cpos.
+ Converts the x-coordinate \a x, to the nearest matching cursor
+ position, depending on the cursor position type, \a cpos.
- \sa cursorToX()
+ \sa cursorToX()
*/
int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const
{
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 44451ec..0f64c33 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -49,6 +49,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qevent.h>
#include <QtGui/qtextformat.h>
+#include <QtGui/qglyphs.h>
QT_BEGIN_HEADER
@@ -166,6 +167,8 @@ public:
qreal minimumWidth() const;
qreal maximumWidth() const;
+ QList<QGlyphs> glyphs() const;
+
QTextEngine *engine() const { return d; }
void setFlags(int flags);
private:
@@ -236,7 +239,10 @@ public:
private:
QTextLine(int line, QTextEngine *e) : i(line), eng(e) {}
void layout_helper(int numGlyphs);
+ QList<QGlyphs> glyphs(int from, int length) const;
+
friend class QTextLayout;
+ friend class QTextFragment;
int i;
QTextEngine *eng;
};
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index 3528d93..21935aa 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -191,6 +191,13 @@ QString QTextList::itemText(const QTextBlock &blockIt) const
QString result;
const int style = format().style();
+ QString numberPrefix;
+ QString numberSuffix = QLatin1String(".");
+
+ if (format().hasProperty(QTextFormat::ListNumberPrefix))
+ numberPrefix = format().numberPrefix();
+ if (format().hasProperty(QTextFormat::ListNumberSuffix))
+ numberSuffix = format().numberSuffix();
switch (style) {
case QTextListFormat::ListDecimal:
@@ -232,7 +239,7 @@ QString QTextList::itemText(const QTextBlock &blockIt) const
if (q > 0) {
int startDigit = i + (i+3)/4;
int numDigits;
- if (i % 4) {
+ if (i % 4) {
// c[i] == 4|5|9|40|50|90|400|500|900
if ((i-2) % 4) {
// c[i] == 4|9|40|90|400|900 => with subtraction (IV, IX, XL, XC, ...)
@@ -263,8 +270,9 @@ QString QTextList::itemText(const QTextBlock &blockIt) const
Q_ASSERT(false);
}
if (blockIt.textDirection() == Qt::RightToLeft)
- return result.prepend(QLatin1Char('.'));
- return result + QLatin1Char('.');
+ return numberSuffix + result + numberPrefix;
+ else
+ return numberPrefix + result + numberSuffix;
}
/*!
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 94f2fc7..0081550 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1655,6 +1655,35 @@ QTextBlock::iterator &QTextBlock::iterator::operator--()
than the \a other text fragment; otherwise returns false.
*/
+/*!
+ Returns the glyphs of this text fragment. The positions of the glyphs are
+ relative to the position of the QTextBlock's layout.
+
+ \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs()
+*/
+QList<QGlyphs> QTextFragment::glyphs() const
+{
+ if (!p || !n)
+ return QList<QGlyphs>();
+
+ int pos = position();
+ int len = length();
+ if (len == 0)
+ return QList<QGlyphs>();
+
+ int blockNode = p->blockMap().findNode(pos);
+
+ const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
+ QTextLayout *layout = blockData->layout;
+
+ QList<QGlyphs> ret;
+ for (int i=0; i<layout->lineCount(); ++i) {
+ QTextLine textLine = layout->lineAt(i);
+ ret += textLine.glyphs(pos, len);
+ }
+
+ return ret;
+}
/*!
Returns the position of this text fragment in the document.
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index d5c1e8d..fface3f 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -44,6 +44,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
+#include <QtGui/qglyphs.h>
QT_BEGIN_HEADER
@@ -315,6 +316,8 @@ public:
int charFormatIndex() const;
QString text() const;
+ QList<QGlyphs> glyphs() const;
+
private:
const QTextDocumentPrivate *p;
int n;
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 0c9655b..c2e47f3 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -636,7 +636,15 @@ void QTextOdfWriter::writeListFormat(QXmlStreamWriter &writer, QTextListFormat f
|| style == QTextListFormat::ListUpperRoman) {
writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
- writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
+
+ if (format.hasProperty(QTextFormat::ListNumberSuffix))
+ writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), format.numberSuffix());
+ else
+ writer.writeAttribute(styleNS, QString::fromLatin1("num-suffix"), QString::fromLatin1("."));
+
+ if (format.hasProperty(QTextFormat::ListNumberPrefix))
+ writer.writeAttribute(styleNS, QString::fromLatin1("num-prefix"), format.numberPrefix());
+
} else {
writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-bullet"));
writer.writeAttribute(textNS, QString::fromLatin1("bullet-char"), bulletChar(style));
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index af8daa5..7fb2783 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -25,7 +25,7 @@ HEADERS += \
text/qabstracttextdocumentlayout.h \
text/qtextdocumentlayout_p.h \
text/qtextcursor.h \
- text/qtextcursor_p.h \
+ text/qtextcursor_p.h \
text/qtextdocumentfragment.h \
text/qtextdocumentfragment_p.h \
text/qtextimagehandler_p.h \
@@ -39,7 +39,9 @@ HEADERS += \
text/qzipwriter_p.h \
text/qtextodfwriter_p.h \
text/qstatictext_p.h \
- text/qstatictext.h
+ text/qstatictext.h \
+ text/qglyphs.h \
+ text/qglyphs_p.h
SOURCES += \
text/qfont.cpp \
@@ -69,7 +71,8 @@ SOURCES += \
text/qcssparser.cpp \
text/qzip.cpp \
text/qtextodfwriter.cpp \
- text/qstatictext.cpp
+ text/qstatictext.cpp \
+ text/qglyphs.cpp
win32 {
SOURCES += \
@@ -78,6 +81,12 @@ win32 {
HEADERS += text/qfontengine_win_p.h
}
+contains(QT_CONFIG, directwrite) {
+ LIBS_PRIVATE += -ldwrite
+ HEADERS += text/qfontenginedirectwrite_p.h
+ SOURCES += text/qfontenginedirectwrite.cpp
+}
+
unix:x11 {
HEADERS += \
text/qfontengine_x11_p.h \
@@ -89,10 +98,16 @@ unix:x11 {
text/qfontengine_ft.cpp
}
-!embedded:!x11:mac {
+!embedded:!qpa:!x11:mac {
+ HEADERS += \
+ text/qfontengine_mac_p.h
+ OBJECTIVE_HEADERS += \
+ text/qfontengine_coretext_p.h
SOURCES += \
- text/qfont_mac.cpp
- OBJECTIVE_SOURCES += text/qfontengine_mac.mm
+ text/qfont_mac.cpp
+ OBJECTIVE_SOURCES += \
+ text/qfontengine_coretext.mm \
+ text/qfontengine_mac.mm
}
embedded {
@@ -110,6 +125,19 @@ embedded {
DEFINES += QT_NO_FONTCONFIG
}
+qpa {
+ SOURCES += \
+ text/qfont_qpa.cpp \
+ text/qfontengine_qpa.cpp \
+ text/qplatformfontdatabase_qpa.cpp
+
+ HEADERS += \
+ text/qplatformfontdatabase_qpa.h
+
+ DEFINES += QT_NO_FONTCONFIG
+ DEFINES += QT_NO_FREETYPE
+}
+
symbian {
SOURCES += \
text/qfont_s60.cpp
@@ -125,10 +153,11 @@ symbian {
text/qfontengine_s60.cpp
HEADERS += \
text/qfontengine_s60_p.h
- LIBS += -lfntstr -lecom
}
+ LIBS += -lfntstr -lecom
}
+!qpa {
contains(QT_CONFIG, freetype) {
SOURCES += \
../3rdparty/freetype/src/base/ftbase.c \
@@ -202,6 +231,7 @@ contains(QT_CONFIG, freetype) {
contains(QT_CONFIG, fontconfig) {
CONFIG += opentype
}
+}#!qpa
DEFINES += QT_NO_OPENTYPE
INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 12f4acf..27684bf 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -220,7 +220,7 @@ QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const
{
Q_D(const QCompletionModel);
if (!index.isValid())
- return QModelIndex();
+ return engine->curParent;
int row;
QModelIndex parent = engine->curParent;
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 514246e..cb5a3ef 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -45,7 +45,7 @@
#include <qdebug.h>
-#if defined(Q_WS_QWS)
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
#include "qdesktopservices_qws.cpp"
#elif defined(Q_WS_X11)
#include "qdesktopservices_x11.cpp"
diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/util/qdesktopservices_mac.cpp
index de71576..e986847 100644
--- a/src/gui/util/qdesktopservices_mac.cpp
+++ b/src/gui/util/qdesktopservices_mac.cpp
@@ -49,6 +49,8 @@
#include <private/qcore_mac_p.h>
#include <qcoreapplication.h>
+#include <ApplicationServices/ApplicationServices.h>
+
QT_BEGIN_NAMESPACE
/*
diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp
new file mode 100644
index 0000000..fdd2a95
--- /dev/null
+++ b/src/gui/util/qflickgesture.cpp
@@ -0,0 +1,715 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgesture.h"
+#include "qapplication.h"
+#include "qevent.h"
+#include "qwidget.h"
+#include "qgraphicsitem.h"
+#include "qgraphicsscene.h"
+#include "qgraphicssceneevent.h"
+#include "qgraphicsview.h"
+#include "qscroller.h"
+#include "private/qevent_p.h"
+#include "private/qflickgesture_p.h"
+#include "qdebug.h"
+
+#ifndef QT_NO_GESTURES
+
+QT_BEGIN_NAMESPACE
+
+//#define QFLICKGESTURE_DEBUG
+
+#ifdef QFLICKGESTURE_DEBUG
+# define qFGDebug qDebug
+#else
+# define qFGDebug while (false) qDebug
+#endif
+
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
+static QMouseEvent *copyMouseEvent(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove: {
+ QMouseEvent *me = static_cast<QMouseEvent *>(e);
+ return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers());
+ }
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseMove: {
+ QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(e);
+#if 1
+ QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress :
+ (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove);
+ return new QMouseEvent(met, QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers());
+#else
+ QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type());
+ copy->setPos(me->pos());
+ copy->setScenePos(me->scenePos());
+ copy->setScreenPos(me->screenPos());
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ copy->setButtonDownPos(button, me->buttonDownPos(button));
+ copy->setButtonDownScenePos(button, me->buttonDownScenePos(button));
+ copy->setButtonDownScreenPos(button, me->buttonDownScreenPos(button));
+ }
+ copy->setLastPos(me->lastPos());
+ copy->setLastScenePos(me->lastScenePos());
+ copy->setLastScreenPos(me->lastScreenPos());
+ copy->setButtons(me->buttons());
+ copy->setButton(me->button());
+ copy->setModifiers(me->modifiers());
+ return copy;
+#endif
+ }
+#endif // QT_NO_GRAPHICSVIEW
+ default:
+ return 0;
+ }
+}
+
+class PressDelayHandler : public QObject
+{
+private:
+ PressDelayHandler(QObject *parent = 0)
+ : QObject(parent)
+ , pressDelayTimer(0)
+ , sendingEvent(false)
+ , mouseButton(Qt::NoButton)
+ , mouseTarget(0)
+ { }
+
+ static PressDelayHandler *inst;
+
+public:
+ enum {
+ UngrabMouseBefore = 1,
+ RegrabMouseAfterwards = 2
+ };
+
+ static PressDelayHandler *instance()
+ {
+ static PressDelayHandler *inst = 0;
+ if (!inst)
+ inst = new PressDelayHandler(QCoreApplication::instance());
+ return inst;
+ }
+
+ bool shouldEventBeIgnored(QEvent *) const
+ {
+ return sendingEvent;
+ }
+
+ bool isDelaying() const
+ {
+ return !pressDelayEvent.isNull();
+ }
+
+ void pressed(QEvent *e, int delay)
+ {
+ if (!pressDelayEvent) {
+ pressDelayEvent.reset(copyMouseEvent(e));
+ pressDelayTimer = startTimer(delay);
+ mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos());
+ mouseButton = pressDelayEvent->button();
+ qFGDebug() << "QFG: consuming/delaying mouse press";
+ } else {
+ qFGDebug() << "QFG: NOT consuming/delaying mouse press";
+ }
+ e->setAccepted(true);
+ }
+
+ bool released(QEvent *e, bool scrollerWasActive, bool scrollerIsActive)
+ {
+ // consume this event if the scroller was or is active
+ bool result = scrollerWasActive || scrollerIsActive;
+
+ // stop the timer
+ if (pressDelayTimer) {
+ killTimer(pressDelayTimer);
+ pressDelayTimer = 0;
+ }
+ // we still haven't even sent the press, so do it now
+ if (pressDelayEvent && mouseTarget && !scrollerIsActive) {
+ QScopedPointer<QMouseEvent> releaseEvent(copyMouseEvent(e));
+
+ qFGDebug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget;
+ sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
+
+ qFGDebug() << "QFG: faking mouse release (due to release) for " << mouseTarget;
+ sendMouseEvent(releaseEvent.data());
+
+ result = true; // consume this event
+ } else if (mouseTarget && scrollerIsActive) {
+ // we grabbed the mouse expicitly when the scroller became active, so undo that now
+ sendMouseEvent(0, UngrabMouseBefore);
+ }
+ pressDelayEvent.reset(0);
+ mouseTarget = 0;
+ return result;
+ }
+
+ void scrollerWasIntercepted()
+ {
+ qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted";
+ if (pressDelayEvent) {
+ // we still haven't even sent the press, so just throw it away now
+ if (pressDelayTimer) {
+ killTimer(pressDelayTimer);
+ pressDelayTimer = 0;
+ }
+ pressDelayEvent.reset(0);
+ }
+ mouseTarget = 0;
+ }
+
+ void scrollerBecameActive()
+ {
+ if (pressDelayEvent) {
+ // we still haven't even sent the press, so just throw it away now
+ qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now";
+ if (pressDelayTimer) {
+ killTimer(pressDelayTimer);
+ pressDelayTimer = 0;
+ }
+ pressDelayEvent.reset(0);
+ mouseTarget = 0;
+ } else if (mouseTarget) {
+ // we did send a press, so we need to fake a release now
+ Qt::MouseButtons mouseButtons = QApplication::mouseButtons();
+
+ // release all pressed mouse buttons
+ /*for (int i = 0; i < 32; ++i) {
+ if (mouseButtons & (1 << i)) {
+ Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
+ mouseButtons &= ~b;
+ QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
+
+ qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
+ QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
+ b, mouseButtons, QApplication::keyboardModifiers());
+ sendMouseEvent(&re);
+ }
+ }*/
+
+ QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX);
+
+ qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
+ QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway,
+ mouseButton, QApplication::mouseButtons() & ~mouseButton,
+ QApplication::keyboardModifiers());
+ sendMouseEvent(&re, RegrabMouseAfterwards);
+ // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
+ }
+ }
+
+protected:
+ void timerEvent(QTimerEvent *e)
+ {
+ if (e->timerId() == pressDelayTimer) {
+ if (pressDelayEvent && mouseTarget) {
+ qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget;
+ sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore);
+ }
+ pressDelayEvent.reset(0);
+
+ if (pressDelayTimer) {
+ killTimer(pressDelayTimer);
+ pressDelayTimer = 0;
+ }
+ }
+ }
+
+ void sendMouseEvent(QMouseEvent *me, int flags = 0)
+ {
+ if (mouseTarget) {
+ sendingEvent = true;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsItem *grabber = 0;
+ if (mouseTarget->parentWidget()) {
+ if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) {
+ if (gv->scene())
+ grabber = gv->scene()->mouseGrabberItem();
+ }
+ }
+
+ if (grabber && (flags & UngrabMouseBefore)) {
+ // GraphicsView Mouse Handling Workaround #1:
+ // we need to ungrab the mouse before re-sending the press,
+ // since the scene had already set the mouse grabber to the
+ // original (and consumed) event's receiver
+ qFGDebug() << "QFG: ungrabbing" << grabber;
+ grabber->ungrabMouse();
+ }
+#endif // QT_NO_GRAPHICSVIEW
+
+ if (me) {
+ QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers());
+ qt_sendSpontaneousEvent(mouseTarget, &copy);
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (grabber && (flags & RegrabMouseAfterwards)) {
+ // GraphicsView Mouse Handling Workaround #2:
+ // we need to re-grab the mouse after sending a faked mouse
+ // release, since we still need the mouse moves for the gesture
+ // (the scene will clear the item's mouse grabber status on
+ // release).
+ qFGDebug() << "QFG: re-grabbing" << grabber;
+ grabber->grabMouse();
+ }
+#endif
+ sendingEvent = false;
+ }
+ }
+
+
+private:
+ int pressDelayTimer;
+ QScopedPointer<QMouseEvent> pressDelayEvent;
+ bool sendingEvent;
+ Qt::MouseButton mouseButton;
+ QPointer<QWidget> mouseTarget;
+};
+
+
+/*!
+ \internal
+ \class QFlickGesture
+ \since 4.8
+ \brief The QFlickGesture class describes a flicking gesture made by the user.
+ \ingroup gestures
+ The QFlickGesture is more complex than the QPanGesture that uses QScroller and QScrollerProperties
+ to decide if it is triggered.
+ This gesture is reacting on touch event as compared to the QMouseFlickGesture.
+
+ \sa {Gestures Programming}, QScroller, QScrollerProperties, QMouseFlickGesture
+*/
+
+/*!
+ \internal
+*/
+QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent)
+ : QGesture(*new QFlickGesturePrivate, parent)
+{
+ d_func()->q_ptr = this;
+ d_func()->receiver = receiver;
+ d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0;
+ d_func()->button = button;
+}
+
+QFlickGesture::~QFlickGesture()
+{ }
+
+QFlickGesturePrivate::QFlickGesturePrivate()
+ : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false)
+{ }
+
+
+//
+// QFlickGestureRecognizer
+//
+
+
+QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button)
+{
+ this->button = button;
+}
+
+/*! \reimp
+ */
+QGesture *QFlickGestureRecognizer::create(QObject *target)
+{
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target);
+ if (go && button == Qt::NoButton) {
+ go->setAcceptTouchEvents(true);
+ }
+#endif
+ return new QFlickGesture(target, button);
+}
+
+/*! \internal
+ The recognize function detects a touch event suitable to start the attached QScroller.
+ The QFlickGesture will be triggered as soon as the scroller is no longer in the state
+ QScroller::Inactive or QScroller::Pressed. It will be finished or canceled
+ at the next QEvent::TouchEnd.
+ Note that the QScroller might continue scrolling (kinetically) at this point.
+ */
+QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
+ QObject *watched,
+ QEvent *event)
+{
+ Q_UNUSED(watched);
+
+ static QElapsedTimer monotonicTimer;
+ if (!monotonicTimer.isValid())
+ monotonicTimer.start();
+
+ QFlickGesture *q = static_cast<QFlickGesture *>(state);
+ QFlickGesturePrivate *d = q->d_func();
+
+ QScroller *scroller = d->receiverScroller;
+ if (!scroller)
+ return Ignore; // nothing to do without a scroller?
+
+ QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver);
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver);
+#endif
+
+ // this is only set for events that we inject into the event loop via sendEvent()
+ if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) {
+ //qFGDebug() << state << "QFG: ignored event: " << event->type();
+ return Ignore;
+ }
+
+ const QMouseEvent *me = 0;
+#ifndef QT_NO_GRAPHICSVIEW
+ const QGraphicsSceneMouseEvent *gsme = 0;
+#endif
+ const QTouchEvent *te = 0;
+ QPoint globalPos;
+
+ // qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
+
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ if (!receiverWidget)
+ return Ignore;
+ if (button != Qt::NoButton) {
+ me = static_cast<const QMouseEvent *>(event);
+ globalPos = me->globalPos();
+ }
+ break;
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseMove:
+ if (!receiverGraphicsObject)
+ return Ignore;
+ if (button != Qt::NoButton) {
+ gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
+ globalPos = gsme->screenPos();
+ }
+ break;
+#endif
+ case QEvent::TouchBegin:
+ case QEvent::TouchEnd:
+ case QEvent::TouchUpdate:
+ if (button == Qt::NoButton) {
+ te = static_cast<const QTouchEvent *>(event);
+ if (!te->touchPoints().isEmpty())
+ globalPos = te->touchPoints().at(0).screenPos().toPoint();
+ }
+ break;
+
+#if defined(Q_WS_MAC)
+ // the only way to distinguish between real mouse wheels and wheel
+ // events generated by the native 2 finger swipe gesture is to listen
+ // for these events (according to Apple's Cocoa Event-Handling Guide)
+
+ case QEvent::NativeGesture: {
+ QNativeGestureEvent *nge = static_cast<QNativeGestureEvent *>(event);
+ if (nge->gestureType == QNativeGestureEvent::GestureBegin)
+ d->macIgnoreWheel = true;
+ else if (nge->gestureType == QNativeGestureEvent::GestureEnd)
+ d->macIgnoreWheel = false;
+ break;
+ }
+#endif
+
+ // consume all wheel events if the scroller is active
+ case QEvent::Wheel:
+ if (d->macIgnoreWheel || (scroller->state() != QScroller::Inactive))
+ return Ignore | ConsumeEventHint;
+ break;
+
+ // consume all dbl click events if the scroller is active
+ case QEvent::MouseButtonDblClick:
+ if (scroller->state() != QScroller::Inactive)
+ return Ignore | ConsumeEventHint;
+ break;
+
+ default:
+ break;
+ }
+
+ if (!me
+#ifndef QT_NO_GRAPHICSVIEW
+ && !gsme
+#endif
+ && !te) // Neither mouse nor touch
+ return Ignore;
+
+ // get the current pointer position in local coordinates.
+ QPointF point;
+ QScroller::Input inputType = (QScroller::Input) 0;
+
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ if (me && me->button() == button && me->buttons() == button) {
+ point = me->globalPos();
+ inputType = QScroller::InputPress;
+ } else if (me) {
+ scroller->stop();
+ return CancelGesture;
+ }
+ break;
+ case QEvent::MouseButtonRelease:
+ if (me && me->button() == button) {
+ point = me->globalPos();
+ inputType = QScroller::InputRelease;
+ }
+ break;
+ case QEvent::MouseMove:
+#ifdef Q_OS_SYMBIAN
+ // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
+ // relies on the windowing system to report the current buttons state.
+ if (me && (me->buttons() == button || !me->buttons())) {
+#else
+ if (me && me->buttons() == button) {
+#endif
+ point = me->globalPos();
+ inputType = QScroller::InputMove;
+ }
+ break;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMousePress:
+ if (gsme && gsme->button() == button && gsme->buttons() == button) {
+ point = gsme->scenePos();
+ inputType = QScroller::InputPress;
+ } else if (gsme) {
+ scroller->stop();
+ return CancelGesture;
+ }
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ if (gsme && gsme->button() == button) {
+ point = gsme->scenePos();
+ inputType = QScroller::InputRelease;
+ }
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+#ifdef Q_OS_SYMBIAN
+ // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix
+ // relies on the windowing system to report the current buttons state.
+ if (gsme && (gsme->buttons() == button || !me->buttons())) {
+#else
+ if (gsme && gsme->buttons() == button) {
+#endif
+ point = gsme->scenePos();
+ inputType = QScroller::InputMove;
+ }
+ break;
+#endif
+
+ case QEvent::TouchBegin:
+ inputType = QScroller::InputPress;
+ // fall through
+ case QEvent::TouchEnd:
+ if (!inputType)
+ inputType = QScroller::InputRelease;
+ // fallthrough
+ case QEvent::TouchUpdate:
+ if (!inputType)
+ inputType = QScroller::InputMove;
+
+ if (te->deviceType() == QTouchEvent::TouchPad) {
+ if (te->touchPoints().count() != 2) // 2 fingers on pad
+ return Ignore;
+
+ point = te->touchPoints().at(0).startScenePos() +
+ ((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) +
+ (te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2;
+ } else { // TouchScreen
+ if (te->touchPoints().count() != 1) // 1 finger on screen
+ return Ignore;
+
+ point = te->touchPoints().at(0).scenePos();
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ // Check for an active scroller at globalPos
+ if (inputType == QScroller::InputPress) {
+ foreach (QScroller *as, QScroller::activeScrollers()) {
+ if (as != scroller) {
+ QRegion scrollerRegion;
+
+ if (QWidget *w = qobject_cast<QWidget *>(as->target())) {
+ scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size());
+#ifndef QT_NO_GRAPHICSVIEW
+ } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) {
+ if (go->scene() && !go->scene()->views().isEmpty()) {
+ foreach (QGraphicsView *gv, go->scene()->views())
+ scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect()))
+ .translated(gv->mapToGlobal(QPoint(0, 0)));
+ }
+#endif
+ }
+ // active scrollers always have priority
+ if (scrollerRegion.contains(globalPos))
+ return Ignore;
+ }
+ }
+ }
+
+ bool scrollerWasDragging = (scroller->state() == QScroller::Dragging);
+ bool scrollerWasScrolling = (scroller->state() == QScroller::Scrolling);
+
+ if (inputType) {
+ if (QWidget *w = qobject_cast<QWidget *>(d->receiver))
+ point = w->mapFromGlobal(point.toPoint());
+#ifndef QT_NO_GRAPHICSVIEW
+ else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver))
+ point = go->mapFromScene(point);
+#endif
+
+ // inform the scroller about the new event
+ scroller->handleInput(inputType, point, monotonicTimer.elapsed());
+ }
+
+ // depending on the scroller state return the gesture state
+ Result result(0);
+ bool scrollerIsActive = (scroller->state() == QScroller::Dragging ||
+ scroller->state() == QScroller::Scrolling);
+
+ // Consume all mouse events while dragging or scrolling to avoid nasty
+ // side effects with Qt's standard widgets.
+ if ((me
+#ifndef QT_NO_GRAPHICSVIEW
+ || gsme
+#endif
+ ) && scrollerIsActive)
+ result |= ConsumeEventHint;
+
+ // The only problem with this approach is that we consume the
+ // MouseRelease when we start the scrolling with a flick gesture, so we
+ // have to fake a MouseRelease "somewhere" to not mess with the internal
+ // states of Qt's widgets (a QPushButton would stay in 'pressed' state
+ // forever, if it doesn't receive a MouseRelease).
+ if (me
+#ifndef QT_NO_GRAPHICSVIEW
+ || gsme
+#endif
+ ) {
+ if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
+ PressDelayHandler::instance()->scrollerBecameActive();
+ else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
+ PressDelayHandler::instance()->scrollerWasIntercepted();
+ }
+
+ if (!inputType) {
+ result |= Ignore;
+ } else {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMousePress:
+#endif
+ if (scroller->state() == QScroller::Pressed) {
+ int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal());
+ if (pressDelay > 0) {
+ result |= ConsumeEventHint;
+
+ PressDelayHandler::instance()->pressed(event, pressDelay);
+ event->accept();
+ }
+ }
+ // fall through
+ case QEvent::TouchBegin:
+ q->setHotSpot(globalPos);
+ result |= scrollerIsActive ? TriggerGesture : MayBeGesture;
+ break;
+
+ case QEvent::MouseMove:
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMouseMove:
+#endif
+ if (PressDelayHandler::instance()->isDelaying())
+ result |= ConsumeEventHint;
+ // fall through
+ case QEvent::TouchUpdate:
+ result |= scrollerIsActive ? TriggerGesture : Ignore;
+ break;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMouseRelease:
+#endif
+ case QEvent::MouseButtonRelease:
+ if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive))
+ result |= ConsumeEventHint;
+ // fall through
+ case QEvent::TouchEnd:
+ result |= scrollerIsActive ? FinishGesture : CancelGesture;
+ break;
+
+ default:
+ result |= Ignore;
+ break;
+ }
+ }
+ return result;
+}
+
+
+/*! \reimp
+ */
+void QFlickGestureRecognizer::reset(QGesture *state)
+{
+ QGestureRecognizer::reset(state);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GESTURES
diff --git a/src/gui/util/qflickgesture_p.h b/src/gui/util/qflickgesture_p.h
new file mode 100644
index 0000000..451b579
--- /dev/null
+++ b/src/gui/util/qflickgesture_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFLICKGESTURE_P_H
+#define QFLICKGESTURE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qevent.h"
+#include "qgesturerecognizer.h"
+#include "private/qgesture_p.h"
+#include "qscroller.h"
+#include "qscopedpointer.h"
+
+#ifndef QT_NO_GESTURES
+
+QT_BEGIN_NAMESPACE
+
+class QFlickGesturePrivate;
+class QGraphicsItem;
+
+class Q_GUI_EXPORT QFlickGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QFlickGesture)
+
+public:
+ QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0);
+ ~QFlickGesture();
+
+ friend class QFlickGestureRecognizer;
+};
+
+class PressDelayHandler;
+
+class QFlickGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QFlickGesture)
+public:
+ QFlickGesturePrivate();
+
+ QPointer<QObject> receiver;
+ QScroller *receiverScroller;
+ Qt::MouseButton button; // NoButton == Touch
+ bool macIgnoreWheel;
+ static PressDelayHandler *pressDelayHandler;
+};
+
+class QFlickGestureRecognizer : public QGestureRecognizer
+{
+public:
+ QFlickGestureRecognizer(Qt::MouseButton button);
+
+ QGesture *create(QObject *target);
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+
+private:
+ Qt::MouseButton button; // NoButton == Touch
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GESTURES
+
+#endif // QFLICKGESTURE_P_H
diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp
new file mode 100644
index 0000000..9c2d24d
--- /dev/null
+++ b/src/gui/util/qscroller.cpp
@@ -0,0 +1,2057 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qevent.h"
+#include "qwidget.h"
+#include "qscroller.h"
+#include "private/qflickgesture_p.h"
+#include "private/qscroller_p.h"
+#include "qscrollerproperties.h"
+#include "private/qscrollerproperties_p.h"
+#include "qnumeric.h"
+#include "math.h"
+
+#include <QTime>
+#include <QElapsedTimer>
+#include <QMap>
+#include <QApplication>
+#include <QAbstractScrollArea>
+#include <QGraphicsObject>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <QDesktopWidget>
+#include <QtCore/qmath.h>
+#include <QtGui/qevent.h>
+#include <qnumeric.h>
+
+#include <QtDebug>
+
+#if defined(Q_WS_X11)
+# include "private/qt_x11_p.h"
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
+//#define QSCROLLER_DEBUG
+
+#ifdef QSCROLLER_DEBUG
+# define qScrollerDebug qDebug
+#else
+# define qScrollerDebug while (false) qDebug
+#endif
+
+QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s)
+{
+ dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress;
+ dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos;
+ dbg << "\n Curve: type:" << s.curve.type() << "\n";
+ return dbg;
+}
+
+
+// a few helper operators to make the code below a lot more readable:
+// otherwise a lot of ifs would have to be multi-line to check both the x
+// and y coordinate separately.
+
+// returns true only if the abs. value of BOTH x and y are <= f
+inline bool operator<=(const QPointF &p, qreal f)
+{
+ return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f);
+}
+
+// returns true only if the abs. value of BOTH x and y are < f
+inline bool operator<(const QPointF &p, qreal f)
+{
+ return (qAbs(p.x()) < f) && (qAbs(p.y()) < f);
+}
+
+// returns true if the abs. value of EITHER x or y are >= f
+inline bool operator>=(const QPointF &p, qreal f)
+{
+ return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f);
+}
+
+// returns true if the abs. value of EITHER x or y are > f
+inline bool operator>(const QPointF &p, qreal f)
+{
+ return (qAbs(p.x()) > f) || (qAbs(p.y()) > f);
+}
+
+// returns a new point with both coordinates having the abs. value of the original one
+inline QPointF qAbs(const QPointF &p)
+{
+ return QPointF(qAbs(p.x()), qAbs(p.y()));
+}
+
+// returns a new point with all components of p1 multiplied by the corresponding components of p2
+inline QPointF operator*(const QPointF &p1, const QPointF &p2)
+{
+ return QPointF(p1.x() * p2.x(), p1.y() * p2.y());
+}
+
+// returns a new point with all components of p1 divided by the corresponding components of p2
+inline QPointF operator/(const QPointF &p1, const QPointF &p2)
+{
+ return QPointF(p1.x() / p2.x(), p1.y() / p2.y());
+}
+
+inline QPointF clampToRect(const QPointF &p, const QRectF &rect)
+{
+ qreal x = qBound(rect.left(), p.x(), rect.right());
+ qreal y = qBound(rect.top(), p.y(), rect.bottom());
+ return QPointF(x, y);
+}
+
+// returns -1, 0 or +1 according to r being <0, ==0 or >0
+inline int qSign(qreal r)
+{
+ return (r < 0) ? -1 : ((r > 0) ? 1 : 0);
+}
+
+// this version is not mathematically exact, but it just works for every
+// easing curve type (even custom ones)
+
+static qreal differentialForProgress(const QEasingCurve &curve, qreal pos)
+{
+ const qreal dx = 0.01;
+ qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx);
+ qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx);
+ qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx);
+
+ //qScrollerDebug() << "differentialForProgress(type: " << curve.type() << ", pos: " << pos << ") = " << d;
+
+ return d;
+}
+
+// this version is not mathematically exact, but it just works for every
+// easing curve type (even custom ones)
+
+static qreal progressForValue(const QEasingCurve &curve, qreal value)
+{
+ if (curve.type() >= QEasingCurve::InElastic &&
+ curve.type() < QEasingCurve::Custom) {
+ qWarning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type());
+ return value;
+ }
+ if (value < qreal(0) || value > qreal(1))
+ return value;
+
+ qreal progress = value, left(0), right(1);
+ for (int iterations = 6; iterations; --iterations) {
+ qreal v = curve.valueForProgress(progress);
+ if (v < value)
+ left = progress;
+ else if (v > value)
+ right = progress;
+ else
+ break;
+ progress = (left + right) / qreal(2);
+ }
+ return progress;
+}
+
+
+#ifndef QT_NO_ANIMATION
+class QScrollTimer : public QAbstractAnimation
+{
+public:
+ QScrollTimer(QScrollerPrivate *_d)
+ : d(_d), ignoreUpdate(false), skip(0)
+ { }
+
+ int duration() const
+ {
+ return -1;
+ }
+
+ void start()
+ {
+ // QAbstractAnimation::start() will immediately call
+ // updateCurrentTime(), but our state is not set correctly yet
+ ignoreUpdate = true;
+ QAbstractAnimation::start();
+ ignoreUpdate = false;
+ skip = 0;
+ }
+
+protected:
+ void updateCurrentTime(int /*currentTime*/)
+ {
+ if (!ignoreUpdate) {
+ if (++skip >= d->frameRateSkip()) {
+ skip = 0;
+ d->timerTick();
+ }
+ }
+ }
+
+private:
+ QScrollerPrivate *d;
+ bool ignoreUpdate;
+ int skip;
+};
+#endif // QT_NO_ANIMATION
+
+/*!
+ \class QScroller
+ \brief The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.
+ \since 4.8
+
+ With kinetic scrolling, the user can push the widget in a given
+ direction and it will continue to scroll in this direction until it is
+ stopped either by the user or by friction. Aspects of inertia, friction
+ and other physical concepts can be changed in order to fine-tune an
+ intuitive user experience.
+
+ The QScroller object is the object that stores the current position and
+ scrolling speed and takes care of updates.
+ QScroller can be triggered by a flick gesture
+
+ \code
+ QWidget *w = ...;
+ QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture);
+ \endcode
+
+ or directly like this:
+
+ \code
+ QWidget *w = ...;
+ QScroller *scroller = QScroller::scroller(w);
+ scroller->scrollTo(QPointF(100, 100));
+ \endcode
+
+ The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to
+ update its geometry information and a QScrollEvent whenever the content of the object should
+ actually be scrolled.
+
+ The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This
+ can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.
+
+ Several examples in the \c scroller examples directory show how QScroller,
+ QScrollEvent and the scroller gesture can be used.
+
+ Even though this kinetic scroller has a large number of settings available via
+ QScrollerProperties, we recommend that you leave them all at their default, platform optimized
+ values. Before changing them you can experiment with the \c plot example in
+ the \c scroller examples directory.
+
+ \sa QScrollEvent, QScrollPrepareEvent, QScrollerProperties
+*/
+
+
+QMap<QObject *, QScroller *> QScrollerPrivate::allScrollers;
+QSet<QScroller *> QScrollerPrivate::activeScrollers;
+
+/*!
+ Returns \c true if a QScroller object was already created for \a target; \c false otherwise.
+
+ \sa scroller()
+*/
+bool QScroller::hasScroller(QObject *target)
+{
+ return (QScrollerPrivate::allScrollers.value(target));
+}
+
+/*!
+ Returns the scroller for the given \a target.
+ As long as the object exists this function will always return the same QScroller instance.
+ If no QScroller exists for the \a target, one will implicitly be created.
+ At no point more than one QScroller will be active on an object.
+
+ \sa hasScroller(), target()
+*/
+QScroller *QScroller::scroller(QObject *target)
+{
+ if (!target) {
+ qWarning("QScroller::scroller() was called with a null target.");
+ return 0;
+ }
+
+ if (QScrollerPrivate::allScrollers.contains(target))
+ return QScrollerPrivate::allScrollers.value(target);
+
+ QScroller *s = new QScroller(target);
+ QScrollerPrivate::allScrollers.insert(target, s);
+ return s;
+}
+
+/*!
+ \overload
+ This is the const version of scroller().
+*/
+const QScroller *QScroller::scroller(const QObject *target)
+{
+ return scroller(const_cast<QObject*>(target));
+}
+
+/*!
+ Returns an application wide list of currently active QScroller objects.
+ Active QScroller objects are in a state() that is not QScroller::Inactive.
+ This function is useful when writing your own gesture recognizer.
+*/
+QList<QScroller *> QScroller::activeScrollers()
+{
+ return QScrollerPrivate::activeScrollers.toList();
+}
+
+/*!
+ Returns the target object of this scroller.
+ \sa hasScroller(), scroller()
+ */
+QObject *QScroller::target() const
+{
+ Q_D(const QScroller);
+ return d->target;
+}
+
+/*!
+ \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties);
+
+ QScroller emits this signal whenever its scroller properties change.
+ \a newProperties are the new scroller properties.
+
+ \sa scrollerProperties
+*/
+
+
+/*! \property QScroller::scrollerProperties
+ \brief The scroller properties of this scroller.
+ The properties are used by the QScroller to determine its scrolling behavior.
+*/
+QScrollerProperties QScroller::scrollerProperties() const
+{
+ Q_D(const QScroller);
+ return d->properties;
+}
+
+void QScroller::setScrollerProperties(const QScrollerProperties &sp)
+{
+ Q_D(QScroller);
+ if (d->properties != sp) {
+ d->properties = sp;
+ emit scrollerPropertiesChanged(sp);
+
+ // we need to force the recalculation here, since the overshootPolicy may have changed and
+ // existing segments may include an overshoot animation.
+ d->recalcScrollingSegments(true);
+ }
+}
+
+#ifndef QT_NO_GESTURES
+
+/*!
+ Registers a custom scroll gesture recognizer, grabs it for the \a
+ target and returns the resulting gesture type. If \a scrollGestureType is
+ set to TouchGesture the gesture triggers on touch events. If it is set to
+ one of LeftMouseButtonGesture, RightMouseButtonGesture or
+ MiddleMouseButtonGesture it triggers on mouse events of the
+ corresponding button.
+
+ Only one scroll gesture can be active on a single object at the same
+ time. If you call this function twice on the same object, it will
+ ungrab the existing gesture before grabbing the new one.
+
+ \note To avoid unwanted side-effects, mouse events are consumed while
+ the gesture is triggered. Since the initial mouse press event is
+ not consumed, the gesture sends a fake mouse release event
+ at the global position \c{(INT_MIN, INT_MIN)}. This ensures that
+ internal states of the widget that received the original mouse press
+ are consistent.
+
+ \sa ungrabGesture, grabbedGesture
+*/
+Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType)
+{
+ // ensure that a scroller for target is created
+ QScroller *s = scroller(target);
+ if (!s)
+ return Qt::GestureType(0);
+
+ QScrollerPrivate *sp = s->d_ptr;
+ if (sp->recognizer)
+ ungrabGesture(target); // ungrab the old gesture
+
+ Qt::MouseButton button;
+ switch (scrollGestureType) {
+ case LeftMouseButtonGesture : button = Qt::LeftButton; break;
+ case RightMouseButtonGesture : button = Qt::RightButton; break;
+ case MiddleMouseButtonGesture: button = Qt::MiddleButton; break;
+ default :
+ case TouchGesture : button = Qt::NoButton; break; // NoButton == Touch
+ }
+
+ sp->recognizer = new QFlickGestureRecognizer(button);
+ sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer);
+
+ if (target->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget *>(target);
+ widget->grabGesture(sp->recognizerType);
+ if (scrollGestureType == TouchGesture)
+ widget->setAttribute(Qt::WA_AcceptTouchEvents);
+#ifndef QT_NO_GRAPHICSVIEW
+ } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
+ if (scrollGestureType == TouchGesture)
+ go->setAcceptTouchEvents(true);
+ go->grabGesture(sp->recognizerType);
+#endif // QT_NO_GRAPHICSVIEW
+ }
+ return sp->recognizerType;
+}
+
+/*!
+ Returns the gesture type currently grabbed for the \a target or 0 if no
+ gesture is grabbed.
+
+ \sa grabGesture, ungrabGesture
+*/
+Qt::GestureType QScroller::grabbedGesture(QObject *target)
+{
+ QScroller *s = scroller(target);
+ if (s && s->d_ptr)
+ return s->d_ptr->recognizerType;
+ else
+ return Qt::GestureType(0);
+}
+
+/*!
+ Ungrabs the gesture for the \a target.
+ Does nothing if no gesture is grabbed.
+
+ \sa grabGesture, grabbedGesture
+*/
+void QScroller::ungrabGesture(QObject *target)
+{
+ QScroller *s = scroller(target);
+ if (!s)
+ return;
+
+ QScrollerPrivate *sp = s->d_ptr;
+ if (!sp->recognizer)
+ return; // nothing to do
+
+ if (target->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget *>(target);
+ widget->ungrabGesture(sp->recognizerType);
+#ifndef QT_NO_GRAPHICSVIEW
+ } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) {
+ go->ungrabGesture(sp->recognizerType);
+#endif
+ }
+
+ QGestureRecognizer::unregisterRecognizer(sp->recognizerType);
+ // do not delete the recognizer. The QGestureManager is doing this.
+ sp->recognizer = 0;
+}
+
+#endif // QT_NO_GESTURES
+
+/*!
+ \internal
+*/
+QScroller::QScroller(QObject *target)
+ : d_ptr(new QScrollerPrivate(this, target))
+{
+ Q_ASSERT(target); // you can't create a scroller without a target in any normal way
+ Q_D(QScroller);
+ d->init();
+}
+
+/*!
+ \internal
+*/
+QScroller::~QScroller()
+{
+ Q_D(QScroller);
+#ifndef QT_NO_GESTURES
+ QGestureRecognizer::unregisterRecognizer(d->recognizerType);
+ // do not delete the recognizer. The QGestureManager is doing this.
+ d->recognizer = 0;
+#endif
+ QScrollerPrivate::allScrollers.remove(d->target);
+ QScrollerPrivate::activeScrollers.remove(this);
+
+ delete d_ptr;
+}
+
+
+/*!
+ \fn QScroller::stateChanged(QScroller::State newState);
+
+ QScroller emits this signal whenever the state changes. \a newState is the new State.
+
+ \sa state
+*/
+
+/*!
+ \property QScroller::state
+ \brief the state of the scroller
+
+ \sa QScroller::State
+*/
+QScroller::State QScroller::state() const
+{
+ Q_D(const QScroller);
+ return d->state;
+}
+
+/*!
+ Stops the scroller and resets its state back to Inactive.
+*/
+void QScroller::stop()
+{
+ Q_D(QScroller);
+ if (d->state != Inactive) {
+ QPointF here = clampToRect(d->contentPosition, d->contentPosRange);
+ qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal);
+ qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical);
+ QPointF snap = here;
+ if (!qIsNaN(snapX))
+ snap.setX(snapX);
+ if (!qIsNaN(snapY))
+ snap.setY(snapY);
+ d->contentPosition = snap;
+ d->overshootPosition = QPointF(0, 0);
+
+ d->setState(Inactive);
+ }
+}
+
+/*!
+ Returns the pixel per meter metric for the scrolled widget.
+
+ The value is reported for both the x and y axis separately by using a QPointF.
+
+ \note Please note that this value should be physically correct. The actual DPI settings
+ that Qt returns for the display may be reported wrongly on purpose by the underlying
+ windowing system, for example on Mac OS X or Maemo 5.
+*/
+QPointF QScroller::pixelPerMeter() const
+{
+ Q_D(const QScroller);
+ QPointF ppm = d->pixelPerMeter;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) {
+ QTransform viewtr;
+ //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
+ if (go->scene() && !go->scene()->views().isEmpty())
+ viewtr = go->scene()->views().first()->viewportTransform();
+ QTransform tr = go->deviceTransform(viewtr);
+ if (tr.isScaling()) {
+ QPointF p0 = tr.map(QPointF(0, 0));
+ QPointF px = tr.map(QPointF(1, 0));
+ QPointF py = tr.map(QPointF(0, 1));
+ ppm.rx() /= QLineF(p0, px).length();
+ ppm.ry() /= QLineF(p0, py).length();
+ }
+ }
+#endif // QT_NO_GRAPHICSVIEW
+ return ppm;
+}
+
+/*!
+ Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging.
+ Returns a zero velocity otherwise.
+
+ The velocity is reported for both the x and y axis separately by using a QPointF.
+
+ \sa pixelPerMeter()
+*/
+QPointF QScroller::velocity() const
+{
+ Q_D(const QScroller);
+ const QScrollerPropertiesPrivate *sp = d->properties.d.data();
+
+ switch (state()) {
+ case Dragging:
+ return d->releaseVelocity;
+ case Scrolling: {
+ QPointF vel;
+ qint64 now = d->monotonicTimer.elapsed();
+
+ if (!d->xSegments.isEmpty()) {
+ const QScrollerPrivate::ScrollSegment &s = d->xSegments.head();
+ qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
+ qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
+ vel.setX(v);
+ }
+
+ if (!d->ySegments.isEmpty()) {
+ const QScrollerPrivate::ScrollSegment &s = d->ySegments.head();
+ qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
+ qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress);
+ vel.setY(v);
+ }
+ return vel;
+ }
+ default:
+ return QPointF(0, 0);
+ }
+}
+
+/*!
+ Returns the estimated final position for the current scroll movement.
+ Returns the current position if the scroller state is not Scrolling.
+ The result is undefined when the scroller state is Inactive.
+
+ The target position is in pixel.
+
+ \sa pixelPerMeter(), scrollTo()
+*/
+QPointF QScroller::finalPosition() const
+{
+ Q_D(const QScroller);
+ return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
+ d->scrollingSegmentsEndPos(Qt::Vertical));
+}
+
+/*!
+ Starts scrolling the widget so that point \a pos is at the top-left position in
+ the viewport.
+
+ The behaviour when scrolling outside the valid scroll area is undefined.
+ In this case the scroller might or might not overshoot.
+
+ The scrolling speed will be calculated so that the given position will
+ be reached after a platform-defined time span.
+
+ \a pos is given in viewport coordinates.
+
+ \sa ensureVisible()
+*/
+void QScroller::scrollTo(const QPointF &pos)
+{
+ // we could make this adjustable via QScrollerProperties
+ scrollTo(pos, 300);
+}
+
+/*! \overload
+
+ This version will reach its destination position in \a scrollTime milliseconds.
+*/
+void QScroller::scrollTo(const QPointF &pos, int scrollTime)
+{
+ Q_D(QScroller);
+
+ if (d->state == Pressed || d->state == Dragging )
+ return;
+
+ // no need to resend a prepare event if we are already scrolling
+ if (d->state == Inactive && !d->prepareScrolling(QPointF()))
+ return;
+
+ QPointF newpos = clampToRect(pos, d->contentPosRange);
+ qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal);
+ qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical);
+ if (!qIsNaN(snapX))
+ newpos.setX(snapX);
+ if (!qIsNaN(snapY))
+ newpos.setY(snapY);
+
+ qScrollerDebug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])";
+
+ if (newpos == d->contentPosition + d->overshootPosition)
+ return;
+
+ QPointF vel = velocity();
+
+ if (scrollTime < 0)
+ scrollTime = 0;
+ qreal time = qreal(scrollTime) / 1000;
+
+ d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo);
+ d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo);
+
+ if (!scrollTime)
+ d->setContentPositionHelperScrolling();
+ d->setState(scrollTime ? Scrolling : Inactive);
+}
+
+/*!
+ Starts scrolling so that the rectangle \a rect is visible inside the
+ viewport with additional margins specified in pixels by \a xmargin and \a ymargin around
+ the rect.
+
+ In cases where it is not possible to fit the rect plus margins inside the viewport the contents
+ are scrolled so that as much as possible is visible from \a rect.
+
+ The scrolling speed is calculated so that the given position is reached after a platform-defined
+ time span.
+
+ This function performs the actual scrolling by calling scrollTo().
+
+ \sa scrollTo
+*/
+void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin)
+{
+ // we could make this adjustable via QScrollerProperties
+ ensureVisible(rect, xmargin, ymargin, 1000);
+}
+
+/*! \overload
+
+ This version will reach its destination position in \a scrollTime milliseconds.
+*/
+void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime)
+{
+ Q_D(QScroller);
+
+ if (d->state == Pressed || d->state == Dragging )
+ return;
+
+ if (d->state == Inactive && !d->prepareScrolling(QPointF()))
+ return;
+
+ // -- calculate the current pos (or the position after the current scroll)
+ QPointF startPos = d->contentPosition + d->overshootPosition;
+ startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal),
+ d->scrollingSegmentsEndPos(Qt::Vertical));
+
+ QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin,
+ rect.width() + 2 * xmargin, rect.height() + 2 * ymargin);
+
+ QSizeF visible = d->viewportSize;
+ QRectF visibleRect(startPos, visible);
+
+ qScrollerDebug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])";
+ qScrollerDebug() << " --> content position:" << d->contentPosition;
+
+ if (visibleRect.contains(marginRect))
+ return;
+
+ QPointF newPos = startPos;
+
+ if (visibleRect.width() < rect.width()) {
+ // at least try to move the rect into view
+ if (rect.left() > visibleRect.left())
+ newPos.setX(rect.left());
+ else if (rect.right() < visibleRect.right())
+ newPos.setX(rect.right() - visible.width());
+
+ } else if (visibleRect.width() < marginRect.width()) {
+ newPos.setX(rect.center().x() - visibleRect.width() / 2);
+ } else if (marginRect.left() > visibleRect.left()) {
+ newPos.setX(marginRect.left());
+ } else if (marginRect.right() < visibleRect.right()) {
+ newPos.setX(marginRect.right() - visible.width());
+ }
+
+ if (visibleRect.height() < rect.height()) {
+ // at least try to move the rect into view
+ if (rect.top() > visibleRect.top())
+ newPos.setX(rect.top());
+ else if (rect.bottom() < visibleRect.bottom())
+ newPos.setX(rect.bottom() - visible.height());
+
+ } else if (visibleRect.height() < marginRect.height()) {
+ newPos.setY(rect.center().y() - visibleRect.height() / 2);
+ } else if (marginRect.top() > visibleRect.top()) {
+ newPos.setY(marginRect.top());
+ } else if (marginRect.bottom() < visibleRect.bottom()) {
+ newPos.setY(marginRect.bottom() - visible.height());
+ }
+
+ // clamp to maximum content position
+ newPos = clampToRect(newPos, d->contentPosRange);
+ if (newPos == startPos)
+ return;
+
+ scrollTo(newPos, scrollTime);
+}
+
+/*! This function resends the QScrollPrepareEvent.
+ Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller.
+ This allows the receiver to re-set content position and content size while
+ scrolling.
+ Calling this function while in the Inactive state is useless as the prepare event
+ is sent again before scrolling starts.
+ */
+void QScroller::resendPrepareEvent()
+{
+ Q_D(QScroller);
+ d->prepareScrolling(d->pressPosition);
+}
+
+/*! Set the snap positions for the horizontal axis to a list of \a positions.
+ This overwrites all previously set snap positions and also a previously
+ set snapping interval.
+ Snapping can be deactivated by setting an empty list of positions.
+ */
+void QScroller::setSnapPositionsX(const QList<qreal> &positions)
+{
+ Q_D(QScroller);
+ d->snapPositionsX = positions;
+ d->snapIntervalX = 0.0;
+
+ d->recalcScrollingSegments();
+}
+
+/*! Set the snap positions for the horizontal axis to regular spaced intervals.
+ The first snap position is at \a first. The next at \a first + \a interval.
+ This can be used to implement a list header.
+ This overwrites all previously set snap positions and also a previously
+ set snapping interval.
+ Snapping can be deactivated by setting an interval of 0.0
+ */
+void QScroller::setSnapPositionsX(qreal first, qreal interval)
+{
+ Q_D(QScroller);
+ d->snapFirstX = first;
+ d->snapIntervalX = interval;
+ d->snapPositionsX.clear();
+
+ d->recalcScrollingSegments();
+}
+
+/*! Set the snap positions for the vertical axis to a list of \a positions.
+ This overwrites all previously set snap positions and also a previously
+ set snapping interval.
+ Snapping can be deactivated by setting an empty list of positions.
+ */
+void QScroller::setSnapPositionsY(const QList<qreal> &positions)
+{
+ Q_D(QScroller);
+ d->snapPositionsY = positions;
+ d->snapIntervalY = 0.0;
+
+ d->recalcScrollingSegments();
+}
+
+/*! Set the snap positions for the vertical axis to regular spaced intervals.
+ The first snap position is at \a first. The next at \a first + \a interval.
+ This overwrites all previously set snap positions and also a previously
+ set snapping interval.
+ Snapping can be deactivated by setting an interval of 0.0
+ */
+void QScroller::setSnapPositionsY(qreal first, qreal interval)
+{
+ Q_D(QScroller);
+ d->snapFirstY = first;
+ d->snapIntervalY = interval;
+ d->snapPositionsY.clear();
+
+ d->recalcScrollingSegments();
+}
+
+
+
+// -------------- private ------------
+
+QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target)
+ : target(_target)
+#ifndef QT_NO_GESTURES
+ , recognizer(0)
+ , recognizerType(Qt::CustomGesture)
+#endif
+ , state(QScroller::Inactive)
+ , firstScroll(true)
+ , pressTimestamp(0)
+ , lastTimestamp(0)
+ , snapFirstX(-1.0)
+ , snapIntervalX(0.0)
+ , snapFirstY(-1.0)
+ , snapIntervalY(0.0)
+#ifndef QT_NO_ANIMATION
+ , scrollTimer(new QScrollTimer(this))
+#endif
+ , q_ptr(q)
+{
+ connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed()));
+}
+
+void QScrollerPrivate::init()
+{
+ setDpiFromWidget(0);
+ monotonicTimer.start();
+}
+
+void QScrollerPrivate::sendEvent(QObject *o, QEvent *e)
+{
+ qt_sendSpontaneousEvent(o, e);
+}
+
+const char *QScrollerPrivate::stateName(QScroller::State state)
+{
+ switch (state) {
+ case QScroller::Inactive: return "inactive";
+ case QScroller::Pressed: return "pressed";
+ case QScroller::Dragging: return "dragging";
+ case QScroller::Scrolling: return "scrolling";
+ default: return "(invalid)";
+ }
+}
+
+const char *QScrollerPrivate::inputName(QScroller::Input input)
+{
+ switch (input) {
+ case QScroller::InputPress: return "press";
+ case QScroller::InputMove: return "move";
+ case QScroller::InputRelease: return "release";
+ default: return "(invalid)";
+ }
+}
+
+void QScrollerPrivate::targetDestroyed()
+{
+#ifndef QT_NO_ANIMATION
+ scrollTimer->stop();
+#endif
+ delete q_ptr;
+}
+
+void QScrollerPrivate::timerTick()
+{
+ struct timerevent {
+ QScroller::State state;
+ typedef void (QScrollerPrivate::*timerhandler_t)();
+ timerhandler_t handler;
+ };
+
+ timerevent timerevents[] = {
+ { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging },
+ { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling },
+ };
+
+ for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) {
+ timerevent *te = timerevents + i;
+
+ if (state == te->state) {
+ (this->*te->handler)();
+ return;
+ }
+ }
+
+#ifndef QT_NO_ANIMATION
+ scrollTimer->stop();
+#endif
+}
+
+/*!
+ This function is used by gesture recognizers to inform the scroller about a new input event.
+ The scroller changes its internal state() according to the input event and its attached
+ scroller properties. The scroller doesn't distinguish between the kind of input device the
+ event came from. Therefore the event needs to be split into the \a input type, a \a position and a
+ milli-second \a timestamp. The \a position needs to be in the target's coordinate system.
+
+ The return value is \c true if the event should be consumed by the calling filter or \c false
+ if the event should be forwarded to the control.
+
+ \note Using grabGesture() should be sufficient for most use cases.
+*/
+bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp)
+{
+ Q_D(QScroller);
+
+ qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")";
+ struct statechange {
+ State state;
+ Input input;
+ typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp);
+ inputhandler_t handler;
+ };
+
+ statechange statechanges[] = {
+ { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive },
+ { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed },
+ { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed },
+ { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging },
+ { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging },
+ { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling }
+ };
+
+ for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) {
+ statechange *sc = statechanges + i;
+
+ if (d->state == sc->state && input == sc->input)
+ return (d->*sc->handler)(position - d->overshootPosition, timestamp);
+ }
+ return false;
+}
+
+#if !defined(Q_WS_MAC)
+// the Mac version is implemented in qscroller_mac.mm
+
+QPointF QScrollerPrivate::realDpi(int screen)
+{
+# ifdef Q_WS_MAEMO_5
+ Q_UNUSED(screen);
+
+ // The DPI value is hardcoded to 96 on Maemo5:
+ // https://projects.maemo.org/bugzilla/show_bug.cgi?id=152525
+ // This value (260) is only correct for the N900 though, but
+ // there's no way to get the real DPI at run time.
+ return QPointF(260, 260);
+
+# elif defined(Q_WS_X11) && !defined(QT_NO_XRANDR)
+ if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
+ int nsizes = 0;
+ // QDesktopWidget is based on Xinerama screens, which do not always
+ // correspond to RandR screens: NVidia's TwinView e.g. will show up
+ // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen.
+ // (although with the combined size of the Xinerama screens).
+ // Additionally, libXrandr will simply crash when calling XRRSizes
+ // for (the non-existent) screen 1 in this scenario.
+ Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen);
+ int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1;
+
+ XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes);
+ if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) {
+ qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
+ qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
+ return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
+ qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
+ }
+ }
+# endif
+
+ QWidget *w = QApplication::desktop()->screen(screen);
+ return QPointF(w->physicalDpiX(), w->physicalDpiY());
+}
+
+#endif // !Q_WS_MAC
+
+
+/*! \internal
+ Returns the resolution of the used screen.
+*/
+QPointF QScrollerPrivate::dpi() const
+{
+ return pixelPerMeter * qreal(0.0254);
+}
+
+/*! \internal
+ Sets the resolution used for scrolling.
+ This resolution is only used by the kinetic scroller. If you change this
+ then the scroller will behave quite different as a lot of the values are
+ given in physical distances (millimeter).
+*/
+void QScrollerPrivate::setDpi(const QPointF &dpi)
+{
+ pixelPerMeter = dpi / qreal(0.0254);
+}
+
+/*! \internal
+ Sets the dpi used for scrolling to the value of the widget.
+*/
+void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
+{
+ QDesktopWidget *dw = QApplication::desktop();
+ setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen()));
+}
+
+/*! \internal
+ Updates the velocity during dragging.
+ Sets releaseVelocity.
+*/
+void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime)
+{
+ if (deltaTime <= 0)
+ return;
+
+ Q_Q(QScroller);
+ QPointF ppm = q->pixelPerMeter();
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+ QPointF deltaPixel = deltaPixelRaw;
+
+ qScrollerDebug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])";
+
+ // faster than 2.5mm/ms seems bogus (that would be a screen height in ~20 ms)
+ if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5))
+ deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength();
+
+ QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm;
+ // around 95% of all updates are in the [1..50] ms range, so make sure
+ // to scale the smoothing factor over that range: this way a 50ms update
+ // will have full impact, while 5ms update will only have a 10% impact.
+ qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50);
+
+ // only smooth if we already have a release velocity and only if the
+ // user hasn't stopped to move his finger for more than 100ms
+ if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) {
+ qScrollerDebug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing);
+ // smooth x or y only if the new velocity is either 0 or at least in
+ // the same direction of the release velocity
+ if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x())))
+ newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing));
+ if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y())))
+ newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing));
+ } else
+ qScrollerDebug() << "NO SMOOTHING to " << newv;
+
+ releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity));
+ releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity));
+
+ qScrollerDebug() << " --> new velocity:" << releaseVelocity;
+}
+
+void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation)
+{
+ if (startPos == stopPos || deltaPos == 0)
+ return;
+
+ ScrollSegment s;
+ if (orientation == Qt::Horizontal && !xSegments.isEmpty())
+ s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress;
+ else if (orientation == Qt::Vertical && !ySegments.isEmpty())
+ s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress;
+ else
+ s.startTime = monotonicTimer.elapsed();
+
+ s.startPos = startPos;
+ s.deltaPos = deltaPos;
+ s.stopPos = stopPos;
+ s.deltaTime = deltaTime * 1000;
+ s.stopProgress = stopProgress;
+ s.curve.setType(curve);
+ s.type = type;
+
+ if (orientation == Qt::Horizontal)
+ xSegments.enqueue(s);
+ else
+ ySegments.enqueue(s);
+
+ qScrollerDebug() << "+++ Added a new ScrollSegment: " << s;
+}
+
+
+/*! \internal
+ Clears the old segments and recalculates them if the current segments are not longer valid
+*/
+void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc)
+{
+ Q_Q(QScroller);
+ QPointF ppm = q->pixelPerMeter();
+
+ releaseVelocity = q->velocity();
+
+ if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal))
+ createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
+
+ if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical))
+ createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
+}
+
+/*! \internal
+ Returns the end position after the current scroll has finished.
+*/
+qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const
+{
+ if (orientation == Qt::Horizontal) {
+ if (xSegments.isEmpty())
+ return contentPosition.x() + overshootPosition.x();
+ else
+ return xSegments.last().stopPos;
+ } else {
+ if (ySegments.isEmpty())
+ return contentPosition.y() + overshootPosition.y();
+ else
+ return ySegments.last().stopPos;
+ }
+}
+
+/*! \internal
+ Checks if the scroller segment end in a valid position.
+*/
+bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation)
+{
+ QQueue<ScrollSegment> *segments;
+ qreal minPos;
+ qreal maxPos;
+
+ if (orientation == Qt::Horizontal) {
+ segments = &xSegments;
+ minPos = contentPosRange.left();
+ maxPos = contentPosRange.right();
+ } else {
+ segments = &ySegments;
+ minPos = contentPosRange.top();
+ maxPos = contentPosRange.bottom();
+ }
+
+ if (segments->isEmpty())
+ return true;
+
+ const ScrollSegment &last = segments->last();
+ qreal stopPos = last.stopPos;
+
+ if (last.type == ScrollTypeScrollTo)
+ return true; // scrollTo is always valid
+
+ if (last.type == ScrollTypeOvershoot &&
+ (stopPos != minPos && stopPos != maxPos))
+ return false;
+
+ if (stopPos < minPos || stopPos > maxPos)
+ return false;
+
+ if (stopPos == minPos || stopPos == maxPos) // the begin and the end of the list are always ok
+ return true;
+
+ qreal nextSnap = nextSnapPos(stopPos, 0, orientation);
+ if (!qIsNaN(nextSnap) && stopPos != nextSnap)
+ return false;
+
+ return true;
+}
+
+/*! \internal
+ Creates the sections needed to scroll to the specific \a endPos to the segments queue.
+*/
+void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type)
+{
+ Q_UNUSED(v);
+
+ if (orientation == Qt::Horizontal)
+ xSegments.clear();
+ else
+ ySegments.clear();
+
+ qScrollerDebug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation);
+
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+
+ qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x()
+ : contentPosition.y() + overshootPosition.y();
+ qreal deltaPos = (endPos - startPos) / 2;
+
+ pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation);
+ pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
+}
+
+/*! \internal
+*/
+void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation)
+{
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+
+ QScrollerProperties::OvershootPolicy policy;
+ qreal minPos;
+ qreal maxPos;
+ qreal viewSize;
+
+ if (orientation == Qt::Horizontal) {
+ xSegments.clear();
+ policy = sp->hOvershootPolicy;
+ minPos = contentPosRange.left();
+ maxPos = contentPosRange.right();
+ viewSize = viewportSize.width();
+ } else {
+ ySegments.clear();
+ policy = sp->vOvershootPolicy;
+ minPos = contentPosRange.top();
+ maxPos = contentPosRange.bottom();
+ viewSize = viewportSize.height();
+ }
+
+ bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn);
+ bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor;
+ bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos);
+
+ qScrollerDebug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation);
+
+ qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type();
+
+ // This is only correct for QEasingCurve::OutQuad (linear velocity,
+ // constant deceleration), but the results look and feel ok for OutExpo
+ // and OutSine as well
+
+ // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime)
+ // v(0) = vrelease
+ // v(deltaTime) = 0
+ // deltaTime = (2 * vrelease) / (a * differntial(0))
+
+ // pos(t) = integrate(v(t)dt)
+ // pos(t) = vrelease * t - 0.5 * a * t * t
+ // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime
+ // deltaPos = pos(deltaTime)
+
+ qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0));
+ qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm;
+ qreal endPos = startPos + deltaPos;
+
+ qScrollerDebug() << " Real Delta:" << deltaPos;
+
+ // -- determine snap points
+ qreal nextSnap = nextSnapPos(endPos, 0, orientation);
+ qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation);
+ qreal higherSnapPos = nextSnapPos(startPos, 1, orientation);
+
+ qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos;
+
+ // - check if we can reach another snap point
+ if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos))
+ higherSnapPos = nextSnap;
+ if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos))
+ lowerSnapPos = nextSnap;
+
+ // -- check if are in overshoot and end in overshoot
+ if ((startPos < minPos && endPos < minPos) ||
+ (startPos > maxPos && endPos > maxPos)) {
+ qreal stopPos = endPos < minPos ? minPos : maxPos;
+ qreal oDeltaTime = sp->overshootScrollTime;
+
+ pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation);
+ return;
+ }
+
+ if (qAbs(v) < sp->minimumVelocity) {
+
+ qScrollerDebug() << "### below minimum Vel" << orientation;
+
+ // - no snap points or already at one
+ if (qIsNaN(nextSnap) || nextSnap == startPos)
+ return; // nothing to do, no scrolling needed.
+
+ // - decide which point to use
+
+ qreal snapDistance = higherSnapPos - lowerSnapPos;
+
+ qreal pressDistance = (orientation == Qt::Horizontal) ?
+ lastPosition.x() - pressPosition.x() :
+ lastPosition.y() - pressPosition.y();
+
+ // if not dragged far enough, pick the next snap point.
+ if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance)
+ endPos = nextSnap;
+ else if (pressDistance < 0.0)
+ endPos = lowerSnapPos;
+ else
+ endPos = higherSnapPos;
+
+ deltaPos = endPos - startPos;
+ qreal midPos = startPos + deltaPos * qreal(0.3);
+ pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation);
+ pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation);
+ return;
+ }
+
+ // - go to the next snappoint if there is one
+ if (v > 0 && !qIsNaN(higherSnapPos)) {
+ // change the time in relation to the changed end position
+ if (endPos - startPos)
+ deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos));
+ if (deltaTime > sp->snapTime)
+ deltaTime = sp->snapTime;
+ endPos = higherSnapPos;
+
+ } else if (v < 0 && !qIsNaN(lowerSnapPos)) {
+ // change the time in relation to the changed end position
+ if (endPos - startPos)
+ deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos));
+ if (deltaTime > sp->snapTime)
+ deltaTime = sp->snapTime;
+ endPos = lowerSnapPos;
+
+ // -- check if we are overshooting
+ } else if (endPos < minPos || endPos > maxPos) {
+ qreal stopPos = endPos < minPos ? minPos : maxPos;
+
+ qScrollerDebug() << "Overshoot: delta:" << (stopPos - startPos);
+
+ qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos));
+
+ if (!canOvershoot) {
+ qScrollerDebug() << "Overshoot stopp:" << stopProgress;
+
+ pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation);
+ } else {
+ qreal oDeltaTime = sp->overshootScrollTime;
+ qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1));
+ qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos;
+ qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor);
+
+ qScrollerDebug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
+
+ if (qAbs(oDistance) > qAbs(oMaxDistance)) {
+ oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos));
+ oDistance = oMaxDistance;
+ qScrollerDebug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress;
+ }
+
+ pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation);
+ pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation);
+ }
+ return;
+ }
+
+ pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation);
+}
+
+
+/*! \internal
+ Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget.
+ Returns true if the scrolling was accepted and a target was returned.
+*/
+bool QScrollerPrivate::prepareScrolling(const QPointF &position)
+{
+ QScrollPrepareEvent spe(position);
+ spe.ignore();
+ sendEvent(target, &spe);
+
+ qScrollerDebug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos();
+ if (spe.isAccepted()) {
+ QPointF oldContentPos = contentPosition + overshootPosition;
+ QPointF contentDelta = spe.contentPos() - oldContentPos;
+
+ viewportSize = spe.viewportSize();
+ contentPosRange = spe.contentPosRange();
+ if (contentPosRange.width() < 0)
+ contentPosRange.setWidth(0);
+ if (contentPosRange.height() < 0)
+ contentPosRange.setHeight(0);
+ contentPosition = clampToRect(spe.contentPos(), contentPosRange);
+ overshootPosition = spe.contentPos() - contentPosition;
+
+ // - check if the content position was moved
+ if (contentDelta != QPointF(0, 0)) {
+ // need to correct all segments
+ for (int i = 0; i < xSegments.count(); i++)
+ xSegments[i].startPos -= contentDelta.x();
+
+ for (int i = 0; i < ySegments.count(); i++)
+ ySegments[i].startPos -= contentDelta.y();
+ }
+
+ if (QWidget *w = qobject_cast<QWidget *>(target))
+ setDpiFromWidget(w);
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) {
+ //TODO: the first view isn't really correct - maybe use an additional field in the prepare event?
+ if (go->scene() && !go->scene()->views().isEmpty())
+ setDpiFromWidget(go->scene()->views().first());
+ }
+#endif
+
+ if (state == QScroller::Scrolling) {
+ recalcScrollingSegments();
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp)
+{
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+
+ QPointF deltaPixel = position - lastPosition;
+ qint64 deltaTime = timestamp - lastTimestamp;
+
+ if (sp->axisLockThreshold) {
+ int dx = qAbs(deltaPixel.x());
+ int dy = qAbs(deltaPixel.y());
+ if (dx || dy) {
+ bool vertical = (dy > dx);
+ qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx);
+ //qScrollerDebug() << "QScroller::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy;
+ if (alpha <= sp->axisLockThreshold) {
+ if (vertical)
+ deltaPixel.setX(0);
+ else
+ deltaPixel.setY(0);
+ }
+ }
+ }
+
+ // calculate velocity (if the user would release the mouse NOW)
+ updateVelocity(deltaPixel, deltaTime);
+
+ // restrict velocity, if content is not scrollable
+ QRectF max = contentPosRange;
+ bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
+ bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
+
+ if (!canScrollX) {
+ deltaPixel.setX(0);
+ releaseVelocity.setX(0);
+ }
+ if (!canScrollY) {
+ deltaPixel.setY(0);
+ releaseVelocity.setY(0);
+ }
+
+// if (firstDrag) {
+// // Do not delay the first drag
+// setContentPositionHelper(q->contentPosition() - overshootDistance - deltaPixel);
+// dragDistance = QPointF(0, 0);
+// } else {
+ dragDistance += deltaPixel;
+// }
+//qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y();
+ if (canScrollX)
+ lastPosition.setX(position.x());
+ if (canScrollY)
+ lastPosition.setY(position.y());
+ lastTimestamp = timestamp;
+}
+
+bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp)
+{
+ if (prepareScrolling(position)) {
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+
+ if (!contentPosRange.isNull() ||
+ (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) ||
+ (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) {
+
+ lastPosition = pressPosition = position;
+ lastTimestamp = pressTimestamp = timestamp;
+ setState(QScroller::Pressed);
+ }
+ }
+ return false;
+}
+
+bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64)
+{
+ if (overshootPosition != QPointF(0.0, 0.0)) {
+ setState(QScroller::Scrolling);
+ return true;
+ } else {
+ setState(QScroller::Inactive);
+ return false;
+ }
+}
+
+bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp)
+{
+ Q_Q(QScroller);
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+ QPointF ppm = q->pixelPerMeter();
+
+ QPointF deltaPixel = position - pressPosition;
+
+ bool moveAborted = false;
+ bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance);
+
+ // check the direction of the mouse drag and abort if it's too much in the wrong direction.
+ if (moveStarted) {
+ QRectF max = contentPosRange;
+ bool canScrollX = (max.width() > 0);
+ bool canScrollY = (max.height() > 0);
+
+ if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
+ canScrollX = true;
+ if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)
+ canScrollY = true;
+
+ if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) {
+ if (!canScrollY)
+ moveAborted = true;
+ } else {
+ if (!canScrollX)
+ moveAborted = true;
+ }
+ }
+
+ if (moveAborted) {
+ setState(QScroller::Inactive);
+ moveStarted = false;
+
+ } else if (moveStarted) {
+ setState(QScroller::Dragging);
+
+ // subtract the dragStartDistance
+ deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength());
+
+ if (deltaPixel != QPointF(0, 0)) {
+ // handleDrag updates lastPosition, lastTimestamp and velocity
+ handleDrag(pressPosition + deltaPixel, timestamp);
+ }
+ }
+ return moveStarted;
+}
+
+bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp)
+{
+ // handleDrag updates lastPosition, lastTimestamp and velocity
+ handleDrag(position, timestamp);
+ return true;
+}
+
+void QScrollerPrivate::timerEventWhileDragging()
+{
+ if (dragDistance != QPointF(0, 0)) {
+ qScrollerDebug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance;
+
+ setContentPositionHelperDragging(-dragDistance);
+ dragDistance = QPointF(0, 0);
+ }
+}
+
+bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp)
+{
+ Q_Q(QScroller);
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+
+ // handleDrag updates lastPosition, lastTimestamp and velocity
+ handleDrag(position, timestamp);
+
+ // check if we moved at all - this can happen if you stop a running
+ // scroller with a press and release shortly afterwards
+ QPointF deltaPixel = position - pressPosition;
+ if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) {
+
+ // handle accelerating flicks
+ if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime &&
+ ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) {
+
+ // - determine if the direction was changed
+ int signX = 0, signY = 0;
+ if (releaseVelocity.x())
+ signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
+ if (releaseVelocity.y())
+ signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;
+
+ if (signX > 0)
+ releaseVelocity.setX(qBound(-sp->maximumVelocity,
+ oldVelocity.x() * sp->acceleratingFlickSpeedupFactor,
+ sp->maximumVelocity));
+ if (signY > 0)
+ releaseVelocity.setY(qBound(-sp->maximumVelocity,
+ oldVelocity.y() * sp->acceleratingFlickSpeedupFactor,
+ sp->maximumVelocity));
+ }
+ }
+
+ QPointF ppm = q->pixelPerMeter();
+ createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal);
+ createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical);
+
+ qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition;
+
+ if (xSegments.isEmpty() && ySegments.isEmpty())
+ setState(QScroller::Inactive);
+ else
+ setState(QScroller::Scrolling);
+
+ return true;
+}
+
+void QScrollerPrivate::timerEventWhileScrolling()
+{
+ qScrollerDebug() << "QScroller::timerEventWhileScrolling()";
+
+ setContentPositionHelperScrolling();
+ if (xSegments.isEmpty() && ySegments.isEmpty())
+ setState(QScroller::Inactive);
+}
+
+bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp)
+{
+ Q_Q(QScroller);
+
+ if ((q->velocity() <= properties.d->maximumClickThroughVelocity) &&
+ (overshootPosition == QPointF(0.0, 0.0))) {
+ setState(QScroller::Inactive);
+ return false;
+ } else {
+ lastPosition = pressPosition = position;
+ lastTimestamp = pressTimestamp = timestamp;
+ setState(QScroller::Pressed);
+ setState(QScroller::Dragging);
+ return true;
+ }
+}
+
+/*! \internal
+ This function handles all state changes of the scroller.
+*/
+void QScrollerPrivate::setState(QScroller::State newstate)
+{
+ Q_Q(QScroller);
+ bool sendLastScroll = false;
+
+ if (state == newstate)
+ return;
+
+ qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")";
+
+ switch (newstate) {
+ case QScroller::Inactive:
+#ifndef QT_NO_ANIMATION
+ scrollTimer->stop();
+#endif
+
+ // send the last scroll event (but only after the current state change was finished)
+ if (!firstScroll)
+ sendLastScroll = true;
+
+ releaseVelocity = QPointF(0, 0);
+ break;
+
+ case QScroller::Pressed:
+#ifndef QT_NO_ANIMATION
+ scrollTimer->stop();
+#endif
+
+ oldVelocity = releaseVelocity;
+ releaseVelocity = QPointF(0, 0);
+ break;
+
+ case QScroller::Dragging:
+ dragDistance = QPointF(0, 0);
+#ifndef QT_NO_ANIMATION
+ if (state == QScroller::Pressed)
+ scrollTimer->start();
+#endif
+ break;
+
+ case QScroller::Scrolling:
+#ifndef QT_NO_ANIMATION
+ scrollTimer->start();
+#endif
+ break;
+ }
+
+ qSwap(state, newstate);
+
+ if (sendLastScroll) {
+ QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished);
+ sendEvent(target, &se);
+ firstScroll = true;
+ }
+ if (state == QScroller::Dragging || state == QScroller::Scrolling)
+ activeScrollers.insert(q);
+ else
+ activeScrollers.remove(q);
+ emit q->stateChanged(state);
+}
+
+
+/*! \internal
+ Helps when setting the content position.
+ It will try to move the content by the requested delta but stop in case
+ when we are coming back from an overshoot or a scrollTo.
+ It will also indicate a new overshooting condition by the overshootX and oversthootY flags.
+
+ In this cases it will reset the velocity variables and other flags.
+
+ Also keeps track of the current over-shooting value in overshootPosition.
+
+ \a deltaPos is the amount of pixels the current content position should be moved
+*/
+void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos)
+{
+ Q_Q(QScroller);
+ QPointF ppm = q->pixelPerMeter();
+ const QScrollerPropertiesPrivate *sp = properties.d.data();
+ QPointF v = q->velocity();
+
+ if (sp->overshootDragResistanceFactor)
+ overshootPosition /= sp->overshootDragResistanceFactor;
+
+ QPointF oldPos = contentPosition + overshootPosition;
+ QPointF newPos = oldPos + deltaPos;
+
+ qScrollerDebug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])";
+ qScrollerDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos;
+
+ QPointF oldClampedPos = clampToRect(oldPos, contentPosRange);
+ QPointF newClampedPos = clampToRect(newPos, contentPosRange);
+
+ // --- handle overshooting and stop if the coordinate is going back inside the normal area
+ bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
+ bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn);
+ bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
+ ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
+ !sp->overshootDragDistanceFactor;
+ bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) ||
+ ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) ||
+ !sp->overshootDragDistanceFactor;
+ bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width());
+ bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height());
+
+ qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0;
+ qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0;
+
+ qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0;
+ qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0;
+
+ qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor;
+ qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor;
+
+ qScrollerDebug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy;
+ qScrollerDebug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX;
+
+ if (sp->overshootDragResistanceFactor) {
+ oldOvershootX *= sp->overshootDragResistanceFactor;
+ oldOvershootY *= sp->overshootDragResistanceFactor;
+ newOvershootX *= sp->overshootDragResistanceFactor;
+ newOvershootY *= sp->overshootDragResistanceFactor;
+ }
+
+ // -- stop at the maximum overshoot distance
+
+ newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX);
+ newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY);
+
+ overshootPosition.setX(newOvershootX);
+ overshootPosition.setY(newOvershootY);
+ contentPosition = newClampedPos;
+
+ QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
+ sendEvent(target, &se);
+ firstScroll = false;
+
+ qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition <<
+ "- overshoot x/y?:" << overshootPosition;
+}
+
+
+qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos)
+{
+ qreal pos = oldPos;
+
+ // check the X segments for new positions
+ while (!segments.isEmpty()) {
+ const ScrollSegment s = segments.head();
+
+ if ((s.startTime + s.deltaTime * s.stopProgress) <= now) {
+ segments.dequeue();
+ pos = s.stopPos;
+ } else if (s.startTime <= now) {
+ qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime);
+ pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress);
+ if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) {
+ segments.dequeue();
+ pos = s.stopPos;
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ return pos;
+}
+
+void QScrollerPrivate::setContentPositionHelperScrolling()
+{
+ qint64 now = monotonicTimer.elapsed();
+ QPointF newPos = contentPosition + overshootPosition;
+
+ newPos.setX(nextSegmentPosition(xSegments, now, newPos.x()));
+ newPos.setY(nextSegmentPosition(ySegments, now, newPos.y()));
+
+ // -- set the position and handle overshoot
+ qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()";
+ qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos;
+
+ QPointF newClampedPos = clampToRect(newPos, contentPosRange);
+
+ overshootPosition = newPos - newClampedPos;
+ contentPosition = newClampedPos;
+
+ QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated);
+ sendEvent(target, &se);
+ firstScroll = false;
+
+ qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition;
+}
+
+/*! \internal
+ Returns the next snap point in direction.
+ If \a direction >0 it will return the next snap point that is larger than the current position.
+ If \a direction <0 it will return the next snap point that is smaller than the current position.
+ If \a direction ==0 it will return the nearest snap point (or the current position if we are already
+ on a snap point.
+ Returns the nearest snap position or NaN if no such point could be found.
+ */
+qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation)
+{
+ qreal bestSnapPos = Q_QNAN;
+ qreal bestSnapPosDist = Q_INFINITY;
+
+ qreal minPos;
+ qreal maxPos;
+
+ if (orientation == Qt::Horizontal) {
+ minPos = contentPosRange.left();
+ maxPos = contentPosRange.right();
+ } else {
+ minPos = contentPosRange.top();
+ maxPos = contentPosRange.bottom();
+ }
+
+ if (orientation == Qt::Horizontal) {
+ // the snap points in the list
+ foreach (qreal snapPos, snapPositionsX) {
+ qreal snapPosDist = snapPos - p;
+ if ((dir > 0 && snapPosDist < 0) ||
+ (dir < 0 && snapPosDist > 0))
+ continue; // wrong direction
+ if (snapPos < minPos || snapPos > maxPos )
+ continue; // invalid
+
+ if (qIsNaN(bestSnapPos) ||
+ qAbs(snapPosDist) < bestSnapPosDist ) {
+ bestSnapPos = snapPos;
+ bestSnapPosDist = qAbs(snapPosDist);
+ }
+ }
+
+ // the snap point interval
+ if (snapIntervalX > 0.0) {
+ qreal first = minPos + snapFirstX;
+ qreal snapPos;
+ if (dir > 0)
+ snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first;
+ else if (dir < 0)
+ snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first;
+ else if (p <= first)
+ snapPos = first;
+ else
+ {
+ qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first;
+ if (p >= last)
+ snapPos = last;
+ else
+ snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first;
+ }
+
+ if (snapPos >= first && snapPos <= maxPos ) {
+ qreal snapPosDist = snapPos - p;
+
+ if (qIsNaN(bestSnapPos) ||
+ qAbs(snapPosDist) < bestSnapPosDist ) {
+ bestSnapPos = snapPos;
+ bestSnapPosDist = qAbs(snapPosDist);
+ }
+ }
+ }
+
+ } else { // (orientation == Qt::Vertical)
+ // the snap points in the list
+ foreach (qreal snapPos, snapPositionsY) {
+ qreal snapPosDist = snapPos - p;
+ if ((dir > 0 && snapPosDist < 0) ||
+ (dir < 0 && snapPosDist > 0))
+ continue; // wrong direction
+ if (snapPos < minPos || snapPos > maxPos )
+ continue; // invalid
+
+ if (qIsNaN(bestSnapPos) ||
+ qAbs(snapPosDist) < bestSnapPosDist) {
+ bestSnapPos = snapPos;
+ bestSnapPosDist = qAbs(snapPosDist);
+ }
+ }
+
+ // the snap point interval
+ if (snapIntervalY > 0.0) {
+ qreal first = minPos + snapFirstY;
+ qreal snapPos;
+ if (dir > 0)
+ snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first;
+ else if (dir < 0)
+ snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first;
+ else if (p <= first)
+ snapPos = first;
+ else
+ {
+ qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first;
+ if (p >= last)
+ snapPos = last;
+ else
+ snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first;
+ }
+
+ if (snapPos >= first && snapPos <= maxPos ) {
+ qreal snapPosDist = snapPos - p;
+
+ if (qIsNaN(bestSnapPos) ||
+ qAbs(snapPosDist) < bestSnapPosDist) {
+ bestSnapPos = snapPos;
+ bestSnapPosDist = qAbs(snapPosDist);
+ }
+ }
+ }
+ }
+
+ return bestSnapPos;
+}
+
+/*!
+ \enum QScroller::State
+
+ This enum contains the different QScroller states.
+
+ \value Inactive The scroller is not scrolling and nothing is pressed.
+ \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged.
+ \value Dragging The scroll area is currently following the touch point or mouse.
+ \value Scrolling The scroll area is moving on it's own.
+*/
+
+/*!
+ \enum QScroller::ScrollerGestureType
+
+ This enum contains the different gesture types that are supported by the QScroller gesture recognizer.
+
+ \value TouchGesture The gesture recognizer will only trigger on touch
+ events. Specifically it will react on single touch points when using a
+ touch screen and dual touch points when using a touchpad.
+ \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events.
+ \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events.
+ \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events.
+*/
+
+/*!
+ \enum QScroller::Input
+
+ This enum contains an input device agnostic view of input events that are relevant for QScroller.
+
+ \value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress,
+ QEvent::GraphicsSceneMousePress, QEvent::TouchBegin)
+
+ \value InputMove The user moved the input device (e.g. QEvent::MouseMove,
+ QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate)
+
+ \value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease,
+ QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd)
+
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h
new file mode 100644
index 0000000..1599c7d
--- /dev/null
+++ b/src/gui/util/qscroller.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLER_H
+#define QSCROLLER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QPointF>
+#include <QtGui/QScrollerProperties>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidget;
+class QScrollerPrivate;
+class QScrollerProperties;
+#ifndef QT_NO_GESTURES
+class QFlickGestureRecognizer;
+class QMouseFlickGestureRecognizer;
+#endif
+
+class Q_GUI_EXPORT QScroller : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(State state READ state NOTIFY stateChanged)
+ Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
+ Q_ENUMS(State)
+
+public:
+ enum State
+ {
+ Inactive,
+ Pressed,
+ Dragging,
+ Scrolling
+ };
+
+ enum ScrollerGestureType
+ {
+ TouchGesture,
+ LeftMouseButtonGesture,
+ RightMouseButtonGesture,
+ MiddleMouseButtonGesture
+ };
+
+ enum Input
+ {
+ InputPress = 1,
+ InputMove,
+ InputRelease
+ };
+
+ static bool hasScroller(QObject *target);
+
+ static QScroller *scroller(QObject *target);
+ static const QScroller *scroller(const QObject *target);
+
+#ifndef QT_NO_GESTURES
+ static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
+ static Qt::GestureType grabbedGesture(QObject *target);
+ static void ungrabGesture(QObject *target);
+#endif
+
+ static QList<QScroller *> activeScrollers();
+
+ QObject *target() const;
+
+ State state() const;
+
+ bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
+
+ void stop();
+ QPointF velocity() const;
+ QPointF finalPosition() const;
+ QPointF pixelPerMeter() const;
+
+ QScrollerProperties scrollerProperties() const;
+
+ void setSnapPositionsX( const QList<qreal> &positions );
+ void setSnapPositionsX( qreal first, qreal interval );
+ void setSnapPositionsY( const QList<qreal> &positions );
+ void setSnapPositionsY( qreal first, qreal interval );
+
+public Q_SLOTS:
+ void setScrollerProperties(const QScrollerProperties &prop);
+ void scrollTo(const QPointF &pos);
+ void scrollTo(const QPointF &pos, int scrollTime);
+ void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
+ void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
+ void resendPrepareEvent();
+
+Q_SIGNALS:
+ void stateChanged(QScroller::State newstate);
+ void scrollerPropertiesChanged(const QScrollerProperties &);
+
+private:
+ QScrollerPrivate *d_ptr;
+
+ QScroller(QObject *target);
+ virtual ~QScroller();
+
+ Q_DISABLE_COPY(QScroller)
+ Q_DECLARE_PRIVATE(QScroller)
+
+#ifndef QT_NO_GESTURES
+ friend class QFlickGestureRecognizer;
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCROLLER_H
diff --git a/src/gui/util/qscroller_mac.mm b/src/gui/util/qscroller_mac.mm
new file mode 100644
index 0000000..4bf69c1
--- /dev/null
+++ b/src/gui/util/qscroller_mac.mm
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qglobal.h>
+
+#ifdef Q_WS_MAC
+
+#import <Cocoa/Cocoa.h>
+
+#include "qscroller_p.h"
+
+QPointF QScrollerPrivate::realDpi(int screen)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSArray *nsscreens = [NSScreen screens];
+
+ if (screen < 0 || screen >= int([nsscreens count]))
+ screen = 0;
+
+ NSScreen *nsscreen = [nsscreens objectAtIndex:screen];
+ CGDirectDisplayID display = [[[nsscreen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
+
+ CGSize mmsize = CGDisplayScreenSize(display);
+ if (mmsize.width > 0 && mmsize.height > 0) {
+ return QPointF(CGDisplayPixelsWide(display) / mmsize.width,
+ CGDisplayPixelsHigh(display) / mmsize.height) * qreal(25.4);
+ } else {
+ return QPointF();
+ }
+ [pool release];
+}
+
+#endif
diff --git a/src/gui/util/qscroller_p.h b/src/gui/util/qscroller_p.h
new file mode 100644
index 0000000..8c5f2e7
--- /dev/null
+++ b/src/gui/util/qscroller_p.h
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLER_P_H
+#define QSCROLLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QObject>
+#include <QPointer>
+#include <QQueue>
+#include <QSet>
+#include <QEasingCurve>
+#include <QElapsedTimer>
+#include <QSizeF>
+#include <QPointF>
+#include <QRectF>
+#include <qscroller.h>
+#include <qscrollerproperties.h>
+#include <private/qscrollerproperties_p.h>
+#include <QAbstractAnimation>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_GESTURES
+class QFlickGestureRecognizer;
+#endif
+
+#ifndef QT_NO_ANIMATION
+class QScrollTimer;
+#endif
+class QScrollerPrivate : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PUBLIC(QScroller)
+
+public:
+ QScrollerPrivate(QScroller *q, QObject *target);
+ void init();
+
+ void sendEvent(QObject *o, QEvent *e);
+
+ void setState(QScroller::State s);
+
+ enum ScrollType {
+ ScrollTypeFlick = 0,
+ ScrollTypeScrollTo,
+ ScrollTypeOvershoot
+ };
+
+ struct ScrollSegment {
+ qint64 startTime;
+ qint64 deltaTime;
+ qreal startPos;
+ qreal deltaPos;
+ QEasingCurve curve;
+ qreal stopProgress; // whatever is..
+ qreal stopPos; // ..reached first
+ ScrollType type;
+ };
+
+ bool pressWhileInactive(const QPointF &position, qint64 timestamp);
+ bool moveWhilePressed(const QPointF &position, qint64 timestamp);
+ bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
+ bool moveWhileDragging(const QPointF &position, qint64 timestamp);
+ bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
+ bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
+
+ void timerTick();
+ void timerEventWhileDragging();
+ void timerEventWhileScrolling();
+
+ bool prepareScrolling(const QPointF &position);
+ void handleDrag(const QPointF &position, qint64 timestamp);
+
+ QPointF realDpi(int screen);
+ QPointF dpi() const;
+ void setDpi(const QPointF &dpi);
+ void setDpiFromWidget(QWidget *widget);
+
+ void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
+ void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
+ void recalcScrollingSegments(bool forceRecalc = false);
+ qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const;
+ bool scrollingSegmentsValid(Qt::Orientation orientation);
+ void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
+ void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation);
+
+ void setContentPositionHelperDragging(const QPointF &deltaPos);
+ void setContentPositionHelperScrolling();
+
+ qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation);
+ static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
+
+ inline int frameRateSkip() const { return properties.d.data()->frameRate; }
+
+ static const char *stateName(QScroller::State state);
+ static const char *inputName(QScroller::Input input);
+
+public slots:
+ void targetDestroyed();
+
+public:
+ // static
+ static QMap<QObject *, QScroller *> allScrollers;
+ static QSet<QScroller *> activeScrollers;
+
+ // non static
+ QObject *target;
+ QScrollerProperties properties;
+#ifndef QT_NO_GESTURES
+ QFlickGestureRecognizer *recognizer;
+ Qt::GestureType recognizerType;
+#endif
+
+ // scroller state:
+
+ // QPointer<QObject> scrollTarget;
+ QSizeF viewportSize;
+ QRectF contentPosRange;
+ QPointF contentPosition;
+ QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
+
+ // state
+
+ bool enabled;
+ QScroller::State state;
+ bool firstScroll; // true if we haven't already send a scroll event
+
+ QPointF oldVelocity; // the release velocity of the last drag
+
+ QPointF pressPosition;
+ QPointF lastPosition;
+ qint64 pressTimestamp;
+ qint64 lastTimestamp;
+
+ QPointF dragDistance; // the distance we should move during the next drag timer event
+
+ QQueue<ScrollSegment> xSegments;
+ QQueue<ScrollSegment> ySegments;
+
+ // snap positions
+ QList<qreal> snapPositionsX;
+ qreal snapFirstX;
+ qreal snapIntervalX;
+ QList<qreal> snapPositionsY;
+ qreal snapFirstY;
+ qreal snapIntervalY;
+
+ QPointF pixelPerMeter;
+
+ QElapsedTimer monotonicTimer;
+
+ QPointF releaseVelocity; // the starting velocity of the scrolling state
+#ifndef QT_NO_ANIMATION
+ QScrollTimer *scrollTimer;
+#endif
+
+ QScroller *q_ptr;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QSCROLLER_P_H
+
diff --git a/src/gui/util/qscrollerproperties.cpp b/src/gui/util/qscrollerproperties.cpp
new file mode 100644
index 0000000..85e2e82
--- /dev/null
+++ b/src/gui/util/qscrollerproperties.cpp
@@ -0,0 +1,393 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPointer>
+#include <QObject>
+#include <QtCore/qmath.h>
+#ifdef Q_WS_WIN
+# include <QLibrary>
+#endif
+
+#include "qscrollerproperties.h"
+#include "private/qscrollerproperties_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static QScrollerPropertiesPrivate *userDefaults = 0;
+static QScrollerPropertiesPrivate *systemDefaults = 0;
+
+QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults()
+{
+ if (!systemDefaults) {
+ QScrollerPropertiesPrivate spp;
+ spp.mousePressEventDelay = qreal(0.25);
+ spp.dragStartDistance = qreal(5.0 / 1000);
+ spp.dragVelocitySmoothingFactor = qreal(0.8);
+ spp.axisLockThreshold = qreal(0);
+ spp.scrollingCurve.setType(QEasingCurve::OutQuad);
+ spp.decelerationFactor = qreal(0.125);
+ spp.minimumVelocity = qreal(50.0 / 1000);
+ spp.maximumVelocity = qreal(500.0 / 1000);
+ spp.maximumClickThroughVelocity = qreal(66.5 / 1000);
+ spp.acceleratingFlickMaximumTime = qreal(1.25);
+ spp.acceleratingFlickSpeedupFactor = qreal(3.0);
+ spp.snapPositionRatio = qreal(0.5);
+ spp.snapTime = qreal(0.3);
+ spp.overshootDragResistanceFactor = qreal(0.5);
+ spp.overshootDragDistanceFactor = qreal(1);
+ spp.overshootScrollDistanceFactor = qreal(0.5);
+ spp.overshootScrollTime = qreal(0.7);
+# ifdef Q_WS_WIN
+ if (QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback"))
+ spp.overshootScrollTime = qreal(0.35);
+# endif
+ spp.hOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
+ spp.vOvershootPolicy = QScrollerProperties::OvershootWhenScrollable;
+ spp.frameRate = QScrollerProperties::Standard;
+
+ systemDefaults = new QScrollerPropertiesPrivate(spp);
+ }
+ return new QScrollerPropertiesPrivate(userDefaults ? *userDefaults : *systemDefaults);
+}
+
+/*!
+ \class QScrollerProperties
+ \brief The QScrollerProperties class stores the settings for a QScroller.
+ \since 4.8
+
+ The QScrollerProperties class stores the parameters used by QScroller.
+
+ The default settings are platform dependent so that Qt emulates the
+ platform behaviour for kinetic scrolling.
+
+ As a convention the QScrollerProperties are in physical units (meter,
+ seconds) and are converted by QScroller using the current DPI.
+
+ \sa QScroller
+*/
+
+/*!
+ Constructs new scroller properties.
+*/
+QScrollerProperties::QScrollerProperties()
+ : d(QScrollerPropertiesPrivate::defaults())
+{
+}
+
+/*!
+ Constructs a copy of \a sp.
+*/
+QScrollerProperties::QScrollerProperties(const QScrollerProperties &sp)
+ : d(new QScrollerPropertiesPrivate(*sp.d))
+{
+}
+
+/*!
+ Assigns \a sp to these scroller properties and returns a reference to these scroller properties.
+*/
+QScrollerProperties &QScrollerProperties::operator=(const QScrollerProperties &sp)
+{
+ *d.data() = *sp.d.data();
+ return *this;
+}
+
+/*!
+ Destroys the scroller properties.
+*/
+QScrollerProperties::~QScrollerProperties()
+{
+}
+
+/*!
+ Returns true if these scroller properties are equal to \a sp; otherwise returns false.
+*/
+bool QScrollerProperties::operator==(const QScrollerProperties &sp) const
+{
+ return *d.data() == *sp.d.data();
+}
+
+/*!
+ Returns true if these scroller properties are different from \a sp; otherwise returns false.
+*/
+bool QScrollerProperties::operator!=(const QScrollerProperties &sp) const
+{
+ return !(*d.data() == *sp.d.data());
+}
+
+bool QScrollerPropertiesPrivate::operator==(const QScrollerPropertiesPrivate &p) const
+{
+ bool same = true;
+ same &= (mousePressEventDelay == p.mousePressEventDelay);
+ same &= (dragStartDistance == p.dragStartDistance);
+ same &= (dragVelocitySmoothingFactor == p.dragVelocitySmoothingFactor);
+ same &= (axisLockThreshold == p.axisLockThreshold);
+ same &= (scrollingCurve == p.scrollingCurve);
+ same &= (decelerationFactor == p.decelerationFactor);
+ same &= (minimumVelocity == p.minimumVelocity);
+ same &= (maximumVelocity == p.maximumVelocity);
+ same &= (maximumClickThroughVelocity == p.maximumClickThroughVelocity);
+ same &= (acceleratingFlickMaximumTime == p.acceleratingFlickMaximumTime);
+ same &= (acceleratingFlickSpeedupFactor == p.acceleratingFlickSpeedupFactor);
+ same &= (snapPositionRatio == p.snapPositionRatio);
+ same &= (snapTime == p.snapTime);
+ same &= (overshootDragResistanceFactor == p.overshootDragResistanceFactor);
+ same &= (overshootDragDistanceFactor == p.overshootDragDistanceFactor);
+ same &= (overshootScrollDistanceFactor == p.overshootScrollDistanceFactor);
+ same &= (overshootScrollTime == p.overshootScrollTime);
+ same &= (hOvershootPolicy == p.hOvershootPolicy);
+ same &= (vOvershootPolicy == p.vOvershootPolicy);
+ same &= (frameRate == p.frameRate);
+ return same;
+}
+
+/*!
+ Sets the scroller properties for all new QScrollerProperties objects to \a sp.
+
+ Use this function to override the platform default properties returned by the default
+ constructor. If you only want to change the scroller properties of a single scroller, use
+ QScroller::setScrollerProperties()
+
+ \note Calling this function will not change the content of already existing
+ QScrollerProperties objects.
+
+ \sa unsetDefaultScrollerProperties()
+*/
+void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties &sp)
+{
+ if (!userDefaults)
+ userDefaults = new QScrollerPropertiesPrivate(*sp.d);
+ else
+ *userDefaults = *sp.d;
+}
+
+/*!
+ Sets the scroller properties returned by the default constructor back to the platform default
+ properties.
+
+ \sa setDefaultScrollerProperties()
+*/
+void QScrollerProperties::unsetDefaultScrollerProperties()
+{
+ delete userDefaults;
+ userDefaults = 0;
+}
+
+/*!
+ Query the \a metric value of the scroller properties.
+
+ \sa setScrollMetric(), ScrollMetric
+*/
+QVariant QScrollerProperties::scrollMetric(ScrollMetric metric) const
+{
+ switch (metric) {
+ case MousePressEventDelay: return d->mousePressEventDelay;
+ case DragStartDistance: return d->dragStartDistance;
+ case DragVelocitySmoothingFactor: return d->dragVelocitySmoothingFactor;
+ case AxisLockThreshold: return d->axisLockThreshold;
+ case ScrollingCurve: return d->scrollingCurve;
+ case DecelerationFactor: return d->decelerationFactor;
+ case MinimumVelocity: return d->minimumVelocity;
+ case MaximumVelocity: return d->maximumVelocity;
+ case MaximumClickThroughVelocity: return d->maximumClickThroughVelocity;
+ case AcceleratingFlickMaximumTime: return d->acceleratingFlickMaximumTime;
+ case AcceleratingFlickSpeedupFactor:return d->acceleratingFlickSpeedupFactor;
+ case SnapPositionRatio: return d->snapPositionRatio;
+ case SnapTime: return d->snapTime;
+ case OvershootDragResistanceFactor: return d->overshootDragResistanceFactor;
+ case OvershootDragDistanceFactor: return d->overshootDragDistanceFactor;
+ case OvershootScrollDistanceFactor: return d->overshootScrollDistanceFactor;
+ case OvershootScrollTime: return d->overshootScrollTime;
+ case HorizontalOvershootPolicy: return QVariant::fromValue(d->hOvershootPolicy);
+ case VerticalOvershootPolicy: return QVariant::fromValue(d->vOvershootPolicy);
+ case FrameRate: return QVariant::fromValue(d->frameRate);
+ case ScrollMetricCount: break;
+ }
+ return QVariant();
+}
+
+/*!
+ Set a specific value of the \a metric ScrollerMetric to \a value.
+
+ \sa scrollMetric(), ScrollMetric
+*/
+void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &value)
+{
+ switch (metric) {
+ case MousePressEventDelay: d->mousePressEventDelay = value.toReal(); break;
+ case DragStartDistance: d->dragStartDistance = value.toReal(); break;
+ case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
+ case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break;
+ case ScrollingCurve: d->scrollingCurve = value.toEasingCurve(); break;
+ case DecelerationFactor: d->decelerationFactor = value.toReal(); break;
+ case MinimumVelocity: d->minimumVelocity = value.toReal(); break;
+ case MaximumVelocity: d->maximumVelocity = value.toReal(); break;
+ case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break;
+ case AcceleratingFlickMaximumTime: d->acceleratingFlickMaximumTime = value.toReal(); break;
+ case AcceleratingFlickSpeedupFactor:d->acceleratingFlickSpeedupFactor = value.toReal(); break;
+ case SnapPositionRatio: d->snapPositionRatio = qBound(qreal(0), value.toReal(), qreal(1)); break;
+ case SnapTime: d->snapTime = value.toReal(); break;
+ case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break;
+ case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
+ case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break;
+ case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break;
+ case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
+ case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break;
+ case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break;
+ case ScrollMetricCount: break;
+ }
+}
+
+/*!
+ \enum QScrollerProperties::FrameRates
+
+ This enum describes the available frame rates used while dragging or scrolling.
+
+ \value Fps60 60 frames per second
+ \value Fps30 30 frames per second
+ \value Fps20 20 frames per second
+ \value Standard the default value is 60 frames per second (which corresponds to QAbstractAnimation).
+*/
+
+/*!
+ \enum QScrollerProperties::OvershootPolicy
+
+ This enum describes the various modes of overshooting.
+
+ \value OvershootWhenScrollable Overshooting is possible when the content is scrollable. This is the
+ default.
+
+ \value OvershootAlwaysOff Overshooting is never enabled, even when the content is scrollable.
+
+ \value OvershootAlwaysOn Overshooting is always enabled, even when the content is not
+ scrollable.
+*/
+
+/*!
+ \enum QScrollerProperties::ScrollMetric
+
+ This enum contains the different scroll metric types. When not indicated otherwise the
+ setScrollMetric function expects a QVariant of type qreal.
+
+ See the QScroller documentation for further details of the concepts behind the different
+ values.
+
+ \value MousePressEventDelay This is the time a mouse press event is delayed when starting
+ a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or
+ release is sent to the scrolled object. If it triggers after that delay the delayed
+ mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX,
+ -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse
+ press plus the real release event are delivered.
+
+ \value DragStartDistance This is the minimum distance the touch or mouse point needs to be
+ moved before the flick gesture is triggered in \c m.
+
+ \value DragVelocitySmoothingFactor A value that describes to which extent new drag velocities are
+ included in the final scrolling velocity. This value should be in the range between \c 0 and
+ \c 1. The lower the value, the more smoothing is applied to the dragging velocity.
+
+ \value AxisLockThreshold Restricts the movement to one axis if the movement is inside an angle
+ around the axis. The threshold must be in the range \c 0 to \c 1.
+
+ \value ScrollingCurve The QEasingCurve used when decelerating the scrolling velocity after an
+ user initiated flick. Please note that this is the easing curve for the positions, \bold{not}
+ the velocity: the default is QEasingCurve::OutQuad, which results in a linear decrease in
+ velocity (1st derivative) and a constant deceleration (2nd derivative).
+
+ \value DecelerationFactor This factor influences how long it takes the scroller to decelerate
+ to 0 velocity. The actual value depends on the chosen ScrollingCurve. For most
+ types the value should be in the range from \c 0.1 to \c 2.0
+
+ \value MinimumVelocity The minimum velocity that is needed after ending the touch or releasing
+ the mouse to start scrolling in \c{m/s}.
+
+ \value MaximumVelocity This is the maximum velocity that can be reached in \c{m/s}.
+
+ \value MaximumClickThroughVelocity This is the maximum allowed scroll speed for a click-through
+ in \c{m/s}. This means that a click on a currently (slowly) scrolling object will not only stop
+ the scrolling but the click event will also be delivered to the UI control. This is
+ useful when using exponential-type scrolling curves.
+
+ \value AcceleratingFlickMaximumTime This is the maximum time in \c seconds that a flick gesture
+ can take to be recognized as an accelerating flick. If set to zero no such gesture is
+ detected. An "accelerating flick" is a flick gesture executed on an already scrolling object.
+ In such cases the scrolling speed is multiplied by AcceleratingFlickSpeedupFactor in order to
+ accelerate it.
+
+ \value AcceleratingFlickSpeedupFactor The current speed is multiplied by this number if an
+ accelerating flick is detected. Should be \c{>= 1}.
+
+ \value SnapPositionRatio This is the distance that the user must drag the area beween two snap
+ points in order to snap it to the next position. \c{0.33} means that the scroll must only
+ reach one third of the distance between two snap points to snap to the next one. The ratio must
+ be between \c 0 and \c 1.
+
+ \value SnapTime This is the time factor for the scrolling curve. A lower value means that the
+ scrolling will take longer. The scrolling distance is independet of this value.
+
+ \value OvershootDragResistanceFactor This value is the factor between the mouse dragging and
+ the actual scroll area movement (during overshoot). The factor must be between \c 0 and \c 1.
+
+ \value OvershootDragDistanceFactor This is the maximum distance for overshoot movements while
+ dragging. The actual overshoot distance is calculated by multiplying this value with the
+ viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
+
+ \value OvershootScrollDistanceFactor This is the maximum distance for overshoot movements while
+ scrolling. The actual overshoot distance is calculated by multiplying this value with the
+ viewport size of the scrolled object. The factor must be between \c 0 and \c 1.
+
+ \value OvershootScrollTime This is the time in \c seconds that is used to play the
+ complete overshoot animation.
+
+ \value HorizontalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
+
+ \value VerticalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy).
+
+ \value FrameRate This is the frame rate which should be used while dragging or scrolling.
+ QScroller uses a QAbstractAnimation timer internally to sync all scrolling operations to other
+ animations that might be active at the same time. If the standard value of 60 frames per
+ second is too fast, it can be lowered with this setting,
+ while still being in-sync with QAbstractAnimation. Please note that only the values of the
+ FrameRates enum are allowed here.
+
+ \value ScrollMetricCount This is always the last entry.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/util/qscrollerproperties.h b/src/gui/util/qscrollerproperties.h
new file mode 100644
index 0000000..75d8932
--- /dev/null
+++ b/src/gui/util/qscrollerproperties.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLERPROPERTIES_H
+#define QSCROLLERPROPERTIES_H
+
+#include <QtCore/QScopedPointer>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QScroller;
+class QScrollerPrivate;
+class QScrollerPropertiesPrivate;
+
+class Q_GUI_EXPORT QScrollerProperties
+{
+public:
+ QScrollerProperties();
+ QScrollerProperties(const QScrollerProperties &sp);
+ QScrollerProperties &operator=(const QScrollerProperties &sp);
+ virtual ~QScrollerProperties();
+
+ bool operator==(const QScrollerProperties &sp) const;
+ bool operator!=(const QScrollerProperties &sp) const;
+
+ static void setDefaultScrollerProperties(const QScrollerProperties &sp);
+ static void unsetDefaultScrollerProperties();
+
+ enum OvershootPolicy
+ {
+ OvershootWhenScrollable,
+ OvershootAlwaysOff,
+ OvershootAlwaysOn
+ };
+
+ enum FrameRates {
+ Standard,
+ Fps60,
+ Fps30,
+ Fps20
+ };
+
+ enum ScrollMetric
+ {
+ MousePressEventDelay, // qreal [s]
+ DragStartDistance, // qreal [m]
+ DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
+ AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
+
+ ScrollingCurve, // QEasingCurve
+ DecelerationFactor, // slope of the curve
+
+ MinimumVelocity, // qreal [m/s]
+ MaximumVelocity, // qreal [m/s]
+ MaximumClickThroughVelocity, // qreal [m/s]
+
+ AcceleratingFlickMaximumTime, // qreal [s]
+ AcceleratingFlickSpeedupFactor, // qreal [1..]
+
+ SnapPositionRatio, // qreal [0..1]
+ SnapTime, // qreal [s]
+
+ OvershootDragResistanceFactor, // qreal [0..1]
+ OvershootDragDistanceFactor, // qreal [0..1]
+ OvershootScrollDistanceFactor, // qreal [0..1]
+ OvershootScrollTime, // qreal [s]
+
+ HorizontalOvershootPolicy, // enum OvershootPolicy
+ VerticalOvershootPolicy, // enum OvershootPolicy
+ FrameRate, // enum FrameRates
+
+ ScrollMetricCount
+ };
+
+ QVariant scrollMetric(ScrollMetric metric) const;
+ void setScrollMetric(ScrollMetric metric, const QVariant &value);
+
+protected:
+ QScopedPointer<QScrollerPropertiesPrivate> d;
+
+private:
+ QScrollerProperties(QScrollerPropertiesPrivate &dd);
+
+ friend class QScrollerPropertiesPrivate;
+ friend class QScroller;
+ friend class QScrollerPrivate;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QScrollerProperties::OvershootPolicy)
+Q_DECLARE_METATYPE(QScrollerProperties::FrameRates)
+
+QT_END_HEADER
+
+#endif // QSCROLLERPROPERTIES_H
diff --git a/src/gui/util/qscrollerproperties_p.h b/src/gui/util/qscrollerproperties_p.h
new file mode 100644
index 0000000..76d8b0a
--- /dev/null
+++ b/src/gui/util/qscrollerproperties_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLERPROPERTIES_P_H
+#define QSCROLLERPROPERTIES_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 <QPointF>
+#include <QEasingCurve>
+#include <qscrollerproperties.h>
+
+QT_BEGIN_NAMESPACE
+
+class QScrollerPropertiesPrivate
+{
+public:
+ static QScrollerPropertiesPrivate *defaults();
+
+ bool operator==(const QScrollerPropertiesPrivate &) const;
+
+ qreal mousePressEventDelay;
+ qreal dragStartDistance;
+ qreal dragVelocitySmoothingFactor;
+ qreal axisLockThreshold;
+ QEasingCurve scrollingCurve;
+ qreal decelerationFactor;
+ qreal minimumVelocity;
+ qreal maximumVelocity;
+ qreal maximumClickThroughVelocity;
+ qreal acceleratingFlickMaximumTime;
+ qreal acceleratingFlickSpeedupFactor;
+ qreal snapPositionRatio;
+ qreal snapTime;
+ qreal overshootDragResistanceFactor;
+ qreal overshootDragDistanceFactor;
+ qreal overshootScrollDistanceFactor;
+ qreal overshootScrollTime;
+ QScrollerProperties::OvershootPolicy hOvershootPolicy;
+ QScrollerProperties::OvershootPolicy vOvershootPolicy;
+ QScrollerProperties::FrameRates frameRate;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSCROLLERPROPERTIES_P_H
+
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp
index 2b7935b..5a0e179 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -305,6 +305,7 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
case WM_CONTEXTMENU:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
+ q->contextMenu()->activateWindow();
}
emit q->activated(QSystemTrayIcon::Context);
break;
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index d1c4ff8..2814a2d 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -6,6 +6,11 @@ HEADERS += \
util/qcompleter_p.h \
util/qdesktopservices.h \
util/qsystemtrayicon_p.h \
+ util/qscroller.h \
+ util/qscroller_p.h \
+ util/qscrollerproperties.h \
+ util/qscrollerproperties_p.h \
+ util/qflickgesture_p.h \
util/qundogroup.h \
util/qundostack.h \
util/qundostack_p.h \
@@ -15,6 +20,9 @@ SOURCES += \
util/qsystemtrayicon.cpp \
util/qcompleter.cpp \
util/qdesktopservices.cpp \
+ util/qscroller.cpp \
+ util/qscrollerproperties.cpp \
+ util/qflickgesture.cpp \
util/qundogroup.cpp \
util/qundostack.cpp \
util/qundoview.cpp
@@ -33,12 +41,12 @@ unix:x11 {
util/qsystemtrayicon_x11.cpp
}
-embedded {
+embedded|qpa {
SOURCES += \
util/qsystemtrayicon_qws.cpp
}
-!embedded:!x11:mac {
+!embedded:!qpa:!x11:mac {
OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
}
@@ -56,4 +64,8 @@ symbian {
} else {
DEFINES += USE_SCHEMEHANDLER
}
-} \ No newline at end of file
+}
+
+macx {
+ OBJECTIVE_SOURCES += util/qscroller_mac.mm
+}
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index 10a6452..d45c56b 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -319,7 +319,7 @@ QList<QAbstractButton *>QAbstractButtonPrivate::queryButtonList() const
return group->d_func()->buttonList;
#endif
- QList<QAbstractButton*>candidates = qFindChildren<QAbstractButton *>(parent);
+ QList<QAbstractButton*>candidates = parent->findChildren<QAbstractButton *>();
if (autoExclusive) {
for (int i = candidates.count() - 1; i >= 0; --i) {
QAbstractButton *candidate = candidates.at(i);
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 2503b99..dabfec0 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -53,6 +53,8 @@
#include "qpainter.h"
#include "qmargins.h"
+#include <QDebug>
+
#include "qabstractscrollarea_p.h"
#include <qwidget.h>
@@ -62,6 +64,10 @@
#include <private/qt_mac_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#ifdef Q_WS_WIN
+# include <qlibrary.h>
+# include <windows.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -295,9 +301,14 @@ void QAbstractScrollAreaPrivate::init()
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
layoutChildren();
#ifndef Q_WS_MAC
-#ifndef QT_NO_GESTURES
+# ifndef QT_NO_GESTURES
viewport->grabGesture(Qt::PanGesture);
+# endif
#endif
+#ifdef Q_WS_MAEMO_5
+# ifndef QT_NO_GESTURES
+ // viewport->grabGesture(Qt::TouchFlickGesture);
+# endif
#endif
}
@@ -552,6 +563,11 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
d->viewport->grabGesture(Qt::PanGesture);
#endif
#endif
+#ifdef Q_WS_MAEMO_5
+#ifndef QT_NO_GESTURES
+// d->viewport->grabGesture(Qt::TouchFlickGesture);
+#endif
+#endif
d->layoutChildren();
if (isVisible())
d->viewport->show();
@@ -986,6 +1002,66 @@ bool QAbstractScrollArea::event(QEvent *e)
return false;
}
#endif // QT_NO_GESTURES
+ case QEvent::ScrollPrepare:
+ {
+ QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
+ if (d->canStartScrollingAt(se->startPos().toPoint())) {
+ QScrollBar *hBar = horizontalScrollBar();
+ QScrollBar *vBar = verticalScrollBar();
+
+ se->setViewportSize(QSizeF(viewport()->size()));
+ se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum()));
+ se->setContentPos(QPointF(hBar->value(), vBar->value()));
+ se->accept();
+ return true;
+ }
+ return false;
+ }
+ case QEvent::Scroll:
+ {
+ QScrollEvent *se = static_cast<QScrollEvent *>(e);
+
+ QScrollBar *hBar = horizontalScrollBar();
+ QScrollBar *vBar = verticalScrollBar();
+ hBar->setValue(se->contentPos().x());
+ vBar->setValue(se->contentPos().y());
+
+#ifdef Q_WS_WIN
+ typedef BOOL (*PtrBeginPanningFeedback)(HWND);
+ typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
+ typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL);
+
+ static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0;
+ static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0;
+ static PtrEndPanningFeedback ptrEndPanningFeedback = 0;
+
+ if (!ptrBeginPanningFeedback)
+ ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback");
+ if (!ptrUpdatePanningFeedback)
+ ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback");
+ if (!ptrEndPanningFeedback)
+ ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback");
+
+ if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) {
+ WId wid = window()->winId();
+
+ if (!se->overshootDistance().isNull() && d->overshoot.isNull())
+ ptrBeginPanningFeedback(wid);
+ if (!se->overshootDistance().isNull())
+ ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false);
+ if (se->overshootDistance().isNull() && !d->overshoot.isNull())
+ ptrEndPanningFeedback(wid, true);
+ } else
+#endif
+ {
+ QPoint delta = d->overshoot - se->overshootDistance().toPoint();
+ if (!delta.isNull())
+ viewport()->move(viewport()->pos() + delta);
+ }
+ d->overshoot = se->overshootDistance().toPoint();
+
+ return true;
+ }
case QEvent::StyleChange:
case QEvent::LayoutDirectionChange:
case QEvent::ApplicationLayoutDirectionChange:
@@ -1047,6 +1123,9 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e)
case QEvent::GestureOverride:
return event(e);
#endif
+ case QEvent::ScrollPrepare:
+ case QEvent::Scroll:
+ return event(e);
default:
break;
}
@@ -1303,6 +1382,32 @@ void QAbstractScrollArea::scrollContentsBy(int, int)
viewport()->update();
}
+bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos )
+{
+ Q_Q(QAbstractScrollArea);
+
+#ifndef QT_NO_GRAPHICSVIEW
+ // don't start scrolling when a drag mode has been set.
+ // don't start scrolling on a movable item.
+ if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) {
+ if (view->dragMode() != QGraphicsView::NoDrag)
+ return false;
+
+ QGraphicsItem *childItem = view->itemAt(startPos);
+
+ if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable))
+ return false;
+ }
+#endif
+
+ // don't start scrolling on a QAbstractSlider
+ if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) {
+ return false;
+ }
+
+ return true;
+}
+
void QAbstractScrollAreaPrivate::_q_hslide(int x)
{
Q_Q(QAbstractScrollArea);
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index 85536e3..76e1c34 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -84,11 +84,13 @@ public:
int left, top, right, bottom; // viewport margin
int xoffset, yoffset;
+ QPoint overshoot;
void init();
void layoutChildren();
// ### Fix for 4.4, talk to Bjoern E or Girish.
virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {}
+ bool canStartScrollingAt( const QPoint &startPos );
void _q_hslide(int);
void _q_vslide(int);
diff --git a/src/gui/widgets/qabstractslider_p.h b/src/gui/widgets/qabstractslider_p.h
index 8af61c4..8887b47 100644
--- a/src/gui/widgets/qabstractslider_p.h
+++ b/src/gui/widgets/qabstractslider_p.h
@@ -117,7 +117,7 @@ public:
;
}
- inline int bound(int val) const { return qMax(minimum, qMin(maximum, val)); }
+ virtual int bound(int val) const { return qMax(minimum, qMin(maximum, val)); }
inline int overflowSafeAdd(int add) const
{
int newValue = value + add;
diff --git a/src/gui/widgets/qcheckbox.cpp b/src/gui/widgets/qcheckbox.cpp
index d3a6472..df2512c 100644
--- a/src/gui/widgets/qcheckbox.cpp
+++ b/src/gui/widgets/qcheckbox.cpp
@@ -300,6 +300,15 @@ QSize QCheckBox::sizeHint() const
return d->sizeHint;
}
+
+/*!
+ \reimp
+*/
+QSize QCheckBox::minimumSizeHint() const
+{
+ return sizeHint();
+}
+
/*!
\reimp
*/
diff --git a/src/gui/widgets/qcheckbox.h b/src/gui/widgets/qcheckbox.h
index f8d5d1c..ae2e932 100644
--- a/src/gui/widgets/qcheckbox.h
+++ b/src/gui/widgets/qcheckbox.h
@@ -65,6 +65,7 @@ public:
QSize sizeHint() const;
+ QSize minimumSizeHint() const;
void setTristate(bool y = true);
bool isTristate() const;
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index ddd56f8..dff37b4 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -44,9 +44,11 @@
#ifdef QT_MAC_USE_COCOA
#import <private/qcocoamenu_mac_p.h>
#import <private/qcocoamenuloader_mac_p.h>
+#import <private/qcocoaapplication_mac_p.h>
#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>
@@ -60,6 +62,7 @@ QT_FORWARD_DECLARE_CLASS(QEvent)
QT_BEGIN_NAMESPACE
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); //qapplication.cpp
+extern NSString *qt_mac_removePrivateUnicode(NSString* string);
QT_END_NAMESPACE
QT_USE_NAMESPACE
@@ -78,7 +81,7 @@ QT_USE_NAMESPACE
return self;
}
-- (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item;
+- (void)menu:(NSMenu*)menu willHighlightItem:(NSMenuItem*)item
{
Q_UNUSED(menu);
@@ -99,7 +102,7 @@ QT_USE_NAMESPACE
}
}
-- (void)menuWillOpen:(NSMenu*)menu;
+- (void)menuWillOpen:(NSMenu*)menu
{
while (QWidget *popup
= QApplication::activePopupWidget())
@@ -109,7 +112,7 @@ QT_USE_NAMESPACE
qt_mac_menu_collapseSeparators(menu, qtmenu->separatorsCollapsible());
}
-- (void)menuDidClose:(NSMenu*)menu;
+- (void)menuDidClose:(NSMenu*)menu
{
qt_mac_emit_menuSignals(((QT_MANGLE_NAMESPACE(QCocoaMenu) *)menu)->qmenu, false);
if (previousAction) {
@@ -156,10 +159,13 @@ QT_USE_NAMESPACE
// In every other case we return NO, which means that Cocoa can do as it pleases
// (i.e., fire the menu action).
NSMenuItem *whichItem;
+ // Change the private unicode keys to the ones used in setting the "Key Equivalents"
+ NSString *characters = qt_mac_removePrivateUnicode([event characters]);
if ([self hasShortcut:menu
- forKey:[event characters]
- forModifiers:([event modifierFlags] & NSDeviceIndependentModifierFlagsMask)
- whichItem:&whichItem]) {
+ forKey:characters
+ // Interested only in Shift, Cmd, Ctrl & Alt Keys, so ignoring masks like, Caps lock, Num Lock ...
+ forModifiers:([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask))
+ whichItem:&whichItem]) {
QWidget *widget = 0;
QAction *qaction = 0;
if (whichItem && [whichItem tag]) {
@@ -170,6 +176,9 @@ QT_USE_NAMESPACE
qApp->activePopupWidget()->focusWidget() : qApp->activePopupWidget());
else if (QApplicationPrivate::focus_widget)
widget = QApplicationPrivate::focus_widget;
+ // If we could not find any receivers, pass it to the active window
+ if (!widget)
+ widget = qApp->activeWindow();
if (qaction && widget) {
int key = qaction->shortcut();
QKeyEvent accel_ev(QEvent::ShortcutOverride, (key & (~Qt::KeyboardModifierMask)),
@@ -177,11 +186,10 @@ QT_USE_NAMESPACE
accel_ev.ignore();
qt_sendSpontaneousEvent(widget, &accel_ev);
if (accel_ev.isAccepted()) {
- if (qt_dispatchKeyEvent(event, widget)) {
- *target = nil;
- *action = nil;
- return YES;
- }
+ qt_dispatchKeyEvent(event, widget);
+ *target = nil;
+ *action = nil;
+ return YES;
}
}
}
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index c1ae3f9..7b4ef50 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -116,7 +116,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu"));
QVariant value = index.data(Qt::ForegroundRole);
- if (qVariantCanConvert<QBrush>(value)) {
+ if (value.canConvert<QBrush>()) {
resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value));
resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value));
resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
@@ -152,7 +152,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
menuOption.icon = qvariant_cast<QPixmap>(variant);
break;
}
- if (qVariantCanConvert<QBrush>(index.data(Qt::BackgroundRole))) {
+ if (index.data(Qt::BackgroundRole).canConvert<QBrush>()) {
menuOption.palette.setBrush(QPalette::All, QPalette::Background,
qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)));
}
@@ -369,6 +369,7 @@ void QComboBoxPrivateContainer::timerEvent(QTimerEvent *timerEvent)
if (timerEvent->timerId() == adjustSizeTimer.timerId()) {
adjustSizeTimer.stop();
if (combo->sizeAdjustPolicy() == QComboBox::AdjustToContents) {
+ combo->updateGeometry();
combo->adjustSize();
combo->update();
}
@@ -704,11 +705,13 @@ void QComboBoxPrivateContainer::hideEvent(QHideEvent *)
{
emit resetButton();
combo->update();
+#ifndef QT_NO_GRAPHICSVIEW
// QGraphicsScenePrivate::removePopup closes the combo box popup, it hides it non-explicitly.
// Hiding/showing the QComboBox after this will unexpectedly show the popup as well.
// Re-hiding the popup container makes sure it is explicitly hidden.
if (QGraphicsProxyWidget *proxy = graphicsProxyWidget())
proxy->hide();
+#endif
}
void QComboBoxPrivateContainer::mousePressEvent(QMouseEvent *e)
@@ -1091,6 +1094,8 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
container->setPalette(q->palette());
container->setWindowOpacity(1.0);
}
+ if (lineEdit)
+ lineEdit->setPalette(q->palette());
}
/*!
@@ -1301,7 +1306,7 @@ QComboBox::~QComboBox()
By default, this property has a value of 10.
\note This property is ignored for non-editable comboboxes in styles that returns
- false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
+ true for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
*/
int QComboBox::maxVisibleItems() const
{
@@ -2011,11 +2016,18 @@ void QComboBox::setCurrentIndex(int index)
void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
{
Q_Q(QComboBox);
- bool indexChanged = (mi != currentIndex);
+
+ QModelIndex normalized;
+ if (mi.column() != modelColumn)
+ normalized = model->index(mi.row(), modelColumn, mi.parent());
+ if (!normalized.isValid())
+ normalized = mi; // Fallback to passed index.
+
+ bool indexChanged = (normalized != currentIndex);
if (indexChanged)
- currentIndex = QPersistentModelIndex(mi);
+ currentIndex = QPersistentModelIndex(normalized);
if (lineEdit) {
- QString newText = q->itemText(currentIndex.row());
+ QString newText = q->itemText(normalized.row());
if (lineEdit->text() != newText)
lineEdit->setText(newText);
updateLineEditGeometry();
diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h
index 0128aa7..fd6f68a 100644
--- a/src/gui/widgets/qcombobox.h
+++ b/src/gui/widgets/qcombobox.h
@@ -68,7 +68,7 @@ class Q_GUI_EXPORT QComboBox : public QWidget
Q_PROPERTY(bool editable READ isEditable WRITE setEditable)
Q_PROPERTY(int count READ count)
Q_PROPERTY(QString currentText READ currentText)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged USER true)
Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy)
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index f3d37ec..cd84b87 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -337,7 +337,7 @@ private:
QComboBox *mCombo;
};
-class QComboBoxPrivate : public QWidgetPrivate
+class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QComboBox)
public:
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 276042f..6337113 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -890,7 +890,13 @@ void QDateTimeEdit::setDisplayFormat(const QString &format)
const bool dateShown = (d->sections & DateSections_Mask);
Q_ASSERT(dateShown || timeShown);
if (timeShown && !dateShown) {
+ QTime time = d->value.toTime();
setDateRange(d->value.toDate(), d->value.toDate());
+ if (d->minimum.toTime() >= d->maximum.toTime()) {
+ setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX);
+ // if the time range became invalid during the adjustment, the time would have been reset
+ setTime(time);
+ }
} else if (dateShown && !timeShown) {
setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX);
d->value = QDateTime(d->value.toDate(), QTime(), d->spec);
@@ -1654,6 +1660,15 @@ void QDateTimeEditPrivate::updateTimeSpec()
minimum = minimum.toDateTime().toTimeSpec(spec);
maximum = maximum.toDateTime().toTimeSpec(spec);
value = value.toDateTime().toTimeSpec(spec);
+
+ // time zone changes can lead to 00:00:00 becomes 01:00:00 and 23:59:59 becomes 00:59:59 (invalid range)
+ const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask);
+ if (!dateShown) {
+ if (minimum.toTime() >= maximum.toTime()){
+ minimum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MIN, spec);
+ maximum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MAX, spec);
+ }
+ }
}
void QDateTimeEditPrivate::updateEdit()
diff --git a/src/gui/widgets/qdial.cpp b/src/gui/widgets/qdial.cpp
index 86981e0..19e8d23 100644
--- a/src/gui/widgets/qdial.cpp
+++ b/src/gui/widgets/qdial.cpp
@@ -83,6 +83,7 @@ public:
int valueFromPoint(const QPoint &) const;
double angle(const QPoint &, const QPoint &) const;
void init();
+ virtual int bound(int val) const;
};
void QDialPrivate::init()
@@ -97,6 +98,20 @@ void QDialPrivate::init()
#endif
}
+int QDialPrivate::bound(int val) const
+{
+ if (wrapping) {
+ if ((val >= minimum) && (val <= maximum))
+ return val;
+ val = minimum + ((val - minimum) % (maximum - minimum));
+ if (val < minimum)
+ val += maximum - minimum;
+ return val;
+ } else {
+ return QAbstractSliderPrivate::bound(val);
+ }
+}
+
/*!
Initialize \a option with the values from this QDial. This method
is useful for subclasses when they need a QStyleOptionSlider, but don't want
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
index 78f45df..6fe87b6 100644
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ b/src/gui/widgets/qdialogbuttonbox.cpp
@@ -562,6 +562,14 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut
} else {
qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
}
+
+#ifdef Q_WS_MAC
+ // Since mnemonics is off by default on Mac, we add a Cmd-D
+ // shortcut here to e.g. make the "Don't Save" button work nativly:
+ if (sbutton == QDialogButtonBox::Discard)
+ button->setShortcut(QKeySequence(QLatin1String("Ctrl+D")));
+#endif
+
return button;
}
@@ -1229,7 +1237,7 @@ bool QDialogButtonBox::event(QEvent *event)
break;
}
- foreach (QPushButton *pb, qFindChildren<QPushButton *>(dialog ? dialog : this)) {
+ foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren<QPushButton *>()) {
if (pb->isDefault() && pb != firstAcceptButton) {
hasDefault = true;
break;
diff --git a/src/gui/widgets/qeffects.cpp b/src/gui/widgets/qeffects.cpp
index 8e1e7c3..6b64d48 100644
--- a/src/gui/widgets/qeffects.cpp
+++ b/src/gui/widgets/qeffects.cpp
@@ -55,19 +55,6 @@
QT_BEGIN_NAMESPACE
/*
- Internal class to get access to protected QWidget-members
-*/
-
-class QAccessWidget : public QWidget
-{
- friend class QAlphaWidget;
- friend class QRollEffect;
-public:
- QAccessWidget(QWidget* parent=0, Qt::WindowFlags f = 0)
- : QWidget(parent, f) {}
-};
-
-/*
Internal class QAlphaWidget.
The QAlphaWidget is shown while the animation lasts
@@ -98,13 +85,12 @@ private:
QImage backImage;
QImage frontImage;
QImage mixedImage;
- QPointer<QAccessWidget> widget;
+ QPointer<QWidget> widget;
int duration;
int elapsed;
bool showWidget;
QTimer anim;
QElapsedTimer checkTime;
- double windowOpacity;
};
static QAlphaWidget* q_blend = 0;
@@ -119,8 +105,7 @@ QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
setEnabled(false);
#endif
setAttribute(Qt::WA_NoSystemBackground, true);
- widget = (QAccessWidget*)w;
- windowOpacity = w->windowOpacity();
+ widget = w;
alpha = 0;
}
@@ -129,7 +114,7 @@ QAlphaWidget::~QAlphaWidget()
#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
// Restore user-defined opacity value
if (widget)
- widget->setWindowOpacity(windowOpacity);
+ widget->setWindowOpacity(1);
#endif
}
@@ -268,10 +253,10 @@ void QAlphaWidget::render()
alpha = 1;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if (alpha >= windowOpacity || !showWidget) {
+ if (alpha >= 1 || !showWidget) {
anim.stop();
qApp->removeEventFilter(this);
- widget->setWindowOpacity(windowOpacity);
+ widget->setWindowOpacity(1);
q_blend = 0;
deleteLater();
} else {
@@ -370,7 +355,7 @@ private slots:
void scroll();
private:
- QPointer<QAccessWidget> widget;
+ QPointer<QWidget> widget;
int currentHeight;
int currentWidth;
@@ -401,7 +386,7 @@ QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient)
setEnabled(false);
#endif
- widget = (QAccessWidget*) w;
+ widget = w;
Q_ASSERT(widget);
setAttribute(Qt::WA_NoSystemBackground, true);
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/qlabel.cpp b/src/gui/widgets/qlabel.cpp
index c5ce414..4714d2f 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/gui/widgets/qlabel.cpp
@@ -1072,7 +1072,7 @@ void QLabel::paintEvent(QPaintEvent *)
else
#endif
if (d->isTextLabel) {
- QRectF lr = d->layoutRect();
+ QRectF lr = d->layoutRect().toAlignedRect();
QStyleOption opt;
opt.initFrom(this);
#ifndef QT_NO_STYLE_STYLESHEET
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 5a281ad..3eac64a 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -112,7 +112,7 @@ void QLineControl::updateDisplayText(bool forceUpdate)
Copies the currently selected text into the clipboard using the given
\a mode.
-
+
\note If the echo mode is set to a mode other than Normal then copy
will not work. This is to prevent using copy as a method of bypassing
password features of the line control.
@@ -493,7 +493,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
/*!
\internal
- Draws the display text for the line control using the given
+ Draws the display text for the line control using the given
\a painter, \a clip, and \a offset. Which aspects of the display text
are drawn is specified by the given \a flags.
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
index 3147b88..636cee7 100644
--- a/src/gui/widgets/qlineedit.h
+++ b/src/gui/widgets/qlineedit.h
@@ -283,6 +283,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
#endif
Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateNeeded(const QRect &))
};
#endif // QT_NO_LINEEDIT
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
index d1eb71f..23ac613 100644
--- a/src/gui/widgets/qlineedit_p.cpp
+++ b/src/gui/widgets/qlineedit_p.cpp
@@ -59,6 +59,13 @@ QT_BEGIN_NAMESPACE
const int QLineEditPrivate::verticalMargin(1);
const int QLineEditPrivate::horizontalMargin(2);
+QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const
+{
+ QRect cr = adjustedContentsRect();
+ int cix = cr.x() - hscroll + horizontalMargin;
+ return rect.translated(QPoint(cix, vscroll));
+}
+
int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
{
QRect cr = adjustedContentsRect();
@@ -68,11 +75,7 @@ int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
QRect QLineEditPrivate::cursorRect() const
{
- QRect cr = adjustedContentsRect();
- int cix = cr.x() - hscroll + horizontalMargin;
- QRect crect = control->cursorRect();
- crect.moveTo(crect.topLeft() + QPoint(cix, vscroll));
- return crect;
+ return adjustedControlRect(control->cursorRect());
}
#ifndef QT_NO_COMPLETER
@@ -141,6 +144,11 @@ void QLineEditPrivate::_q_selectionChanged()
emit q->selectionChanged();
}
+void QLineEditPrivate::_q_updateNeeded(const QRect &rect)
+{
+ q_func()->update(adjustedControlRect(rect));
+}
+
void QLineEditPrivate::init(const QString& txt)
{
Q_Q(QLineEdit);
@@ -176,7 +184,7 @@ void QLineEditPrivate::init(const QString& txt)
q, SLOT(update()));
QObject::connect(control, SIGNAL(updateNeeded(QRect)),
- q, SLOT(update()));
+ q, SLOT(_q_updateNeeded(QRect)));
QStyleOptionFrameV2 opt;
q->initStyleOption(&opt);
@@ -216,9 +224,8 @@ void QLineEditPrivate::setCursorVisible(bool visible)
if ((bool)cursorVisible == visible)
return;
cursorVisible = visible;
- QRect r = cursorRect();
if (control->inputMask().isEmpty())
- q->update(r);
+ q->update(cursorRect());
else
q->update();
}
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
index 873190f..32f6077 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -94,6 +94,8 @@ public:
#endif
void init(const QString&);
+ QRect adjustedControlRect(const QRect &) const;
+
int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
QRect cursorRect() const;
void setCursorVisible(bool visible);
@@ -129,6 +131,7 @@ public:
void _q_editFocusChange(bool);
#endif
void _q_selectionChanged();
+ void _q_updateNeeded(const QRect &);
#ifndef QT_NO_COMPLETER
void _q_completionHighlighted(QString);
#endif
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index d8f8e91..43d6796 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -1516,15 +1516,28 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3)
return;
- // ### Disable the unified toolbar when using anything but the native graphics system.
- // ### Disable when using alien widgets as well
- if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false)
- return;
-
d->useHIToolBar = set;
createWinId(); // We need the hiview for down below.
+#ifdef QT_MAC_USE_COCOA
+ // Activate the unified toolbar with the raster engine.
+ if (windowSurface() && set) {
+ d->layout->unifiedSurface = new QUnifiedToolbarSurface(this);
+ }
+#endif // QT_MAC_USE_COCOA
+
d->layout->updateHIToolBarStatus();
+
+#ifdef QT_MAC_USE_COCOA
+ // Deactivate the unified toolbar with the raster engine.
+ if (windowSurface() && !set) {
+ if (d->layout->unifiedSurface) {
+ delete d->layout->unifiedSurface;
+ d->layout->unifiedSurface = 0;
+ }
+ }
+#endif // QT_MAC_USE_COCOA
+
// Enabling the unified toolbar clears the opaque size grip setting, update it.
d->macUpdateOpaqueSizeGrip();
#else
@@ -1634,7 +1647,7 @@ QMenu *QMainWindow::createPopupMenu()
Q_D(QMainWindow);
QMenu *menu = 0;
#ifndef QT_NO_DOCKWIDGET
- QList<QDockWidget *> dockwidgets = qFindChildren<QDockWidget *>(this);
+ QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>();
if (dockwidgets.size()) {
menu = new QMenu(this);
for (int i = 0; i < dockwidgets.size(); ++i) {
@@ -1648,7 +1661,7 @@ QMenu *QMainWindow::createPopupMenu()
}
#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
- QList<QToolBar *> toolbars = qFindChildren<QToolBar *>(this);
+ QList<QToolBar *> toolbars = findChildren<QToolBar *>();
if (toolbars.size()) {
if (!menu)
menu = new QMenu(this);
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 6bc07e1..d4afe07 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -73,6 +73,10 @@
# include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#ifdef QT_NO_DOCKWIDGET
+extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
+#endif
+
#ifdef Q_DEBUG_MAINWINDOW_LAYOUT
# include <QTextStream>
#endif
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index 8ba96fb..761a433 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -43,6 +43,7 @@
#include <qtoolbar.h>
#include <private/qtoolbarlayout_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qtoolbar_p.h>
#ifndef QT_MAC_USE_COCOA
#include <Carbon/Carbon.h>
@@ -354,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();
+#if defined(QT_MAC_USE_COCOA)
+ unifiedSurface->removeToolbar(toolbar);
+#endif
+ layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar);
}
macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0);
} else {
@@ -362,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);
}
}
@@ -386,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 already) 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());
@@ -398,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);
@@ -408,6 +424,7 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
beforeIndex = qtoolbarsInUnifiedToolbarList.size();
int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
+
#ifndef QT_MAC_USE_COCOA
HIToolbarRef macToolbar = NULL;
if ((GetWindowToolbar(window, &macToolbar) == noErr) && !macToolbar) {
@@ -444,6 +461,18 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
#endif
}
qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar);
+
+ // Adding to the unified toolbar surface for the raster engine.
+ if (layoutState.mainWindow->windowSurface()) {
+ QPoint offset(0, 0);
+ for (int i = 0; i < beforeIndex; ++i) {
+ offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width());
+ }
+#ifdef QT_MAC_USE_COCOA
+ unifiedSurface->insertToolbar(toolbar, offset);
+#endif // QT_MAC_USE_COCOA
+ }
+
#ifndef QT_MAC_USE_COCOA
QCFType<HIToolbarItemRef> outItem;
const QObject *stupidArray[] = { toolbar, this };
@@ -460,6 +489,19 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
#endif
}
+#ifdef QT_MAC_USE_COCOA
+void QMainWindowLayout::updateUnifiedToolbarOffset()
+{
+ QPoint offset(0, 0);
+
+ for (int i = 1; i < qtoolbarsInUnifiedToolbarList.length(); ++i) {
+ offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i - 1)->size().width());
+ qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset;
+ }
+}
+#endif // QT_MAC_USE_COCOA
+
+
void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
{
QHash<void *, QToolBar *>::iterator it = unifiedToolbarHash.begin();
@@ -533,11 +575,11 @@ void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
QMacCocoaAutoReleasePool pool;
QWidgetItem layoutItem(tb);
QSize size = layoutItem.maximumSize();
- NSSize nssize = NSMakeSize(size.width(), size.height() - 2);
+ NSSize nssize = NSMakeSize(size.width(), size.height());
[item setMaxSize:nssize];
size = layoutItem.minimumSize();
nssize.width = size.width();
- nssize.height = size.height() - 2;
+ nssize.height = size.height();
[item setMinSize:nssize];
}
#else
diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h
index 489e913..20aca61 100644
--- a/src/gui/widgets/qmainwindowlayout_p.h
+++ b/src/gui/widgets/qmainwindowlayout_p.h
@@ -70,12 +70,12 @@
//#define Q_DEBUG_MAINWINDOW_LAYOUT
-#ifdef Q_DEBUG_MAINWINDOW_LAYOUT
+#if defined(Q_DEBUG_MAINWINDOW_LAYOUT) && !defined(QT_NO_DOCKWIDGET)
QT_BEGIN_NAMESPACE
class QTextStream;
Q_GUI_EXPORT void qt_dumpLayout(QTextStream &qout, QMainWindow *window);
QT_END_NAMESPACE
-#endif // Q_DEBUG_MAINWINDOW_LAYOUT
+#endif // Q_DEBUG_MAINWINDOW_LAYOUT && !QT_NO_DOCKWIDGET
#ifdef Q_WS_MAC
// Forward defs to make avoid including Carbon.h (faster compile you know ;).
@@ -85,7 +85,11 @@ typedef HIObjectRef HIToolbarItemRef;
typedef const void * CFTypeRef;
typedef const struct __CFString * CFStringRef;
-#endif
+# ifdef QT_MAC_USE_COCOA
+#include <private/qunifiedtoolbarsurface_mac_p.h>
+# endif // QT_MAC_USE_COCOA
+
+#endif // Q_WS_MAC
QT_BEGIN_NAMESPACE
@@ -338,7 +342,13 @@ public:
bool activateUnifiedToolbarAfterFullScreen;
void syncUnifiedToolbarVisibility();
bool blockVisiblityCheck;
-#endif
+
+#ifdef QT_MAC_USE_COCOA
+ QUnifiedToolbarSurface *unifiedSurface;
+ void updateUnifiedToolbarOffset();
+#endif // QT_MAC_USE_COCOA
+
+#endif // Q_WS_MAC
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp
index b02db4c..2a486bb 100644
--- a/src/gui/widgets/qmdiarea.cpp
+++ b/src/gui/widgets/qmdiarea.cpp
@@ -674,6 +674,8 @@ QMdiAreaPrivate::QMdiAreaPrivate()
viewMode(QMdiArea::SubWindowView),
#ifndef QT_NO_TABBAR
documentMode(false),
+ tabsClosable(false),
+ tabsMovable(false),
#endif
#ifndef QT_NO_TABWIDGET
tabShape(QTabWidget::Rounded),
@@ -792,6 +794,27 @@ void QMdiAreaPrivate::_q_currentTabChanged(int index)
#endif // QT_NO_TABBAR
}
+void QMdiAreaPrivate::_q_closeTab(int index)
+{
+#ifdef QT_NO_TABBAR
+ Q_UNUSED(index);
+#else
+ QMdiSubWindow *subWindow = childWindows.at(index);
+ Q_ASSERT(subWindow);
+ subWindow->close();
+#endif // QT_NO_TABBAR
+}
+
+void QMdiAreaPrivate::_q_moveTab(int from, int to)
+{
+#ifdef QT_NO_TABBAR
+ Q_UNUSED(from);
+ Q_UNUSED(to);
+#else
+ childWindows.move(from, to);
+#endif // QT_NO_TABBAR
+}
+
/*!
\internal
*/
@@ -1519,6 +1542,8 @@ void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode)
Q_ASSERT(!tabBar);
tabBar = new QMdiAreaTabBar(q);
tabBar->setDocumentMode(documentMode);
+ tabBar->setTabsClosable(tabsClosable);
+ tabBar->setMovable(tabsMovable);
#ifndef QT_NO_TABWIDGET
tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition));
#endif
@@ -1550,6 +1575,8 @@ void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode)
updateTabBarGeometry();
QObject::connect(tabBar, SIGNAL(currentChanged(int)), q, SLOT(_q_currentTabChanged(int)));
+ QObject::connect(tabBar, SIGNAL(tabCloseRequested(int)), q, SLOT(_q_closeTab(int)));
+ QObject::connect(tabBar, SIGNAL(tabMoved(int,int)), q, SLOT(_q_moveTab(int,int)));
} else
#endif // QT_NO_TABBAR
{ // SubWindowView
@@ -1636,6 +1663,8 @@ void QMdiAreaPrivate::refreshTabBar()
return;
tabBar->setDocumentMode(documentMode);
+ tabBar->setTabsClosable(tabsClosable);
+ tabBar->setMovable(tabsMovable);
#ifndef QT_NO_TABWIDGET
tabBar->setShape(tabBarShapeFrom(tabShape, tabPosition));
#endif
@@ -2114,6 +2143,56 @@ void QMdiArea::setDocumentMode(bool enabled)
d->documentMode = enabled;
d->refreshTabBar();
}
+
+/*!
+ \property QMdiArea::tabsClosable
+ \brief whether the tab bar should place close buttons on each tab in tabbed view mode.
+ \since 4.8
+
+ Tabs are not closable by default.
+
+ \sa QTabBar::tabsClosable, setViewMode()
+*/
+bool QMdiArea::tabsClosable() const
+{
+ Q_D(const QMdiArea);
+ return d->tabsClosable;
+}
+
+void QMdiArea::setTabsClosable(bool closable)
+{
+ Q_D(QMdiArea);
+ if (d->tabsClosable == closable)
+ return;
+
+ d->tabsClosable = closable;
+ d->refreshTabBar();
+}
+
+/*!
+ \property QMdiArea::tabsMovable
+ \brief whether the user can move the tabs within the tabbar area in tabbed view mode.
+ \since 4.8
+
+ Tabs are not movable by default.
+
+ \sa QTabBar::tabsMovable, setViewMode()
+*/
+bool QMdiArea::tabsMovable() const
+{
+ Q_D(const QMdiArea);
+ return d->tabsMovable;
+}
+
+void QMdiArea::setTabsMovable(bool movable)
+{
+ Q_D(QMdiArea);
+ if (d->tabsMovable == movable)
+ return;
+
+ d->tabsMovable = movable;
+ d->refreshTabBar();
+}
#endif // QT_NO_TABBAR
#ifndef QT_NO_TABWIDGET
diff --git a/src/gui/widgets/qmdiarea.h b/src/gui/widgets/qmdiarea.h
index 809bfe4..a4b357c 100644
--- a/src/gui/widgets/qmdiarea.h
+++ b/src/gui/widgets/qmdiarea.h
@@ -65,6 +65,8 @@ class Q_GUI_EXPORT QMdiArea : public QAbstractScrollArea
Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
#ifndef QT_NO_TABBAR
Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
+ Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
+ Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
#endif
#ifndef QT_NO_TABWIDGET
Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
@@ -116,6 +118,12 @@ public:
#ifndef QT_NO_TABBAR
bool documentMode() const;
void setDocumentMode(bool enabled);
+
+ void setTabsClosable(bool closable);
+ bool tabsClosable() const;
+
+ void setTabsMovable(bool movable);
+ bool tabsMovable() const;
#endif
#ifndef QT_NO_TABWIDGET
void setTabShape(QTabWidget::TabShape shape);
@@ -156,7 +164,9 @@ private:
Q_DECLARE_PRIVATE(QMdiArea)
Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
- Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int index))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
diff --git a/src/gui/widgets/qmdiarea_p.h b/src/gui/widgets/qmdiarea_p.h
index 5d85659..e5e2057 100644
--- a/src/gui/widgets/qmdiarea_p.h
+++ b/src/gui/widgets/qmdiarea_p.h
@@ -165,6 +165,8 @@ public:
QMdiArea::ViewMode viewMode;
#ifndef QT_NO_TABBAR
bool documentMode;
+ bool tabsClosable;
+ bool tabsMovable;
#endif
#ifndef QT_NO_TABWIDGET
QTabWidget::TabShape tabShape;
@@ -189,6 +191,8 @@ public:
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
void _q_currentTabChanged(int index);
+ void _q_closeTab(int index);
+ void _q_moveTab(int from, int to);
// Functions.
void appendChild(QMdiSubWindow *child);
diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp
index 58d28f6..6f2b676 100644
--- a/src/gui/widgets/qmdisubwindow.cpp
+++ b/src/gui/widgets/qmdisubwindow.cpp
@@ -2203,7 +2203,7 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip)
void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const
{
// See if we can find any size grips
- QList<QSizeGrip *> sizeGrips = qFindChildren<QSizeGrip *>(q_func());
+ QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>();
foreach (QSizeGrip *grip, sizeGrips)
grip->setVisible(visible);
}
@@ -2319,7 +2319,7 @@ void QMdiSubWindow::setWidget(QWidget *widget)
widget->setParent(this);
#ifndef QT_NO_SIZEGRIP
- QSizeGrip *sizeGrip = qFindChild<QSizeGrip *>(widget);
+ QSizeGrip *sizeGrip = widget->findChild<QSizeGrip *>();
if (sizeGrip)
sizeGrip->installEventFilter(this);
if (d->sizeGrip)
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 2f4bb4b..b12e5c5 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2787,7 +2787,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
if (d->sloppyRegion.contains(e->pos())) {
d->sloppyAction = action;
QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6);
- } else {
+ } else if (action != d->currentAction) {
d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this));
}
}
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
index f8f2637..daac916 100644
--- a/src/gui/widgets/qmenu.h
+++ b/src/gui/widgets/qmenu.h
@@ -51,6 +51,10 @@
#include <QtGui/qpixmap.h>
#endif
+#ifdef Q_WS_WINCE
+#include <windef.h> // for HMENU
+#endif
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index ad3ca81..2977558 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -1254,15 +1254,11 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction
NSString *keySequenceToKeyEqivalent(const QKeySequence &accel)
{
quint32 accel_key = (accel[0] & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL));
- extern QChar qt_macSymbolForQtKey(int key); // qkeysequence.cpp
- QChar keyEquiv = qt_macSymbolForQtKey(accel_key);
- if (keyEquiv.isNull()) {
- if (accel_key >= Qt::Key_F1 && accel_key <= Qt::Key_F15)
- keyEquiv = (accel_key - Qt::Key_F1) + NSF1FunctionKey;
- else
- keyEquiv = unichar(QChar(accel_key).toLower().unicode());
- }
- return [NSString stringWithCharacters:&keyEquiv.unicode() length:1];
+ extern QChar qtKey2CocoaKey(Qt::Key key);
+ QChar cocoa_key = qtKey2CocoaKey(Qt::Key(accel_key));
+ if (cocoa_key.isNull())
+ cocoa_key = QChar(accel_key).toLower().unicode();
+ return [NSString stringWithCharacters:&cocoa_key.unicode() length:1];
}
// return the cocoa modifier mask for the QKeySequence (currently only looks at the first one).
@@ -2052,8 +2048,7 @@ bool QMenuBar::macUpdateMenuBar()
{
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
- if (!qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar)))
- return QMenuBarPrivate::macUpdateMenuBarImmediatly();
+ qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar));
return true;
#else
return QMenuBarPrivate::macUpdateMenuBarImmediatly();
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index f9c5d82..d614bb8 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -264,7 +264,8 @@ void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
// However if we don't have any items, we still need the item array. Otherwise
// menupane will crash. That's why we create item array here manually, and
// AddMenuItemL will then use the existing array.
- CEikMenuPane::CItemArray* itemArray = q_check_ptr(new CEikMenuPane::CItemArray);
+ CEikMenuPane::CItemArray* itemArray = new CEikMenuPane::CItemArray;
+ Q_CHECK_PTR(itemArray);
menuPane->SetItemArray(itemArray);
menuPane->SetItemArrayOwnedExternally(EFalse);
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index d2bc7aa..86a78ad 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -113,8 +113,6 @@ static void resolveAygLibs()
if (!aygResolved) {
aygResolved = true;
QLibrary aygLib(QLatin1String("aygshell"));
- if (!aygLib.load())
- return;
ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar");
ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey");
}
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/qradiobutton.cpp b/src/gui/widgets/qradiobutton.cpp
index 6af5de4..bb13017 100644
--- a/src/gui/widgets/qradiobutton.cpp
+++ b/src/gui/widgets/qradiobutton.cpp
@@ -207,6 +207,14 @@ QSize QRadioButton::sizeHint() const
/*!
\reimp
*/
+QSize QRadioButton::minimumSizeHint() const
+{
+ return sizeHint();
+}
+
+/*!
+ \reimp
+*/
bool QRadioButton::hitButton(const QPoint &pos) const
{
QStyleOptionButton opt;
diff --git a/src/gui/widgets/qradiobutton.h b/src/gui/widgets/qradiobutton.h
index c21ba11..b720498 100644
--- a/src/gui/widgets/qradiobutton.h
+++ b/src/gui/widgets/qradiobutton.h
@@ -62,6 +62,7 @@ public:
explicit QRadioButton(const QString &text, QWidget *parent=0);
QSize sizeHint() const;
+ QSize minimumSizeHint() const;
protected:
bool event(QEvent *e);
diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp
index 266b163..630aecf 100644
--- a/src/gui/widgets/qsizegrip.cpp
+++ b/src/gui/widgets/qsizegrip.cpp
@@ -78,15 +78,6 @@ static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)
return w;
}
-static inline bool hasHeightForWidth(QWidget *widget)
-{
- if (!widget)
- return false;
- if (QLayout *layout = widget->layout())
- return layout->hasHeightForWidth();
- return widget->sizePolicy().hasHeightForWidth();
-}
-
class QSizeGripPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QSizeGrip)
@@ -318,7 +309,8 @@ 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->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) {
+ && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE);
@@ -340,7 +332,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
}
#endif // Q_WS_X11
#ifdef Q_WS_WIN
- if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) {
+ if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
uint orientation = 0;
if (d->atBottom())
orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT;
@@ -429,12 +421,13 @@ 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) && !hasHeightForWidth(tlw))
+ && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
return;
#endif
#ifdef Q_WS_WIN
if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId()
- && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) {
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
MSG msg;
while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
return;
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index 02a4cc2..22fd2a9 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -697,6 +697,9 @@ void QDoubleSpinBox::setSuffix(const QString &suffix)
d->suffix = suffix;
d->updateEdit();
+
+ d->cachedSizeHint = QSize();
+ updateGeometry();
}
/*!
diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/gui/widgets/qsplashscreen.cpp
index a70e361..9c486bf 100644
--- a/src/gui/widgets/qsplashscreen.cpp
+++ b/src/gui/widgets/qsplashscreen.cpp
@@ -64,7 +64,6 @@ public:
int currAlign;
inline QSplashScreenPrivate();
- void drawContents();
};
/*!
@@ -121,10 +120,9 @@ public:
perhaps Qt::WindowStaysOnTopHint.
*/
QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
- : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | f)
+ : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
- d_func()->pixmap = pixmap;
- setPixmap(d_func()->pixmap); // Does an implicit repaint
+ setPixmap(pixmap); // Does an implicit repaint
}
/*!
@@ -165,7 +163,6 @@ void QSplashScreen::mousePressEvent(QMouseEvent *)
*/
void QSplashScreen::repaint()
{
- d_func()->drawContents();
QWidget::repaint();
QApplication::flush();
}
@@ -226,8 +223,8 @@ void QSplashScreen::finish(QWidget *mainWin)
{
if (mainWin) {
#if defined(Q_WS_X11)
- extern void qt_x11_wait_for_window_manager(QWidget *mainWin);
- qt_x11_wait_for_window_manager(mainWin);
+ extern void qt_x11_wait_for_window_manager(QWidget *mainWin, bool);
+ qt_x11_wait_for_window_manager(mainWin, false);
#endif
}
close();
@@ -241,23 +238,13 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap)
{
Q_D(QSplashScreen);
- if (pixmap.hasAlpha()) {
- QPixmap opaque(pixmap.size());
- QPainter p(&opaque);
- p.fillRect(0, 0, pixmap.width(), pixmap.height(), palette().background());
- p.drawPixmap(0, 0, pixmap);
- p.end();
- d->pixmap = opaque;
- } else {
- d->pixmap = pixmap;
- }
+ d->pixmap = pixmap;
+ setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());
- QRect r(0, 0, d->pixmap.size().width(), d->pixmap.size().height());
- resize(d->pixmap.size());
+ QRect r(QPoint(), d->pixmap.size());
+ resize(r.size());
move(QApplication::desktop()->screenGeometry().center() - r.center());
- if (!isVisible())
- d->drawContents();
- else
+ if (isVisible())
repaint();
}
@@ -271,23 +258,6 @@ const QPixmap QSplashScreen::pixmap() const
}
/*!
- \internal
-*/
-void QSplashScreenPrivate::drawContents()
-{
- Q_Q(QSplashScreen);
- QPixmap textPix = pixmap;
- if (!textPix.isNull()) {
- QPainter painter(&textPix);
- painter.initFrom(q);
- q->drawContents(&painter);
- QPalette p = q->palette();
- p.setBrush(q->backgroundRole(), QBrush(textPix));
- q->setPalette(p);
- }
-}
-
-/*!
\internal
*/
inline QSplashScreenPrivate::QSplashScreenPrivate() : currAlign(Qt::AlignLeft)
@@ -304,8 +274,7 @@ void QSplashScreen::drawContents(QPainter *painter)
{
Q_D(QSplashScreen);
painter->setPen(d->currColor);
- QRect r = rect();
- r.setRect(r.x() + 5, r.y() + 5, r.width() - 10, r.height() - 10);
+ QRect r = rect().adjusted(5, 5, -5, -5);
if (Qt::mightBeRichText(d->currStatus)) {
QTextDocument doc;
#ifdef QT_NO_TEXTHTMLPARSER
@@ -346,6 +315,13 @@ void QSplashScreen::drawContents(QPainter *painter)
/*! \reimp */
bool QSplashScreen::event(QEvent *e)
{
+ if (e->type() == QEvent::Paint) {
+ Q_D(QSplashScreen);
+ QPainter painter(this);
+ if (!d->pixmap.isNull())
+ painter.drawPixmap(QPoint(), d->pixmap);
+ drawContents(&painter);
+ }
return QWidget::event(e);
}
diff --git a/src/gui/widgets/qstackedwidget.cpp b/src/gui/widgets/qstackedwidget.cpp
index 62822ab..a1c225b 100644
--- a/src/gui/widgets/qstackedwidget.cpp
+++ b/src/gui/widgets/qstackedwidget.cpp
@@ -49,12 +49,54 @@
QT_BEGIN_NAMESPACE
+/**
+ QStackedLayout does not support height for width (simply because it does not reimplement
+ heightForWidth() and hasHeightForWidth()). That is not possible to fix without breaking
+ binary compatibility. (QLayout is subject to multiple inheritance).
+ However, we can fix QStackedWidget by simply using a modified version of QStackedLayout
+ that reimplements the hfw-related functions:
+ */
+class QStackedLayoutHFW : public QStackedLayout
+{
+public:
+ QStackedLayoutHFW(QWidget *parent = 0) : QStackedLayout(parent) {}
+ bool hasHeightForWidth() const;
+ int heightForWidth(int width) const;
+};
+
+bool QStackedLayoutHFW::hasHeightForWidth() const
+{
+ const int n = count();
+
+ for (int i = 0; i < n; ++i) {
+ if (QLayoutItem *item = itemAt(i)) {
+ if (item->hasHeightForWidth())
+ return true;
+ }
+ }
+ return false;
+}
+
+int QStackedLayoutHFW::heightForWidth(int width) const
+{
+ const int n = count();
+
+ int hfw = 0;
+ for (int i = 0; i < n; ++i) {
+ if (QLayoutItem *item = itemAt(i)) {
+ hfw = qMax(hfw, item->heightForWidth(width));
+ }
+ }
+ return hfw;
+}
+
+
class QStackedWidgetPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QStackedWidget)
public:
QStackedWidgetPrivate():layout(0){}
- QStackedLayout *layout;
+ QStackedLayoutHFW *layout;
bool blockChildAdd;
};
@@ -138,7 +180,7 @@ QStackedWidget::QStackedWidget(QWidget *parent)
: QFrame(*new QStackedWidgetPrivate, parent)
{
Q_D(QStackedWidget);
- d->layout = new QStackedLayout(this);
+ d->layout = new QStackedLayoutHFW(this);
connect(d->layout, SIGNAL(widgetRemoved(int)), this, SIGNAL(widgetRemoved(int)));
connect(d->layout, SIGNAL(currentChanged(int)), this, SIGNAL(currentChanged(int)));
}
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 3233772..c5d0892 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1292,6 +1292,8 @@ QSize QTabBar::sizeHint() const
QSize QTabBar::minimumSizeHint() const
{
Q_D(const QTabBar);
+ if (d->layoutDirty)
+ const_cast<QTabBarPrivate*>(d)->layoutTabs();
if (!d->useScrollButtons) {
QRect r;
for (int i = 0; i < d->tabList.count(); ++i)
@@ -1304,22 +1306,23 @@ QSize QTabBar::minimumSizeHint() const
return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height());
}
+// Compute the most-elided possible text, for minimumSizeHint
static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
{
- if (text.length() <= 7)
+ if (text.length() <= 3)
return text;
static const QLatin1String Ellipses("...");
QString ret;
switch (mode) {
case Qt::ElideRight:
- ret = text.left(4) + Ellipses;
+ ret = text.left(2) + Ellipses;
break;
case Qt::ElideMiddle:
- ret = text.left(2) + Ellipses + text.right(2);
+ ret = text.left(1) + Ellipses + text.right(1);
break;
case Qt::ElideLeft:
- ret = Ellipses + text.right(4);
+ ret = Ellipses + text.right(2);
break;
case Qt::ElideNone:
ret = text;
@@ -1966,7 +1969,7 @@ void QTabBar::keyPressEvent(QKeyEvent *event)
event->ignore();
return;
}
- int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
+ int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1;
d->setCurrentNextEnabledIndex(offset);
}
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp
index b7bc30f..c296b77 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/gui/widgets/qtabwidget.cpp
@@ -195,6 +195,7 @@ public:
void _q_removeTab(int);
void _q_tabMoved(int from, int to);
void init();
+ bool hasHeightForWidth() const;
QTabBar *tabs;
QStackedWidget *stack;
@@ -246,6 +247,15 @@ void QTabWidgetPrivate::init()
}
+bool QTabWidgetPrivate::hasHeightForWidth() const
+{
+ bool has = size_policy.hasHeightForWidth();
+ if (!has && stack)
+ has = qt_widget_private(stack)->hasHeightForWidth();
+ return has;
+}
+
+
/*!
Initialize \a option with the values from this QTabWidget. This method is useful
for subclasses when they need a QStyleOptionTabWidgetFrame, but don't want to fill
@@ -816,8 +826,8 @@ QSize QTabWidget::sizeHint() const
{
Q_D(const QTabWidget);
QSize lc(0, 0), rc(0, 0);
- QStyleOption opt(0);
- opt.init(this);
+ QStyleOptionTabWidgetFrameV2 opt;
+ initStyleOption(&opt);
opt.state = QStyle::State_None;
if (d->leftCornerWidget)
@@ -865,14 +875,58 @@ QSize QTabWidget::minimumSizeHint() const
QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
- QStyleOption opt(0);
- opt.rect = rect();
+ QStyleOptionTabWidgetFrameV2 opt;
+ initStyleOption(&opt);
opt.palette = palette();
opt.state = QStyle::State_None;
return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this)
.expandedTo(QApplication::globalStrut());
}
+/*
+ \reimp
+*/
+int QTabWidget::heightForWidth(int width) const
+{
+ Q_D(const QTabWidget);
+ QStyleOptionTabWidgetFrameV2 opt;
+ initStyleOption(&opt);
+ opt.state = QStyle::State_None;
+
+ QSize zero(0,0);
+ const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this)
+ .expandedTo(QApplication::globalStrut());
+
+ QSize lc(0, 0), rc(0, 0);
+ if (d->leftCornerWidget)
+ lc = d->leftCornerWidget->sizeHint();
+ if(d->rightCornerWidget)
+ rc = d->rightCornerWidget->sizeHint();
+ if (!d->dirty) {
+ QTabWidget *that = (QTabWidget*)this;
+ that->setUpLayout(true);
+ }
+ QSize t(d->tabs->sizeHint());
+
+ if(usesScrollButtons())
+ t = t.boundedTo(QSize(200,200));
+ else
+ t = t.boundedTo(QApplication::desktop()->size());
+
+ const bool tabIsHorizontal = (d->pos == North || d->pos == South);
+ const int contentsWidth = width - padding.width();
+ int stackWidth = contentsWidth;
+ if (!tabIsHorizontal)
+ stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width()));
+
+ int stackHeight = d->stack->heightForWidth(stackWidth);
+ QSize s(stackWidth, stackHeight);
+
+ QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t);
+ return (contentSize + padding).expandedTo(QApplication::globalStrut()).height();
+}
+
+
/*!
\reimp
*/
diff --git a/src/gui/widgets/qtabwidget.h b/src/gui/widgets/qtabwidget.h
index cabb78d..b0e6fb3 100644
--- a/src/gui/widgets/qtabwidget.h
+++ b/src/gui/widgets/qtabwidget.h
@@ -129,6 +129,7 @@ public:
QSize sizeHint() const;
QSize minimumSizeHint() const;
+ int heightForWidth(int width) const;
void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp
index 813ec3e..531acb4 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/gui/widgets/qtoolbarlayout.cpp
@@ -647,15 +647,15 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const
void QToolBarLayout::setExpanded(bool exp)
{
- if (exp == expanded)
+ QWidget *tb = qobject_cast<QToolBar*>(parentWidget());
+ if (!tb)
+ return;
+ if (exp == expanded && !tb->isWindow())
return;
expanded = exp;
extension->setChecked(expanded);
- QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
- if (!tb)
- return;
if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
#ifdef QT_NO_DOCKWIDGET
animating = false;
diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/gui/widgets/qtoolbutton.cpp
index 8f64e20..2c9f15c 100644
--- a/src/gui/widgets/qtoolbutton.cpp
+++ b/src/gui/widgets/qtoolbutton.cpp
@@ -394,9 +394,6 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
option->toolButtonStyle = Qt::ToolButtonTextOnly;
else if (option->toolButtonStyle != Qt::ToolButtonTextOnly)
option->toolButtonStyle = Qt::ToolButtonIconOnly;
- } else {
- if (d->text.isEmpty() && option->toolButtonStyle != Qt::ToolButtonIconOnly)
- option->toolButtonStyle = Qt::ToolButtonIconOnly;
}
option->pos = pos();
diff --git a/src/gui/widgets/qvalidator.h b/src/gui/widgets/qvalidator.h
index 6627062..5a0162a 100644
--- a/src/gui/widgets/qvalidator.h
+++ b/src/gui/widgets/qvalidator.h
@@ -101,7 +101,7 @@ class Q_GUI_EXPORT QIntValidator : public QValidator
public:
explicit QIntValidator(QObject * parent = 0);
- QIntValidator(int bottom, int top, QObject * parent);
+ QIntValidator(int bottom, int top, QObject *parent = 0);
~QIntValidator();
QValidator::State validate(QString &, int &) const;
@@ -142,7 +142,7 @@ class Q_GUI_EXPORT QDoubleValidator : public QValidator
public:
explicit QDoubleValidator(QObject * parent = 0);
- QDoubleValidator(double bottom, double top, int decimals, QObject * parent);
+ QDoubleValidator(double bottom, double top, int decimals, QObject *parent = 0);
~QDoubleValidator();
enum Notation {
@@ -186,7 +186,7 @@ class Q_GUI_EXPORT QRegExpValidator : public QValidator
public:
explicit QRegExpValidator(QObject *parent = 0);
- QRegExpValidator(const QRegExp& rx, QObject *parent);
+ QRegExpValidator(const QRegExp& rx, QObject *parent = 0);
~QRegExpValidator();
virtual QValidator::State validate(QString& input, int& pos) const;
diff --git a/src/gui/widgets/qworkspace.cpp b/src/gui/widgets/qworkspace.cpp
index 5c37ccd..bf50d07 100644
--- a/src/gui/widgets/qworkspace.cpp
+++ b/src/gui/widgets/qworkspace.cpp
@@ -2923,7 +2923,7 @@ void QWorkspaceChild::setActive(bool b)
iconw->setActive(act);
update();
- QList<QWidget*> wl = qFindChildren<QWidget*>(childWidget);
+ QList<QWidget*> wl = childWidget->findChildren<QWidget*>();
if (act) {
for (int i = 0; i < wl.size(); ++i) {
QWidget *w = wl.at(i);
diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
index 937b8d6..669b838 100644
--- a/src/gui/widgets/widgets.pri
+++ b/src/gui/widgets/widgets.pri
@@ -144,7 +144,7 @@ SOURCES += \
widgets/qplaintextedit.cpp \
widgets/qprintpreviewwidget.cpp
-!embedded:mac {
+!embedded:!qpa:mac {
HEADERS += widgets/qmacnativewidget_mac.h \
widgets/qmaccocoaviewcontainer_mac.h
OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \
diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro
index 8964ab0..44764a9 100644
--- a/src/imports/folderlistmodel/folderlistmodel.pro
+++ b/src/imports/folderlistmodel/folderlistmodel.pro
@@ -16,8 +16,8 @@ qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
TARGET.UID3 = 0x20021320
- isEmpty(DESTDIR):importFiles.sources = qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll qmldir
- else:importFiles.sources = $$DESTDIR/qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll qmldir
+ isEmpty(DESTDIR):importFiles.files = qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll qmldir
+ else:importFiles.files = $$DESTDIR/qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro
index a4c914d..ad872ba 100644
--- a/src/imports/gestures/gestures.pro
+++ b/src/imports/gestures/gestures.pro
@@ -16,8 +16,8 @@ qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
TARGET.UID3 = 0x2002131F
- isEmpty(DESTDIR):importFiles.sources = qmlgesturesplugin$${QT_LIBINFIX}.dll qmldir
- else:importFiles.sources = $$DESTDIR/qmlgesturesplugin$${QT_LIBINFIX}.dll qmldir
+ isEmpty(DESTDIR):importFiles.files = qmlgesturesplugin$${QT_LIBINFIX}.dll qmldir
+ else:importFiles.files = $$DESTDIR/qmlgesturesplugin$${QT_LIBINFIX}.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro
index bb9da01..90b50e4 100644
--- a/src/imports/particles/particles.pro
+++ b/src/imports/particles/particles.pro
@@ -20,8 +20,8 @@ qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
symbian:{
TARGET.UID3 = 0x2002131E
- isEmpty(DESTDIR):importFiles.sources = qmlparticlesplugin$${QT_LIBINFIX}.dll qmldir
- else:importFiles.sources = $$DESTDIR/qmlparticlesplugin$${QT_LIBINFIX}.dll qmldir
+ isEmpty(DESTDIR):importFiles.files = qmlparticlesplugin$${QT_LIBINFIX}.dll qmldir
+ else:importFiles.files = $$DESTDIR/qmlparticlesplugin$${QT_LIBINFIX}.dll qmldir
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
DEPLOYMENT = importFiles
diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
index 4d87f72..4d9c3c2 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp
@@ -133,7 +133,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
}
}
- delete streams;
+ delete[] streams;
}
}
@@ -207,7 +207,7 @@ QList<int> QAudioDeviceInfoInternal::frequencyList()
rc << vr[i].mMaximum;
}
- delete vr;
+ delete[] vr;
}
}
@@ -351,7 +351,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
}
}
- delete audioDevices;
+ delete[] audioDevices;
}
}
diff --git a/src/multimedia/multimedia.pro b/src/multimedia/multimedia.pro
index 852322d..e827cdd 100644
--- a/src/multimedia/multimedia.pro
+++ b/src/multimedia/multimedia.pro
@@ -4,7 +4,7 @@ QT = core gui
DEFINES += QT_BUILD_MULTIMEDIA_LIB QT_NO_USING_NAMESPACE
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
include(../qbase.pri)
diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp
index 66835f2..0562a84 100644
--- a/src/multimedia/video/qvideosurfaceformat.cpp
+++ b/src/multimedia/video/qvideosurfaceformat.cpp
@@ -502,11 +502,11 @@ QList<QByteArray> QVideoSurfaceFormat::propertyNames() const
QVariant QVideoSurfaceFormat::property(const char *name) const
{
if (qstrcmp(name, "handleType") == 0) {
- return qVariantFromValue(d->handleType);
+ return QVariant::fromValue(d->handleType);
} else if (qstrcmp(name, "pixelFormat") == 0) {
- return qVariantFromValue(d->pixelFormat);
+ return QVariant::fromValue(d->pixelFormat);
} else if (qstrcmp(name, "handleType") == 0) {
- return qVariantFromValue(d->handleType);
+ return QVariant::fromValue(d->handleType);
} else if (qstrcmp(name, "frameSize") == 0) {
return d->frameSize;
} else if (qstrcmp(name, "frameWidth") == 0) {
@@ -516,15 +516,15 @@ QVariant QVideoSurfaceFormat::property(const char *name) const
} else if (qstrcmp(name, "viewport") == 0) {
return d->viewport;
} else if (qstrcmp(name, "scanLineDirection") == 0) {
- return qVariantFromValue(d->scanLineDirection);
+ return QVariant::fromValue(d->scanLineDirection);
} else if (qstrcmp(name, "frameRate") == 0) {
- return qVariantFromValue(d->frameRate);
+ return QVariant::fromValue(d->frameRate);
} else if (qstrcmp(name, "pixelAspectRatio") == 0) {
- return qVariantFromValue(d->pixelAspectRatio);
+ return QVariant::fromValue(d->pixelAspectRatio);
} else if (qstrcmp(name, "sizeHint") == 0) {
return sizeHint();
} else if (qstrcmp(name, "yCbCrColorSpace") == 0) {
- return qVariantFromValue(d->ycbcrColorSpace);
+ return QVariant::fromValue(d->ycbcrColorSpace);
} else {
int id = 0;
for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {}
@@ -546,7 +546,7 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value)
} else if (qstrcmp(name, "pixelFormat") == 0) {
// read only.
} else if (qstrcmp(name, "frameSize") == 0) {
- if (qVariantCanConvert<QSize>(value)) {
+ if (value.canConvert<QSize>()) {
d->frameSize = qvariant_cast<QSize>(value);
d->viewport = QRect(QPoint(0, 0), d->frameSize);
}
@@ -555,21 +555,21 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value)
} else if (qstrcmp(name, "frameHeight") == 0) {
// read only.
} else if (qstrcmp(name, "viewport") == 0) {
- if (qVariantCanConvert<QRect>(value))
+ if (value.canConvert<QRect>())
d->viewport = qvariant_cast<QRect>(value);
} else if (qstrcmp(name, "scanLineDirection") == 0) {
- if (qVariantCanConvert<Direction>(value))
+ if (value.canConvert<Direction>())
d->scanLineDirection = qvariant_cast<Direction>(value);
} else if (qstrcmp(name, "frameRate") == 0) {
- if (qVariantCanConvert<qreal>(value))
+ if (value.canConvert<qreal>())
d->frameRate = qvariant_cast<qreal>(value);
} else if (qstrcmp(name, "pixelAspectRatio") == 0) {
- if (qVariantCanConvert<QSize>(value))
+ if (value.canConvert<QSize>())
d->pixelAspectRatio = qvariant_cast<QSize>(value);
} else if (qstrcmp(name, "sizeHint") == 0) {
// read only.
} else if (qstrcmp(name, "yCbCrColorSpace") == 0) {
- if (qVariantCanConvert<YCbCrColorSpace>(value))
+ if (value.canConvert<YCbCrColorSpace>())
d->ycbcrColorSpace = qvariant_cast<YCbCrColorSpace>(value);
} else {
int id = 0;
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index ce79b06..57a79b3 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -8,12 +8,11 @@ HEADERS += \
access/qhttpnetworkreply_p.h \
access/qhttpnetworkconnection_p.h \
access/qhttpnetworkconnectionchannel_p.h \
- access/qfilenetworkreply_p.h \
+ access/qnetworkaccessauthenticationmanager_p.h \
access/qnetworkaccessmanager.h \
access/qnetworkaccessmanager_p.h \
access/qnetworkaccesscache_p.h \
access/qnetworkaccessbackend_p.h \
- access/qnetworkaccessdatabackend_p.h \
access/qnetworkaccessdebugpipebackend_p.h \
access/qnetworkaccesshttpbackend_p.h \
access/qnetworkaccessfilebackend_p.h \
@@ -29,10 +28,13 @@ HEADERS += \
access/qnetworkreply.h \
access/qnetworkreply_p.h \
access/qnetworkreplyimpl_p.h \
+ access/qnetworkreplydataimpl_p.h \
+ access/qnetworkreplyfileimpl_p.h \
access/qabstractnetworkcache_p.h \
access/qabstractnetworkcache.h \
access/qnetworkdiskcache_p.h \
- access/qnetworkdiskcache.h
+ access/qnetworkdiskcache.h \
+ access/qhttpthreaddelegate_p.h
SOURCES += \
access/qftp.cpp \
@@ -42,11 +44,10 @@ SOURCES += \
access/qhttpnetworkreply.cpp \
access/qhttpnetworkconnection.cpp \
access/qhttpnetworkconnectionchannel.cpp \
- access/qfilenetworkreply.cpp \
+ access/qnetworkaccessauthenticationmanager.cpp \
access/qnetworkaccessmanager.cpp \
access/qnetworkaccesscache.cpp \
access/qnetworkaccessbackend.cpp \
- access/qnetworkaccessdatabackend.cpp \
access/qnetworkaccessdebugpipebackend.cpp \
access/qnetworkaccessfilebackend.cpp \
access/qnetworkaccesscachebackend.cpp \
@@ -57,7 +58,10 @@ SOURCES += \
access/qnetworkrequest.cpp \
access/qnetworkreply.cpp \
access/qnetworkreplyimpl.cpp \
+ access/qnetworkreplydataimpl.cpp \
+ access/qnetworkreplyfileimpl.cpp \
access/qabstractnetworkcache.cpp \
- access/qnetworkdiskcache.cpp
+ access/qnetworkdiskcache.cpp \
+ access/qhttpthreaddelegate.cpp
include($$PWD/../../3rdparty/zlib_dependency.pri)
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index c2eca8a..29ae5b0 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -119,6 +119,7 @@ void QHttpNetworkConnectionPrivate::init()
{
for (int i = 0; i < channelCount; i++) {
channels[i].setConnection(this->q_func());
+ channels[i].ssl = encrypt;
channels[i].init();
}
}
@@ -285,7 +286,13 @@ void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket,
int i = indexOf(socket);
// remove the corrupt data if any
reply->d_func()->eraseData();
+
+ // Clean the channel
channels[i].close();
+ channels[i].reply = 0;
+ channels[i].request = QHttpNetworkRequest();
+ channels[i].requeueCurrentlyPipelinedRequests();
+
// send the next request
QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
}
@@ -480,7 +487,7 @@ void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)
QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
}
-void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socket)
+bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)
{
Q_ASSERT(socket);
@@ -493,8 +500,7 @@ void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socke
prepareRequest(messagePair);
channels[i].request = messagePair.first;
channels[i].reply = messagePair.second;
- channels[i].sendRequest();
- return;
+ return true;
}
if (!lowPriorityQueue.isEmpty()) {
@@ -504,9 +510,9 @@ void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socke
prepareRequest(messagePair);
channels[i].request = messagePair.first;
channels[i].reply = messagePair.second;
- channels[i].sendRequest();
- return;
+ return true;
}
+ return false;
}
// this is called from _q_startNextRequest and when a request has been sent down a socket from the channel
@@ -557,33 +563,35 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket)
|| channels[i].state == QHttpNetworkConnectionChannel::ReadingState))
return;
-
- //qDebug() << "QHttpNetworkConnectionPrivate::fillPipeline processing highPriorityQueue, size=" << highPriorityQueue.size() << " alreadyPipelined=" << channels[i].alreadyPipelinedRequests.length();
int lengthBefore;
while (!highPriorityQueue.isEmpty()) {
lengthBefore = channels[i].alreadyPipelinedRequests.length();
fillPipeline(highPriorityQueue, channels[i]);
- if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength)
+ if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {
+ channels[i].pipelineFlush();
return;
+ }
if (lengthBefore == channels[i].alreadyPipelinedRequests.length())
break; // did not process anything, now do the low prio queue
}
- //qDebug() << "QHttpNetworkConnectionPrivate::fillPipeline processing lowPriorityQueue, size=" << lowPriorityQueue.size() << " alreadyPipelined=" << channels[i].alreadyPipelinedRequests.length();
while (!lowPriorityQueue.isEmpty()) {
lengthBefore = channels[i].alreadyPipelinedRequests.length();
fillPipeline(lowPriorityQueue, channels[i]);
- if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength)
+ if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {
+ channels[i].pipelineFlush();
return;
+ }
if (lengthBefore == channels[i].alreadyPipelinedRequests.length())
break; // did not process anything
}
+ channels[i].pipelineFlush();
}
// returns true when the processing of a queue has been done
@@ -756,7 +764,7 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
//resend the necessary ones.
for (int i = 0; i < channelCount; ++i) {
- if (channels[i].resendCurrent) {
+ if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {
channels[i].resendCurrent = false;
channels[i].state = QHttpNetworkConnectionChannel::IdleState;
@@ -775,17 +783,8 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
// try to get a free AND connected socket
for (int i = 0; i < channelCount; ++i) {
if (!channels[i].reply && !channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
- dequeueAndSendRequest(channels[i].socket);
- }
- }
-
- // return fast if there is nothing to do
- if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
- return;
- // try to get a free unconnected socket
- for (int i = 0; i < channelCount; ++i) {
- if (!channels[i].reply && !channels[i].isSocketBusy()) {
- dequeueAndSendRequest(channels[i].socket);
+ if (dequeueRequest(channels[i].socket))
+ channels[i].sendRequest();
}
}
@@ -802,6 +801,21 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
for (int i = 0; i < channelCount; i++)
if (channels[i].socket->state() == QAbstractSocket::ConnectedState)
fillPipeline(channels[i].socket);
+
+ // If there is not already any connected channels we need to connect a new one.
+ // We do not pair the channel with the request until we know if it is
+ // connected or not. This is to reuse connected channels before we connect new once.
+ int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count();
+ for (int i = 0; i < channelCount; ++i) {
+ if (channels[i].socket->state() == QAbstractSocket::ConnectingState)
+ queuedRequest--;
+ if ( queuedRequest <=0 )
+ break;
+ if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState)) {
+ channels[i].ensureConnection();
+ queuedRequest--;
+ }
+ }
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index d4748c1..874ea22 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -161,7 +161,7 @@ public:
QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request);
void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke
- void dequeueAndSendRequest(QAbstractSocket *socket);
+ bool dequeueRequest(QAbstractSocket *socket);
void prepareRequest(HttpMessagePair &request);
void fillPipeline(QAbstractSocket *socket);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 700b455..6564b4b 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE
QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel()
: socket(0)
+ , ssl(false)
, state(IdleState)
, reply(0)
, written(0)
@@ -90,11 +91,10 @@ void QHttpNetworkConnectionChannel::init()
#else
socket = new QTcpSocket;
#endif
-
- // limit the socket read buffer size. we will read everything into
- // the QHttpNetworkReply anyway, so let's grow only that and not
- // here and there.
- socket->setReadBufferSize(64*1024);
+#ifndef QT_NO_NETWORKPROXY
+ // Set by QNAM anyway, but let's be safe here
+ socket->setProxy(QNetworkProxy::NoProxy);
+#endif
QObject::connect(socket, SIGNAL(bytesWritten(qint64)),
this, SLOT(_q_bytesWritten(qint64)),
@@ -147,10 +147,12 @@ void QHttpNetworkConnectionChannel::init()
void QHttpNetworkConnectionChannel::close()
{
- socket->blockSignals(true);
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ state = QHttpNetworkConnectionChannel::IdleState;
+ else
+ state = QHttpNetworkConnectionChannel::ClosingState;
+
socket->close();
- socket->blockSignals(false);
- state = QHttpNetworkConnectionChannel::IdleState;
}
@@ -174,11 +176,12 @@ bool QHttpNetworkConnectionChannel::sendRequest()
written = 0; // excluding the header
bytesTotal = 0;
- reply->d_func()->clear();
- reply->d_func()->connection = connection;
- reply->d_func()->connectionChannel = this;
- reply->d_func()->autoDecompress = request.d->autoDecompress;
- reply->d_func()->pipeliningUsed = false;
+ QHttpNetworkReplyPrivate *replyPrivate = reply->d_func();
+ replyPrivate->clear();
+ replyPrivate->connection = connection;
+ replyPrivate->connectionChannel = this;
+ replyPrivate->autoDecompress = request.d->autoDecompress;
+ replyPrivate->pipeliningUsed = false;
// if the url contains authentication parameters, use the new ones
// both channels will use the new authentication parameters
@@ -254,7 +257,7 @@ bool QHttpNetworkConnectionChannel::sendRequest()
#endif
{
// get pointer to upload data
- qint64 currentReadSize;
+ qint64 currentReadSize = 0;
qint64 desiredReadSize = qMin(socketWriteMaxSize, bytesTotal - written);
const char *readPointer = uploadByteDevice->readPointer(desiredReadSize, currentReadSize);
@@ -337,7 +340,6 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
return;
}
- qint64 bytes = 0;
QAbstractSocket::SocketState socketState = socket->state();
// connection might be closed to signal the end of data
@@ -358,12 +360,14 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
}
// read loop for the response
- while (socket->bytesAvailable()) {
+ qint64 bytes = 0;
+ qint64 lastBytes = bytes;
+ do {
+ lastBytes = bytes;
+
QHttpNetworkReplyPrivate::ReplyState state = reply->d_func()->state;
switch (state) {
case QHttpNetworkReplyPrivate::NothingDoneState: {
- // only eat whitespace on the first call
- eatWhitespace();
state = reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;
// fallthrough
}
@@ -387,6 +391,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
return;
}
bytes += headerBytes;
+ // If headers were parsed successfully now it is the ReadingDataState
if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) {
if (replyPrivate->isGzipped() && replyPrivate->autoDecompress) {
// remove the Content-Length from header
@@ -401,6 +406,10 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
}
if (replyPrivate->shouldEmitSignals())
emit reply->headerChanged();
+ // After headerChanged had been emitted
+ // we can suddenly have a replyPrivate->userProvidedDownloadBuffer
+ // this is handled in the ReadingDataState however
+
if (!replyPrivate->expectContent()) {
replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState;
allDone();
@@ -422,22 +431,29 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
// to the read buffer maximum size, but we don't care since they should be small.
return;
}
- if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress
- && replyPrivate->bodyLength > 0) {
- // bulk files like images should fulfill these properties and
- // we can therefore save on memory copying
- bytes = replyPrivate->readBodyFast(socket, &replyPrivate->responseData);
- replyPrivate->totalProgress += bytes;
+
+ if (replyPrivate->userProvidedDownloadBuffer) {
+ // the user provided a direct buffer where we should put all our data in.
+ // this only works when we can tell the user the content length and he/she can allocate
+ // the buffer in that size.
+ // note that this call will read only from the still buffered data
+ qint64 haveRead = replyPrivate->readBodyVeryFast(socket, replyPrivate->userProvidedDownloadBuffer + replyPrivate->totalProgress);
+ bytes += haveRead;
+ replyPrivate->totalProgress += haveRead;
+
+ // the user will get notified of it via progress signal
+ if (haveRead > 0)
+ emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);
+ } else if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress
+ && replyPrivate->bodyLength > 0) {
+ // bulk files like images should fulfill these properties and
+ // we can therefore save on memory copying
+ qint64 haveRead = replyPrivate->readBodyFast(socket, &replyPrivate->responseData);
+ bytes += haveRead;
+ replyPrivate->totalProgress += haveRead;
if (replyPrivate->shouldEmitSignals()) {
- QPointer<QHttpNetworkReply> replyPointer = reply;
emit reply->readyRead();
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return;
emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return;
}
}
else
@@ -445,8 +461,9 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
// use the traditional slower reading (for compressed encoding, chunked encoding,
// no content-length etc)
QByteDataBuffer byteDatas;
- bytes = replyPrivate->readBody(socket, &byteDatas);
- if (bytes) {
+ qint64 haveRead = replyPrivate->readBody(socket, &byteDatas);
+ if (haveRead) {
+ bytes += haveRead;
if (replyPrivate->autoDecompress)
replyPrivate->appendCompressedReplyData(byteDatas);
else
@@ -455,22 +472,16 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
if (!replyPrivate->autoDecompress) {
replyPrivate->totalProgress += bytes;
if (replyPrivate->shouldEmitSignals()) {
- QPointer<QHttpNetworkReply> replyPointer = reply;
// important: At the point of this readyRead(), the byteDatas list must be empty,
// else implicit sharing will trigger memcpy when the user is reading data!
emit reply->readyRead();
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return;
emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return;
}
}
#ifndef QT_NO_COMPRESS
else if (!expand(false)) { // expand a chunk if possible
- return; // ### expand failed
+ // If expand() failed we can just return, it had already called connection->emitReplyError()
+ return;
}
#endif
}
@@ -487,12 +498,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
default:
break;
}
- }
+ } while (bytes != lastBytes && reply);
}
// called when unexpectedly reading a -1 or when data is expected but socket is closed
void QHttpNetworkConnectionChannel::handleUnexpectedEOF()
{
+ Q_ASSERT(reply);
if (reconnectAttempts <= 0) {
// too many errors reading/receiving/parsing the status, close the socket and emit error
requeueCurrentlyPipelinedRequests();
@@ -515,7 +527,8 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
// resend this request after we receive the disconnected signal
if (socketState == QAbstractSocket::ClosingState) {
- resendCurrent = true;
+ if (reply)
+ resendCurrent = true;
return false;
}
@@ -530,7 +543,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
if (socketState != QAbstractSocket::ConnectedState) {
// connect to the host if not already connected.
state = QHttpNetworkConnectionChannel::ConnectingState;
- pendingEncrypt = connection->d_func()->encrypt;
+ pendingEncrypt = ssl;
// reset state
pipeliningSupported = PipeliningSupportUnknown;
@@ -553,23 +566,46 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
#ifndef QT_NO_NETWORKPROXY
// HTTPS always use transparent proxy.
- if (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy && !connection->d_func()->encrypt) {
+ if (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy && !ssl) {
connectHost = connection->d_func()->networkProxy.hostName();
connectPort = connection->d_func()->networkProxy.port();
}
#endif
- if (connection->d_func()->encrypt) {
+ if (ssl) {
#ifndef QT_NO_OPENSSL
QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket);
sslSocket->connectToHostEncrypted(connectHost, connectPort);
if (ignoreAllSslErrors)
sslSocket->ignoreSslErrors();
sslSocket->ignoreSslErrors(ignoreSslErrorsList);
+
+ // limit the socket read buffer size. we will read everything into
+ // the QHttpNetworkReply anyway, so let's grow only that and not
+ // here and there.
+ socket->setReadBufferSize(64*1024);
#else
connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);
#endif
} else {
- socket->connectToHost(connectHost, connectPort);
+ // In case of no proxy we can use the Unbuffered QTcpSocket
+#ifndef QT_NO_NETWORKPROXY
+ if (connection->d_func()->networkProxy.type() == QNetworkProxy::NoProxy
+ && connection->cacheProxy().type() == QNetworkProxy::NoProxy
+ && connection->transparentProxy().type() == QNetworkProxy::NoProxy) {
+#endif
+ socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered);
+ // For an Unbuffered QTcpSocket, the read buffer size has a special meaning.
+ socket->setReadBufferSize(1*1024);
+#ifndef QT_NO_NETWORKPROXY
+ } else {
+ socket->connectToHost(connectHost, connectPort);
+
+ // limit the socket read buffer size. we will read everything into
+ // the QHttpNetworkReply anyway, so let's grow only that and not
+ // here and there.
+ socket->setReadBufferSize(64*1024);
+ }
+#endif
}
return false;
}
@@ -599,18 +635,10 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete)
reply->d_func()->totalProgress += inflated.size();
reply->d_func()->appendUncompressedReplyData(inflated);
if (reply->d_func()->shouldEmitSignals()) {
- QPointer<QHttpNetworkReply> replyPointer = reply;
// important: At the point of this readyRead(), inflated must be cleared,
// else implicit sharing will trigger memcpy when the user is reading data!
emit reply->readyRead();
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return true;
emit reply->dataReadProgress(reply->d_func()->totalProgress, 0);
- // make sure that the reply is valid
- if (replyPointer.isNull())
- return true;
-
}
}
} else {
@@ -625,32 +653,44 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete)
void QHttpNetworkConnectionChannel::allDone()
{
+ Q_ASSERT(reply);
#ifndef QT_NO_COMPRESS
// expand the whole data.
- if (reply->d_func()->expectContent() && reply->d_func()->autoDecompress && !reply->d_func()->streamEnd)
- expand(true); // ### if expand returns false, its an error
+ if (reply->d_func()->expectContent() && reply->d_func()->autoDecompress && !reply->d_func()->streamEnd) {
+ bool expandResult = expand(true);
+ // If expand() failed we can just return, it had already called connection->emitReplyError()
+ if (!expandResult)
+ return;
+ }
#endif
+
+ if (!reply) {
+ qWarning() << "QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt.nokia.com/";
+ return;
+ }
+
// while handling 401 & 407, we might reset the status code, so save this.
bool emitFinished = reply->d_func()->shouldEmitSignals();
- handleStatus();
- // ### at this point there should be no more data on the socket
- // close if server requested
bool connectionCloseEnabled = reply->d_func()->isConnectionCloseEnabled();
- if (connectionCloseEnabled)
- close();
+ detectPipeliningSupport();
+
+ handleStatus();
+ // handleStatus() might have removed the reply because it already called connection->emitReplyError()
+
// queue the finished signal, this is required since we might send new requests from
// slot connected to it. The socket will not fire readyRead signal, if we are already
// in the slot connected to readyRead
- if (emitFinished)
+ if (reply && emitFinished)
QMetaObject::invokeMethod(reply, "finished", Qt::QueuedConnection);
+
+
// reset the reconnection attempts after we receive a complete reply.
// in case of failures, each channel will attempt two reconnects before emitting error.
reconnectAttempts = 2;
- detectPipeliningSupport();
-
// now the channel can be seen as free/idle again, all signal emissions for the reply have been done
- this->state = QHttpNetworkConnectionChannel::IdleState;
+ if (state != QHttpNetworkConnectionChannel::ClosingState)
+ state = QHttpNetworkConnectionChannel::IdleState;
// if it does not need to be sent again we can set it to 0
// the previous code did not do that and we had problems with accidental re-sending of a
@@ -688,12 +728,20 @@ void QHttpNetworkConnectionChannel::allDone()
// this was wrong, allDone gets called from that function anyway.
}
} else if (alreadyPipelinedRequests.isEmpty() && socket->bytesAvailable() > 0) {
- eatWhitespace();
// this is weird. we had nothing pipelined but still bytes available. better close it.
- if (socket->bytesAvailable() > 0)
- close();
+ //if (socket->bytesAvailable() > 0)
+ // close();
+ //
+ // FIXME
+ // We do not close it anymore now, but should introduce this again after having fixed
+ // the chunked decoder in QHttpNetworkReply to read the whitespace after the last chunk.
+ // (Currently this is worked around by readStatus in the QHttpNetworkReply ignoring
+ // leading whitespace.
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} else if (alreadyPipelinedRequests.isEmpty()) {
+ if (connectionCloseEnabled)
+ if (socket->state() != QAbstractSocket::UnconnectedState)
+ close();
if (qobject_cast<QHttpNetworkConnection*>(connection))
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
@@ -701,6 +749,7 @@ void QHttpNetworkConnectionChannel::allDone()
void QHttpNetworkConnectionChannel::detectPipeliningSupport()
{
+ Q_ASSERT(reply);
// detect HTTP Pipelining support
QByteArray serverHeaderField;
if (
@@ -738,30 +787,6 @@ void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests()
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
-void QHttpNetworkConnectionChannel::eatWhitespace()
-{
- char c;
- do {
- qint64 ret = socket->peek(&c, 1);
-
- // nothing read, fine.
- if (ret == 0)
- return;
-
- // EOF from socket?
- if (ret == -1)
- return; // FIXME, we need to stop processing. however the next stuff done will also do that.
-
- // read all whitespace and line endings
- if (c == 11 || c == '\n' || c == '\r' || c == ' ' || c == 31) {
- socket->read(&c, 1);
- continue;
- } else {
- break;
- }
- } while(true);
-}
-
void QHttpNetworkConnectionChannel::handleStatus()
{
Q_ASSERT(socket);
@@ -808,6 +833,7 @@ void QHttpNetworkConnectionChannel::handleStatus()
bool QHttpNetworkConnectionChannel::resetUploadData()
{
+ Q_ASSERT(reply);
QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
if (!uploadByteDevice)
return true;
@@ -822,7 +848,7 @@ bool QHttpNetworkConnectionChannel::resetUploadData()
}
-void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
+void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
{
// this is only called for simple GET
@@ -835,21 +861,38 @@ void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
reply->d_func()->pipeliningUsed = true;
#ifndef QT_NO_NETWORKPROXY
- QByteArray header = QHttpNetworkRequestPrivate::header(request,
- (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy));
+ pipeline.append(QHttpNetworkRequestPrivate::header(request,
+ (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy)));
#else
- QByteArray header = QHttpNetworkRequestPrivate::header(request, false);
+ pipeline.append(QHttpNetworkRequestPrivate::header(request, false));
#endif
- socket->write(header);
alreadyPipelinedRequests.append(pair);
+
+ // pipelineFlush() needs to be called at some point afterwards
}
+void QHttpNetworkConnectionChannel::pipelineFlush()
+{
+ if (pipeline.isEmpty())
+ return;
+
+ // The goal of this is so that we have everything in one TCP packet.
+ // For the Unbuffered QTcpSocket this is manually needed, the buffered
+ // QTcpSocket does it automatically.
+ // Also, sometimes the OS does it for us (Nagle's algorithm) but that
+ // happens only sometimes.
+ socket->write(pipeline);
+ pipeline.clear();
+}
+
+
void QHttpNetworkConnectionChannel::closeAndResendCurrentRequest()
{
requeueCurrentlyPipelinedRequests();
close();
- resendCurrent = true;
+ if (reply)
+ resendCurrent = true;
if (qobject_cast<QHttpNetworkConnection*>(connection))
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
@@ -877,6 +920,22 @@ bool QHttpNetworkConnectionChannel::isSocketReading() const
//private slots
void QHttpNetworkConnectionChannel::_q_readyRead()
{
+ if (socket->state() == QAbstractSocket::ConnectedState && socket->bytesAvailable() == 0) {
+ // We got a readyRead but no bytes are available..
+ // This happens for the Unbuffered QTcpSocket
+ // Also check if socket is in ConnectedState since
+ // this function may also be invoked via the event loop.
+ char c;
+ qint64 ret = socket->peek(&c, 1);
+ if (ret < 0) {
+ _q_error(socket->error());
+ // We still need to handle the reply so it emits its signals etc.
+ if (reply)
+ _q_receiveReply();
+ return;
+ }
+ }
+
if (isSocketWaiting() || isSocketReading()) {
state = QHttpNetworkConnectionChannel::ReadingState;
if (reply)
@@ -895,6 +954,12 @@ void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes)
void QHttpNetworkConnectionChannel::_q_disconnected()
{
+ if (state == QHttpNetworkConnectionChannel::ClosingState) {
+ state = QHttpNetworkConnectionChannel::IdleState;
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ return;
+ }
+
// read the available data before closing
if (isSocketWaiting() || isSocketReading()) {
if (reply) {
@@ -932,10 +997,10 @@ void QHttpNetworkConnectionChannel::_q_connected()
//channels[i].reconnectAttempts = 2;
if (!pendingEncrypt) {
state = QHttpNetworkConnectionChannel::IdleState;
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
if (reply)
sendRequest();
- else
- close();
}
}
@@ -1001,6 +1066,9 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
QPointer<QHttpNetworkConnection> that = connection;
QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString());
+ // Need to dequeu the request so that we can emit the error.
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
if (reply) {
reply->d_func()->errorString = errorString;
emit reply->finishedWithError(errorCode, errorString);
@@ -1016,7 +1084,11 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
#ifndef QT_NO_NETWORKPROXY
void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth)
{
- connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
+ // Need to dequeue the request before we can emit the error.
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
}
#endif
@@ -1032,7 +1104,10 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
return; // ### error
state = QHttpNetworkConnectionChannel::IdleState;
pendingEncrypt = false;
- sendRequest();
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ sendRequest();
}
void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
@@ -1043,7 +1118,10 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
// Also pause the connection because socket notifiers may fire while an user
// dialog is displaying
connection->d_func()->pauseConnection();
- emit reply->sslErrors(errors);
+ if (pendingEncrypt && !reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ emit reply->sslErrors(errors);
connection->d_func()->resumeConnection();
}
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index 22a0d6f..893d75e 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -95,9 +95,11 @@ public:
WritingState = 2, // writing the data
WaitingState = 4, // waiting for reply
ReadingState = 8, // reading the reply
- BusyState = (ConnectingState|WritingState|WaitingState|ReadingState)
+ ClosingState = 16,
+ BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|ClosingState)
};
QAbstractSocket *socket;
+ bool ssl;
ChannelState state;
QHttpNetworkRequest request; // current request
QHttpNetworkReply *reply; // current reply for this request
@@ -124,7 +126,11 @@ public:
};
PipeliningSupport pipeliningSupported;
QList<HttpMessagePair> alreadyPipelinedRequests;
-
+ QByteArray pipeline; // temporary buffer that gets sent to socket in pipelineFlush
+ void pipelineInto(HttpMessagePair &pair);
+ void pipelineFlush();
+ void requeueCurrentlyPipelinedRequests();
+ void detectPipeliningSupport();
QHttpNetworkConnectionChannel();
@@ -144,15 +150,9 @@ public:
bool resetUploadData(); // return true if resetting worked or there is no upload data
- void pipelineInto(HttpMessagePair &pair);
- void requeueCurrentlyPipelinedRequests();
- void detectPipeliningSupport();
-
void handleUnexpectedEOF();
void closeAndResendCurrentRequest();
- void eatWhitespace();
-
bool isSocketBusy() const;
bool isSocketWriting() const;
bool isSocketWaiting() const;
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index e608005..704cf3a 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -119,6 +119,7 @@ void QHttpNetworkReply::setRequest(const QHttpNetworkRequest &request)
{
Q_D(QHttpNetworkReply);
d->request = request;
+ d->ssl = request.isSsl();
}
int QHttpNetworkReply::statusCode() const
@@ -176,6 +177,12 @@ qint64 QHttpNetworkReply::bytesAvailableNextBlock() const
return -1;
}
+bool QHttpNetworkReply::readAnyAvailable() const
+{
+ Q_D(const QHttpNetworkReply);
+ return (d->responseData.bufferCount() > 0);
+}
+
QByteArray QHttpNetworkReply::readAny()
{
Q_D(QHttpNetworkReply);
@@ -201,6 +208,25 @@ void QHttpNetworkReply::setDownstreamLimited(bool dsl)
d->connection->d_func()->readMoreLater(this);
}
+bool QHttpNetworkReply::supportsUserProvidedDownloadBuffer()
+{
+ Q_D(QHttpNetworkReply);
+ return (!d->isChunked() && !d->autoDecompress && d->bodyLength > 0);
+}
+
+void QHttpNetworkReply::setUserProvidedDownloadBuffer(char* b)
+{
+ Q_D(QHttpNetworkReply);
+ if (supportsUserProvidedDownloadBuffer())
+ d->userProvidedDownloadBuffer = b;
+}
+
+char* QHttpNetworkReply::userProvidedDownloadBuffer()
+{
+ Q_D(QHttpNetworkReply);
+ return d->userProvidedDownloadBuffer;
+}
+
bool QHttpNetworkReply::isFinished() const
{
return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState;
@@ -218,7 +244,10 @@ QHttpNetworkConnection* QHttpNetworkReply::connection()
QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
- : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100),
+ : QHttpNetworkHeaderPrivate(newUrl)
+ , state(NothingDoneState)
+ , ssl(false)
+ , statusCode(100),
majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0),
chunkedTransferEncoding(false),
connectionCloseEnabled(true),
@@ -226,6 +255,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
autoDecompress(false), responseData(), requestIsPrepared(false)
,pipeliningUsed(false), downstreamLimited(false)
+ ,userProvidedDownloadBuffer(0)
{
}
@@ -459,6 +489,8 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket)
return -1; // unexpected EOF
else if (haveRead == 0)
break; // read more later
+ else if (haveRead == 1 && bytes == 0 && (c == 11 || c == '\n' || c == '\r' || c == ' ' || c == 31))
+ continue; // Ignore all whitespace that was trailing froma previous request on that socket
bytes++;
@@ -634,12 +666,32 @@ bool QHttpNetworkReplyPrivate::isConnectionCloseEnabled()
// note this function can only be used for non-chunked, non-compressed with
// known content length
+qint64 QHttpNetworkReplyPrivate::readBodyVeryFast(QAbstractSocket *socket, char *b)
+{
+ // This first read is to flush the buffer inside the socket
+ qint64 haveRead = 0;
+ haveRead = socket->read(b, bodyLength - contentRead);
+ if (haveRead == -1) {
+ return 0; // ### error checking here;
+ }
+ contentRead += haveRead;
+
+ if (contentRead == bodyLength) {
+ state = AllDoneState;
+ }
+
+ return haveRead;
+}
+
+// note this function can only be used for non-chunked, non-compressed with
+// known content length
qint64 QHttpNetworkReplyPrivate::readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb)
{
+
qint64 toBeRead = qMin(socket->bytesAvailable(), bodyLength - contentRead);
QByteArray bd;
bd.resize(toBeRead);
- qint64 haveRead = socket->read(bd.data(), bd.size());
+ qint64 haveRead = socket->read(bd.data(), toBeRead);
if (haveRead == -1) {
bd.clear();
return 0; // ### error checking here;
@@ -661,29 +713,34 @@ qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QByteDataBuff
{
qint64 bytes = 0;
if (isChunked()) {
- bytes += readReplyBodyChunked(socket, out); // chunked transfer encoding (rfc 2616, sec 3.6)
- } else if (bodyLength > 0) { // we have a Content-Length
+ // chunked transfer encoding (rfc 2616, sec 3.6)
+ bytes += readReplyBodyChunked(socket, out);
+ } else if (bodyLength > 0) {
+ // we have a Content-Length
bytes += readReplyBodyRaw(socket, out, bodyLength - contentRead);
if (contentRead + bytes == bodyLength)
state = AllDoneState;
} else {
+ // no content length. just read what's possible
bytes += readReplyBodyRaw(socket, out, socket->bytesAvailable());
}
contentRead += bytes;
return bytes;
}
-qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size)
+qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QAbstractSocket *socket, QByteDataBuffer *out, qint64 size)
{
+ // FIXME get rid of this function and just use readBodyFast and give it socket->bytesAvailable()
qint64 bytes = 0;
- Q_ASSERT(in);
+ Q_ASSERT(socket);
Q_ASSERT(out);
- int toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, in->bytesAvailable()));
+ int toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, socket->bytesAvailable()));
+
while (toBeRead > 0) {
QByteArray byteData;
byteData.resize(toBeRead);
- qint64 haveRead = in->read(byteData.data(), byteData.size());
+ qint64 haveRead = socket->read(byteData.data(), byteData.size());
if (haveRead <= 0) {
// ### error checking here
byteData.clear();
@@ -695,25 +752,35 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QIODevice *in, QByteDataBuffer
bytes += haveRead;
size -= haveRead;
- toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, in->bytesAvailable()));
+ toBeRead = qMin<qint64>(128*1024, qMin<qint64>(size, socket->bytesAvailable()));
}
return bytes;
}
-qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out)
+qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QAbstractSocket *socket, QByteDataBuffer *out)
{
qint64 bytes = 0;
- while (in->bytesAvailable()) { // while we can read from input
- // if we are done with the current chunk, get the size of the new chunk
+ while (socket->bytesAvailable()) {
if (currentChunkRead >= currentChunkSize) {
+ // For the first chunk and when we're done with a chunk
currentChunkSize = 0;
currentChunkRead = 0;
if (bytes) {
+ // After a chunk
char crlf[2];
- bytes += in->read(crlf, 2); // read the "\r\n" after the chunk
+ // read the "\r\n" after the chunk
+ qint64 haveRead = socket->read(crlf, 2);
+ // FIXME: This code is slightly broken and not optimal. What if the 2 bytes are not available yet?!
+ // For nice reasons (the toLong in getChunkSize accepting \n at the beginning
+ // it right now still works, but we should definitely fix this.
+
+ if (haveRead != 2)
+ return bytes; // FIXME
+ bytes += haveRead;
}
- bytes += getChunkSize(in, &currentChunkSize);
+ // Note that chunk size gets stored in currentChunkSize, what is returned is the bytes read
+ bytes += getChunkSize(socket, &currentChunkSize);
if (currentChunkSize == -1)
break;
}
@@ -723,8 +790,8 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBu
break;
}
- // otherwise, try to read what is missing for this chunk
- qint64 haveRead = readReplyBodyRaw (in, out, currentChunkSize - currentChunkRead);
+ // otherwise, try to begin reading this chunk / to read what is missing for this chunk
+ qint64 haveRead = readReplyBodyRaw (socket, out, currentChunkSize - currentChunkRead);
currentChunkRead += haveRead;
bytes += haveRead;
@@ -734,22 +801,25 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBu
return bytes;
}
-qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize)
+qint64 QHttpNetworkReplyPrivate::getChunkSize(QAbstractSocket *socket, qint64 *chunkSize)
{
qint64 bytes = 0;
char crlf[2];
*chunkSize = -1;
- int bytesAvailable = in->bytesAvailable();
+
+ int bytesAvailable = socket->bytesAvailable();
+ // FIXME rewrite to permanent loop without bytesAvailable
while (bytesAvailable > bytes) {
- qint64 sniffedBytes = in->peek(crlf, 2);
+ qint64 sniffedBytes = socket->peek(crlf, 2);
int fragmentSize = fragment.size();
+
// check the next two bytes for a "\r\n", skip blank lines
if ((fragmentSize && sniffedBytes == 2 && crlf[0] == '\r' && crlf[1] == '\n')
||(fragmentSize > 1 && fragment.endsWith('\r') && crlf[0] == '\n'))
{
- bytes += in->read(crlf, 1); // read the \r or \n
+ bytes += socket->read(crlf, 1); // read the \r or \n
if (crlf[0] == '\r')
- bytes += in->read(crlf, 1); // read the \n
+ bytes += socket->read(crlf, 1); // read the \n
bool ok = false;
// ignore the chunk-extension
fragment = fragment.mid(0, fragment.indexOf(';')).trimmed();
@@ -759,10 +829,15 @@ qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize)
} else {
// read the fragment to the buffer
char c = 0;
- bytes += in->read(&c, 1);
+ qint64 haveRead = socket->read(&c, 1);
+ if (haveRead < 0) {
+ return -1; // FIXME
+ }
+ bytes += haveRead;
fragment.append(c);
}
}
+
return bytes;
}
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index 812de7d..cc0f671 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -125,10 +125,15 @@ public:
qint64 bytesAvailable() const;
qint64 bytesAvailableNextBlock() const;
+ bool readAnyAvailable() const;
QByteArray readAny();
QByteArray readAll();
void setDownstreamLimited(bool t);
+ bool supportsUserProvidedDownloadBuffer();
+ void setUserProvidedDownloadBuffer(char*);
+ char* userProvidedDownloadBuffer();
+
bool isFinished() const;
bool isPipeliningUsed() const;
@@ -150,6 +155,7 @@ Q_SIGNALS:
void finished();
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
void headerChanged();
+ // FIXME we need to change this to qint64!
void dataReadProgress(int done, int total);
void dataSendProgress(qint64 done, qint64 total);
void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator);
@@ -175,15 +181,16 @@ public:
qint64 readHeader(QAbstractSocket *socket);
void parseHeader(const QByteArray &header);
qint64 readBody(QAbstractSocket *socket, QByteDataBuffer *out);
+ qint64 readBodyVeryFast(QAbstractSocket *socket, char *b);
qint64 readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb);
bool findChallenge(bool forProxy, QByteArray &challenge) const;
QAuthenticatorPrivate::Method authenticationMethod(bool isProxy) const;
void clear();
void clearHttpLayerInformation();
- qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size);
- qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out);
- qint64 getChunkSize(QIODevice *in, qint64 *chunkSize);
+ qint64 readReplyBodyRaw(QAbstractSocket *in, QByteDataBuffer *out, qint64 size);
+ qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out);
+ qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize);
void appendUncompressedReplyData(QByteArray &qba);
void appendUncompressedReplyData(QByteDataBuffer &data);
@@ -212,6 +219,7 @@ public:
} state;
QHttpNetworkRequest request;
+ bool ssl;
int statusCode;
int majorVersion;
int minorVersion;
@@ -241,6 +249,8 @@ public:
bool pipeliningUsed;
bool downstreamLimited;
+
+ char* userProvidedDownloadBuffer;
};
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 5e5222e..8573364 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -63,6 +63,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest
pipeliningAllowed = other.pipeliningAllowed;
customVerb = other.customVerb;
withCredentials = other.withCredentials;
+ ssl = other.ssl;
}
QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
@@ -73,6 +74,7 @@ bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &ot
{
return QHttpNetworkHeaderPrivate::operator==(other)
&& (operation == other.operation)
+ && (ssl == other.ssl)
&& (uploadByteDevice == other.uploadByteDevice);
}
@@ -199,6 +201,15 @@ void QHttpNetworkRequest::setUrl(const QUrl &url)
d->url = url;
}
+bool QHttpNetworkRequest::isSsl() const
+{
+ return d->ssl;
+}
+void QHttpNetworkRequest::setSsl(bool s)
+{
+ d->ssl = s;
+}
+
qint64 QHttpNetworkRequest::contentLength() const
{
return d->contentLength();
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index 0cf88f2..c7e9b0f 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -116,6 +116,9 @@ public:
bool withCredentials() const;
void setWithCredentials(bool b);
+ bool isSsl() const;
+ void setSsl(bool);
+
void setUploadByteDevice(QNonContiguousByteDevice *bd);
QNonContiguousByteDevice* uploadByteDevice() const;
@@ -146,6 +149,7 @@ public:
bool autoDecompress;
bool pipeliningAllowed;
bool withCredentials;
+ bool ssl;
};
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
new file mode 100644
index 0000000..81410a4
--- /dev/null
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -0,0 +1,518 @@
+/****************************************************************************
+**
+** 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 "qhttpthreaddelegate_p.h"
+
+#include <QThread>
+#include <QTimer>
+#include <QAuthenticator>
+#include <QEventLoop>
+
+#include "private/qhttpnetworkreply_p.h"
+#include "private/qnetworkaccesscache_p.h"
+#include "private/qnoncontiguousbytedevice_p.h"
+
+
+QT_BEGIN_NAMESPACE
+
+static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
+{
+ QNetworkReply::NetworkError code;
+ // we've got an error
+ switch (httpStatusCode) {
+ case 401: // Authorization required
+ code = QNetworkReply::AuthenticationRequiredError;
+ break;
+
+ case 403: // Access denied
+ code = QNetworkReply::ContentOperationNotPermittedError;
+ break;
+
+ case 404: // Not Found
+ code = QNetworkReply::ContentNotFoundError;
+ break;
+
+ case 405: // Method Not Allowed
+ code = QNetworkReply::ContentOperationNotPermittedError;
+ break;
+
+ case 407:
+ code = QNetworkReply::ProxyAuthenticationRequiredError;
+ break;
+
+ default:
+ if (httpStatusCode > 500) {
+ // some kind of server error
+ code = QNetworkReply::ProtocolUnknownError;
+ } else if (httpStatusCode >= 400) {
+ // content error we did not handle above
+ code = QNetworkReply::UnknownContentError;
+ } else {
+ qWarning("QNetworkAccess: got HTTP status code %d which is not expected from url: \"%s\"",
+ httpStatusCode, qPrintable(url.toString()));
+ code = QNetworkReply::ProtocolFailure;
+ }
+ }
+
+ return code;
+}
+
+
+static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy)
+{
+ QByteArray result;
+ QUrl copy = url;
+ bool isEncrypted = copy.scheme().toLower() == QLatin1String("https");
+ copy.setPort(copy.port(isEncrypted ? 443 : 80));
+ result = copy.toEncoded(QUrl::RemoveUserInfo | QUrl::RemovePath |
+ QUrl::RemoveQuery | QUrl::RemoveFragment);
+
+#ifndef QT_NO_NETWORKPROXY
+ if (proxy && proxy->type() != QNetworkProxy::NoProxy) {
+ 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;
+
+ default:
+ break;
+ }
+
+ if (!key.scheme().isEmpty()) {
+ key.setUserName(proxy->user());
+ key.setHost(proxy->hostName());
+ key.setPort(proxy->port());
+ key.setEncodedQuery(result);
+ result = key.toEncoded();
+ }
+ }
+#endif
+
+ return "http-connection:" + result;
+}
+
+class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection,
+ public QNetworkAccessCache::CacheableObject
+{
+ // Q_OBJECT
+public:
+ QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt)
+ : QHttpNetworkConnection(hostName, port, encrypt)
+ {
+ setExpires(true);
+ setShareable(true);
+ }
+
+ virtual void dispose()
+ {
+#if 0 // sample code; do this right with the API
+ Q_ASSERT(!isWorking());
+#endif
+ delete this;
+ }
+};
+
+
+QThreadStorage<QNetworkAccessCache *> QHttpThreadDelegate::connections;
+
+
+QHttpThreadDelegate::~QHttpThreadDelegate()
+{
+ // It could be that the main thread has asked us to shut down, so we need to delete the HTTP reply
+ if (httpReply) {
+ delete httpReply;
+ }
+
+ // Get the object cache that stores our QHttpNetworkConnection objects
+ // and release the entry for this QHttpNetworkConnection
+ if (connections.hasLocalData() && !cacheKey.isEmpty()) {
+ connections.localData()->releaseEntry(cacheKey);
+ }
+}
+
+
+QHttpThreadDelegate::QHttpThreadDelegate(QObject *parent) :
+ QObject(parent)
+ , ssl(false)
+ , downloadBufferMaximumSize(0)
+ , pendingDownloadData(0)
+ , pendingDownloadProgress(0)
+ , synchronous(false)
+ , incomingStatusCode(0)
+ , isPipeliningUsed(false)
+ , incomingContentLength(-1)
+ , incomingErrorCode(QNetworkReply::NoError)
+ , downloadBuffer(0)
+ , httpConnection(0)
+ , httpReply(0)
+{
+}
+
+// This is invoked as BlockingQueuedConnection from QNetworkAccessHttpBackend in the user thread
+void QHttpThreadDelegate::startRequestSynchronously()
+{
+ synchronous = true;
+
+ QEventLoop synchronousRequestLoop;
+ this->synchronousRequestLoop = &synchronousRequestLoop;
+
+ // Worst case timeout
+ QTimer::singleShot(30*1000, this, SLOT(abortRequest()));
+
+ QMetaObject::invokeMethod(this, "startRequest", Qt::QueuedConnection);
+ synchronousRequestLoop.exec();
+
+ connections.localData()->releaseEntry(cacheKey);
+ connections.setLocalData(0);
+
+}
+
+
+// This is invoked as QueuedConnection from QNetworkAccessHttpBackend in the user thread
+void QHttpThreadDelegate::startRequest()
+{
+ // Check QThreadStorage for the QNetworkAccessCache
+ // If not there, create this connection cache
+ if (!connections.hasLocalData()) {
+ connections.setLocalData(new QNetworkAccessCache());
+ }
+
+ // check if we have an open connection to this host
+ QUrl urlCopy = httpRequest.url();
+ urlCopy.setPort(urlCopy.port(ssl ? 443 : 80));
+
+ if (transparentProxy.type() != QNetworkProxy::NoProxy)
+ cacheKey = makeCacheKey(urlCopy, &transparentProxy);
+ else if (cacheProxy.type() != QNetworkProxy::NoProxy)
+ cacheKey = makeCacheKey(urlCopy, &cacheProxy);
+ else
+ cacheKey = makeCacheKey(urlCopy, 0);
+
+
+ // the http object is actually a QHttpNetworkConnection
+ httpConnection = static_cast<QNetworkAccessCachedHttpConnection *>(connections.localData()->requestEntryNow(cacheKey));
+ if (httpConnection == 0) {
+ // no entry in cache; create an object
+ // the http object is actually a QHttpNetworkConnection
+ httpConnection = new QNetworkAccessCachedHttpConnection(urlCopy.host(), urlCopy.port(), ssl);
+#ifndef QT_NO_OPENSSL
+ // Set the QSslConfiguration from this QNetworkRequest.
+ if (ssl) {
+ httpConnection->setSslConfiguration(incomingSslConfiguration);
+ }
+#endif
+
+#ifndef QT_NO_NETWORKPROXY
+ httpConnection->setTransparentProxy(transparentProxy);
+ httpConnection->setCacheProxy(cacheProxy);
+#endif
+
+ // cache the QHttpNetworkConnection corresponding to this cache key
+ connections.localData()->addEntry(cacheKey, httpConnection);
+ }
+
+
+ // Send the request to the connection
+ httpReply = httpConnection->sendRequest(httpRequest);
+ httpReply->setParent(this);
+
+ // Connect the reply signals that we need to handle and then forward
+ if (synchronous) {
+ connect(httpReply,SIGNAL(headerChanged()), this, SLOT(synchronousHeaderChangedSlot()));
+ connect(httpReply,SIGNAL(finished()), this, SLOT(synchronousFinishedSlot()));
+ connect(httpReply,SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString)),
+ this, SLOT(synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError,QString)));
+
+ connect(httpReply, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)),
+ this, SLOT(synchronousAuthenticationRequiredSlot(QHttpNetworkRequest,QAuthenticator*)));
+ connect(httpReply, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ this, SLOT(synchronousProxyAuthenticationRequiredSlot(QNetworkProxy,QAuthenticator*)));
+
+ // Don't care about ignored SSL errors for now in the synchronous HTTP case.
+ } else if (!synchronous) {
+ connect(httpReply,SIGNAL(headerChanged()), this, SLOT(headerChangedSlot()));
+ connect(httpReply,SIGNAL(finished()), this, SLOT(finishedSlot()));
+ connect(httpReply,SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString)),
+ this, SLOT(finishedWithErrorSlot(QNetworkReply::NetworkError,QString)));
+ // some signals are only interesting when normal asynchronous style is used
+ connect(httpReply,SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ connect(httpReply,SIGNAL(dataReadProgress(int, int)), this, SLOT(dataReadProgressSlot(int,int)));
+ connect(httpReply, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)),
+ this, SLOT(cacheCredentialsSlot(QHttpNetworkRequest,QAuthenticator*)));
+#ifndef QT_NO_OPENSSL
+ connect(httpReply,SIGNAL(sslErrors(const QList<QSslError>)), this, SLOT(sslErrorsSlot(QList<QSslError>)));
+#endif
+
+ // In the asynchronous HTTP case we can just forward those signals
+ // Connect the reply signals that we can directly forward
+ connect(httpReply, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)),
+ this, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)));
+ connect(httpReply, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
+ }
+}
+
+// This gets called from the user thread or by the synchronous HTTP timeout timer
+void QHttpThreadDelegate::abortRequest()
+{
+ if (httpReply) {
+ delete httpReply;
+ httpReply = 0;
+ this->deleteLater();
+ }
+
+ // Got aborted by the timeout timer
+ if (synchronous)
+ incomingErrorCode = QNetworkReply::TimeoutError;
+}
+
+void QHttpThreadDelegate::readyReadSlot()
+{
+ // Don't do in zerocopy case
+ if (!downloadBuffer.isNull())
+ return;
+
+ while (httpReply->readAnyAvailable()) {
+ pendingDownloadData->fetchAndAddRelease(1);
+ emit downloadData(httpReply->readAny());
+ }
+}
+
+void QHttpThreadDelegate::finishedSlot()
+{
+ if (!httpReply) {
+ qWarning() << "QHttpThreadDelegate::finishedSlot: HTTP reply had already been deleted, internal problem. Please report.";
+ return;
+ }
+
+ // If there is still some data left emit that now
+ while (httpReply->readAnyAvailable()) {
+ pendingDownloadData->fetchAndAddRelease(1);
+ emit downloadData(httpReply->readAny());
+ }
+
+#ifndef QT_NO_OPENSSL
+ if (ssl)
+ emit sslConfigurationChanged(httpReply->sslConfiguration());
+#endif
+
+ if (httpReply->statusCode() >= 400) {
+ // it's an error reply
+ QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
+ "Error downloading %1 - server replied: %2"));
+ msg = msg.arg(QString::fromAscii(httpRequest.url().toEncoded()), httpReply->reasonPhrase());
+ emit error(statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()), msg);
+ }
+
+ emit downloadFinished();
+
+ QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
+ httpReply = 0;
+}
+
+void QHttpThreadDelegate::synchronousFinishedSlot()
+{
+ if (httpReply->statusCode() >= 400) {
+ // it's an error reply
+ QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
+ "Error downloading %1 - server replied: %2"));
+ incomingErrorDetail = msg.arg(QString::fromAscii(httpRequest.url().toEncoded()), httpReply->reasonPhrase());
+ incomingErrorCode = statusCodeFromHttp(httpReply->statusCode(), httpRequest.url());
+ }
+
+ synchronousDownloadData = httpReply->readAll();
+
+ QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection);
+ httpReply = 0;
+}
+
+void QHttpThreadDelegate::finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail)
+{
+ if (!httpReply) {
+ qWarning() << "QHttpThreadDelegate::finishedWithErrorSlot: HTTP reply had already been deleted, internal problem. Please report.";
+ return;
+ }
+
+#ifndef QT_NO_OPENSSL
+ if (ssl)
+ emit sslConfigurationChanged(httpReply->sslConfiguration());
+#endif
+ emit error(errorCode,detail);
+ emit downloadFinished();
+
+
+ QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
+ httpReply = 0;
+}
+
+
+void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail)
+{
+ incomingErrorCode = errorCode;
+ incomingErrorDetail = detail;
+
+ QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection);
+ httpReply = 0;
+}
+
+static void downloadBufferDeleter(char *ptr)
+{
+ delete[] ptr;
+}
+
+void QHttpThreadDelegate::headerChangedSlot()
+{
+#ifndef QT_NO_OPENSSL
+ if (ssl)
+ emit sslConfigurationChanged(httpReply->sslConfiguration());
+#endif
+
+ // Is using a zerocopy buffer allowed by user and possible with this reply?
+ if (httpReply->supportsUserProvidedDownloadBuffer()
+ && downloadBufferMaximumSize > 0) {
+ char *buf = new char[httpReply->contentLength()]; // throws if allocation fails
+ if (buf) {
+ downloadBuffer = QSharedPointer<char>(buf, downloadBufferDeleter);
+ httpReply->setUserProvidedDownloadBuffer(buf);
+ }
+ }
+
+ // We fetch this into our own
+ incomingHeaders = httpReply->header();
+ incomingStatusCode = httpReply->statusCode();
+ incomingReasonPhrase = httpReply->reasonPhrase();
+ isPipeliningUsed = httpReply->isPipeliningUsed();
+ incomingContentLength = httpReply->contentLength();
+
+ emit downloadMetaData(incomingHeaders,
+ incomingStatusCode,
+ incomingReasonPhrase,
+ isPipeliningUsed,
+ downloadBuffer,
+ incomingContentLength);
+}
+
+void QHttpThreadDelegate::synchronousHeaderChangedSlot()
+{
+ // Store the information we need in this object, the QNetworkAccessHttpBackend will later read it
+ incomingHeaders = httpReply->header();
+ incomingStatusCode = httpReply->statusCode();
+ incomingReasonPhrase = httpReply->reasonPhrase();
+ isPipeliningUsed = httpReply->isPipeliningUsed();
+ incomingContentLength = httpReply->contentLength();
+}
+
+
+void QHttpThreadDelegate::dataReadProgressSlot(int done, int total)
+{
+ // If we don't have a download buffer don't attempt to go this codepath
+ // It is not used by QNetworkAccessHttpBackend
+ if (downloadBuffer.isNull())
+ return;
+
+ pendingDownloadProgress->fetchAndAddRelease(1);
+ emit downloadProgress(done, total);
+}
+
+void QHttpThreadDelegate::cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
+{
+ authenticationManager->cacheCredentials(request.url(), authenticator);
+}
+
+
+#ifndef QT_NO_OPENSSL
+void QHttpThreadDelegate::sslErrorsSlot(const QList<QSslError> &errors)
+{
+ emit sslConfigurationChanged(httpReply->sslConfiguration());
+
+ bool ignoreAll = false;
+ QList<QSslError> specificErrors;
+ emit sslErrors(errors, &ignoreAll, &specificErrors);
+ if (ignoreAll)
+ httpReply->ignoreSslErrors();
+ if (!specificErrors.isEmpty())
+ httpReply->ignoreSslErrors(specificErrors);
+}
+#endif
+
+void QHttpThreadDelegate::synchronousAuthenticationRequiredSlot(const QHttpNetworkRequest &request, QAuthenticator *a)
+{
+ Q_UNUSED(request);
+
+ // Ask the credential cache
+ QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedCredentials(httpRequest.url(), a);
+ if (!credential.isNull()) {
+ a->setUser(credential.user);
+ a->setPassword(credential.password);
+ }
+
+ // Disconnect this connection now since we only want to ask the authentication cache once.
+ QObject::disconnect(this, SLOT(synchronousAuthenticationRequiredSlot(QHttpNetworkRequest,QAuthenticator*)));
+}
+
+#ifndef QT_NO_NETWORKPROXY
+void QHttpThreadDelegate::synchronousProxyAuthenticationRequiredSlot(const QNetworkProxy &p, QAuthenticator *a)
+{
+ // Ask the credential cache
+ QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedProxyCredentials(p, a);
+ if (!credential.isNull()) {
+ a->setUser(credential.user);
+ a->setPassword(credential.password);
+ }
+
+ // Disconnect this connection now since we only want to ask the authentication cache once.
+ QObject::disconnect(this, SLOT(synchronousProxyAuthenticationRequiredSlot(QNetworkProxy,QAuthenticator*)));
+}
+
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
new file mode 100644
index 0000000..3b598aa
--- /dev/null
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** 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 QHTTPTHREADDELEGATE_H
+#define QHTTPTHREADDELEGATE_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 <QObject>
+#include <QThreadStorage>
+#include <QNetworkProxy>
+#include <QSslConfiguration>
+#include <QSslError>
+#include <QList>
+#include <QNetworkReply>
+#include "qhttpnetworkrequest_p.h"
+#include "qhttpnetworkconnection_p.h"
+#include <QSharedPointer>
+#include "qsslconfiguration.h"
+#include "private/qnoncontiguousbytedevice_p.h"
+#include "qnetworkaccessauthenticationmanager_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QAuthenticator;
+class QHttpNetworkReply;
+class QEventLoop;
+class QNetworkAccessCache;
+class QNetworkAccessCachedHttpConnection;
+
+class QHttpThreadDelegate : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QHttpThreadDelegate(QObject *parent = 0);
+
+ ~QHttpThreadDelegate();
+
+ // incoming
+ bool ssl;
+#ifndef QT_NO_OPENSSL
+ QSslConfiguration incomingSslConfiguration;
+#endif
+ QHttpNetworkRequest httpRequest;
+ qint64 downloadBufferMaximumSize;
+ // From backend, modified by us for signal compression
+ QSharedPointer<QAtomicInt> pendingDownloadData;
+ QSharedPointer<QAtomicInt> pendingDownloadProgress;
+#ifndef QT_NO_NETWORKPROXY
+ QNetworkProxy cacheProxy;
+ QNetworkProxy transparentProxy;
+#endif
+ QSharedPointer<QNetworkAccessAuthenticationManager> authenticationManager;
+ bool synchronous;
+
+ // outgoing, Retrieved in the synchronous HTTP case
+ QByteArray synchronousDownloadData;
+ QList<QPair<QByteArray,QByteArray> > incomingHeaders;
+ int incomingStatusCode;
+ QString incomingReasonPhrase;
+ bool isPipeliningUsed;
+ qint64 incomingContentLength;
+ QNetworkReply::NetworkError incomingErrorCode;
+ QString incomingErrorDetail;
+
+protected:
+ // The zerocopy download buffer, if used:
+ QSharedPointer<char> downloadBuffer;
+ // The QHttpNetworkConnection that is used
+ QNetworkAccessCachedHttpConnection *httpConnection;
+ QByteArray cacheKey;
+ QHttpNetworkReply *httpReply;
+
+ // Used for implementing the synchronous HTTP, see startRequestSynchronously()
+ QEventLoop *synchronousRequestLoop;
+
+signals:
+ void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *);
+#ifndef QT_NO_NETWORKPROXY
+ void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *);
+#endif
+#ifndef QT_NO_OPENSSL
+ void sslErrors(const QList<QSslError> &, bool *, QList<QSslError> *);
+ void sslConfigurationChanged(const QSslConfiguration);
+#endif
+ void downloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64);
+ void downloadProgress(qint64, qint64);
+ void downloadData(QByteArray);
+ void error(QNetworkReply::NetworkError, const QString);
+ void downloadFinished();
+public slots:
+ // This are called via QueuedConnection from user thread
+ void startRequest();
+ void abortRequest();
+ // This is called with a BlockingQueuedConnection from user thread
+ void startRequestSynchronously();
+protected slots:
+ // From QHttp*
+ void readyReadSlot();
+ void finishedSlot();
+ void finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
+ void synchronousFinishedSlot();
+ void synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString());
+ void headerChangedSlot();
+ void synchronousHeaderChangedSlot();
+ void dataReadProgressSlot(int done, int total);
+ void cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator);
+#ifndef QT_NO_OPENSSL
+ void sslErrorsSlot(const QList<QSslError> &errors);
+#endif
+
+ void synchronousAuthenticationRequiredSlot(const QHttpNetworkRequest &request, QAuthenticator *);
+#ifndef QT_NO_NETWORKPROXY
+ void synchronousProxyAuthenticationRequiredSlot(const QNetworkProxy &, QAuthenticator *);
+#endif
+
+protected:
+ // Cache for all the QHttpNetworkConnection objects.
+ // This is per thread.
+ static QThreadStorage<QNetworkAccessCache *> connections;
+
+};
+
+// This QNonContiguousByteDevice is connected to the QNetworkAccessHttpBackend
+// and represents the PUT/POST data.
+class QNonContiguousByteDeviceThreadForwardImpl : public QNonContiguousByteDevice
+{
+ Q_OBJECT
+protected:
+ bool wantDataPending;
+ qint64 m_amount;
+ char *m_data;
+ QByteArray m_dataArray;
+ bool m_atEnd;
+ qint64 m_size;
+public:
+ QNonContiguousByteDeviceThreadForwardImpl(bool aE, qint64 s)
+ : QNonContiguousByteDevice(),
+ wantDataPending(false),
+ m_amount(0),
+ m_data(0),
+ m_atEnd(aE),
+ m_size(s)
+ {
+ }
+
+ ~QNonContiguousByteDeviceThreadForwardImpl()
+ {
+ }
+
+ const char* readPointer(qint64 maximumLength, qint64 &len)
+ {
+ if (m_amount == 0 && wantDataPending == false) {
+ len = 0;
+ wantDataPending = true;
+ emit wantData(maximumLength);
+ } else if (m_amount == 0 && wantDataPending == true) {
+ // Do nothing, we already sent a wantData signal and wait for results
+ len = 0;
+ } else if (m_amount > 0) {
+ len = m_amount;
+ return m_data;
+ }
+ // cannot happen
+ return 0;
+ }
+
+ bool advanceReadPointer(qint64 a)
+ {
+ if (m_data == 0)
+ return false;
+
+ m_amount -= a;
+ m_data += a;
+
+ // To main thread to inform about our state
+ emit processedData(a);
+
+ // FIXME possible optimization, already ask user thread for some data
+
+ return true;
+ }
+
+ bool atEnd()
+ {
+ if (m_amount > 0)
+ return false;
+ else
+ return m_atEnd;
+ }
+
+ bool reset()
+ {
+ m_amount = 0;
+ m_data = 0;
+
+ // Communicate as BlockingQueuedConnection
+ bool b = false;
+ emit resetData(&b);
+ return b;
+ }
+
+ qint64 size()
+ {
+ return m_size;
+ }
+
+public slots:
+ // From user thread:
+ void haveDataSlot(QByteArray dataArray, bool dataAtEnd, qint64 dataSize)
+ {
+ wantDataPending = false;
+
+ m_dataArray = dataArray;
+ m_data = const_cast<char*>(m_dataArray.constData());
+ m_amount = dataArray.size();
+
+ m_atEnd = dataAtEnd;
+ m_size = dataSize;
+
+ // This will tell the HTTP code (QHttpNetworkConnectionChannel) that we have data available now
+ emit readyRead();
+ }
+
+signals:
+ // void readyRead(); in parent class
+ // void readProgress(qint64 current, qint64 total); happens in the main thread with the real bytedevice
+
+ // to main thread:
+ void wantData(qint64);
+ void processedData(qint64);
+ void resetData(bool *b);
+};
+
+QT_END_NAMESPACE
+
+#endif // QHTTPTHREADDELEGATE_H
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 b1d3ae9..5aedac9 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -106,12 +106,10 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM
QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice()
{
- QNonContiguousByteDevice* device = 0;
-
if (reply->outgoingDataBuffer)
- device = QNonContiguousByteDeviceFactory::create(reply->outgoingDataBuffer);
+ uploadByteDevice = QSharedPointer<QNonContiguousByteDevice>(QNonContiguousByteDeviceFactory::create(reply->outgoingDataBuffer));
else if (reply->outgoingData) {
- device = QNonContiguousByteDeviceFactory::create(reply->outgoingData);
+ uploadByteDevice = QSharedPointer<QNonContiguousByteDevice>(QNonContiguousByteDeviceFactory::create(reply->outgoingData));
} else {
return 0;
}
@@ -120,21 +118,20 @@ QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice()
reply->request.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute,
QVariant(false)) == QVariant(true);
if (bufferDisallowed)
- device->disableReset();
-
- // make sure we delete this later
- device->setParent(this);
+ uploadByteDevice->disableReset();
- connect(device, SIGNAL(readProgress(qint64,qint64)), this, SLOT(emitReplyUploadProgress(qint64,qint64)));
+ // We want signal emissions only for normal asynchronous uploads
+ if (!isSynchronous())
+ connect(uploadByteDevice.data(), SIGNAL(readProgress(qint64,qint64)), this, SLOT(emitReplyUploadProgress(qint64,qint64)));
- return device;
+ return uploadByteDevice.data();
}
// need to have this function since the reply is a private member variable
// and the special backends need to access this.
void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal)
{
- if (reply->isFinished())
+ if (reply->isFinished)
return;
reply->emitUploadProgress(bytesSent, bytesTotal);
}
@@ -241,6 +238,17 @@ void QNetworkAccessBackend::writeDownstreamData(QIODevice *data)
reply->appendDownstreamData(data);
}
+// not actually appending data, it was already written to the user buffer
+void QNetworkAccessBackend::writeDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal)
+{
+ reply->appendDownstreamDataDownloadBuffer(bytesReceived, bytesTotal);
+}
+
+char* QNetworkAccessBackend::getDownloadBuffer(qint64 size)
+{
+ return reply->getDownloadBuffer(size);
+}
+
QVariant QNetworkAccessBackend::header(QNetworkRequest::KnownHeaders header) const
{
return reply->q_func()->header(header);
@@ -316,11 +324,6 @@ void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator
manager->authenticationRequired(this, authenticator);
}
-void QNetworkAccessBackend::cacheCredentials(QAuthenticator *authenticator)
-{
- manager->cacheCredentials(this->reply->url, authenticator);
-}
-
void QNetworkAccessBackend::metaDataChanged()
{
reply->metaDataChanged();
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index 90a2594..644ae2d 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -70,7 +70,6 @@ class QNetworkAccessManagerPrivate;
class QNetworkReplyImplPrivate;
class QAbstractNetworkCache;
class QNetworkCacheMetaData;
-class QNetworkAccessBackendUploadIODevice;
class QNonContiguousByteDevice;
// Should support direct file upload from disk or download to disk.
@@ -175,12 +174,17 @@ protected:
// Create the device used for reading the upload data
QNonContiguousByteDevice* createUploadByteDevice();
-
// these functions control the downstream mechanism
// that is, data that has come via the connection and is going out the backend
qint64 nextDownstreamBlockSize() const;
void writeDownstreamData(QByteDataBuffer &list);
+ // not actually appending data, it was already written to the user buffer
+ void writeDownstreamDataDownloadBuffer(qint64, qint64);
+ char* getDownloadBuffer(qint64);
+
+ QSharedPointer<QNonContiguousByteDevice> uploadByteDevice;
+
public slots:
// for task 251801, needs to be a slot to be called asynchronously
void writeDownstreamData(QIODevice *data);
@@ -192,19 +196,22 @@ protected slots:
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
#endif
void authenticationRequired(QAuthenticator *auth);
- void cacheCredentials(QAuthenticator *auth);
void metaDataChanged();
void redirectionRequested(const QUrl &destination);
void sslErrors(const QList<QSslError> &errors);
void emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal);
+protected:
+ // FIXME In the long run we should get rid of our QNAM architecture
+ // and scrap this ReplyImpl/Backend distinction.
+ QNetworkAccessManagerPrivate *manager;
+ QNetworkReplyImplPrivate *reply;
+
private:
friend class QNetworkAccessManager;
friend class QNetworkAccessManagerPrivate;
- friend class QNetworkAccessBackendUploadIODevice;
friend class QNetworkReplyImplPrivate;
- QNetworkAccessManagerPrivate *manager;
- QNetworkReplyImplPrivate *reply;
+
bool synchronous;
};
diff --git a/src/network/access/qnetworkaccessdatabackend.cpp b/src/network/access/qnetworkaccessdatabackend.cpp
deleted file mode 100644
index beced2f..0000000
--- a/src/network/access/qnetworkaccessdatabackend.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the 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 "qnetworkaccessdatabackend_p.h"
-#include "qnetworkrequest.h"
-#include "qnetworkreply.h"
-#include "qurlinfo.h"
-#include "private/qdataurl_p.h"
-#include <qcoreapplication.h>
-
-QT_BEGIN_NAMESPACE
-
-QNetworkAccessBackend *
-QNetworkAccessDataBackendFactory::create(QNetworkAccessManager::Operation,
- const QNetworkRequest &request) const
-{
- if (request.url().scheme() == QLatin1String("data"))
- return new QNetworkAccessDataBackend;
-
- return 0;
-}
-
-QNetworkAccessDataBackend::QNetworkAccessDataBackend()
-{
-}
-
-QNetworkAccessDataBackend::~QNetworkAccessDataBackend()
-{
-}
-
-void QNetworkAccessDataBackend::open()
-{
- QUrl uri = request().url();
-
- if (operation() != QNetworkAccessManager::GetOperation &&
- operation() != QNetworkAccessManager::HeadOperation) {
- // data: doesn't support anything but GET
- const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
- "Operation not supported on %1")
- .arg(uri.toString());
- error(QNetworkReply::ContentOperationNotPermittedError, msg);
- finished();
- return;
- }
-
- QPair<QString, QByteArray> decoded = qDecodeDataUrl(uri);
-
- if (! decoded.first.isNull()) {
- setHeader(QNetworkRequest::ContentTypeHeader, decoded.first);
- setHeader(QNetworkRequest::ContentLengthHeader, decoded.second.size());
- emit metaDataChanged();
-
- QByteDataBuffer list;
- list.append(decoded.second);
- decoded.second.clear(); // important because of implicit sharing!
- writeDownstreamData(list);
-
- finished();
- return;
- }
-
- // something wrong with this URI
- const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
- "Invalid URI: %1").arg(uri.toString());
- error(QNetworkReply::ProtocolFailure, msg);
- finished();
-}
-
-void QNetworkAccessDataBackend::closeDownstreamChannel()
-{
-}
-
-void QNetworkAccessDataBackend::closeUpstreamChannel()
-{
-}
-
-bool QNetworkAccessDataBackend::waitForDownstreamReadyRead(int)
-{
- return false;
-}
-
-bool QNetworkAccessDataBackend::waitForUpstreamBytesWritten(int)
-{
- return false;
-}
-
-bool QNetworkAccessDataBackend::processRequestSynchronously()
-{
-#ifndef QT_NO_BEARERMANAGEMENT
- start();
-#else
- open();
-#endif
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index ae8a51a..7ebf626 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -65,11 +65,18 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
}
QUrl url = request.url();
- if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty())
+ if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) {
return new QNetworkAccessFileBackend;
- else if (!url.isEmpty() && url.authority().isEmpty()) {
- // check if QFile could, in theory, open this URL
+ } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) {
+ // check if QFile could, in theory, open this URL via the file engines
+ // it has to be in the format:
+ // prefix:path/to/file
+ // or prefix:/path/to/file
+ //
+ // this construct here must match the one below in open()
QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
+ if ((url.scheme().length()==1) && fi.exists())
+ qWarning("QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
return new QNetworkAccessFileBackend;
}
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index b0303aa..e34e6bb 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -77,7 +77,7 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op,
}
QUrl url = request.url();
- if (url.scheme() == QLatin1String("ftp"))
+ if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0)
return new QNetworkAccessFtpBackend;
return 0;
}
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 108ac68..a031cd0 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -52,60 +52,19 @@
#include "QtCore/qdatetime.h"
#include "QtCore/qelapsedtimer.h"
#include "QtNetwork/qsslconfiguration.h"
+#include "qhttpthreaddelegate_p.h"
+#include "qthread.h"
#ifndef QT_NO_HTTP
#include <string.h> // for strchr
-QT_BEGIN_NAMESPACE
+Q_DECLARE_METATYPE(QSharedPointer<char>)
-enum {
- DefaultHttpPort = 80,
- DefaultHttpsPort = 443
-};
+QT_BEGIN_NAMESPACE
class QNetworkProxy;
-static QByteArray makeCacheKey(QNetworkAccessHttpBackend *backend, QNetworkProxy *proxy)
-{
- QByteArray result;
- QUrl copy = backend->url();
- bool isEncrypted = copy.scheme().toLower() == QLatin1String("https");
- copy.setPort(copy.port(isEncrypted ? DefaultHttpsPort : DefaultHttpPort));
- result = copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath |
- QUrl::RemoveQuery | QUrl::RemoveFragment);
-
-#ifndef QT_NO_NETWORKPROXY
- if (proxy->type() != QNetworkProxy::NoProxy) {
- 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;
-
- default:
- break;
- }
-
- if (!key.scheme().isEmpty()) {
- key.setUserName(proxy->user());
- key.setHost(proxy->hostName());
- key.setPort(proxy->port());
- key.setEncodedQuery(result);
- result = key.toEncoded();
- }
- }
-#endif
-
- return "http-connection:" + result;
-}
-
static inline bool isSeparator(register char c)
{
static const char separators[] = "()<>@,;:\\\"/[]?={}";
@@ -230,71 +189,13 @@ QNetworkAccessHttpBackendFactory::create(QNetworkAccessManager::Operation op,
return 0;
}
-static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url)
-{
- QNetworkReply::NetworkError code;
- // we've got an error
- switch (httpStatusCode) {
- case 401: // Authorization required
- code = QNetworkReply::AuthenticationRequiredError;
- break;
-
- case 403: // Access denied
- code = QNetworkReply::ContentOperationNotPermittedError;
- break;
-
- case 404: // Not Found
- code = QNetworkReply::ContentNotFoundError;
- break;
-
- case 405: // Method Not Allowed
- code = QNetworkReply::ContentOperationNotPermittedError;
- break;
-
- case 407:
- code = QNetworkReply::ProxyAuthenticationRequiredError;
- break;
-
- default:
- if (httpStatusCode > 500) {
- // some kind of server error
- code = QNetworkReply::ProtocolUnknownError;
- } else if (httpStatusCode >= 400) {
- // content error we did not handle above
- code = QNetworkReply::UnknownContentError;
- } else {
- qWarning("QNetworkAccess: got HTTP status code %d which is not expected from url: \"%s\"",
- httpStatusCode, qPrintable(url.toString()));
- code = QNetworkReply::ProtocolFailure;
- }
- }
-
- return code;
-}
-
-class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection,
- public QNetworkAccessCache::CacheableObject
-{
- // Q_OBJECT
-public:
- QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt)
- : QHttpNetworkConnection(hostName, port, encrypt)
- {
- setExpires(true);
- setShareable(true);
- }
-
- virtual void dispose()
- {
-#if 0 // sample code; do this right with the API
- Q_ASSERT(!isWorking());
-#endif
- delete this;
- }
-};
-
QNetworkAccessHttpBackend::QNetworkAccessHttpBackend()
- : QNetworkAccessBackend(), httpReply(0), http(0), uploadDevice(0)
+ : QNetworkAccessBackend()
+ , statusCode(0)
+ , pendingDownloadDataEmissions(new QAtomicInt())
+ , pendingDownloadProgressEmissions(new QAtomicInt())
+ , loadingFromCache(false)
+ , usingZerocopyDownloadBuffer(false)
#ifndef QT_NO_OPENSSL
, pendingSslConfiguration(0), pendingIgnoreAllSslErrors(false)
#endif
@@ -304,44 +205,14 @@ QNetworkAccessHttpBackend::QNetworkAccessHttpBackend()
QNetworkAccessHttpBackend::~QNetworkAccessHttpBackend()
{
- if (http)
- disconnectFromHttp();
+ // This will do nothing if the request was already finished or aborted
+ emit abortHttpRequest();
+
#ifndef QT_NO_OPENSSL
delete pendingSslConfiguration;
#endif
}
-void QNetworkAccessHttpBackend::disconnectFromHttp()
-{
- if (http) {
- // This is abut disconnecting signals, not about disconnecting TCP connections
- disconnect(http, 0, this, 0);
-
- // Get the object cache that stores our QHttpNetworkConnection objects
- QNetworkAccessCache *cache = QNetworkAccessManagerPrivate::getObjectCache(this);
-
- // synchronous calls are not put into the cache, so for them the key is empty
- if (!cacheKey.isEmpty())
- cache->releaseEntry(cacheKey);
- }
-
- // This is abut disconnecting signals, not about disconnecting TCP connections
- if (httpReply)
- disconnect(httpReply, 0, this, 0);
-
- http = 0;
- httpReply = 0;
- cacheKey.clear();
-}
-
-void QNetworkAccessHttpBackend::finished()
-{
- if (http)
- disconnectFromHttp();
- // call parent
- QNetworkAccessBackend::finished();
-}
-
/*
For a given httpRequest
1) If AlwaysNetwork, return
@@ -353,10 +224,12 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
QNetworkRequest::CacheLoadControl CacheLoadControlAttribute =
(QNetworkRequest::CacheLoadControl)request().attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt();
if (CacheLoadControlAttribute == QNetworkRequest::AlwaysNetwork) {
- // forced reload from the network
- // tell any caching proxy servers to reload too
- httpRequest.setHeaderField("Cache-Control", "no-cache");
- httpRequest.setHeaderField("Pragma", "no-cache");
+ // If the request does not already specify preferred cache-control
+ // force reload from the network and tell any caching proxy servers to reload too
+ if (!request().rawHeaderList().contains("Cache-Control")) {
+ httpRequest.setHeaderField("Cache-Control", "no-cache");
+ httpRequest.setHeaderField("Pragma", "no-cache");
+ }
return;
}
@@ -490,9 +363,82 @@ static QHttpNetworkRequest::Priority convert(const QNetworkRequest::Priority& pr
void QNetworkAccessHttpBackend::postRequest()
{
+ QThread *thread = 0;
+ if (isSynchronous()) {
+ // A synchronous HTTP request uses its own thread
+ thread = new QThread();
+ QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ thread->start();
+ } else if (!manager->httpThread) {
+ // We use the manager-global thread.
+ // At some point we could switch to having multiple threads if it makes sense.
+ manager->httpThread = new QThread();
+ QObject::connect(manager->httpThread, SIGNAL(finished()), manager->httpThread, SLOT(deleteLater()));
+ manager->httpThread->start();
+#ifndef QT_NO_NETWORKPROXY
+ qRegisterMetaType<QNetworkProxy>("QNetworkProxy");
+#endif
+#ifndef QT_NO_OPENSSL
+ qRegisterMetaType<QList<QSslError> >("QList<QSslError>");
+ qRegisterMetaType<QSslConfiguration>("QSslConfiguration");
+#endif
+ qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >("QList<QPair<QByteArray,QByteArray> >");
+ qRegisterMetaType<QHttpNetworkRequest>("QHttpNetworkRequest");
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
+ qRegisterMetaType<QSharedPointer<char> >("QSharedPointer<char>");
+
+ thread = manager->httpThread;
+ } else {
+ // Asynchronous request, thread already exists
+ thread = manager->httpThread;
+ }
+
+ QUrl url = request().url();
+ httpRequest.setUrl(url);
+
+ bool ssl = url.scheme().toLower() == QLatin1String("https");
+ setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, ssl);
+ httpRequest.setSsl(ssl);
+
+
+#ifndef QT_NO_NETWORKPROXY
+ QNetworkProxy transparentProxy, cacheProxy;
+
+ foreach (const QNetworkProxy &p, proxyList()) {
+ // use the first proxy that works
+ // for non-encrypted connections, any transparent or HTTP proxy
+ // for encrypted, only transparent proxies
+ if (!ssl
+ && (p.capabilities() & QNetworkProxy::CachingCapability)
+ && (p.type() == QNetworkProxy::HttpProxy ||
+ p.type() == QNetworkProxy::HttpCachingProxy)) {
+ cacheProxy = p;
+ transparentProxy = QNetworkProxy::NoProxy;
+ break;
+ }
+ if (p.isTransparentProxy()) {
+ transparentProxy = p;
+ cacheProxy = QNetworkProxy::NoProxy;
+ break;
+ }
+ }
+
+ // check if at least one of the proxies
+ if (transparentProxy.type() == QNetworkProxy::DefaultProxy &&
+ cacheProxy.type() == QNetworkProxy::DefaultProxy) {
+ // unsuitable proxies
+ QMetaObject::invokeMethod(this, "error", isSynchronous() ? Qt::DirectConnection : Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProxyNotFoundError),
+ Q_ARG(QString, tr("No suitable proxy found")));
+ QMetaObject::invokeMethod(this, "finished", isSynchronous() ? Qt::DirectConnection : Qt::QueuedConnection);
+ return;
+ }
+#endif
+
+
bool loadedFromCache = false;
- QHttpNetworkRequest httpRequest;
httpRequest.setPriority(convert(request().priority()));
+
switch (operation()) {
case QNetworkAccessManager::GetOperation:
httpRequest.setOperation(QHttpNetworkRequest::Get);
@@ -507,13 +453,13 @@ void QNetworkAccessHttpBackend::postRequest()
case QNetworkAccessManager::PostOperation:
invalidateCache();
httpRequest.setOperation(QHttpNetworkRequest::Post);
- httpRequest.setUploadByteDevice(createUploadByteDevice());
+ createUploadByteDevice();
break;
case QNetworkAccessManager::PutOperation:
invalidateCache();
httpRequest.setOperation(QHttpNetworkRequest::Put);
- httpRequest.setUploadByteDevice(createUploadByteDevice());
+ createUploadByteDevice();
break;
case QNetworkAccessManager::DeleteOperation:
@@ -524,7 +470,7 @@ void QNetworkAccessHttpBackend::postRequest()
case QNetworkAccessManager::CustomOperation:
invalidateCache(); // for safety reasons, we don't know what the operation does
httpRequest.setOperation(QHttpNetworkRequest::Custom);
- httpRequest.setUploadByteDevice(createUploadByteDevice());
+ createUploadByteDevice();
httpRequest.setCustomVerb(request().attribute(
QNetworkRequest::CustomVerbAttribute).toByteArray());
break;
@@ -533,8 +479,6 @@ void QNetworkAccessHttpBackend::postRequest()
break; // can't happen
}
- httpRequest.setUrl(url());
-
QList<QByteArray> headers = request().rawHeaderList();
if (resumeOffset != 0) {
if (headers.contains("Range")) {
@@ -558,6 +502,7 @@ void QNetworkAccessHttpBackend::postRequest()
httpRequest.setHeaderField("Range", "bytes=" + QByteArray::number(resumeOffset) + '-');
}
}
+
foreach (const QByteArray &header, headers)
httpRequest.setHeaderField(header, request().rawHeader(header));
@@ -576,31 +521,155 @@ void QNetworkAccessHttpBackend::postRequest()
QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
httpRequest.setWithCredentials(false);
- httpReply = http->sendRequest(httpRequest);
- httpReply->setParent(this);
+
+ // Create the HTTP thread delegate
+ QHttpThreadDelegate *delegate = new QHttpThreadDelegate;
+
+ // For the synchronous HTTP, this is the normal way the delegate gets deleted
+ // For the asynchronous HTTP this is a safety measure, the delegate deletes itself when HTTP is finished
+ connect(thread, SIGNAL(finished()), delegate, SLOT(deleteLater()));
+
+ // Set the properties it needs
+ delegate->httpRequest = httpRequest;
+#ifndef QT_NO_NETWORKPROXY
+ delegate->cacheProxy = cacheProxy;
+ delegate->transparentProxy = transparentProxy;
+#endif
+ delegate->ssl = ssl;
#ifndef QT_NO_OPENSSL
- if (pendingSslConfiguration)
- httpReply->setSslConfiguration(*pendingSslConfiguration);
- if (pendingIgnoreAllSslErrors)
- httpReply->ignoreSslErrors();
- httpReply->ignoreSslErrors(pendingIgnoreSslErrorsList);
- connect(httpReply, SIGNAL(sslErrors(QList<QSslError>)),
- SLOT(sslErrors(QList<QSslError>)));
+ if (ssl)
+ delegate->incomingSslConfiguration = request().sslConfiguration();
#endif
- connect(httpReply, SIGNAL(readyRead()), SLOT(replyReadyRead()));
- connect(httpReply, SIGNAL(finished()), SLOT(replyFinished()));
- connect(httpReply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)),
- SLOT(httpError(QNetworkReply::NetworkError,QString)));
- connect(httpReply, SIGNAL(headerChanged()), SLOT(replyHeaderChanged()));
- connect(httpReply, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)),
- SLOT(httpCacheCredentials(QHttpNetworkRequest,QAuthenticator*)));
+ // Do we use synchronous HTTP?
+ delegate->synchronous = isSynchronous();
+
+ // The authentication manager is used to avoid the BlockingQueuedConnection communication
+ // from HTTP thread to user thread in some cases.
+ delegate->authenticationManager = manager->authenticationManager;
+
+ if (!isSynchronous()) {
+ // Tell our zerocopy policy to the delegate
+ delegate->downloadBufferMaximumSize =
+ request().attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute).toLongLong();
+
+ // These atomic integers are used for signal compression
+ delegate->pendingDownloadData = pendingDownloadDataEmissions;
+ delegate->pendingDownloadProgress = pendingDownloadProgressEmissions;
+
+ // Connect the signals of the delegate to us
+ connect(delegate, SIGNAL(downloadData(QByteArray)),
+ this, SLOT(replyDownloadData(QByteArray)),
+ Qt::QueuedConnection);
+ connect(delegate, SIGNAL(downloadFinished()),
+ this, SLOT(replyFinished()),
+ Qt::QueuedConnection);
+ connect(delegate, SIGNAL(downloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64)),
+ this, SLOT(replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64)),
+ Qt::QueuedConnection);
+ connect(delegate, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(replyDownloadProgressSlot(qint64,qint64)),
+ Qt::QueuedConnection);
+ connect(delegate, SIGNAL(error(QNetworkReply::NetworkError,QString)),
+ this, SLOT(httpError(QNetworkReply::NetworkError, const QString)),
+ Qt::QueuedConnection);
+#ifndef QT_NO_OPENSSL
+ connect(delegate, SIGNAL(sslConfigurationChanged(QSslConfiguration)),
+ this, SLOT(replySslConfigurationChanged(QSslConfiguration)),
+ Qt::QueuedConnection);
+#endif
+ // Those need to report back, therefire BlockingQueuedConnection
+ connect(delegate, SIGNAL(authenticationRequired(QHttpNetworkRequest,QAuthenticator*)),
+ this, SLOT(httpAuthenticationRequired(QHttpNetworkRequest,QAuthenticator*)),
+ Qt::BlockingQueuedConnection);
#ifndef QT_NO_NETWORKPROXY
- connect(httpReply, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
- SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
+ connect (delegate, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
+ Qt::BlockingQueuedConnection);
#endif
- connect(httpReply, SIGNAL(authenticationRequired(const QHttpNetworkRequest,QAuthenticator*)),
- SLOT(httpAuthenticationRequired(const QHttpNetworkRequest,QAuthenticator*)));
+#ifndef QT_NO_OPENSSL
+ connect(delegate, SIGNAL(sslErrors(QList<QSslError>,bool*,QList<QSslError>*)),
+ this, SLOT(replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *)),
+ Qt::BlockingQueuedConnection);
+#endif
+ // This signal we will use to start the request.
+ connect(this, SIGNAL(startHttpRequest()), delegate, SLOT(startRequest()));
+ connect(this, SIGNAL(abortHttpRequest()), delegate, SLOT(abortRequest()));
+
+ if (uploadByteDevice) {
+ QNonContiguousByteDeviceThreadForwardImpl *forwardUploadDevice =
+ new QNonContiguousByteDeviceThreadForwardImpl(uploadByteDevice->atEnd(), uploadByteDevice->size());
+ if (uploadByteDevice->isResetDisabled())
+ forwardUploadDevice->disableReset();
+ forwardUploadDevice->setParent(delegate); // needed to make sure it is moved on moveToThread()
+ delegate->httpRequest.setUploadByteDevice(forwardUploadDevice);
+
+ // From main thread to user thread:
+ QObject::connect(this, SIGNAL(haveUploadData(QByteArray, bool, qint64)),
+ forwardUploadDevice, SLOT(haveDataSlot(QByteArray, bool, qint64)), Qt::QueuedConnection);
+ QObject::connect(uploadByteDevice.data(), SIGNAL(readyRead()),
+ forwardUploadDevice, SIGNAL(readyRead()),
+ Qt::QueuedConnection);
+
+ // From http thread to user thread:
+ QObject::connect(forwardUploadDevice, SIGNAL(wantData(qint64)),
+ this, SLOT(wantUploadDataSlot(qint64)));
+ QObject::connect(forwardUploadDevice, SIGNAL(processedData(qint64)),
+ this, SLOT(sentUploadDataSlot(qint64)));
+ connect(forwardUploadDevice, SIGNAL(resetData(bool*)),
+ this, SLOT(resetUploadDataSlot(bool*)),
+ Qt::BlockingQueuedConnection); // this is the only one with BlockingQueued!
+ }
+ } else if (isSynchronous()) {
+ connect(this, SIGNAL(startHttpRequestSynchronously()), delegate, SLOT(startRequestSynchronously()), Qt::BlockingQueuedConnection);
+
+ if (uploadByteDevice) {
+ // For the synchronous HTTP use case the use thread (this one here) is blocked
+ // so we cannot use the asynchronous upload architecture.
+ // We therefore won't use the QNonContiguousByteDeviceThreadForwardImpl but directly
+ // use the uploadByteDevice provided to us by the QNetworkReplyImpl.
+ // The code that is in QNetworkReplyImplPrivate::setup() makes sure it is safe to use from a thread
+ // since it only wraps a QRingBuffer
+ delegate->httpRequest.setUploadByteDevice(uploadByteDevice.data());
+ }
+ }
+
+
+ // Move the delegate to the http thread
+ delegate->moveToThread(thread);
+ // This call automatically moves the uploadDevice too for the asynchronous case.
+
+ // Send an signal to the delegate so it starts working in the other thread
+ if (isSynchronous()) {
+ emit startHttpRequestSynchronously(); // This one is BlockingQueuedConnection, so it will return when all work is done
+
+ if (delegate->incomingErrorCode != QNetworkReply::NoError) {
+ replyDownloadMetaData
+ (delegate->incomingHeaders,
+ delegate->incomingStatusCode,
+ delegate->incomingReasonPhrase,
+ delegate->isPipeliningUsed,
+ QSharedPointer<char>(),
+ delegate->incomingContentLength);
+ httpError(delegate->incomingErrorCode, delegate->incomingErrorDetail);
+ } else {
+ replyDownloadMetaData
+ (delegate->incomingHeaders,
+ delegate->incomingStatusCode,
+ delegate->incomingReasonPhrase,
+ delegate->isPipeliningUsed,
+ QSharedPointer<char>(),
+ delegate->incomingContentLength);
+ replyDownloadData(delegate->synchronousDownloadData);
+ }
+
+ // End the thread. It will delete itself from the finished() signal
+ thread->quit();
+
+ finished();
+ } else {
+ emit startHttpRequest(); // Signal to the HTTP thread and go back to user.
+ }
}
void QNetworkAccessHttpBackend::invalidateCache()
@@ -612,159 +681,52 @@ void QNetworkAccessHttpBackend::invalidateCache()
void QNetworkAccessHttpBackend::open()
{
- QUrl url = request().url();
- bool encrypt = url.scheme().toLower() == QLatin1String("https");
- setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, encrypt);
-
- // set the port number in the reply if it wasn't set
- url.setPort(url.port(encrypt ? DefaultHttpsPort : DefaultHttpPort));
-
- QNetworkProxy *theProxy = 0;
-#ifndef QT_NO_NETWORKPROXY
- QNetworkProxy transparentProxy, cacheProxy;
-
- foreach (const QNetworkProxy &p, proxyList()) {
- // use the first proxy that works
- // for non-encrypted connections, any transparent or HTTP proxy
- // for encrypted, only transparent proxies
- if (!encrypt
- && (p.capabilities() & QNetworkProxy::CachingCapability)
- && (p.type() == QNetworkProxy::HttpProxy ||
- p.type() == QNetworkProxy::HttpCachingProxy)) {
- cacheProxy = p;
- transparentProxy = QNetworkProxy::NoProxy;
- theProxy = &cacheProxy;
- break;
- }
- if (p.isTransparentProxy()) {
- transparentProxy = p;
- cacheProxy = QNetworkProxy::NoProxy;
- theProxy = &transparentProxy;
- break;
- }
- }
-
- // check if at least one of the proxies
- if (transparentProxy.type() == QNetworkProxy::DefaultProxy &&
- cacheProxy.type() == QNetworkProxy::DefaultProxy) {
- // unsuitable proxies
- if (isSynchronous()) {
- error(QNetworkReply::ProxyNotFoundError, tr("No suitable proxy found"));
- finished();
- } else {
- QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
- Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProxyNotFoundError),
- Q_ARG(QString, tr("No suitable proxy found")));
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
- }
- return;
- }
-#endif
-
- if (isSynchronous()) {
- // for synchronous requests, we just create a new connection
- http = new QHttpNetworkConnection(1, url.host(), url.port(), encrypt, this);
-#ifndef QT_NO_NETWORKPROXY
- http->setTransparentProxy(transparentProxy);
- http->setCacheProxy(cacheProxy);
-#endif
- postRequest();
- processRequestSynchronously();
- } else {
- // check if we have an open connection to this host
- cacheKey = makeCacheKey(this, theProxy);
- QNetworkAccessCache *cache = QNetworkAccessManagerPrivate::getObjectCache(this);
- // the http object is actually a QHttpNetworkConnection
- http = static_cast<QNetworkAccessCachedHttpConnection *>(cache->requestEntryNow(cacheKey));
- if (http == 0) {
- // no entry in cache; create an object
- // the http object is actually a QHttpNetworkConnection
- http = new QNetworkAccessCachedHttpConnection(url.host(), url.port(), encrypt);
-
-#ifndef QT_NO_NETWORKPROXY
- http->setTransparentProxy(transparentProxy);
- http->setCacheProxy(cacheProxy);
-#endif
-
- // cache the QHttpNetworkConnection corresponding to this cache key
- cache->addEntry(cacheKey, static_cast<QNetworkAccessCachedHttpConnection *>(http.data()));
- }
- postRequest();
- }
+ postRequest();
}
void QNetworkAccessHttpBackend::closeDownstreamChannel()
{
- // this indicates that the user closed the stream while the reply isn't finished yet
+ // FIXME Maybe we can get rid of this whole architecture part
}
void QNetworkAccessHttpBackend::downstreamReadyWrite()
{
- readFromHttp();
- if (httpReply && httpReply->bytesAvailable() == 0 && httpReply->isFinished())
- replyFinished();
+ // FIXME Maybe we can get rid of this whole architecture part
}
void QNetworkAccessHttpBackend::setDownstreamLimited(bool b)
{
- if (httpReply)
- httpReply->setDownstreamLimited(b);
-}
-
-void QNetworkAccessHttpBackend::replyReadyRead()
-{
- readFromHttp();
+ Q_UNUSED(b);
+ // We know that readBuffer maximum size limiting is broken since quite a while.
+ // The task to fix this is QTBUG-15065
}
-void QNetworkAccessHttpBackend::readFromHttp()
+void QNetworkAccessHttpBackend::replyDownloadData(QByteArray d)
{
- if (!httpReply)
+ int pendingSignals = (int)pendingDownloadDataEmissions->fetchAndAddAcquire(-1) - 1;
+
+ if (pendingSignals > 0) {
+ // Some more signal emissions to this slot are pending.
+ // Instead of writing the downstream data, we wait
+ // and do it in the next call we get
+ // (signal comppression)
+ pendingDownloadData.append(d);
return;
-
- // We read possibly more than nextDownstreamBlockSize(), but
- // this is not a critical thing since it is already in the
- // memory anyway
-
- QByteDataBuffer list;
-
- while (httpReply->bytesAvailable() != 0 && nextDownstreamBlockSize() != 0 && nextDownstreamBlockSize() > list.byteAmount()) {
- list.append(httpReply->readAny());
}
- if (!list.isEmpty())
- writeDownstreamData(list);
+ pendingDownloadData.append(d);
+ d.clear();
+ writeDownstreamData(pendingDownloadData);
+ pendingDownloadData.clear();
}
void QNetworkAccessHttpBackend::replyFinished()
{
- if (httpReply->bytesAvailable())
- // we haven't read everything yet. Wait some more.
+ // We are already loading from cache, we still however
+ // got this signal because it was posted already
+ if (loadingFromCache)
return;
- int statusCode = httpReply->statusCode();
- if (statusCode >= 400) {
- // it's an error reply
- QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
- "Error downloading %1 - server replied: %2"));
- msg = msg.arg(url().toString(), httpReply->reasonPhrase());
- error(statusCodeFromHttp(httpReply->statusCode(), httpReply->url()), msg);
- }
-
-#ifndef QT_NO_OPENSSL
- // store the SSL configuration now
- // once we call finished(), we won't have access to httpReply anymore
- QSslConfiguration sslConfig = httpReply->sslConfiguration();
- if (pendingSslConfiguration) {
- *pendingSslConfiguration = sslConfig;
- } else if (!sslConfig.isNull()) {
- QT_TRY {
- pendingSslConfiguration = new QSslConfiguration(sslConfig);
- } QT_CATCH(...) {
- qWarning("QNetworkAccess: could not allocate a QSslConfiguration object for a SSL connection.");
- }
- }
-#endif
-
finished();
}
@@ -786,12 +748,27 @@ void QNetworkAccessHttpBackend::checkForRedirect(const int statusCode)
}
}
-void QNetworkAccessHttpBackend::replyHeaderChanged()
+void QNetworkAccessHttpBackend::replyDownloadMetaData
+ (QList<QPair<QByteArray,QByteArray> > hm,
+ int sc,QString rp,bool pu,
+ QSharedPointer<char> db,
+ qint64 contentLength)
{
- setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, httpReply->isPipeliningUsed());
+ statusCode = sc;
+ reasonPhrase = rp;
+
+ // Download buffer
+ if (!db.isNull()) {
+ reply->setDownloadBuffer(db, contentLength);
+ usingZerocopyDownloadBuffer = true;
+ } else {
+ usingZerocopyDownloadBuffer = false;
+ }
+
+ setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu);
// reconstruct the HTTP header
- QList<QPair<QByteArray, QByteArray> > headerMap = httpReply->header();
+ QList<QPair<QByteArray, QByteArray> > headerMap = hm;
QList<QPair<QByteArray, QByteArray> >::ConstIterator it = headerMap.constBegin(),
end = headerMap.constEnd();
QByteArray header;
@@ -808,11 +785,10 @@ void QNetworkAccessHttpBackend::replyHeaderChanged()
setRawHeader(it->first, value);
}
- setAttribute(QNetworkRequest::HttpStatusCodeAttribute, httpReply->statusCode());
- setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, httpReply->reasonPhrase());
+ setAttribute(QNetworkRequest::HttpStatusCodeAttribute, statusCode);
+ setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase);
// is it a redirection?
- const int statusCode = httpReply->statusCode();
checkForRedirect(statusCode);
if (statusCode >= 500 && statusCode < 600) {
@@ -854,19 +830,29 @@ void QNetworkAccessHttpBackend::replyHeaderChanged()
if (!isCachingEnabled())
setCachingEnabled(true);
}
+
metaDataChanged();
}
-void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkRequest &,
- QAuthenticator *auth)
+void QNetworkAccessHttpBackend::replyDownloadProgressSlot(qint64 received, qint64 total)
{
- authenticationRequired(auth);
+ // we can be sure here that there is a download buffer
+
+ int pendingSignals = (int)pendingDownloadProgressEmissions->fetchAndAddAcquire(-1) - 1;
+ if (pendingSignals > 0) {
+ // Let's ignore this signal and look at the next one coming in
+ // (signal comppression)
+ return;
+ }
+
+ // Now do the actual notification of new bytes
+ writeDownstreamDataDownloadBuffer(received, total);
}
-void QNetworkAccessHttpBackend::httpCacheCredentials(const QHttpNetworkRequest &,
- QAuthenticator *auth)
+void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkRequest &,
+ QAuthenticator *auth)
{
- cacheCredentials(auth);
+ authenticationRequired(auth);
}
void QNetworkAccessHttpBackend::httpError(QNetworkReply::NetworkError errorCode,
@@ -875,8 +861,56 @@ void QNetworkAccessHttpBackend::httpError(QNetworkReply::NetworkError errorCode,
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
qDebug() << "http error!" << errorCode << errorString;
#endif
+
error(errorCode, errorString);
- finished();
+}
+
+#ifndef QT_NO_OPENSSL
+void QNetworkAccessHttpBackend::replySslErrors(
+ const QList<QSslError> &list, bool *ignoreAll, QList<QSslError> *toBeIgnored)
+{
+ // Go to generic backend
+ sslErrors(list);
+ // Check if the callback set any ignore and return this here to http thread
+ if (pendingIgnoreAllSslErrors)
+ *ignoreAll = true;
+ if (!pendingIgnoreSslErrorsList.isEmpty())
+ *toBeIgnored = pendingIgnoreSslErrorsList;
+}
+
+void QNetworkAccessHttpBackend::replySslConfigurationChanged(const QSslConfiguration &c)
+{
+ // Receiving the used SSL configuration from the HTTP thread
+ if (pendingSslConfiguration)
+ *pendingSslConfiguration = c;
+ else if (!c.isNull())
+ pendingSslConfiguration = new QSslConfiguration(c);
+}
+#endif
+
+// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
+void QNetworkAccessHttpBackend::resetUploadDataSlot(bool *r)
+{
+ *r = uploadByteDevice->reset();
+}
+
+// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
+void QNetworkAccessHttpBackend::sentUploadDataSlot(qint64 amount)
+{
+ uploadByteDevice->advanceReadPointer(amount);
+}
+
+// Coming from QNonContiguousByteDeviceThreadForwardImpl in HTTP thread
+void QNetworkAccessHttpBackend::wantUploadDataSlot(qint64 maxSize)
+{
+ // call readPointer
+ qint64 currentUploadDataLength = 0;
+ char *data = const_cast<char*>(uploadByteDevice->readPointer(maxSize, currentUploadDataLength));
+ // Let's make a copy of this data
+ QByteArray dataArray(data, currentUploadDataLength);
+
+ // Communicate back to HTTP thread
+ emit haveUploadData(dataArray, uploadByteDevice->atEnd(), uploadByteDevice->size());
}
/*
@@ -927,8 +961,10 @@ bool QNetworkAccessHttpBackend::sendCacheContents(const QNetworkCacheMetaData &m
#if defined(QNETWORKACCESSHTTPBACKEND_DEBUG)
qDebug() << "Successfully sent cache:" << url() << contents->size() << "bytes";
#endif
- if (httpReply)
- disconnect(httpReply, SIGNAL(finished()), this, SLOT(replyFinished()));
+
+ // Set the following flag so we can ignore some signals from HTTP thread
+ // that would still come
+ loadingFromCache = true;
return true;
}
@@ -941,39 +977,29 @@ void QNetworkAccessHttpBackend::copyFinished(QIODevice *dev)
#ifndef QT_NO_OPENSSL
void QNetworkAccessHttpBackend::ignoreSslErrors()
{
- if (httpReply)
- httpReply->ignoreSslErrors();
- else
- pendingIgnoreAllSslErrors = true;
+ pendingIgnoreAllSslErrors = true;
}
void QNetworkAccessHttpBackend::ignoreSslErrors(const QList<QSslError> &errors)
{
- if (httpReply) {
- httpReply->ignoreSslErrors(errors);
- } else {
- // the pending list is set if QNetworkReply::ignoreSslErrors(const QList<QSslError> &errors)
- // is called before QNetworkAccessManager::get() (or post(), etc.)
- pendingIgnoreSslErrorsList = errors;
- }
+ // the pending list is set if QNetworkReply::ignoreSslErrors(const QList<QSslError> &errors)
+ // is called before QNetworkAccessManager::get() (or post(), etc.)
+ pendingIgnoreSslErrorsList = errors;
}
void QNetworkAccessHttpBackend::fetchSslConfiguration(QSslConfiguration &config) const
{
- if (httpReply)
- config = httpReply->sslConfiguration();
- else if (pendingSslConfiguration)
+ if (pendingSslConfiguration)
config = *pendingSslConfiguration;
+ else
+ config = request().sslConfiguration();
}
void QNetworkAccessHttpBackend::setSslConfiguration(const QSslConfiguration &newconfig)
{
- if (httpReply)
- httpReply->setSslConfiguration(newconfig);
- else if (pendingSslConfiguration)
- *pendingSslConfiguration = newconfig;
- else
- pendingSslConfiguration = new QSslConfiguration(newconfig);
+ // Setting a SSL configuration on a reply is not supported. The user needs to set
+ // her/his QSslConfiguration on the QNetworkRequest.
+ Q_UNUSED(newconfig);
}
#endif
@@ -1078,7 +1104,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
bool canDiskCache;
// only cache GET replies by default, all other replies (POST, PUT, DELETE)
// are not cacheable by default (according to RFC 2616 section 9)
- if (httpReply->request().operation() == QHttpNetworkRequest::Get) {
+ if (httpRequest.operation() == QHttpNetworkRequest::Get) {
canDiskCache = true;
// 14.32
@@ -1096,7 +1122,7 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
canDiskCache = false;
// responses to POST might be cacheable
- } else if (httpReply->request().operation() == QHttpNetworkRequest::Post) {
+ } else if (httpRequest.operation() == QHttpNetworkRequest::Post) {
canDiskCache = false;
// some pages contain "expires:" and "cache-control: no-cache" field,
@@ -1110,12 +1136,11 @@ QNetworkCacheMetaData QNetworkAccessHttpBackend::fetchCacheMetaData(const QNetwo
}
metaData.setSaveToDisk(canDiskCache);
- int statusCode = httpReply->statusCode();
QNetworkCacheMetaData::AttributesMap attributes;
if (statusCode != 304) {
// update the status code
attributes.insert(QNetworkRequest::HttpStatusCodeAttribute, statusCode);
- attributes.insert(QNetworkRequest::HttpReasonPhraseAttribute, httpReply->reasonPhrase());
+ attributes.insert(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase);
} else {
// this is a redirection, keep the attributes intact
attributes = oldMetaData.attributes();
@@ -1131,7 +1156,8 @@ bool QNetworkAccessHttpBackend::canResume() const
return false;
// Can only resume if server/resource supports Range header.
- if (httpReply->headerField("Accept-Ranges", "none") == "none")
+ QByteArray acceptRangesheaderName("Accept-Ranges");
+ if (!hasRawHeader(acceptRangesheaderName) || rawHeader(acceptRangesheaderName) == "none")
return false;
// We only support resuming for byte ranges.
@@ -1141,6 +1167,11 @@ bool QNetworkAccessHttpBackend::canResume() const
return false;
}
+ // If we're using a download buffer then we don't support resuming/migration
+ // right now. Too much trouble.
+ if (usingZerocopyDownloadBuffer)
+ return false;
+
return true;
}
@@ -1149,87 +1180,6 @@ void QNetworkAccessHttpBackend::setResumeOffset(quint64 offset)
resumeOffset = offset;
}
-bool QNetworkAccessHttpBackend::processRequestSynchronously()
-{
- QHttpNetworkConnectionChannel *channel = &http->channels()[0];
-
- // Disconnect all socket signals. They will only confuse us when using waitFor*
- QObject::disconnect(channel->socket, 0, 0, 0);
-
- qint64 timeout = 20*1000; // 20 sec
- QElapsedTimer timeoutTimer;
-
- bool waitResult = channel->socket->waitForConnected(timeout);
- timeoutTimer.start();
-
- if (!waitResult || channel->socket->state() != QAbstractSocket::ConnectedState) {
- error(QNetworkReply::UnknownNetworkError, QLatin1String("could not connect"));
- return false;
- }
- channel->_q_connected(); // this will send the request (via sendRequest())
-
-#ifndef QT_NO_OPENSSL
- if (http->isSsl()) {
- qint64 remainingTimeEncrypted = timeout - timeoutTimer.elapsed();
- if (!static_cast<QSslSocket *>(channel->socket)->waitForEncrypted(remainingTimeEncrypted)) {
- error(QNetworkReply::SslHandshakeFailedError,
- QLatin1String("could not encrypt or timeout while encrypting"));
- return false;
- }
- channel->_q_encrypted();
- }
-#endif
-
- // if we get a 401 or 407, we might need to send the request twice, see below
- bool authenticating = false;
-
- do {
- channel->sendRequest();
-
- qint64 remainingTimeBytesWritten;
- while(channel->socket->bytesToWrite() > 0 ||
- channel->state == QHttpNetworkConnectionChannel::WritingState) {
- remainingTimeBytesWritten = timeout - timeoutTimer.elapsed();
- channel->sendRequest(); // triggers channel->socket->write()
- if (!channel->socket->waitForBytesWritten(remainingTimeBytesWritten)) {
- error(QNetworkReply::TimeoutError,
- QLatin1String("could not write bytes to socket or timeout while writing"));
- return false;
- }
- }
-
- qint64 remainingTimeBytesRead = timeout - timeoutTimer.elapsed();
- // Loop for at most remainingTime until either the socket disconnects
- // or the reply is finished
- do {
- waitResult = channel->socket->waitForReadyRead(remainingTimeBytesRead);
- remainingTimeBytesRead = timeout - timeoutTimer.elapsed();
- if (!waitResult || remainingTimeBytesRead <= 0
- || channel->socket->state() != QAbstractSocket::ConnectedState) {
- error(QNetworkReply::TimeoutError,
- QLatin1String("could not read from socket or timeout while reading"));
- return false;
- }
-
- if (channel->socket->bytesAvailable())
- channel->_q_readyRead();
-
- if (!httpReply)
- return false; // we got a 401 or 407 and cannot handle it (it might happen that
- // disconnectFromHttp() was called, in that case the reply is zero)
- // ### I am quite sure this does not work for NTLM
- // ### how about uploading to an auth / proxyAuth site?
-
- authenticating = (httpReply->statusCode() == 401 || httpReply->statusCode() == 407);
-
- if (httpReply->isFinished())
- break;
- } while (remainingTimeBytesRead > 0);
- } while (authenticating);
-
- return true;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_HTTP
diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h
index 85d4983..712dd2f 100644
--- a/src/network/access/qnetworkaccesshttpbackend_p.h
+++ b/src/network/access/qnetworkaccesshttpbackend_p.h
@@ -61,6 +61,8 @@
#include "QtCore/qpointer.h"
#include "QtCore/qdatetime.h"
+#include "QtCore/qsharedpointer.h"
+#include "qatomic.h"
#ifndef QT_NO_HTTP
@@ -99,23 +101,44 @@ public:
bool canResume() const;
void setResumeOffset(quint64 offset);
- virtual bool processRequestSynchronously();
+signals:
+ // To HTTP thread:
+ void startHttpRequest();
+ void abortHttpRequest();
+ void startHttpRequestSynchronously();
+
+ void haveUploadData(QByteArray dataArray, bool dataAtEnd, qint64 dataSize);
private slots:
- void replyReadyRead();
+ // From HTTP thread:
+ void replyDownloadData(QByteArray);
void replyFinished();
- void replyHeaderChanged();
+ void replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64);
+ void replyDownloadProgressSlot(qint64,qint64);
void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth);
- void httpCacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *auth);
void httpError(QNetworkReply::NetworkError error, const QString &errorString);
+#ifndef QT_NO_OPENSSL
+ void replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *);
+ void replySslConfigurationChanged(const QSslConfiguration&);
+#endif
+
+ // From QNonContiguousByteDeviceThreadForwardImpl in HTTP thread:
+ void resetUploadDataSlot(bool *r);
+ void wantUploadDataSlot(qint64);
+ void sentUploadDataSlot(qint64);
+
bool sendCacheContents(const QNetworkCacheMetaData &metaData);
- void finished(); // override
private:
- QHttpNetworkReply *httpReply;
- QPointer<QHttpNetworkConnection> http;
- QByteArray cacheKey;
- QNetworkAccessBackendUploadIODevice *uploadDevice;
+ QHttpNetworkRequest httpRequest; // There is also a copy in the HTTP thread
+ int statusCode;
+ QString reasonPhrase;
+ // Will be increased by HTTP thread:
+ QSharedPointer<QAtomicInt> pendingDownloadDataEmissions;
+ QSharedPointer<QAtomicInt> pendingDownloadProgressEmissions;
+ bool loadingFromCache;
+ QByteDataBuffer pendingDownloadData;
+ bool usingZerocopyDownloadBuffer;
#ifndef QT_NO_OPENSSL
QSslConfiguration *pendingSslConfiguration;
@@ -125,7 +148,6 @@ private:
quint64 resumeOffset;
- void disconnectFromHttp();
void validateCache(QHttpNetworkRequest &httpRequest, bool &loadedFromCache);
void invalidateCache();
void postRequest();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 5b518de..7e75045 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -53,10 +53,10 @@
#include "qnetworkaccesshttpbackend_p.h"
#include "qnetworkaccessftpbackend_p.h"
#include "qnetworkaccessfilebackend_p.h"
-#include "qnetworkaccessdatabackend_p.h"
#include "qnetworkaccessdebugpipebackend_p.h"
#include "qnetworkaccesscachebackend_p.h"
-#include "qfilenetworkreply_p.h"
+#include "qnetworkreplydataimpl_p.h"
+#include "qnetworkreplyfileimpl_p.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qurl.h"
@@ -65,13 +65,14 @@
#include "QtNetwork/qsslconfiguration.h"
#include "QtNetwork/qnetworkconfigmanager.h"
+#include "qthread.h"
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_HTTP
Q_GLOBAL_STATIC(QNetworkAccessHttpBackendFactory, httpBackend)
#endif // QT_NO_HTTP
Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend)
-Q_GLOBAL_STATIC(QNetworkAccessDataBackendFactory, dataBackend)
#ifndef QT_NO_FTP
Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend)
#endif // QT_NO_FTP
@@ -85,7 +86,7 @@ static void ensureInitialized()
#ifndef QT_NO_HTTP
(void) httpBackend();
#endif // QT_NO_HTTP
- (void) dataBackend();
+
#ifndef QT_NO_FTP
(void) ftpBackend();
#endif
@@ -342,107 +343,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
@@ -452,6 +352,8 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent)
: QObject(*new QNetworkAccessManagerPrivate, parent)
{
ensureInitialized();
+
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
}
/*!
@@ -946,30 +848,19 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
{
Q_D(QNetworkAccessManager);
- // 4.7 only hotfix fast path for data:// URLs
- // In 4.8 this is solved with QNetworkReplyDataImpl and will work there
- // This hotfix is done for not needing a QNetworkSession for data://
- if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation)
- && (req.url().scheme() == QLatin1String("data"))) {
- QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
- QNetworkReplyImplPrivate *priv = reply->d_func();
- priv->manager = this;
- priv->backend = new QNetworkAccessDataBackend();
- priv->backend->manager = this->d_func();
- priv->backend->setParent(reply);
- priv->backend->reply = priv;
- priv->setup(op, req, outgoingData);
- return reply;
- }
+ bool isLocalFile = req.url().isLocalFile();
+ QString scheme = req.url().scheme().toLower();
// fast path for GET on file:// URLs
- // Also if the scheme is empty we consider it a file.
// The QNetworkAccessFileBackend will right now only be used for PUT
if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation)
- && (req.url().scheme() == QLatin1String("file")
- || req.url().scheme() == QLatin1String("qrc")
- || req.url().scheme().isEmpty())) {
- return new QFileNetworkReply(this, req, op);
+ && (isLocalFile || scheme == QLatin1String("qrc"))) {
+ return new QNetworkReplyFileImpl(this, req, op);
+ }
+
+ if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation)
+ && scheme == QLatin1String("data")) {
+ return new QNetworkReplyDataImpl(this, req, op);
}
// A request with QNetworkRequest::AlwaysCache does not need any bearer management
@@ -995,8 +886,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
#ifndef QT_NO_BEARERMANAGEMENT
// Return a disabled network reply if network access is disabled.
// Except if the scheme is empty or file://.
- if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") ||
- req.url().scheme().isEmpty())) {
+ if (!d->networkAccessible && !isLocalFile) {
return new QDisabledNetworkReply(this, req, op);
}
@@ -1030,7 +920,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
if (d->cookieJar) {
QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url());
if (!cookies.isEmpty())
- request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
+ request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
}
}
@@ -1038,7 +928,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
QUrl url = request.url();
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
#ifndef QT_NO_BEARERMANAGEMENT
- if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) {
+ if (!isLocalFile) {
connect(this, SIGNAL(networkSessionConnected()),
reply, SLOT(_q_networkSessionConnected()));
}
@@ -1135,10 +1025,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;
}
@@ -1151,7 +1041,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
@@ -1168,10 +1058,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;
}
}
@@ -1183,75 +1073,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)
@@ -1275,77 +1097,25 @@ 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();
+
+ if (manager->d_func()->httpThread) {
+ // The thread will deleteLater() itself from its finished() signal
+ manager->d_func()->httpThread->quit();
+ manager->d_func()->httpThread = 0;
+ }
}
QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()
{
+ if (httpThread) {
+ // The thread will deleteLater() itself from its finished() signal
+ httpThread->quit();
+ httpThread = 0;
+ }
}
#ifndef QT_NO_BEARERMANAGEMENT
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 7ef009f..d67b8ac 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -156,6 +156,8 @@ protected:
private:
friend class QNetworkReplyImplPrivate;
+ friend class QNetworkAccessHttpBackend;
+
Q_DECLARE_PRIVATE(QNetworkAccessManager)
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index cf4d2f3..ee6ad70 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
@@ -72,6 +73,7 @@ class QNetworkAccessManagerPrivate: public QObjectPrivate
public:
QNetworkAccessManagerPrivate()
: networkCache(0), cookieJar(0),
+ httpThread(0),
#ifndef QT_NO_NETWORKPROXY
proxyFactory(0),
#endif
@@ -81,7 +83,8 @@ public:
online(false),
initializeSession(true),
#endif
- cookieJarCreated(false)
+ cookieJarCreated(false),
+ authenticationManager(new QNetworkAccessAuthenticationManager)
{ }
~QNetworkAccessManagerPrivate();
@@ -121,6 +124,8 @@ public:
QNetworkCookieJar *cookieJar;
+ QThread *httpThread;
+
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy proxy;
@@ -137,6 +142,9 @@ public:
bool cookieJarCreated;
+ // The cache with authorization data:
+ QSharedPointer<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/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp
index ba7109f..c176dde 100644
--- a/src/network/access/qnetworkreply.cpp
+++ b/src/network/access/qnetworkreply.cpp
@@ -49,6 +49,7 @@ QNetworkReplyPrivate::QNetworkReplyPrivate()
: readBufferMaxSize(0),
operation(QNetworkAccessManager::UnknownOperation),
errorCode(QNetworkReply::NoError)
+ , isFinished(false)
{
// set the default attribute values
attributes.insert(QNetworkRequest::ConnectionEncryptedAttribute, false);
@@ -462,7 +463,7 @@ QNetworkReply::NetworkError QNetworkReply::error() const
*/
bool QNetworkReply::isFinished() const
{
- return d_func()->isFinished();
+ return d_func()->isFinished;
}
/*!
@@ -718,6 +719,21 @@ void QNetworkReply::setError(NetworkError errorCode, const QString &errorString)
}
/*!
+ \since 4.8
+ Sets the reply as \a finished.
+
+ After having this set the replies data must not change.
+
+ \sa isFinished()
+*/
+void QNetworkReply::setFinished(bool finished)
+{
+ Q_D(QNetworkReply);
+ d->isFinished = finished;
+}
+
+
+/*!
Sets the URL being processed to be \a url. Normally, the URL
matches that of the request that was posted, but for a variety of
reasons it can be different (for example, a file path being made
diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h
index efc28f7..3a511cc 100644
--- a/src/network/access/qnetworkreply.h
+++ b/src/network/access/qnetworkreply.h
@@ -163,6 +163,7 @@ protected:
void setOperation(QNetworkAccessManager::Operation operation);
void setRequest(const QNetworkRequest &request);
void setError(NetworkError errorCode, const QString &errorString);
+ void setFinished(bool);
void setUrl(const QUrl &url);
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
void setRawHeader(const QByteArray &headerName, const QByteArray &value);
diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h
index c40d8fa..03cc6bd 100644
--- a/src/network/access/qnetworkreply_p.h
+++ b/src/network/access/qnetworkreply_p.h
@@ -71,12 +71,11 @@ public:
qint64 readBufferMaxSize;
QNetworkAccessManager::Operation operation;
QNetworkReply::NetworkError errorCode;
+ bool isFinished;
static inline void setManager(QNetworkReply *reply, QNetworkAccessManager *manager)
{ reply->d_func()->manager = manager; }
- virtual bool isFinished() const { return false; }
-
Q_DECLARE_PUBLIC(QNetworkReply)
};
diff --git a/src/network/access/qnetworkreplydataimpl.cpp b/src/network/access/qnetworkreplydataimpl.cpp
new file mode 100644
index 0000000..a09ff5c
--- /dev/null
+++ b/src/network/access/qnetworkreplydataimpl.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 "qnetworkreplydataimpl_p.h"
+#include "private/qdataurl_p.h"
+#include <QtCore/QCoreApplication>
+#include <QtCore/QMetaObject>
+
+QT_BEGIN_NAMESPACE
+
+QNetworkReplyDataImplPrivate::QNetworkReplyDataImplPrivate()
+ : QNetworkReplyPrivate()
+{
+}
+
+QNetworkReplyDataImplPrivate::~QNetworkReplyDataImplPrivate()
+{
+}
+
+QNetworkReplyDataImpl::~QNetworkReplyDataImpl()
+{
+}
+
+QNetworkReplyDataImpl::QNetworkReplyDataImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
+ : QNetworkReply(*new QNetworkReplyDataImplPrivate(), parent)
+{
+ Q_D(QNetworkReplyDataImpl);
+ setRequest(req);
+ setUrl(req.url());
+ setOperation(op);
+ setFinished(true);
+ QNetworkReply::open(QIODevice::ReadOnly);
+
+ QUrl url = req.url();
+
+ // FIXME qDecodeDataUrl should instead be rewritten to have the QByteArray
+ // and the mime type as an output parameter and return a bool instead
+ d->decodeDataUrlResult = qDecodeDataUrl(url);
+
+ if (! d->decodeDataUrlResult.first.isNull()) {
+ QString &mimeType = d->decodeDataUrlResult.first;
+ qint64 size = d->decodeDataUrlResult.second.size();
+ setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
+ setHeader(QNetworkRequest::ContentLengthHeader, size);
+ QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
+
+ d->decodedData.setBuffer(&d->decodeDataUrlResult.second);
+ d->decodedData.open(QIODevice::ReadOnly);
+
+ QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
+ Q_ARG(qint64,size), Q_ARG(qint64, size));
+ QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+ } else {
+ // something wrong with this URI
+ const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
+ "Invalid URI: %1").arg(QString::fromLatin1(url.toEncoded()));
+ setError(QNetworkReply::ProtocolFailure, msg);
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolFailure));
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+ }
+}
+
+void QNetworkReplyDataImpl::close()
+{
+ QNetworkReply::close();
+}
+
+void QNetworkReplyDataImpl::abort()
+{
+ QNetworkReply::close();
+}
+
+qint64 QNetworkReplyDataImpl::bytesAvailable() const
+{
+ Q_D(const QNetworkReplyDataImpl);
+ return QNetworkReply::bytesAvailable() + d->decodedData.bytesAvailable();
+}
+
+bool QNetworkReplyDataImpl::isSequential () const
+{
+ return true;
+}
+
+qint64 QNetworkReplyDataImpl::size() const
+{
+ Q_D(const QNetworkReplyDataImpl);
+ return d->decodedData.size();
+}
+
+/*!
+ \internal
+*/
+qint64 QNetworkReplyDataImpl::readData(char *data, qint64 maxlen)
+{
+ Q_D(QNetworkReplyDataImpl);
+
+ // TODO idea:
+ // Instead of decoding the whole data into new memory, we could decode on demand.
+ // Note that this might be tricky to do.
+
+ return d->decodedData.read(data, maxlen);
+}
+
+
+QT_END_NAMESPACE
+
+#include "moc_qnetworkreplydataimpl_p.cpp"
+
diff --git a/src/network/access/qnetworkreplydataimpl_p.h b/src/network/access/qnetworkreplydataimpl_p.h
new file mode 100644
index 0000000..2048376
--- /dev/null
+++ b/src/network/access/qnetworkreplydataimpl_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QNETWORKREPLYDATAIMPL_H
+#define QNETWORKREPLYDATAIMPL_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 "qnetworkreply.h"
+#include "qnetworkreply_p.h"
+#include "qnetworkaccessmanager.h"
+#include <QBuffer>
+
+QT_BEGIN_NAMESPACE
+
+
+class QNetworkReplyDataImplPrivate;
+class QNetworkReplyDataImpl: public QNetworkReply
+{
+ Q_OBJECT
+public:
+ QNetworkReplyDataImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op);
+ ~QNetworkReplyDataImpl();
+ virtual void abort();
+
+ // reimplemented from QNetworkReply
+ virtual void close();
+ virtual qint64 bytesAvailable() const;
+ virtual bool isSequential () const;
+ qint64 size() const;
+
+ virtual qint64 readData(char *data, qint64 maxlen);
+
+ Q_DECLARE_PRIVATE(QNetworkReplyDataImpl)
+};
+
+class QNetworkReplyDataImplPrivate: public QNetworkReplyPrivate
+{
+public:
+ QNetworkReplyDataImplPrivate();
+ ~QNetworkReplyDataImplPrivate();
+
+ QPair<QString, QByteArray> decodeDataUrlResult;
+ QBuffer decodedData;
+
+ Q_DECLARE_PUBLIC(QNetworkReplyDataImpl)
+};
+
+QT_END_NAMESPACE
+
+#endif // QNETWORKREPLYDATAIMPL_H
diff --git a/src/network/access/qfilenetworkreply.cpp b/src/network/access/qnetworkreplyfileimpl.cpp
index 0048928..babee32 100644
--- a/src/network/access/qfilenetworkreply.cpp
+++ b/src/network/access/qnetworkreplyfileimpl.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qfilenetworkreply_p.h"
+#include "qnetworkreplyfileimpl_p.h"
#include "QtCore/qdatetime.h"
#include <QtCore/QCoreApplication>
@@ -48,31 +48,25 @@
QT_BEGIN_NAMESPACE
-QFileNetworkReplyPrivate::QFileNetworkReplyPrivate()
- : QNetworkReplyPrivate(), fileEngine(0), fileSize(0), filePos(0)
+QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate()
+ : QNetworkReplyPrivate(), realFileSize(0)
{
}
-QFileNetworkReplyPrivate::~QFileNetworkReplyPrivate()
+QNetworkReplyFileImpl::~QNetworkReplyFileImpl()
{
- delete fileEngine;
}
-QFileNetworkReply::~QFileNetworkReply()
-{
-}
-
-QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
- : QNetworkReply(*new QFileNetworkReplyPrivate(), parent)
+QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
+ : QNetworkReply(*new QNetworkReplyFileImplPrivate(), parent)
{
setRequest(req);
setUrl(req.url());
setOperation(op);
+ setFinished(true);
QNetworkReply::open(QIODevice::ReadOnly);
- qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
-
- QFileNetworkReplyPrivate *d = (QFileNetworkReplyPrivate*) d_func();
+ QNetworkReplyFileImplPrivate *d = (QNetworkReplyFileImplPrivate*) d_func();
QUrl url = req.url();
if (url.host() == QLatin1String("localhost"))
@@ -113,15 +107,15 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req
return;
}
- d->fileEngine = QAbstractFileEngine::create(fileName);
- bool opened = d->fileEngine->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ d->realFile.setFileName(fileName);
+ bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
// could we open the file?
if (!opened) {
QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2")
- .arg(fileName, d->fileEngine->errorString());
+ .arg(d->realFile.fileName(), d->realFile.errorString());
- if (fi.exists()) {
+ if (d->realFile.exists()) {
setError(QNetworkReply::ContentAccessDenied, msg);
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied));
@@ -134,79 +128,62 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req
return;
}
- d->fileSize = fi.size();
setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified());
- setHeader(QNetworkRequest::ContentLengthHeader, d->fileSize);
+ d->realFileSize = fi.size();
+ setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize);
QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
- Q_ARG(qint64, d->fileSize), Q_ARG(qint64, d->fileSize));
+ Q_ARG(qint64, d->realFileSize), Q_ARG(qint64, d->realFileSize));
QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
-
-bool QFileNetworkReplyPrivate::isFinished() const
+void QNetworkReplyFileImpl::close()
{
- return true;
-}
-
-void QFileNetworkReply::close()
-{
- Q_D(QFileNetworkReply);
+ Q_D(QNetworkReplyFileImpl);
QNetworkReply::close();
- if (d->fileEngine)
- d->fileEngine->close();
+ d->realFile.close();
}
-void QFileNetworkReply::abort()
+void QNetworkReplyFileImpl::abort()
{
- Q_D(QFileNetworkReply);
+ Q_D(QNetworkReplyFileImpl);
QNetworkReply::close();
- if (d->fileEngine)
- d->fileEngine->close();
+ d->realFile.close();
}
-qint64 QFileNetworkReply::bytesAvailable() const
+qint64 QNetworkReplyFileImpl::bytesAvailable() const
{
- Q_D(const QFileNetworkReply);
- if (!d->fileEngine)
- return 0;
-
- return QNetworkReply::bytesAvailable() + d->fileSize - d->filePos;
+ Q_D(const QNetworkReplyFileImpl);
+ return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable();
}
-bool QFileNetworkReply::isSequential () const
+bool QNetworkReplyFileImpl::isSequential () const
{
return true;
}
-qint64 QFileNetworkReply::size() const
+qint64 QNetworkReplyFileImpl::size() const
{
- Q_D(const QFileNetworkReply);
- return d->fileSize;
+ Q_D(const QNetworkReplyFileImpl);
+ return d->realFileSize;
}
/*!
\internal
*/
-qint64 QFileNetworkReply::readData(char *data, qint64 maxlen)
+qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
{
- Q_D(QFileNetworkReply);
- if (!d->fileEngine)
+ Q_D(QNetworkReplyFileImpl);
+ qint64 ret = d->realFile.read(data, maxlen);
+ if (ret == 0 && bytesAvailable() == 0)
return -1;
-
- qint64 ret = d->fileEngine->read(data, maxlen);
- if (ret == 0 && bytesAvailable() == 0) {
- return -1; // everything had been read
- } else if (ret > 0) {
- d->filePos += ret;
- }
-
- return ret;
+ else
+ return ret;
}
QT_END_NAMESPACE
-#include "moc_qfilenetworkreply_p.cpp"
+#include "moc_qnetworkreplyfileimpl_p.cpp"
diff --git a/src/network/access/qfilenetworkreply_p.h b/src/network/access/qnetworkreplyfileimpl_p.h
index ace556e..c5126de 100644
--- a/src/network/access/qfilenetworkreply_p.h
+++ b/src/network/access/qnetworkreplyfileimpl_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFILENETWORKREPLY_P_H
-#define QFILENETWORKREPLY_P_H
+#ifndef QNETWORKREPLYFILEIMPL_H
+#define QNETWORKREPLYFILEIMPL_H
//
// W A R N I N G
@@ -62,13 +62,13 @@
QT_BEGIN_NAMESPACE
-class QFileNetworkReplyPrivate;
-class QFileNetworkReply: public QNetworkReply
+class QNetworkReplyFileImplPrivate;
+class QNetworkReplyFileImpl: public QNetworkReply
{
Q_OBJECT
public:
- QFileNetworkReply(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op);
- ~QFileNetworkReply();
+ QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op);
+ ~QNetworkReplyFileImpl();
virtual void abort();
// reimplemented from QNetworkReply
@@ -79,24 +79,20 @@ public:
virtual qint64 readData(char *data, qint64 maxlen);
- Q_DECLARE_PRIVATE(QFileNetworkReply)
+ Q_DECLARE_PRIVATE(QNetworkReplyFileImpl)
};
-class QFileNetworkReplyPrivate: public QNetworkReplyPrivate
+class QNetworkReplyFileImplPrivate: public QNetworkReplyPrivate
{
public:
- QFileNetworkReplyPrivate();
- ~QFileNetworkReplyPrivate();
+ QNetworkReplyFileImplPrivate();
- QAbstractFileEngine *fileEngine;
- qint64 fileSize;
- qint64 filePos;
+ QFile realFile;
+ qint64 realFileSize;
- virtual bool isFinished() const;
-
- Q_DECLARE_PUBLIC(QFileNetworkReply)
+ Q_DECLARE_PUBLIC(QNetworkReplyFileImpl)
};
QT_END_NAMESPACE
-#endif // QFILENETWORKREPLY_P_H
+#endif // QNETWORKREPLYFILEIMPL_H
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 894df79..1c9fa3e 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -52,16 +52,22 @@
#include <QtCore/QCoreApplication>
+Q_DECLARE_METATYPE(QSharedPointer<char>)
+
QT_BEGIN_NAMESPACE
inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate()
- : backend(0), outgoingData(0), outgoingDataBuffer(0),
+ : backend(0), outgoingData(0),
copyDevice(0),
cacheEnabled(false), cacheSaveDevice(0),
notificationHandlingPaused(false),
bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1),
httpStatusCode(0),
state(Idle)
+ , downloadBufferReadPosition(0)
+ , downloadBufferCurrentSize(0)
+ , downloadBufferMaximumSize(0)
+ , downloadBuffer(0)
{
}
@@ -111,6 +117,7 @@ void QNetworkReplyImplPrivate::_q_startOperation()
if (backend && backend->isSynchronous()) {
state = Finished;
+ q_func()->setFinished(true);
} else {
if (state != Finished) {
if (operation == QNetworkAccessManager::GetOperation)
@@ -129,6 +136,10 @@ void QNetworkReplyImplPrivate::_q_copyReadyRead()
if (!copyDevice || !q->isOpen())
return;
+ // FIXME Optimize to use download buffer if it is a QBuffer.
+ // Needs to be done where sendCacheContents() (?) of HTTP is emitting
+ // metaDataChanged ?
+
forever {
qint64 bytesToRead = nextDownstreamBlockSize();
if (bytesToRead == 0)
@@ -201,7 +212,7 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingData()
if (!outgoingDataBuffer) {
// first call, create our buffer
- outgoingDataBuffer = new QRingBuffer();
+ outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer());
QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData()));
QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished()));
@@ -295,20 +306,22 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
// Internal code that does a HTTP reply for the synchronous Ajax
// in QtWebKit.
QVariant synchronousHttpAttribute = req.attribute(
- static_cast<QNetworkRequest::Attribute>(QNetworkRequest::DownloadBufferAttribute + 1));
- if (backend && synchronousHttpAttribute.toBool()) {
- backend->setSynchronous(true);
- if (outgoingData && outgoingData->isSequential()) {
- outgoingDataBuffer = new QRingBuffer();
- QByteArray data;
- do {
- data = outgoingData->readAll();
- if (data.isEmpty())
- break;
- outgoingDataBuffer->append(data);
- } while (1);
- }
+ static_cast<QNetworkRequest::Attribute>(QNetworkRequest::SynchronousRequestAttribute));
+ // The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer.
+ // Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway.
+ if (synchronousHttpAttribute.toBool() && outgoingData) {
+ outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer());
+ qint64 previousDataSize = 0;
+ do {
+ previousDataSize = outgoingDataBuffer->size();
+ outgoingDataBuffer->append(outgoingData->readAll());
+ } while (outgoingDataBuffer->size() != previousDataSize);
}
+
+ if (backend)
+ backend->setSynchronous(synchronousHttpAttribute.toBool());
+
+
if (outgoingData && backend && !backend->isSynchronous()) {
// there is data to be uploaded, e.g. HTTP POST.
@@ -338,10 +351,6 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
}
}
} else {
- // No outgoing data (e.g. HTTP GET request)
- // or no backend
- // if no backend, _q_startOperation will handle the error of this
-
// for HTTP, we want to send out the request as fast as possible to the network, without
// invoking methods in a QueuedConnection
#ifndef QT_NO_HTTP
@@ -573,8 +582,6 @@ void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()
{
Q_Q(QNetworkReplyImpl);
- QPointer<QNetworkReplyImpl> qq = q;
-
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
if (preMigrationDownloaded != Q_INT64_C(-1))
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
@@ -585,13 +592,10 @@ void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()
// else implicit sharing will trigger memcpy when the user is reading data!
emit q->readyRead();
- // hopefully we haven't been deleted here
- if (!qq.isNull()) {
- resumeNotificationHandling();
- // do we still have room in the buffer?
- if (nextDownstreamBlockSize() > 0)
- backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
- }
+ resumeNotificationHandling();
+ // do we still have room in the buffer?
+ if (nextDownstreamBlockSize() > 0)
+ backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
}
// this is used when it was fetched from the cache, right?
@@ -626,6 +630,73 @@ void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data)
qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented");
}
+static void downloadBufferDeleter(char *ptr)
+{
+ delete[] ptr;
+}
+
+char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size)
+{
+ Q_Q(QNetworkReplyImpl);
+
+ if (!downloadBuffer) {
+ // We are requested to create it
+ // Check attribute() if allocating a buffer of that size can be allowed
+ QVariant bufferAllocationPolicy = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute);
+ if (bufferAllocationPolicy.isValid() && bufferAllocationPolicy.toLongLong() >= size) {
+ downloadBufferCurrentSize = 0;
+ downloadBufferMaximumSize = size;
+ downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails
+ downloadBufferPointer = QSharedPointer<char>(downloadBuffer, downloadBufferDeleter);
+
+ q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue<QSharedPointer<char> > (downloadBufferPointer));
+ }
+ }
+
+ return downloadBuffer;
+}
+
+void QNetworkReplyImplPrivate::setDownloadBuffer(QSharedPointer<char> sp, qint64 size)
+{
+ Q_Q(QNetworkReplyImpl);
+
+ downloadBufferPointer = sp;
+ downloadBuffer = downloadBufferPointer.data();
+ downloadBufferCurrentSize = 0;
+ downloadBufferMaximumSize = size;
+ q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue<QSharedPointer<char> > (downloadBufferPointer));
+}
+
+
+void QNetworkReplyImplPrivate::appendDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal)
+{
+ Q_Q(QNetworkReplyImpl);
+ if (!q->isOpen())
+ return;
+
+ if (cacheEnabled && !cacheSaveDevice)
+ initCacheSaveDevice();
+
+ if (cacheSaveDevice && bytesReceived == bytesTotal) {
+// if (lastBytesDownloaded == -1)
+// lastBytesDownloaded = 0;
+// cacheSaveDevice->write(downloadBuffer + lastBytesDownloaded, bytesReceived - lastBytesDownloaded);
+
+ // Write everything in one go if we use a download buffer. might be more performant.
+ cacheSaveDevice->write(downloadBuffer, bytesTotal);
+ }
+
+ bytesDownloaded = bytesReceived;
+ lastBytesDownloaded = bytesReceived;
+
+ downloadBufferCurrentSize = bytesReceived;
+
+ emit q->downloadProgress(bytesDownloaded, bytesTotal);
+ // Only emit readyRead when actual data is there
+ if (bytesDownloaded > 0)
+ emit q->readyRead();
+}
+
void QNetworkReplyImplPrivate::finished()
{
Q_Q(QNetworkReplyImpl);
@@ -664,6 +735,8 @@ void QNetworkReplyImplPrivate::finished()
resumeNotificationHandling();
state = Finished;
+ q->setFinished(true);
+
pendingNotifications.clear();
pauseNotificationHandling();
@@ -691,6 +764,11 @@ void QNetworkReplyImplPrivate::finished()
void QNetworkReplyImplPrivate::error(QNetworkReplyImpl::NetworkError code, const QString &errorMessage)
{
Q_Q(QNetworkReplyImpl);
+ // Can't set and emit multiple errors.
+ if (errorCode != QNetworkReply::NoError) {
+ qWarning() << "QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.";
+ return;
+ }
errorCode = code;
q->setErrorString(errorMessage);
@@ -734,11 +812,6 @@ void QNetworkReplyImplPrivate::sslErrors(const QList<QSslError> &errors)
#endif
}
-bool QNetworkReplyImplPrivate::isFinished() const
-{
- return (state == Finished || state == Aborted);
-}
-
QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent)
: QNetworkReply(*new QNetworkReplyImplPrivate, parent)
{
@@ -753,9 +826,6 @@ QNetworkReplyImpl::~QNetworkReplyImpl()
// save had been properly finished. So if it is still enabled it means we got deleted/aborted.
if (d->isCachingEnabled())
d->networkCache()->remove(url());
-
- if (d->outgoingDataBuffer)
- delete d->outgoingDataBuffer;
}
void QNetworkReplyImpl::abort()
@@ -773,7 +843,7 @@ void QNetworkReplyImpl::abort()
QNetworkReply::close();
if (d->state != QNetworkReplyImplPrivate::Finished) {
- // emit signals
+ // call finished which will emit signals
d->error(OperationCanceledError, tr("Operation canceled"));
d->finished();
}
@@ -801,7 +871,7 @@ void QNetworkReplyImpl::close()
QNetworkReply::close();
- // emit signals
+ // call finished which will emit signals
d->error(OperationCanceledError, tr("Operation canceled"));
d->finished();
}
@@ -820,6 +890,13 @@ bool QNetworkReplyImpl::canReadLine () const
*/
qint64 QNetworkReplyImpl::bytesAvailable() const
{
+ // Special case for the "zero copy" download buffer
+ Q_D(const QNetworkReplyImpl);
+ if (d->downloadBuffer) {
+ qint64 maxAvail = d->downloadBufferCurrentSize - d->downloadBufferReadPosition;
+ return QNetworkReply::bytesAvailable() + maxAvail;
+ }
+
return QNetworkReply::bytesAvailable() + d_func()->readBuffer.byteAmount();
}
@@ -874,8 +951,22 @@ void QNetworkReplyImpl::ignoreSslErrorsImplementation(const QList<QSslError> &er
qint64 QNetworkReplyImpl::readData(char *data, qint64 maxlen)
{
Q_D(QNetworkReplyImpl);
+
+ // Special case code if we have the "zero copy" download buffer
+ if (d->downloadBuffer) {
+ qint64 maxAvail = qMin<qint64>(d->downloadBufferCurrentSize - d->downloadBufferReadPosition, maxlen);
+ if (maxAvail == 0)
+ return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0;
+ // FIXME what about "Aborted" state?
+ qMemCopy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);
+ d->downloadBufferReadPosition += maxAvail;
+ return maxAvail;
+ }
+
+
if (d->readBuffer.isEmpty())
return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0;
+ // FIXME what about "Aborted" state?
d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
if (maxlen == 1) {
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index f5ea8ca..1a9ab7e 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -62,6 +62,7 @@
#include "QtCore/qbuffer.h"
#include "private/qringbuffer_p.h"
#include "private/qbytedata_p.h"
+#include <QSharedPointer>
QT_BEGIN_NAMESPACE
@@ -163,17 +164,19 @@ public:
void appendDownstreamData(QIODevice *data);
void appendDownstreamData(const QByteArray &data);
+ void setDownloadBuffer(QSharedPointer<char> sp, qint64 size);
+ char* getDownloadBuffer(qint64 size);
+ void appendDownstreamDataDownloadBuffer(qint64, qint64);
+
void finished();
void error(QNetworkReply::NetworkError code, const QString &errorString);
void metaDataChanged();
void redirectionRequested(const QUrl &target);
void sslErrors(const QList<QSslError> &errors);
- bool isFinished() const;
-
QNetworkAccessBackend *backend;
QIODevice *outgoingData;
- QRingBuffer *outgoingDataBuffer;
+ QSharedPointer<QRingBuffer> outgoingDataBuffer;
QIODevice *copyDevice;
QAbstractNetworkCache *networkCache() const;
@@ -191,6 +194,7 @@ public:
QList<QNetworkProxy> proxyList;
#endif
+ // Used for normal downloading. For "zero copy" the downloadBuffer is used
QByteDataBuffer readBuffer;
qint64 bytesDownloaded;
qint64 lastBytesDownloaded;
@@ -202,6 +206,14 @@ public:
State state;
+ // only used when the "zero copy" style is used. Else readBuffer is used.
+ // Please note that the whole "zero copy" download buffer API is private right now. Do not use it.
+ qint64 downloadBufferReadPosition;
+ qint64 downloadBufferCurrentSize;
+ qint64 downloadBufferMaximumSize;
+ QSharedPointer<char> downloadBufferPointer;
+ char* downloadBuffer;
+
Q_DECLARE_PUBLIC(QNetworkReplyImpl)
};
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 7eec24e..a48a26f 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -226,6 +226,8 @@ QT_BEGIN_NAMESPACE
\omitvalue DownloadBufferAttribute
+ \omitvalue SynchronousRequestAttribute
+
\value User
Special type. Additional information can be passed in
QVariants with types ranging from User to UserMax. The default
@@ -757,7 +759,7 @@ static QVariant parseCookieHeader(const QByteArray &raw)
result += parsed;
}
- return qVariantFromValue(result);
+ return QVariant::fromValue(result);
}
static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QByteArray &value)
@@ -790,7 +792,7 @@ static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QBy
return parseCookieHeader(value);
case QNetworkRequest::SetCookieHeader:
- return qVariantFromValue(QNetworkCookie::parseCookies(value));
+ return QVariant::fromValue(QNetworkCookie::parseCookies(value));
default:
Q_ASSERT(0);
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 586e6ff..b5ef109 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -84,9 +84,7 @@ public:
CookieSaveControlAttribute,
MaximumDownloadBufferSizeAttribute, // internal
DownloadBufferAttribute, // internal
-
- // (DownloadBufferAttribute + 1) is reserved internal for QSynchronousHttpNetworkReply
- // add the enum in 4.8
+ SynchronousRequestAttribute, // internal
User = 1000,
UserMax = 32767
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
index 684e02b..d58d5ec 100644
--- a/src/network/bearer/bearer.pri
+++ b/src/network/bearer/bearer.pri
@@ -17,4 +17,3 @@ SOURCES += bearer/qnetworksession.cpp \
bearer/qbearerengine.cpp \
bearer/qbearerplugin.cpp \
bearer/qsharednetworksession.cpp
-
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
index 55a1a69..7447051 100644
--- a/src/network/bearer/qbearerengine.cpp
+++ b/src/network/bearer/qbearerengine.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
QBearerEngine::QBearerEngine(QObject *parent)
-: QObject(parent), mutex(QMutex::Recursive)
+ : QObject(parent), mutex(QMutex::Recursive)
{
}
@@ -54,6 +54,7 @@ QBearerEngine::~QBearerEngine()
{
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
+
for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
it.value()->isValid = false;
it.value()->id.clear();
@@ -93,19 +94,20 @@ bool QBearerEngine::configurationsInUse() const
QMutexLocker locker(&mutex);
- for (it = accessPointConfigurations.begin(),
- end = accessPointConfigurations.end(); it != end; ++it) {
+ for (it = accessPointConfigurations.constBegin(),
+ end = accessPointConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
- for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
+ for (it = snapConfigurations.constBegin(),
+ end = snapConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
- for (it = userChoiceConfigurations.begin(),
- end = userChoiceConfigurations.end(); it != end; ++it) {
+ for (it = userChoiceConfigurations.constBegin(),
+ end = userChoiceConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h
index 9bce2b6..e246355 100644
--- a/src/network/bearer/qbearerengine_p.h
+++ b/src/network/bearer/qbearerengine_p.h
@@ -78,7 +78,7 @@ class Q_NETWORK_EXPORT QBearerEngine : public QObject
friend class QNetworkConfigurationManagerPrivate;
public:
- QBearerEngine(QObject *parent = 0);
+ explicit QBearerEngine(QObject *parent = 0);
virtual ~QBearerEngine();
virtual bool hasIdentifier(const QString &id) = 0;
@@ -96,7 +96,6 @@ Q_SIGNALS:
void configurationAdded(QNetworkConfigurationPrivatePointer config);
void configurationRemoved(QNetworkConfigurationPrivatePointer config);
void configurationChanged(QNetworkConfigurationPrivatePointer config);
-
void updateCompleted();
protected:
@@ -114,4 +113,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+#endif // QBEARERENGINE_P_H
diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp
index 76659b5..c198d67 100644
--- a/src/network/bearer/qbearerplugin.cpp
+++ b/src/network/bearer/qbearerplugin.cpp
@@ -41,14 +41,12 @@
#include "qbearerplugin_p.h"
-#include <QtCore/qdebug.h>
-
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent)
-: QObject(parent)
+ : QObject(parent)
{
}
diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h
index 4c7c221..a800f90 100644
--- a/src/network/bearer/qbearerplugin_p.h
+++ b/src/network/bearer/qbearerplugin_p.h
@@ -68,7 +68,7 @@ QT_MODULE(Network)
struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface
{
- virtual QBearerEngine *create(const QString &key = QString()) const = 0;
+ virtual QBearerEngine *create(const QString &key) const = 0;
};
#define QBearerEngineFactoryInterface_iid "com.trolltech.Qt.QBearerEngineFactoryInterface"
@@ -84,7 +84,7 @@ public:
virtual ~QBearerEnginePlugin();
virtual QStringList keys() const = 0;
- virtual QBearerEngine *create(const QString &key = QString()) const = 0;
+ virtual QBearerEngine *create(const QString &key) const = 0;
};
QT_END_NAMESPACE
@@ -93,4 +93,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+#endif // QBEARERPLUGIN_P_H
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index dc4e4f7..9e1eaea 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -52,7 +52,8 @@
QT_BEGIN_NAMESPACE
#define Q_GLOBAL_STATIC_QAPP_DESTRUCTION(TYPE, NAME) \
- Q_GLOBAL_STATIC_INIT(TYPE, NAME); \
+ static QGlobalStatic<TYPE > this_##NAME \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
static void NAME##_cleanup() \
{ \
delete this_##NAME.pointer; \
@@ -117,14 +118,14 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
*/
/*!
- \fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration& config)
+ \fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration &config)
This signal is emitted whenever a new network configuration is added to the system. The new
configuration is specified by \a config.
*/
/*!
- \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration& configuration)
+ \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config)
This signal is emitted when a configuration is about to be removed from the system. The removed
\a configuration is invalid but retains name and identifier.
@@ -137,7 +138,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
be initiated via \l updateConfigurations().
*/
-/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration& config)
+/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration &config)
This signal is emitted when the \l {QNetworkConfiguration::state()}{state} of \a config changes.
*/
@@ -197,7 +198,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
/*!
Constructs a QNetworkConfigurationManager with the given \a parent.
*/
-QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent )
+QNetworkConfigurationManager::QNetworkConfigurationManager(QObject *parent)
: QObject(parent)
{
QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
@@ -206,12 +207,12 @@ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent )
this, SIGNAL(configurationAdded(QNetworkConfiguration)));
connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)),
this, SIGNAL(configurationRemoved(QNetworkConfiguration)));
- connect(priv, SIGNAL(configurationUpdateComplete()),
- this, SIGNAL(updateCompleted()));
- connect(priv, SIGNAL(onlineStateChanged(bool)),
- this, SIGNAL(onlineStateChanged(bool)));
connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)),
this, SIGNAL(configurationChanged(QNetworkConfiguration)));
+ connect(priv, SIGNAL(onlineStateChanged(bool)),
+ this, SIGNAL(onlineStateChanged(bool)));
+ connect(priv, SIGNAL(configurationUpdateComplete()),
+ this, SIGNAL(updateCompleted()));
priv->enablePolling();
}
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
index 5949c6a..565156c 100644
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ b/src/network/bearer/qnetworkconfigmanager.h
@@ -68,7 +68,6 @@ class QNetworkConfigurationManagerExport QNetworkConfigurationManager : public Q
Q_OBJECT
public:
-
enum Capability {
CanStartAndStopInterfaces = 0x00000001,
DirectConnectionRouting = 0x00000002,
@@ -81,26 +80,26 @@ public:
Q_DECLARE_FLAGS(Capabilities, Capability)
- QNetworkConfigurationManager( QObject* parent = 0 );
+ explicit QNetworkConfigurationManager(QObject *parent = 0);
virtual ~QNetworkConfigurationManager();
-
QNetworkConfigurationManager::Capabilities capabilities() const;
- QNetworkConfiguration defaultConfiguration() const;
+ QNetworkConfiguration defaultConfiguration() const;
QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags flags = 0) const;
- QNetworkConfiguration configurationFromIdentifier(const QString& identifier) const;
- void updateConfigurations();
+ QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
bool isOnline() const;
+public Q_SLOTS:
+ void updateConfigurations();
+
Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration& config);
- void configurationRemoved(const QNetworkConfiguration& config);
- void configurationChanged(const QNetworkConfiguration& config);
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
void onlineStateChanged(bool isOnline);
void updateCompleted();
-
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
@@ -115,5 +114,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKCONFIGURATIONMANAGER_H
-
+#endif // QNETWORKCONFIGURATIONMANAGER_H
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index c321328..c108ad3 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
#endif
QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
-: pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
+ : QObject(), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
{
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
@@ -73,13 +73,12 @@ QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
qDeleteAll(sessionEngines);
}
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration()
+QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
{
QMutexLocker locker(&mutex);
foreach (QBearerEngine *engine, sessionEngines) {
QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
-
if (ptr) {
QNetworkConfiguration config;
config.d = ptr;
@@ -98,8 +97,8 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
QMutexLocker locker(&engine->mutex);
- for (it = engine->snapConfigurations.begin(), end = engine->snapConfigurations.end();
- it != end; ++it) {
+ for (it = engine->snapConfigurations.begin(),
+ end = engine->snapConfigurations.end(); it != end; ++it) {
QNetworkConfigurationPrivatePointer ptr = it.value();
QMutexLocker configLocker(&ptr->mutex);
@@ -109,10 +108,8 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
config.d = ptr;
return config;
} else if (!defaultConfiguration) {
- if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
+ if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
defaultConfiguration = ptr;
- }
}
}
}
@@ -136,8 +133,6 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
6. Discovered Other
*/
- defaultConfiguration.reset();
-
foreach (QBearerEngine *engine, sessionEngines) {
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
@@ -151,8 +146,7 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
QMutexLocker configLocker(&ptr->mutex);
QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
- if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
+ if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
if (!defaultConfiguration) {
defaultConfiguration = ptr;
} else {
@@ -196,7 +190,7 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
return QNetworkConfiguration();
}
-QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter)
+QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter) const
{
QList<QNetworkConfiguration> result;
@@ -240,7 +234,7 @@ QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurati
return result;
}
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier)
+QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier) const
{
QNetworkConfiguration item;
@@ -250,11 +244,11 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIden
QMutexLocker locker(&engine->mutex);
if (engine->accessPointConfigurations.contains(identifier))
- item.d = engine->accessPointConfigurations.value(identifier);
+ item.d = engine->accessPointConfigurations[identifier];
else if (engine->snapConfigurations.contains(identifier))
- item.d = engine->snapConfigurations.value(identifier);
+ item.d = engine->snapConfigurations[identifier];
else if (engine->userChoiceConfigurations.contains(identifier))
- item.d = engine->userChoiceConfigurations.value(identifier);
+ item.d = engine->userChoiceConfigurations[identifier];
else
continue;
@@ -264,14 +258,14 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIden
return item;
}
-bool QNetworkConfigurationManagerPrivate::isOnline()
+bool QNetworkConfigurationManagerPrivate::isOnline() const
{
QMutexLocker locker(&mutex);
return !onlineConfigurations.isEmpty();
}
-QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities()
+QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const
{
QMutexLocker locker(&mutex);
@@ -353,7 +347,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
QMutexLocker locker(&mutex);
if (firstUpdate) {
- if (sender())
+ if (qobject_cast<QBearerEngine *>(sender()))
return;
if (thread() != QCoreApplicationPrivate::mainThread()) {
@@ -366,10 +360,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
updating = false;
#ifndef QT_NO_LIBRARY
- QFactoryLoader *l = loader();
-
QBearerEngine *generic = 0;
+ QFactoryLoader *l = loader();
foreach (const QString &key, l->keys()) {
QBearerEnginePlugin *plugin = qobject_cast<QBearerEnginePlugin *>(l->instance(key));
if (plugin) {
@@ -403,11 +396,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
- if (!updatingEngines.isEmpty() && engine) {
- int index = sessionEngines.indexOf(engine);
- if (index >= 0)
- updatingEngines.remove(index);
- }
+ if (engine && !updatingEngines.isEmpty())
+ updatingEngines.remove(engine);
if (updating && updatingEngines.isEmpty()) {
updating = false;
@@ -415,10 +405,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
if (engine && !pollingEngines.isEmpty()) {
- int index = sessionEngines.indexOf(engine);
- if (index >= 0)
- pollingEngines.remove(index);
-
+ pollingEngines.remove(engine);
if (pollingEngines.isEmpty())
startPolling();
}
@@ -438,13 +425,13 @@ void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
updating = true;
- for (int i = 0; i < sessionEngines.count(); ++i) {
- updatingEngines.insert(i);
- QMetaObject::invokeMethod(sessionEngines.at(i), "requestUpdate");
+ foreach (QBearerEngine *engine, sessionEngines) {
+ updatingEngines.insert(engine);
+ QMetaObject::invokeMethod(engine, "requestUpdate");
}
}
-QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines()
+QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() const
{
QMutexLocker locker(&mutex);
@@ -455,35 +442,11 @@ void QNetworkConfigurationManagerPrivate::startPolling()
{
QMutexLocker locker(&mutex);
- bool pollingRequired = false;
-
- if (forcedPolling > 0) {
- foreach (QBearerEngine *engine, sessionEngines) {
- if (engine->requiresPolling()) {
- pollingRequired = true;
- break;
- }
- }
- }
-
- if (!pollingRequired) {
- foreach (QBearerEngine *engine, sessionEngines) {
- if (engine->configurationsInUse()) {
- pollingRequired = true;
- break;
- }
- }
- }
-
- if (pollingRequired) {
- if (!pollTimer) {
- pollTimer = new QTimer(this);
- pollTimer->setInterval(10000);
- pollTimer->setSingleShot(true);
- connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
+ foreach (QBearerEngine *engine, sessionEngines) {
+ if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
+ QTimer::singleShot(10000, this, SLOT(pollEngines()));
+ break;
}
-
- pollTimer->start();
}
}
@@ -491,13 +454,10 @@ void QNetworkConfigurationManagerPrivate::pollEngines()
{
QMutexLocker locker(&mutex);
- for (int i = 0; i < sessionEngines.count(); ++i) {
- if (!sessionEngines.at(i)->requiresPolling())
- continue;
-
- if (forcedPolling || sessionEngines.at(i)->configurationsInUse()) {
- pollingEngines.insert(i);
- QMetaObject::invokeMethod(sessionEngines.at(i), "requestUpdate");
+ foreach (QBearerEngine *engine, sessionEngines) {
+ if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
+ pollingEngines.insert(engine);
+ QMetaObject::invokeMethod(engine, "requestUpdate");
}
}
}
@@ -509,7 +469,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling()
++forcedPolling;
if (forcedPolling == 1)
- QMetaObject::invokeMethod(this, "startPolling");
+ startPolling();
}
void QNetworkConfigurationManagerPrivate::disablePolling()
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 0c20853..81f38c5 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -64,7 +64,6 @@
QT_BEGIN_NAMESPACE
class QBearerEngine;
-class QTimer;
class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject
{
@@ -74,57 +73,54 @@ public:
QNetworkConfigurationManagerPrivate();
virtual ~QNetworkConfigurationManagerPrivate();
- QNetworkConfiguration defaultConfiguration();
- QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter);
- QNetworkConfiguration configurationFromIdentifier(const QString &identifier);
+ QNetworkConfiguration defaultConfiguration() const;
+ QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter) const;
+ QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
- bool isOnline();
+ bool isOnline() const;
- QNetworkConfigurationManager::Capabilities capabilities();
+ QNetworkConfigurationManager::Capabilities capabilities() const;
void performAsyncConfigurationUpdate();
- QList<QBearerEngine *> engines();
-
- Q_INVOKABLE void startPolling();
+ QList<QBearerEngine *> engines() const;
void enablePolling();
void disablePolling();
-public slots:
+public Q_SLOTS:
void updateConfigurations();
Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration& config);
- void configurationRemoved(const QNetworkConfiguration& config);
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
void configurationUpdateComplete();
- void configurationChanged(const QNetworkConfiguration& config);
void onlineStateChanged(bool isOnline);
- void abort();
+private Q_SLOTS:
+ void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
+ void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
+ void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
+
+ void pollEngines();
private:
- QTimer *pollTimer;
+ void startPolling();
- QMutex mutex;
+private:
+ mutable QMutex mutex;
QList<QBearerEngine *> sessionEngines;
QSet<QString> onlineConfigurations;
- QSet<int> pollingEngines;
- QSet<int> updatingEngines;
+ QSet<QBearerEngine *> pollingEngines;
+ QSet<QBearerEngine *> updatingEngines;
int forcedPolling;
bool updating;
bool firstUpdate;
-
-private Q_SLOTS:
- void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
- void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
- void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
-
- void pollEngines();
};
Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate();
@@ -133,4 +129,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H
+#endif // QNETWORKCONFIGURATIONMANAGERPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index fbcdc74..4cc3099 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -212,44 +212,38 @@ QNetworkConfiguration::QNetworkConfiguration()
/*!
Creates a copy of the QNetworkConfiguration object contained in \a other.
*/
-QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration& other)
+QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration &other)
: d(other.d)
{
}
/*!
- Copies the content of the QNetworkConfiguration object contained in \a other into this one.
+ Frees the resources associated with the QNetworkConfiguration object.
*/
-QNetworkConfiguration& QNetworkConfiguration::operator=(const QNetworkConfiguration& other)
+QNetworkConfiguration::~QNetworkConfiguration()
{
- d = other.d;
- return *this;
}
/*!
- Frees the resources associated with the QNetworkConfiguration object.
+ Copies the content of the QNetworkConfiguration object contained in \a other into this one.
*/
-QNetworkConfiguration::~QNetworkConfiguration()
+QNetworkConfiguration &QNetworkConfiguration::operator=(const QNetworkConfiguration &other)
{
+ d = other.d;
+ return *this;
}
/*!
Returns true, if this configuration is the same as the \a other
configuration given; otherwise returns false.
*/
-bool QNetworkConfiguration::operator==(const QNetworkConfiguration& other) const
+bool QNetworkConfiguration::operator==(const QNetworkConfiguration &other) const
{
- if (!d)
- return !other.d;
-
- if (!other.d)
- return false;
-
return (d == other.d);
}
/*!
- \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration& other) const
+ \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration &other) const
Returns true if this configuration is not the same as the \a other
configuration given; otherwise returns false.
@@ -370,11 +364,14 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
{
QList<QNetworkConfiguration> results;
- if (type() != QNetworkConfiguration::ServiceNetwork || !isValid())
+ if (!d)
return results;
QMutexLocker locker(&d->mutex);
+ if (d->type != QNetworkConfiguration::ServiceNetwork || !d->isValid)
+ return results;
+
QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers);
while (i.hasNext()) {
i.next();
@@ -510,4 +507,3 @@ QString QNetworkConfiguration::bearerTypeName() const
}
QT_END_NAMESPACE
-
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 9370816..2e8dadd 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -73,12 +73,12 @@ class QNetworkConfigurationExport QNetworkConfiguration
public:
QNetworkConfiguration();
QNetworkConfiguration(const QNetworkConfiguration& other);
- QNetworkConfiguration &operator=(const QNetworkConfiguration& other);
+ QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
~QNetworkConfiguration();
- bool operator==(const QNetworkConfiguration& cp) const;
- inline bool operator!=(const QNetworkConfiguration& cp) const
- { return !operator==(cp); }
+ bool operator==(const QNetworkConfiguration &other) const;
+ inline bool operator!=(const QNetworkConfiguration &other) const
+ { return !operator==(other); }
enum Type {
InternetAccessPoint = 0,
@@ -100,7 +100,6 @@ public:
Discovered = 0x0000006,
Active = 0x000000e
};
-
Q_DECLARE_FLAGS(StateFlags, StateFlag)
#ifndef QT_MOBILITY_BEARER
@@ -155,4 +154,4 @@ QTM_END_NAMESPACE
QT_END_HEADER
-#endif //QNETWORKCONFIGURATION_H
+#endif // QNETWORKCONFIGURATION_H
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index 3a9259d..a38bc0b 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -65,18 +65,17 @@ typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfi
class QNetworkConfigurationPrivate : public QSharedData
{
public:
- QNetworkConfigurationPrivate ()
- : mutex(QMutex::Recursive), type(QNetworkConfiguration::Invalid),
+ QNetworkConfigurationPrivate() :
+ mutex(QMutex::Recursive),
+ type(QNetworkConfiguration::Invalid),
purpose(QNetworkConfiguration::UnknownPurpose),
bearerType(QNetworkConfiguration::BearerUnknown),
isValid(false), roamingSupported(false)
- {
- }
-
+ {}
virtual ~QNetworkConfigurationPrivate()
{
//release pointers to member configurations
- serviceNetworkMembers.clear();
+ serviceNetworkMembers.clear();
}
virtual QString bearerTypeName() const
@@ -100,11 +99,9 @@ public:
bool roamingSupported;
private:
- // disallow detaching
- QNetworkConfigurationPrivate &operator=(const QNetworkConfigurationPrivate &other);
- QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other);
+ Q_DISABLE_COPY(QNetworkConfigurationPrivate)
};
QT_END_NAMESPACE
-#endif //QNETWORKCONFIGURATIONPRIVATE_H
+#endif // QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 9503553..af60a43 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -39,11 +39,12 @@
**
****************************************************************************/
+#include "qnetworksession.h"
+#include "qbearerengine_p.h"
+
#include <QEventLoop>
#include <QTimer>
-#include "qnetworksession.h"
-#include "qbearerengine_p.h"
#include "qnetworkconfigmanager_p.h"
#include "qnetworksession_p.h"
@@ -165,7 +166,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless)
+ \fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless)
This signal is emitted when the preferred configuration/access point for the
session changes. Only sessions which are based on service network configurations
@@ -224,30 +225,29 @@ QT_BEGIN_NAMESPACE
\sa QNetworkConfiguration
*/
-QNetworkSession::QNetworkSession(const QNetworkConfiguration& connectionConfig, QObject* parent)
-: QObject(parent), d(0)
+QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent)
+ : QObject(parent), d(0)
{
// invalid configuration
- if (connectionConfig.identifier().isNull())
- return;
-
- foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) {
- if (engine->hasIdentifier(connectionConfig.identifier())) {
- d = engine->createSessionBackend();
- d->q = this;
- d->publicConfig = connectionConfig;
- d->syncStateWithInterface();
- connect(d, SIGNAL(quitPendingWaitsForOpened()), this, SIGNAL(opened()));
- connect(d, SIGNAL(error(QNetworkSession::SessionError)),
- this, SIGNAL(error(QNetworkSession::SessionError)));
- connect(d, SIGNAL(stateChanged(QNetworkSession::State)),
- this, SIGNAL(stateChanged(QNetworkSession::State)));
- connect(d, SIGNAL(closed()), this, SIGNAL(closed()));
- connect(d, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
- this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
- connect(d, SIGNAL(newConfigurationActivated()),
- this, SIGNAL(newConfigurationActivated()));
- break;
+ if (!connectionConfig.identifier().isEmpty()) {
+ foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) {
+ if (engine->hasIdentifier(connectionConfig.identifier())) {
+ d = engine->createSessionBackend();
+ d->q = this;
+ d->publicConfig = connectionConfig;
+ d->syncStateWithInterface();
+ connect(d, SIGNAL(quitPendingWaitsForOpened()), this, SIGNAL(opened()));
+ connect(d, SIGNAL(error(QNetworkSession::SessionError)),
+ this, SIGNAL(error(QNetworkSession::SessionError)));
+ connect(d, SIGNAL(stateChanged(QNetworkSession::State)),
+ this, SIGNAL(stateChanged(QNetworkSession::State)));
+ connect(d, SIGNAL(closed()), this, SIGNAL(closed()));
+ connect(d, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
+ this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
+ connect(d, SIGNAL(newConfigurationActivated()),
+ this, SIGNAL(newConfigurationActivated()));
+ break;
+ }
}
}
@@ -317,19 +317,16 @@ bool QNetworkSession::waitForOpened(int msecs)
return false;
}
- QEventLoop* loop = new QEventLoop(this);
- QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()),
- loop, SLOT(quit()));
- QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)),
- loop, SLOT(quit()));
+ QEventLoop loop;
+ QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), &loop, SLOT(quit()));
+ QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), &loop, SLOT(quit()));
//final call
- if (msecs>=0)
- QTimer::singleShot(msecs, loop, SLOT(quit()));
+ if (msecs >= 0)
+ QTimer::singleShot(msecs, &loop, SLOT(quit()));
- loop->exec();
- loop->disconnect();
- loop->deleteLater();
+ // enter the event loop and wait for opened/error/timeout
+ loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
return d->isOpen;
}
@@ -475,7 +472,7 @@ QString QNetworkSession::errorString() const
\code
QNetworkConfigurationManager mgr;
QNetworkConfiguration ap = mgr.defaultConfiguration();
- QNetworkSession* session = new QNetworkSession(ap);
+ QNetworkSession *session = new QNetworkSession(ap);
... //code activates session
QString ident = session->sessionProperty("ActiveConfiguration").toString();
@@ -520,20 +517,13 @@ QString QNetworkSession::errorString() const
has no effect for sessions that do not require polling.
\endtable
*/
-QVariant QNetworkSession::sessionProperty(const QString& key) const
+QVariant QNetworkSession::sessionProperty(const QString &key) const
{
- if (!d)
- return QVariant();
-
- if (!d->publicConfig.isValid())
+ if (!d || !d->publicConfig.isValid())
return QVariant();
- if (key == QLatin1String("ActiveConfiguration")) {
- if (!d->isOpen)
- return QString();
- else
- return d->activeConfig.identifier();
- }
+ if (key == QLatin1String("ActiveConfiguration"))
+ return d->isOpen ? d->activeConfig.identifier() : QString();
if (key == QLatin1String("UserChoiceConfiguration")) {
if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
@@ -556,7 +546,7 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
Note that the \e UserChoiceConfiguration and \e ActiveConfiguration
properties are read only and cannot be changed using this method.
*/
-void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value)
+void QNetworkSession::setSessionProperty(const QString &key, const QVariant &value)
{
if (!d)
return;
@@ -590,7 +580,7 @@ void QNetworkSession::migrate()
*/
void QNetworkSession::ignore()
{
- // Needed on at least Symbian platform: the roaming must be explicitly
+ // Needed on at least Symbian platform: the roaming must be explicitly
// ignore()'d or migrate()'d
if (d)
d->ignore();
@@ -684,11 +674,12 @@ quint64 QNetworkSession::activeTime() const
void QNetworkSession::connectNotify(const char *signal)
{
QObject::connectNotify(signal);
- //check for preferredConfigurationChanged() signal connect notification
- //This is not required on all platforms
+
if (!d)
return;
+ //check for preferredConfigurationChanged() signal connect notification
+ //This is not required on all platforms
if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0)
d->setALREnabled(true);
}
@@ -696,19 +687,20 @@ void QNetworkSession::connectNotify(const char *signal)
/*!
\internal
- This function is called when the client disconnects from the preferredConfigurationChanged()
- signal.
+ This function is called when the client disconnects from the
+ preferredConfigurationChanged() signal.
\sa connectNotify()
*/
void QNetworkSession::disconnectNotify(const char *signal)
{
QObject::disconnectNotify(signal);
- //check for preferredConfigurationChanged() signal disconnect notification
- //This is not required on all platforms
+
if (!d)
return;
+ //check for preferredConfigurationChanged() signal disconnect notification
+ //This is not required on all platforms
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 ee28e64..688f37e 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -71,6 +71,7 @@ class QNetworkSessionPrivate;
class QNetworkSessionExport QNetworkSession : public QObject
{
Q_OBJECT
+
public:
enum State {
Invalid = 0,
@@ -89,7 +90,8 @@ public:
OperationNotSupportedError,
InvalidConfigurationError
};
- explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
+
+ explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = 0);
virtual ~QNetworkSession();
bool isOpen() const;
@@ -101,8 +103,8 @@ public:
State state() const;
SessionError error() const;
QString errorString() const;
- QVariant sessionProperty(const QString& key) const;
- void setSessionProperty(const QString& key, const QVariant& value);
+ QVariant sessionProperty(const QString &key) const;
+ void setSessionProperty(const QString &key, const QVariant &value);
quint64 bytesWritten() const;
quint64 bytesReceived() const;
@@ -121,13 +123,12 @@ public Q_SLOTS:
void accept();
void reject();
-
Q_SIGNALS:
void stateChanged(QNetworkSession::State);
void opened();
void closed();
void error(QNetworkSession::SessionError);
- void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless);
+ void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
void newConfigurationActivated();
protected:
@@ -135,9 +136,9 @@ protected:
virtual void disconnectNotify(const char *signal);
private:
- QNetworkSessionPrivate* d;
friend class QNetworkSessionPrivate;
- };
+ QNetworkSessionPrivate *d;
+};
#ifndef QT_MOBILITY_BEARER
QT_END_NAMESPACE
@@ -151,4 +152,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSION_H
+#endif // QNETWORKSESSION_H
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index d24eeb1..707ad37 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -67,14 +67,11 @@ class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject
friend class QNetworkSession;
public:
- QNetworkSessionPrivate()
- : state(QNetworkSession::Invalid), isOpen(false)
- {
- }
-
+ QNetworkSessionPrivate() : QObject(),
+ state(QNetworkSession::Invalid), isOpen(false)
+ {}
virtual ~QNetworkSessionPrivate()
- {
- }
+ {}
//called by QNetworkSession constructor and ensures
//that the state is immediately updated (w/o actually opening
@@ -85,14 +82,14 @@ public:
#ifndef QT_NO_NETWORKINTERFACE
virtual QNetworkInterface currentInterface() const = 0;
#endif
- virtual QVariant sessionProperty(const QString& key) const = 0;
- virtual void setSessionProperty(const QString& key, const QVariant& value) = 0;
+ virtual QVariant sessionProperty(const QString &key) const = 0;
+ virtual void setSessionProperty(const QString &key, const QVariant &value) = 0;
virtual void open() = 0;
virtual void close() = 0;
virtual void stop() = 0;
- virtual void setALREnabled(bool /*enabled*/) { }
+ virtual void setALREnabled(bool /*enabled*/) {}
virtual void migrate() = 0;
virtual void accept() = 0;
virtual void ignore() = 0;
@@ -150,5 +147,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSIONPRIVATE_H
-
+#endif // QNETWORKSESSIONPRIVATE_H
diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h
index dc84166..25b4ec2 100644
--- a/src/network/bearer/qsharednetworksession_p.h
+++ b/src/network/bearer/qsharednetworksession_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,6 +64,8 @@
QT_BEGIN_NAMESPACE
+uint qHash(const QNetworkConfiguration& config);
+
class QSharedNetworkSessionManager
{
public:
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/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index 261313a..5ec6041 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -56,9 +56,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_THREAD
Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager)
-#endif
//#define QHOSTINFO_DEBUG
@@ -87,10 +85,8 @@ Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager)
\snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 0
- The slot is invoked when the results are ready. (If you use
- Qt for Embedded Linux and disabled multithreading support by defining
- \c QT_NO_THREAD, lookupHost() will block until the lookup has
- finished.) The results are stored in a QHostInfo object. Call
+ The slot is invoked when the results are ready. The results are
+ stored in a QHostInfo object. Call
addresses() to get the list of IP addresses for the host, and
hostName() to get the host name that was looked up.
@@ -176,14 +172,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
return id;
}
-#ifdef QT_NO_THREAD
- QHostInfo hostInfo = QHostInfoAgent::fromName(name);
- hostInfo.setLookupId(id);
- QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
- QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
- receiver, member, Qt::QueuedConnection);
- result.data()->emitResultsReady(hostInfo);
-#else
QHostInfoLookupManager *manager = theHostInfoLookupManager();
if (manager) {
// the application is still alive
@@ -204,8 +192,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
manager->scheduleLookup(runnable);
}
-#endif
-
return id;
}
@@ -216,12 +202,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
*/
void QHostInfo::abortHostLookup(int id)
{
-#ifndef QT_NO_THREAD
theHostInfoLookupManager()->abortLookup(id);
-#else
- // we cannot abort if it was non threaded.. the result signal has already been posted
- Q_UNUSED(id);
-#endif
}
/*!
@@ -425,7 +406,6 @@ void QHostInfo::setErrorString(const QString &str)
\sa hostName()
*/
-#ifndef QT_NO_THREAD
QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i)
{
setAutoDelete(true);
@@ -753,6 +733,4 @@ void QHostInfoCache::clear()
cache.clear();
}
-#endif // QT_NO_THREAD
-
QT_END_NAMESPACE
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 331443b..b568ec2 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -60,8 +60,6 @@
#include "QtCore/qwaitcondition.h"
#include "QtCore/qobject.h"
#include "QtCore/qpointer.h"
-
-#ifndef QT_NO_THREAD
#include "QtCore/qthread.h"
#include "QtCore/qthreadpool.h"
#include "QtCore/qmutex.h"
@@ -70,7 +68,7 @@
#include "QtCore/qqueue.h"
#include <QElapsedTimer>
#include <QCache>
-#endif
+
QT_BEGIN_NAMESPACE
@@ -112,7 +110,6 @@ public:
int lookupId;
};
-#ifndef QT_NO_THREAD
// These functions are outside of the QHostInfo class and strictly internal.
// Do NOT use them outside of QAbstractSocket.
QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id);
@@ -192,8 +189,6 @@ private slots:
void waitForThreadPoolDone() { threadPool.waitForDone(); }
};
-#endif
-
QT_END_NAMESPACE
#endif // QHOSTINFO_P_H
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 111c4c6..22f6e0d 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -132,9 +132,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
// Load res_init on demand.
static volatile bool triedResolve = false;
if (!triedResolve) {
-#ifndef QT_NO_THREAD
QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_init));
-#endif
if (!triedResolve) {
resolveLibrary();
triedResolve = true;
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index bddda41..58f309b 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -39,11 +39,6 @@
**
****************************************************************************/
-#if defined Q_CC_MSVC && _MSC_VER <=1300
-//VC.net 2002 support for templates doesn't match some PSDK requirements
-#define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0]))
-#endif
-
#include <winsock2.h>
#include "qhostinfo_p.h"
@@ -115,9 +110,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
// Load res_init on demand.
static volatile bool triedResolve = false;
if (!triedResolve) {
-#ifndef QT_NO_THREAD
QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo));
-#endif
if (!triedResolve) {
resolveLibrary();
triedResolve = true;
diff --git a/src/network/network.pro b/src/network/network.pro
index 7ed7d3a..948922b 100644
--- a/src/network/network.pro
+++ b/src/network/network.pro
@@ -13,7 +13,7 @@ DEFINES += QT_BUILD_NETWORK_LIB QT_NO_USING_NAMESPACE
QT = core
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x64000000
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
include(access/access.pri)
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index f927ae2..c7c2e82 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -356,6 +356,10 @@
to enable.
\value KeepAliveOption Set this to 1 to enable the SO_KEEPALIVE socket option
+ \value MulticastTtlOption Set this to an integer value to set IP_MULTICAST_TTL (TTL for multicast datagrams) socket option.
+
+ \value MulticastLoopbackOption Set this to 1 to enable the IP_MULTICAST_LOOP (multicast loopback) socket option.
+
\sa QAbstractSocket::setSocketOption(), QAbstractSocket::socketOption()
*/
@@ -466,9 +470,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
peerPort(0),
socketEngine(0),
cachedSocketDescriptor(-1),
-#ifdef Q_OS_LINUX
- addToBytesAvailable(0),
-#endif
readBufferMaxSize(0),
readBuffer(QABSTRACTSOCKET_BUFFERSIZE),
writeBuffer(QABSTRACTSOCKET_BUFFERSIZE),
@@ -630,8 +631,9 @@ bool QAbstractSocketPrivate::canReadNotification()
// only emit readyRead() when not recursing, and only if there is data available
bool hasData = newBytes > 0
#ifndef QT_NO_UDPSOCKET
- || (!isBuffered && socketEngine && socketEngine->hasPendingDatagrams())
+ || (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams())
#endif
+ || (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine)
;
if (!emittedReadyRead && hasData) {
@@ -1132,10 +1134,6 @@ bool QAbstractSocketPrivate::readFromSocket()
Q_Q(QAbstractSocket);
// Find how many bytes we can read from the socket layer.
qint64 bytesToRead = socketEngine->bytesAvailable();
-#ifdef Q_OS_LINUX
- if (bytesToRead > 0) // ### See setSocketDescriptor()
- bytesToRead += addToBytesAvailable;
-#endif
if (bytesToRead == 0) {
// Under heavy load, certain conditions can trigger read notifications
// for socket notifiers on which there is no activity. If we continue
@@ -1370,10 +1368,6 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
d->localAddress.clear();
d->peerAddress.clear();
d->peerName = hostName;
-#ifdef Q_OS_LINUX
- // ### See setSocketDescriptor().
- d->addToBytesAvailable = 0;
-#endif
if (d->hostLookupId != -1) {
QHostInfo::abortHostLookup(d->hostLookupId);
d->hostLookupId = -1;
@@ -1391,8 +1385,11 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
}
#endif
- if (!d_func()->isBuffered)
- openMode |= QAbstractSocket::Unbuffered;
+ if (openMode & QIODevice::Unbuffered)
+ d->isBuffered = false; // Unbuffered QTcpSocket
+ else if (!d_func()->isBuffered)
+ openMode |= QAbstractSocket::Unbuffered; // QUdpSocket
+
QIODevice::open(openMode);
d->state = HostLookupState;
emit stateChanged(d->state);
@@ -1472,10 +1469,12 @@ qint64 QAbstractSocket::bytesAvailable() const
{
Q_D(const QAbstractSocket);
qint64 available = QIODevice::bytesAvailable();
- if (d->isBuffered)
- available += (qint64) d->readBuffer.size();
- else if (d->socketEngine && d->socketEngine->isValid())
+
+ available += (qint64) d->readBuffer.size();
+
+ if (!d->isBuffered && d->socketEngine && d->socketEngine->isValid())
available += d->socketEngine->bytesAvailable();
+
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::bytesAvailable() == %llu", available);
#endif
@@ -1633,17 +1632,6 @@ bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState sock
d->peerAddress = d->socketEngine->peerAddress();
d->cachedSocketDescriptor = socketDescriptor;
-#ifdef Q_OS_LINUX
- // ### This is a workaround for certain broken Linux kernels, when using
- // QTcpSocket with a Unix domain socket. It was introduced around 2.6.9,
- // and fixed at some point after that.
- // http://archive.linux-usenet.com/index-t-73300.html
- // We can provide a better workaround for this: readFromSocket() can loop
- // while reading, but this must happen without triggering an implicit
- // close because of reading after the socket has closed.
- d->addToBytesAvailable = 4096;
-#endif
-
return true;
}
@@ -1673,6 +1661,14 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons
case KeepAliveOption:
d_func()->socketEngine->setOption(QAbstractSocketEngine::KeepAliveOption, value.toInt());
break;
+
+ case MulticastTtlOption:
+ d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastTtlOption, value.toInt());
+ break;
+
+ case MulticastLoopbackOption:
+ d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastLoopbackOption, value.toInt());
+ break;
}
}
@@ -1702,6 +1698,13 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
case KeepAliveOption:
ret = d_func()->socketEngine->option(QAbstractSocketEngine::KeepAliveOption);
break;
+
+ case MulticastTtlOption:
+ ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastTtlOption);
+ break;
+ case MulticastLoopbackOption:
+ ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastLoopbackOption);
+ break;
}
if (ret == -1)
return QVariant();
@@ -2119,42 +2122,51 @@ bool QAbstractSocket::flush()
qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
{
Q_D(QAbstractSocket);
- if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid())
- d->socketEngine->setReadNotificationEnabled(true);
- if (!d->isBuffered) {
- if (!d->socketEngine)
- return -1; // no socket engine is probably EOF
- qint64 readBytes = d->socketEngine->read(data, maxSize);
- if (readBytes < 0) {
- d->socketError = d->socketEngine->error();
- setErrorString(d->socketEngine->errorString());
- }
- if (!d->socketEngine->isReadNotificationEnabled())
- d->socketEngine->setReadNotificationEnabled(true);
-#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld",
- data, qt_prettyDebug(data, 32, readBytes).data(), maxSize,
- readBytes);
-#endif
- return readBytes;
- }
-
- if (d->readBuffer.isEmpty())
+ // This is for a buffered QTcpSocket
+ if (d->isBuffered && d->readBuffer.isEmpty())
// if we're still connected, return 0 indicating there may be more data in the future
// if we're not connected, return -1 indicating EOF
return d->state == QAbstractSocket::ConnectedState ? qint64(0) : qint64(-1);
- // If readFromSocket() read data, copy it to its destination.
- if (maxSize == 1) {
+ // short cut for a char read if we have something in the buffer
+ if (maxSize == 1 && !d->readBuffer.isEmpty()) {
*data = d->readBuffer.getChar();
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', 1) == 1",
+ qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', 1) == 1 [char buffer]",
data, isprint(int(uchar(*data))) ? *data : '?', *data);
#endif
+ if (d->readBuffer.isEmpty() && d->socketEngine && d->socketEngine->isValid())
+ d->socketEngine->setReadNotificationEnabled(true);
return 1;
}
+ // Special case for an Unbuffered QTcpSocket
+ // Re-filling the buffer.
+ if (d->socketType == TcpSocket
+ && !d->isBuffered
+ && d->readBuffer.size() < maxSize
+ && d->readBufferMaxSize > 0
+ && maxSize < d->readBufferMaxSize
+ && d->socketEngine
+ && d->socketEngine->isValid()) {
+ // Our buffer is empty and a read() was requested for a byte amount that is smaller
+ // than the readBufferMaxSize. This means that we should fill our buffer since we want
+ // such small reads come from the buffer and not always go to the costly socket engine read()
+ qint64 bytesToRead = d->socketEngine->bytesAvailable();
+ if (bytesToRead > 0) {
+ char *ptr = d->readBuffer.reserve(bytesToRead);
+ qint64 readBytes = d->socketEngine->read(ptr, bytesToRead);
+ if (readBytes == -2) {
+ // No bytes currently available for reading.
+ d->readBuffer.chop(bytesToRead);
+ } else {
+ d->readBuffer.chop(int(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes)));
+ }
+ }
+ }
+
+ // First try to satisfy the read from the buffer
qint64 bytesToRead = qMin(qint64(d->readBuffer.size()), maxSize);
qint64 readSoFar = 0;
while (readSoFar < bytesToRead) {
@@ -2166,8 +2178,56 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
d->readBuffer.free(bytesToReadFromThisBlock);
}
+ if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid())
+ d->socketEngine->setReadNotificationEnabled(true);
+
+ if (readSoFar > 0) {
+ // we read some data from buffer.
+ // Just return, readyRead will be emitted again
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld",
+ qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', %lli) == %lli [buffer]",
+ data, isprint(int(uchar(*data))) ? *data : '?', *data, maxSize, readSoFar);
+#endif
+
+ if (d->readBuffer.isEmpty() && d->socketEngine)
+ d->socketEngine->setReadNotificationEnabled(true);
+ return readSoFar;
+ }
+
+ // This code path is for Unbuffered QTcpSocket or for connected UDP
+
+ if (!d->isBuffered) {
+ if (!d->socketEngine)
+ return -1; // no socket engine is probably EOF
+ if (!d->socketEngine->isValid())
+ return -1; // This is for unbuffered TCP when we already had been disconnected
+ if (d->state != QAbstractSocket::ConnectedState)
+ return -1; // This is for unbuffered TCP if we're not connected yet
+ qint64 readBytes = d->socketEngine->read(data, maxSize);
+ if (readBytes == -2) {
+ // -2 from the engine means no bytes available (EAGAIN) so read more later
+ return 0;
+ } else if (readBytes < 0) {
+ d->socketError = d->socketEngine->error();
+ setErrorString(d->socketEngine->errorString());
+ d->resetSocketLayer();
+ d->state = QAbstractSocket::UnconnectedState;
+ } else if (!d->socketEngine->isReadNotificationEnabled()) {
+ // Only do this when there was no error
+ d->socketEngine->setReadNotificationEnabled(true);
+ }
+
+#if defined (QABSTRACTSOCKET_DEBUG)
+ qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld [engine]",
+ data, qt_prettyDebug(data, 32, readBytes).data(), maxSize,
+ readBytes);
+#endif
+ return readBytes;
+ }
+
+
+#if defined (QABSTRACTSOCKET_DEBUG)
+ qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld [unreachable]",
data, qt_prettyDebug(data, qMin<qint64>(32, readSoFar), readSoFar).data(),
maxSize, readSoFar);
#endif
@@ -2192,7 +2252,23 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
return -1;
}
- if (!d->isBuffered) {
+ if (!d->isBuffered && d->socketType == TcpSocket && d->writeBuffer.isEmpty()) {
+ // This code is for the new Unbuffered QTcpSocket use case
+ qint64 written = d->socketEngine->write(data, size);
+ if (written < 0) {
+ d->socketError = d->socketEngine->error();
+ setErrorString(d->socketEngine->errorString());
+ return written;
+ } else if (written < size) {
+ // Buffer what was not written yet
+ char *ptr = d->writeBuffer.reserve(size - written);
+ memcpy(ptr, data + written, size - written);
+ if (d->socketEngine)
+ d->socketEngine->setWriteNotificationEnabled(true);
+ }
+ return size; // size=actually written + what has been buffered
+ } else if (!d->isBuffered && d->socketType != TcpSocket) {
+ // This is for a QUdpSocket that was connect()ed
qint64 written = d->socketEngine->write(data, size);
if (written < 0) {
d->socketError = d->socketEngine->error();
@@ -2211,6 +2287,12 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
return written;
}
+ // This is the code path for normal buffered QTcpSocket or
+ // unbuffered QTcpSocket when there was already something in the
+ // write buffer and therefore we could not do a direct engine write.
+ // We just write to our write buffer and enable the write notifier
+ // The write notifier then flush()es the buffer.
+
char *ptr = d->writeBuffer.reserve(size);
if (size == 1)
*ptr = *data;
@@ -2549,7 +2631,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
// ensure that the read notification is enabled if we've now got
// room in the read buffer
// but only if we're not inside canReadNotification -- that will take care on its own
- if (size == 0 || d->readBuffer.size() < size)
+ if ((size == 0 || d->readBuffer.size() < size) && d->state == QAbstractSocket::ConnectedState) // Do not change the notifier unless we are connected.
d->socketEngine->setReadNotificationEnabled(true);
}
}
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index 3bc6f97..24f5478 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -64,6 +64,7 @@ class QAuthenticator;
class Q_NETWORK_EXPORT QAbstractSocket : public QIODevice
{
Q_OBJECT
+ Q_ENUMS(SocketType NetworkLayerProtocol SocketError SocketState SocketOption)
public:
enum SocketType {
TcpSocket,
@@ -118,7 +119,9 @@ public:
};
enum SocketOption {
LowDelayOption, // TCP_NODELAY
- KeepAliveOption // SO_KEEPALIVE
+ KeepAliveOption, // SO_KEEPALIVE
+ MulticastTtlOption, // IP_MULTICAST_TTL
+ MulticastLoopbackOption // IP_MULTICAST_LOOPBACK
};
QAbstractSocket(SocketType socketType, QObject *parent);
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index e7cc9e3..7e6343e 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -138,9 +138,6 @@ public:
void setupSocketNotifiers();
bool readFromSocket();
-#ifdef Q_OS_LINUX
- qint64 addToBytesAvailable;
-#endif
qint64 readBufferMaxSize;
QRingBuffer readBuffer;
QRingBuffer writeBuffer;
diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h
index f83300d..ee6dad6 100644
--- a/src/network/socket/qabstractsocketengine_p.h
+++ b/src/network/socket/qabstractsocketengine_p.h
@@ -61,6 +61,9 @@ QT_BEGIN_NAMESPACE
class QAuthenticator;
class QAbstractSocketEnginePrivate;
+#ifndef QT_NO_NETWORKINTERFACE
+class QNetworkInterface;
+#endif
class QNetworkProxy;
class QAbstractSocketEngineReceiver {
@@ -94,7 +97,9 @@ public:
BindExclusively,
ReceiveOutOfBandData,
LowDelayOption,
- KeepAliveOption
+ KeepAliveOption,
+ MulticastTtlOption,
+ MulticastLoopbackOption
};
virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) = 0;
@@ -118,13 +123,22 @@ public:
virtual qint64 write(const char *data, qint64 len) = 0;
#ifndef QT_NO_UDPSOCKET
+#ifndef QT_NO_NETWORKINTERFACE
+ virtual bool joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface) = 0;
+ virtual bool leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface) = 0;
+ virtual QNetworkInterface multicastInterface() const = 0;
+ virtual bool setMulticastInterface(const QNetworkInterface &iface) = 0;
+#endif // QT_NO_NETWORKINTERFACE
+
virtual qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
quint16 *port = 0) = 0;
virtual qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
quint16 port) = 0;
virtual bool hasPendingDatagrams() const = 0;
virtual qint64 pendingDatagramSize() const = 0;
-#endif
+#endif // QT_NO_UDPSOCKET
virtual qint64 bytesToWrite() const = 0;
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index a338d97..df06a46 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -45,6 +45,7 @@
#include "qurl.h"
#include "qhttp.h"
#include "qelapsedtimer.h"
+#include "qnetworkinterface.h"
#if !defined(QT_NO_NETWORKPROXY) && !defined(QT_NO_HTTP)
#include <qdebug.h>
@@ -239,6 +240,36 @@ qint64 QHttpSocketEngine::write(const char *data, qint64 len)
}
#ifndef QT_NO_UDPSOCKET
+#ifndef QT_NO_NETWORKINTERFACE
+bool QHttpSocketEngine::joinMulticastGroup(const QHostAddress &,
+ const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+
+bool QHttpSocketEngine::leaveMulticastGroup(const QHostAddress &,
+ const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+
+QNetworkInterface QHttpSocketEngine::multicastInterface() const
+{
+ return QNetworkInterface();
+}
+
+bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+#endif // QT_NO_NETWORKINTERFACE
+
qint64 QHttpSocketEngine::readDatagram(char *, qint64, QHostAddress *,
quint16 *)
{
@@ -714,7 +745,10 @@ void QHttpSocketEngine::emitReadNotification()
{
Q_D(QHttpSocketEngine);
d->readNotificationActivated = true;
- if (d->readNotificationEnabled && !d->readNotificationPending) {
+ // if there is a connection notification pending we have to emit the readNotification
+ // incase there is connection error. This is only needed for Windows, but it does not
+ // hurt in other cases.
+ if ((d->readNotificationEnabled && !d->readNotificationPending) || d->connectionNotificationPending) {
d->readNotificationPending = true;
QMetaObject::invokeMethod(this, "emitPendingReadNotification", Qt::QueuedConnection);
}
diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h
index 79affd4..361ef5c 100644
--- a/src/network/socket/qhttpsocketengine_p.h
+++ b/src/network/socket/qhttpsocketengine_p.h
@@ -102,6 +102,15 @@ public:
qint64 write(const char *data, qint64 len);
#ifndef QT_NO_UDPSOCKET
+#ifndef QT_NO_NETWORKINTERFACE
+ bool joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface);
+ bool leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface);
+ QNetworkInterface multicastInterface() const;
+ bool setMulticastInterface(const QNetworkInterface &iface);
+#endif // QT_NO_NETWORKINTERFACE
+
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
quint16 *port = 0);
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
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/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 5c818bd..7c9911a 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -98,6 +98,7 @@
#include <qabstracteventdispatcher.h>
#include <qsocketnotifier.h>
+#include <qnetworkinterface.h>
#include "qnativesocketengine_p.h"
#include <private/qthread_p.h>
@@ -646,6 +647,54 @@ int QNativeSocketEngine::accept()
return d->nativeAccept();
}
+#ifndef QT_NO_NETWORKINTERFACE
+
+/*!
+ \since 4.8
+*/
+bool QNativeSocketEngine::joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ Q_D(QNativeSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::joinMulticastGroup(), false);
+ Q_CHECK_STATE(QNativeSocketEngine::joinMulticastGroup(), QAbstractSocket::BoundState, false);
+ Q_CHECK_TYPE(QNativeSocketEngine::joinMulticastGroup(), QAbstractSocket::UdpSocket, false);
+ return d->nativeJoinMulticastGroup(groupAddress, iface);
+}
+
+/*!
+ \since 4.8
+*/
+bool QNativeSocketEngine::leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ Q_D(QNativeSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::leaveMulticastGroup(), false);
+ Q_CHECK_STATE(QNativeSocketEngine::leaveMulticastGroup(), QAbstractSocket::BoundState, false);
+ Q_CHECK_TYPE(QNativeSocketEngine::leaveMulticastGroup(), QAbstractSocket::UdpSocket, false);
+ return d->nativeLeaveMulticastGroup(groupAddress, iface);
+}
+
+/*! \since 4.8 */
+QNetworkInterface QNativeSocketEngine::multicastInterface() const
+{
+ Q_D(const QNativeSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::multicastInterface(), QNetworkInterface());
+ Q_CHECK_TYPE(QNativeSocketEngine::multicastInterface(), QAbstractSocket::UdpSocket, QNetworkInterface());
+ return d->nativeMulticastInterface();
+}
+
+/*! \since 4.8 */
+bool QNativeSocketEngine::setMulticastInterface(const QNetworkInterface &iface)
+{
+ Q_D(QNativeSocketEngine);
+ Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setMulticastInterface(), false);
+ Q_CHECK_TYPE(QNativeSocketEngine::setMulticastInterface(), QAbstractSocket::UdpSocket, false);
+ return d->nativeSetMulticastInterface(iface);
+}
+
+#endif // QT_NO_NETWORKINTERFACE
+
/*!
Returns the number of bytes that are currently available for
reading. On error, -1 is returned.
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 0abaf24..d2ccb21 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -101,6 +101,9 @@ union qt_sockaddr {
};
class QNativeSocketEnginePrivate;
+#ifndef QT_NO_NETWORKINTERFACE
+class QNetworkInterface;
+#endif
class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine
{
@@ -123,6 +126,15 @@ public:
int accept();
void close();
+#ifndef QT_NO_NETWORKINTERFACE
+ bool joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+ bool leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+ QNetworkInterface multicastInterface() const;
+ bool setMulticastInterface(const QNetworkInterface &iface);
+#endif
+
qint64 bytesAvailable() const;
qint64 read(char *data, qint64 maxlen);
@@ -237,6 +249,14 @@ public:
bool nativeBind(const QHostAddress &address, quint16 port);
bool nativeListen(int backlog);
int nativeAccept();
+#ifndef QT_NO_NETWORKINTERFACE
+ bool nativeJoinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+ bool nativeLeaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+ QNetworkInterface nativeMulticastInterface() const;
+ bool nativeSetMulticastInterface(const QNetworkInterface &iface);
+#endif
qint64 nativeBytesAvailable() const;
bool nativeHasPendingDatagrams() const;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index c601bdb..091b285 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -46,6 +46,7 @@
#include "qhostaddress.h"
#include "qelapsedtimer.h"
#include "qvarlengtharray.h"
+#include "qnetworkinterface.h"
#include <time.h>
#include <errno.h>
#include <fcntl.h>
@@ -244,6 +245,30 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
case QNativeSocketEngine::KeepAliveOption:
n = SO_KEEPALIVE;
break;
+ case QNativeSocketEngine::MulticastTtlOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
}
int v = -1;
@@ -327,6 +352,30 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
case QNativeSocketEngine::KeepAliveOption:
n = SO_KEEPALIVE;
break;
+ case QNativeSocketEngine::MulticastTtlOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
}
return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
@@ -566,6 +615,174 @@ int QNativeSocketEnginePrivate::nativeAccept()
return acceptedDescriptor;
}
+#ifndef QT_NO_NETWORKINTERFACE
+
+static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
+ int how6,
+ int how4,
+ const QHostAddress &groupAddress,
+ const QNetworkInterface &interface)
+{
+ int level = 0;
+ int sockOpt = 0;
+ void *sockArg;
+ int sockArgSize;
+
+ ip_mreq mreq4;
+#ifndef QT_NO_IPV6
+ ipv6_mreq mreq6;
+
+ if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ sockOpt = how6;
+ sockArg = &mreq6;
+ sockArgSize = sizeof(mreq6);
+ memset(&mreq6, 0, sizeof(mreq6));
+ Q_IPV6ADDR ip6 = groupAddress.toIPv6Address();
+ memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
+ mreq6.ipv6mr_interface = interface.index();
+ } else
+#endif
+ if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
+ level = IPPROTO_IP;
+ sockOpt = how4;
+ sockArg = &mreq4;
+ sockArgSize = sizeof(mreq4);
+ memset(&mreq4, 0, sizeof(mreq4));
+ mreq4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
+
+ if (interface.isValid()) {
+ QList<QNetworkAddressEntry> addressEntries = interface.addressEntries();
+ if (!addressEntries.isEmpty()) {
+ QHostAddress firstIP = addressEntries.first().ip();
+ mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
+ } else {
+ d->setError(QAbstractSocket::NetworkError,
+ QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
+ return false;
+ }
+ } else {
+ mreq4.imr_interface.s_addr = INADDR_ANY;
+ }
+ } else {
+ // unreachable
+ d->setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QNativeSocketEnginePrivate::ProtocolUnsupportedErrorString);
+ return false;
+ }
+
+ int res = setsockopt(d->socketDescriptor, level, sockOpt, sockArg, sockArgSize);
+ if (res == -1) {
+ switch (errno) {
+ case ENOPROTOOPT:
+ d->setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QNativeSocketEnginePrivate::OperationUnsupportedErrorString);
+ break;
+ case EADDRNOTAVAIL:
+ d->setError(QAbstractSocket::SocketAddressNotAvailableError,
+ QNativeSocketEnginePrivate::AddressNotAvailableErrorString);
+ break;
+ default:
+ d->setError(QAbstractSocket::UnknownSocketError,
+ QNativeSocketEnginePrivate::UnknownSocketErrorString);
+ break;
+ }
+ return false;
+ }
+ return true;
+}
+
+bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface)
+{
+ return multicastMembershipHelper(this,
+#ifndef QT_NO_IPV6
+ IPV6_JOIN_GROUP,
+#else
+ 0,
+#endif
+ IP_ADD_MEMBERSHIP,
+ groupAddress,
+ interface);
+}
+
+bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface)
+{
+ return multicastMembershipHelper(this,
+#ifndef QT_NO_IPV6
+ IPV6_LEAVE_GROUP,
+#else
+ 0,
+#endif
+ IP_DROP_MEMBERSHIP,
+ groupAddress,
+ interface);
+}
+
+QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
+{
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ uint v;
+ QT_SOCKOPTLEN_T sizeofv = sizeof(v);
+ if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, &sizeofv) == -1)
+ return QNetworkInterface();
+ return QNetworkInterface::interfaceFromIndex(v);
+ }
+#endif
+
+ struct in_addr v = { 0 };
+ QT_SOCKOPTLEN_T sizeofv = sizeof(v);
+ if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, &sizeofv) == -1)
+ return QNetworkInterface();
+ if (v.s_addr != 0 && sizeofv >= sizeof(v)) {
+ QHostAddress ipv4(ntohl(v.s_addr));
+ QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
+ for (int i = 0; i < ifaces.count(); ++i) {
+ const QNetworkInterface &iface = ifaces.at(i);
+ QList<QNetworkAddressEntry> entries = iface.addressEntries();
+ for (int j = 0; j < entries.count(); ++j) {
+ const QNetworkAddressEntry &entry = entries.at(j);
+ if (entry.ip() == ipv4)
+ return iface;
+ }
+ }
+ }
+ return QNetworkInterface();
+}
+
+bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
+{
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ uint v = iface.index();
+ return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, sizeof(v)) != -1);
+ }
+#endif
+
+ struct in_addr v;
+ if (iface.isValid()) {
+ QList<QNetworkAddressEntry> entries = iface.addressEntries();
+ for (int i = 0; i < entries.count(); ++i) {
+ const QNetworkAddressEntry &entry = entries.at(i);
+ const QHostAddress &ip = entry.ip();
+ if (ip.protocol() == QAbstractSocket::IPv4Protocol) {
+ v.s_addr = htonl(ip.toIPv4Address());
+ int r = ::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, sizeof(v));
+ if (r != -1)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ v.s_addr = INADDR_ANY;
+ return (::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, sizeof(v)) != -1);
+}
+
+#endif // QT_NO_NETWORKINTERFACE
+
qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
{
int nbytes = 0;
@@ -877,7 +1094,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
{
Q_Q(QNativeSocketEngine);
if (!q->isValid()) {
- qWarning("QNativeSocketEngine::unbufferedRead: Invalid socket");
+ qWarning("QNativeSocketEngine::nativeRead: Invalid socket");
return -1;
}
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index c1dc984..940569a 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <winsock2.h>
+#include <ws2tcpip.h>
#include "qnativesocketengine_p.h"
@@ -47,6 +48,7 @@
#include <qsocketnotifier.h>
#include <qdebug.h>
#include <qdatetime.h>
+#include <qnetworkinterface.h>
//#define QNATIVESOCKETENGINE_DEBUG
#if defined(QNATIVESOCKETENGINE_DEBUG)
@@ -335,15 +337,17 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
}
#if !defined(Q_OS_WINCE)
- // enable new behavior using
- // SIO_UDP_CONNRESET
- DWORD dwBytesReturned = 0;
- int bNewBehavior = 1;
- if (::WSAIoctl(socket, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior),
- NULL, 0, &dwBytesReturned, NULL, NULL) == SOCKET_ERROR) {
- // not to worry isBogusUdpReadNotification() should handle this otherwise
- int err = WSAGetLastError();
- WS_ERROR_DEBUG(err);
+ if (socketType == QAbstractSocket::UdpSocket) {
+ // enable new behavior using
+ // SIO_UDP_CONNRESET
+ DWORD dwBytesReturned = 0;
+ int bNewBehavior = 1;
+ if (::WSAIoctl(socket, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior),
+ NULL, 0, &dwBytesReturned, NULL, NULL) == SOCKET_ERROR) {
+ // not to worry isBogusUdpReadNotification() should handle this otherwise
+ int err = WSAGetLastError();
+ WS_ERROR_DEBUG(err);
+ }
}
#endif
@@ -399,6 +403,30 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
case QNativeSocketEngine::KeepAliveOption:
n = SO_KEEPALIVE;
break;
+ case QNativeSocketEngine::MulticastTtlOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
}
int v = -1;
@@ -459,6 +487,30 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
case QNativeSocketEngine::KeepAliveOption:
n = SO_KEEPALIVE;
break;
+ case QNativeSocketEngine::MulticastTtlOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+#endif
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
}
if (::setsockopt(socketDescriptor, level, n, (char*)&v, sizeof(v)) != 0) {
@@ -589,6 +641,11 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
socketState = QAbstractSocket::UnconnectedState;
break;
}
+ if (value == WSAEADDRNOTAVAIL) {
+ setError(QAbstractSocket::NetworkError, AddressNotAvailableErrorString);
+ socketState = QAbstractSocket::UnconnectedState;
+ break;
+ }
}
// fall through
}
@@ -648,8 +705,26 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
}
-bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 port)
+bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port)
{
+ QHostAddress address = a;
+ switch (address.protocol()) {
+ case QAbstractSocket::IPv6Protocol:
+ if (address.toIPv6Address()[0] == 0xff) {
+ // binding to a multicast address
+ address = QHostAddress(QHostAddress::AnyIPv6);
+ }
+ break;
+ case QAbstractSocket::IPv4Protocol:
+ if ((address.toIPv4Address() & 0xffff0000) == 0xefff0000) {
+ // binding to a multicast address
+ address = QHostAddress(QHostAddress::Any);
+ }
+ break;
+ default:
+ break;
+ }
+
struct sockaddr_in sockAddrIPv4;
qt_sockaddr_in6 sockAddrIPv6;
struct sockaddr *sockAddrPtr = 0;
@@ -747,6 +822,160 @@ int QNativeSocketEnginePrivate::nativeAccept()
return acceptedDescriptor;
}
+static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
+ int how6,
+ int how4,
+ const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ int level = 0;
+ int sockOpt = 0;
+ char *sockArg;
+ int sockArgSize;
+
+ struct ip_mreq mreq4;
+#ifndef QT_NO_IPV6
+ struct ipv6_mreq mreq6;
+
+ if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
+ level = IPPROTO_IPV6;
+ sockOpt = how6;
+ sockArg = reinterpret_cast<char *>(&mreq6);
+ sockArgSize = sizeof(mreq6);
+ memset(&mreq6, 0, sizeof(mreq6));
+ Q_IPV6ADDR ip6 = groupAddress.toIPv6Address();
+ memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
+ mreq6.ipv6mr_interface = iface.index();
+ } else
+#endif
+ if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
+ level = IPPROTO_IP;
+ sockOpt = how4;
+ sockArg = reinterpret_cast<char *>(&mreq4);
+ sockArgSize = sizeof(mreq4);
+ memset(&mreq4, 0, sizeof(mreq4));
+ mreq4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
+
+ if (iface.isValid()) {
+ QList<QNetworkAddressEntry> addressEntries = iface.addressEntries();
+ if (!addressEntries.isEmpty()) {
+ QHostAddress firstIP = addressEntries.first().ip();
+ mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
+ } else {
+ d->setError(QAbstractSocket::NetworkError,
+ QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
+ return false;
+ }
+ } else {
+ mreq4.imr_interface.s_addr = INADDR_ANY;
+ }
+ } else {
+ // unreachable
+ d->setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QNativeSocketEnginePrivate::ProtocolUnsupportedErrorString);
+ return false;
+ }
+
+ int res = setsockopt(d->socketDescriptor, level, sockOpt, sockArg, sockArgSize);
+ if (res == -1) {
+ d->setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QNativeSocketEnginePrivate::OperationUnsupportedErrorString);
+ return false;
+ }
+ return true;
+}
+
+bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ return multicastMembershipHelper(this,
+#ifndef QT_NO_IPV6
+ IPV6_JOIN_GROUP,
+#else
+ 0,
+#endif
+ IP_ADD_MEMBERSHIP,
+ groupAddress,
+ iface);
+}
+
+bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ return multicastMembershipHelper(this,
+#ifndef QT_NO_IPV6
+ IPV6_LEAVE_GROUP,
+#else
+ 0,
+#endif
+ IP_DROP_MEMBERSHIP,
+ groupAddress,
+ iface);
+}
+
+QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
+{
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ uint v;
+ QT_SOCKOPTLEN_T sizeofv = sizeof(v);
+ if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, &sizeofv) == -1)
+ return QNetworkInterface();
+ return QNetworkInterface::interfaceFromIndex(v);
+ }
+#endif
+
+ struct in_addr v;
+ v.s_addr = 0;
+ QT_SOCKOPTLEN_T sizeofv = sizeof(v);
+ if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (char *) &v, &sizeofv) == -1)
+ return QNetworkInterface();
+ if (v.s_addr != 0 && sizeofv >= QT_SOCKOPTLEN_T(sizeof(v))) {
+ QHostAddress ipv4(ntohl(v.s_addr));
+ QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
+ for (int i = 0; i < ifaces.count(); ++i) {
+ const QNetworkInterface &iface = ifaces.at(i);
+ if (!(iface.flags() & QNetworkInterface::CanMulticast))
+ continue;
+ QList<QNetworkAddressEntry> entries = iface.addressEntries();
+ for (int j = 0; j < entries.count(); ++j) {
+ const QNetworkAddressEntry &entry = entries.at(j);
+ if (entry.ip() == ipv4)
+ return iface;
+ }
+ }
+ }
+ return QNetworkInterface();
+}
+
+bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
+{
+#ifndef QT_NO_IPV6
+ if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ uint v = iface.isValid() ? iface.index() : 0;
+ return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, sizeof(v)) != -1);
+ }
+#endif
+
+ struct in_addr v;
+ if (iface.isValid()) {
+ QList<QNetworkAddressEntry> entries = iface.addressEntries();
+ for (int i = 0; i < entries.count(); ++i) {
+ const QNetworkAddressEntry &entry = entries.at(i);
+ const QHostAddress &ip = entry.ip();
+ if (ip.protocol() == QAbstractSocket::IPv4Protocol) {
+ v.s_addr = htonl(ip.toIPv4Address());
+ int r = ::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (char *) &v, sizeof(v));
+ if (r != -1)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ v.s_addr = INADDR_ANY;
+ return (::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (char *) &v, sizeof(v)) != -1);
+}
qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
{
@@ -816,7 +1045,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
bool result = false;
fd_set readS;
FD_ZERO(&readS);
- FD_SET(socketDescriptor, &readS);
+ FD_SET((SOCKET)socketDescriptor, &readS);
timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 5000;
@@ -1111,7 +1340,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
memset(&fds, 0, sizeof(fd_set));
fds.fd_count = 1;
- fds.fd_array[0] = socketDescriptor;
+ fds.fd_array[0] = (SOCKET)socketDescriptor;
struct timeval tv;
tv.tv_sec = timeout / 1000;
@@ -1125,12 +1354,12 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co
// Windows needs this to report errors when connecting a socket ...
fd_set fdexception;
FD_ZERO(&fdexception);
- FD_SET(socketDescriptor, &fdexception);
+ FD_SET((SOCKET)socketDescriptor, &fdexception);
ret = select(0, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv);
// ... but if it is actually set, pretend it did not happen
- if (ret > 0 && FD_ISSET(socketDescriptor, &fdexception))
+ if (ret > 0 && FD_ISSET((SOCKET)socketDescriptor, &fdexception))
ret--;
}
@@ -1157,16 +1386,16 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout,
memset(&fdread, 0, sizeof(fd_set));
if (checkRead) {
fdread.fd_count = 1;
- fdread.fd_array[0] = socketDescriptor;
+ fdread.fd_array[0] = (SOCKET)socketDescriptor;
}
memset(&fdwrite, 0, sizeof(fd_set));
FD_ZERO(&fdexception);
if (checkWrite) {
fdwrite.fd_count = 1;
- fdwrite.fd_array[0] = socketDescriptor;
+ fdwrite.fd_array[0] = (SOCKET)socketDescriptor;
// Windows needs this to report errors when connecting a socket
- FD_SET(socketDescriptor, &fdexception);
+ FD_SET((SOCKET)socketDescriptor, &fdexception);
}
struct timeval tv;
@@ -1180,7 +1409,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout,
#endif
//... but if it is actually set, pretend it did not happen
- if (ret > 0 && FD_ISSET(socketDescriptor, &fdexception))
+ if (ret > 0 && FD_ISSET((SOCKET)socketDescriptor, &fdexception))
ret--;
if (readEnabled)
@@ -1189,8 +1418,8 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout,
if (ret <= 0)
return ret;
- *selectForRead = FD_ISSET(socketDescriptor, &fdread);
- *selectForWrite = FD_ISSET(socketDescriptor, &fdwrite);
+ *selectForRead = FD_ISSET((SOCKET)socketDescriptor, &fdread);
+ *selectForWrite = FD_ISSET((SOCKET)socketDescriptor, &fdwrite);
return ret;
}
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 53035d2..10a2695 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -56,6 +56,7 @@
#include "qurl.h"
#include "qauthenticator.h"
#include <qendian.h>
+#include <qnetworkinterface.h>
QT_BEGIN_NAMESPACE
@@ -1544,6 +1545,37 @@ qint64 QSocks5SocketEngine::write(const char *data, qint64 len)
}
#ifndef QT_NO_UDPSOCKET
+#ifndef QT_NO_NETWORKINTERFACE
+bool QSocks5SocketEngine::joinMulticastGroup(const QHostAddress &,
+ const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+
+bool QSocks5SocketEngine::leaveMulticastGroup(const QHostAddress &,
+ const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+
+
+QNetworkInterface QSocks5SocketEngine::multicastInterface() const
+{
+ return QNetworkInterface();
+}
+
+bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &)
+{
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Operation on socket is not supported"));
+ return false;
+}
+#endif // QT_NO_NETWORKINTERFACE
+
qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QHostAddress *addr,
quint16 *port)
{
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index 808628a..9492d45 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -92,6 +92,15 @@ public:
qint64 write(const char *data, qint64 len);
#ifndef QT_NO_UDPSOCKET
+#ifndef QT_NO_NETWORKINTERFACE
+ bool joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface);
+ bool leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &interface);
+ QNetworkInterface multicastInterface() const;
+ bool setMulticastInterface(const QNetworkInterface &iface);
+#endif // QT_NO_NETWORKINTERFACE
+
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
quint16 *port = 0);
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index 83f3690..97a5466 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -77,14 +77,23 @@
\snippet doc/src/snippets/code/src_network_socket_qudpsocket.cpp 0
+ QUdpSocket also supports UDP multicast. Use joinMulticastGroup() and
+ leaveMulticastGroup() to control group membership, and
+ QAbstractSocket::MulticastTtlOption and
+ QAbstractSocket::MulticastLoopbackOption to set the TTL and loopback socket
+ options. Use setMulticastInterface() to control the outgoing interface for
+ multicast datagrams, and multicastInterface() to query it.
+
With QUdpSocket, you can also establish a virtual connection to a
UDP server using connectToHost() and then use read() and write()
to exchange datagrams without specifying the receiver for each
datagram.
- The \l{network/broadcastsender}{Broadcast Sender} and
- \l{network/broadcastreceiver}{Broadcast Receiver} examples
- illustrate how to use QUdpSocket in applications.
+ The \l{network/broadcastsender}{Broadcast Sender},
+ \l{network/broadcastreceiver}{Broadcast Receiver},
+ \l{network/multicastsender}{Multicast Sender}, and
+ \l{network/multicastreceiver}{Multicast Receiver} examples illustrate how
+ to use QUdpSocket in applications.
\section1 Symbian Platform Security Requirements
@@ -145,6 +154,7 @@
*/
#include "qhostaddress.h"
+#include "qnetworkinterface.h"
#include "qabstractsocket_p.h"
#include "qudpsocket.h"
@@ -328,6 +338,116 @@ bool QUdpSocket::bind(quint16 port, BindMode mode)
return bind(QHostAddress::Any, port, mode);
}
+#ifndef QT_NO_NETWORKINTERFACE
+
+/*!
+ \since 4.8
+
+ Joins the the multicast group specified by \a groupAddress on the default
+ interface chosen by the operating system. The socket must be in BoundState,
+ otherwise an error occurs.
+
+ This function returns true if successful; otherwise it returns false
+ and sets the socket error accordingly.
+
+ \sa leaveMulticastGroup()
+*/
+bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress)
+{
+ return joinMulticastGroup(groupAddress, QNetworkInterface());
+}
+
+/*!
+ \since 4.8
+ \overload
+
+ Joins the multicast group address \a groupAddress on the interface \a
+ iface.
+
+ \sa leaveMulticastGroup()
+*/
+bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ Q_D(QUdpSocket);
+ QT_CHECK_BOUND("QUdpSocket::joinMulticastGroup()", false);
+ return d->socketEngine->joinMulticastGroup(groupAddress, iface);
+}
+
+/*!
+ \since 4.8
+
+ Leaves the multicast group specified by \a groupAddress on the default
+ interface chosen by the operating system. The socket must be in BoundState,
+ otherwise an error occurs.
+
+ This function returns true if successful; otherwise it returns false and
+ sets the socket error accordingly.
+
+ \sa joinMulticastGroup()
+*/
+bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress)
+{
+ return leaveMulticastGroup(groupAddress, QNetworkInterface());
+}
+
+/*!
+ \since 4.8
+ \overload
+
+ Leaves the multicast group specified by \a groupAddress on the interface \a
+ iface.
+
+ \sa joinMulticastGroup()
+*/
+bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface)
+{
+ QT_CHECK_BOUND("QUdpSocket::leaveMulticastGroup()", false);
+ return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface);
+}
+
+/*!
+ \since 4.8
+
+ Returns the interface for the outgoing interface for multicast datagrams.
+ This corresponds to the IP_MULTICAST_IF socket option for IPv4 sockets and
+ the IPV6_MULTICAST_IF socket option for IPv6 sockets. If no interface has
+ been previously set, this function returns an invalid QNetworkInterface.
+ The socket must be in BoundState, otherwise an invalid QNetworkInterface is
+ returned.
+
+ \sa setMulticastInterface()
+*/
+QNetworkInterface QUdpSocket::multicastInterface() const
+{
+ Q_D(const QUdpSocket);
+ QT_CHECK_BOUND("QUdpSocket::multicastInterface()", QNetworkInterface());
+ return d->socketEngine->multicastInterface();
+}
+
+/*!
+ \since 4.8
+
+ Sets the outgoing interface for multicast datagrams to the interface \a
+ iface. This corresponds to the IP_MULTICAST_IF socket option for IPv4
+ sockets and the IPV6_MULTICAST_IF socket option for IPv6 sockets. The
+ socket must be in BoundState, otherwise this function does nothing.
+
+ \sa multicastInterface(), joinMulticastGroup(), leaveMulticastGroup()
+*/
+void QUdpSocket::setMulticastInterface(const QNetworkInterface &iface)
+{
+ Q_D(QUdpSocket);
+ if (!isValid()) {
+ qWarning("QUdpSocket::setMulticastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState");
+ return;
+ }
+ d->socketEngine->setMulticastInterface(iface);
+}
+
+#endif // QT_NO_NETWORKINTERFACE
+
/*!
Returns true if at least one datagram is waiting to be read;
otherwise returns false.
diff --git a/src/network/socket/qudpsocket.h b/src/network/socket/qudpsocket.h
index 1236ee3..7502349 100644
--- a/src/network/socket/qudpsocket.h
+++ b/src/network/socket/qudpsocket.h
@@ -53,6 +53,7 @@ QT_MODULE(Network)
#ifndef QT_NO_UDPSOCKET
+class QNetworkInterface;
class QUdpSocketPrivate;
class Q_NETWORK_EXPORT QUdpSocket : public QAbstractSocket
@@ -76,6 +77,18 @@ public:
bool bind(quint16 port, BindMode mode);
// ### Qt 5: Merge the bind functions
+#ifndef QT_NO_NETWORKINTERFACE
+ bool joinMulticastGroup(const QHostAddress &groupAddress);
+ bool joinMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+ bool leaveMulticastGroup(const QHostAddress &groupAddress);
+ bool leaveMulticastGroup(const QHostAddress &groupAddress,
+ const QNetworkInterface &iface);
+
+ QNetworkInterface multicastInterface() const;
+ void setMulticastInterface(const QNetworkInterface &iface);
+#endif
+
bool hasPendingDatagrams() const;
qint64 pendingDatagramSize() const;
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host = 0, quint16 *port = 0);
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/qssl.cpp b/src/network/ssl/qssl.cpp
index e9e7d21..5594296 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -101,12 +101,17 @@ QT_BEGIN_NAMESPACE
Describes the protocol of the cipher.
- \value SslV3 SSLv3 - the default protocol.
+ \value SslV3 SSLv3
\value SslV2 SSLv2
\value TlsV1 TLSv1
\value UnknownProtocol The cipher's protocol cannot be determined.
\value AnyProtocol The socket understands SSLv2, SSLv3, and TLSv1. This
value is used by QSslSocket only.
+ \value TlsV1SslV3 On the client side, this will send
+ a TLS 1.0 Client Hello, enabling TLSv1 and SSLv3 connections.
+ On the server side, this will enable both SSLv3 and TLSv1 connections.
+ \value SecureProtocols The default option, using protocols known to be secure;
+ currently behaves like TlsV1SslV3.
Note: most servers using SSL understand both versions (2 and 3),
but it is recommended to use the latest version only for security
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index 4c035fd..24dbb09 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -75,8 +75,10 @@ namespace QSsl {
enum SslProtocol {
SslV3,
SslV2,
- TlsV1,
+ TlsV1, // ### Qt 5: rename to TlsV1_0 or so
AnyProtocol,
+ TlsV1SslV3,
+ SecureProtocols,
UnknownProtocol = -1
};
}
diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
index 3592226..150f77e 100644
--- a/src/network/ssl/qsslconfiguration.cpp
+++ b/src/network/ssl/qsslconfiguration.cpp
@@ -213,7 +213,7 @@ bool QSslConfiguration::isNull() const
*/
QSsl::SslProtocol QSslConfiguration::protocol() const
{
- return d ? d->protocol : QSsl::SslV3;
+ return d ? d->protocol : QSsl::SecureProtocols;
}
/*!
@@ -518,7 +518,7 @@ void QSslConfiguration::setCaCertificates(const QList<QSslCertificate> &certific
\list
\o no local certificate and no private key
- \o protocol SSLv3
+ \o protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used)
\o the system's default CA certificate list
\o the cipher list equal to the list of the SSL libraries'
supported SSL ciphers
diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h
index b039e69..a5af51a 100644
--- a/src/network/ssl/qsslconfiguration_p.h
+++ b/src/network/ssl/qsslconfiguration_p.h
@@ -80,7 +80,7 @@ class QSslConfigurationPrivate: public QSharedData
{
public:
QSslConfigurationPrivate()
- : protocol(QSsl::SslV3),
+ : protocol(QSsl::SecureProtocols),
peerVerifyMode(QSslSocket::AutoVerifyPeer),
peerVerifyDepth(0)
{ }
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 4252123..98e2dc5 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -56,7 +56,7 @@
QSslSocket establishes a secure, encrypted TCP connection you can
use for transmitting encrypted data. It can operate in both client
and server mode, and it supports modern SSL protocols, including
- SSLv3 and TLSv1. By default, QSslSocket uses SSLv3, but you can
+ SSLv3 and TLSv1. By default, QSslSocket uses TLSv1, but you can
change the SSL protocol by calling setProtocol() as long as you do
it before the handshake has started.
@@ -143,6 +143,15 @@
setDefaultCaCertificates().
\endlist
+ \note If available, root certificates on Unix (excluding Mac OS X) will be
+ loaded on demand from the standard certificate directories. If
+ you do not want to load root certificates on demand, you need to call either
+ the static function setDefaultCaCertificates() before the first SSL handshake
+ is made in your application, (e.g. via
+ "QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());"),
+ or call setCaCertificates() on your QSslSocket instance prior to the SSL
+ handshake.
+
For more information about ciphers and certificates, refer to QSslCipher and
QSslCertificate.
@@ -543,7 +552,7 @@ bool QSslSocket::isEncrypted() const
}
/*!
- Returns the socket's SSL protocol. By default, \l QSsl::SslV3 is used.
+ Returns the socket's SSL protocol. By default, \l QSsl::SecureProtocols is used.
\sa setProtocol()
*/
@@ -650,6 +659,34 @@ void QSslSocket::setPeerVerifyDepth(int depth)
}
/*!
+ \since 4.8
+
+ Returns the different hostname for the certificate validation, as set by
+ setPeerVerifyName or by connectToHostEncrypted.
+
+ \sa setPeerVerifyName(), connectToHostEncrypted()
+*/
+QString QSslSocket::peerVerifyName() const
+{
+ Q_D(const QSslSocket);
+ return d->verificationPeerName;
+}
+
+/*!
+ \since 4.8
+
+ Sets a different hostname for the certificate validation instead of the one used for the TCP
+ connection.
+
+ \sa connectToHostEncrypted()
+*/
+void QSslSocket::setPeerVerifyName(const QString &hostName)
+{
+ Q_D(QSslSocket);
+ d->verificationPeerName = hostName;
+}
+
+/*!
\reimp
Returns the number of decrypted bytes that are immediately available for
@@ -1249,6 +1286,7 @@ void QSslSocket::setCaCertificates(const QList<QSslCertificate> &certificates)
{
Q_D(QSslSocket);
d->configuration.caCertificates = certificates;
+ d->allowRootCertOnDemandLoading = false;
}
/*!
@@ -1258,6 +1296,9 @@ void QSslSocket::setCaCertificates(const QList<QSslCertificate> &certificates)
handshake with addCaCertificate(), addCaCertificates(), and
setCaCertificates().
+ \note On Unix, this method may return an empty list if the root
+ certificates are loaded on demand.
+
\sa addCaCertificate(), addCaCertificates(), setCaCertificates()
*/
QList<QSslCertificate> QSslSocket::caCertificates() const
@@ -1311,10 +1352,9 @@ void QSslSocket::addDefaultCaCertificates(const QList<QSslCertificate> &certific
/*!
Sets the default CA certificate database to \a certificates. The
default CA certificate database is originally set to your system's
- default CA certificate database. If no system default database is
- found, Qt will provide its own default database. You can override
- the default CA certificate database with your own CA certificate
- database using this function.
+ default CA certificate database. You can override the default CA
+ certificate database with your own CA certificate database using
+ this function.
Each SSL socket's CA certificate database is initialized to the
default CA certificate database.
@@ -1336,6 +1376,9 @@ void QSslSocket::setDefaultCaCertificates(const QList<QSslCertificate> &certific
Each SSL socket's CA certificate database is initialized to the
default CA certificate database.
+ \note On Unix, this method may return an empty list if the root
+ certificates are loaded on demand.
+
\sa caCertificates()
*/
QList<QSslCertificate> QSslSocket::defaultCaCertificates()
@@ -1803,6 +1846,7 @@ QSslSocketPrivate::QSslSocketPrivate()
, connectionEncrypted(false)
, ignoreAllSslErrors(false)
, readyReadEmittedPointer(0)
+ , allowRootCertOnDemandLoading(true)
, plainSocket(0)
{
QSslConfigurationPrivate::deepCopyDefaultConfiguration(&configuration);
@@ -1879,6 +1923,7 @@ void QSslSocketPrivate::setDefaultSupportedCiphers(const QList<QSslCipher> &ciph
*/
QList<QSslCertificate> QSslSocketPrivate::defaultCaCertificates()
{
+ // ### Qt5: rename everything containing "caCertificates" to "rootCertificates" or similar
QSslSocketPrivate::ensureInitialized();
QMutexLocker locker(&globalData()->mutex);
return globalData()->config->caCertificates;
@@ -1893,6 +1938,9 @@ void QSslSocketPrivate::setDefaultCaCertificates(const QList<QSslCertificate> &c
QMutexLocker locker(&globalData()->mutex);
globalData()->config.detach();
globalData()->config->caCertificates = certs;
+ // when the certificates are set explicitly, we do not want to
+ // load the system certificates on demand
+ s_loadRootCertsOnDemand = false;
}
/*!
@@ -2192,6 +2240,20 @@ void QSslSocketPrivate::_q_flushReadBuffer()
transmit();
}
+/*!
+ \internal
+*/
+QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()
+{
+ return QList<QByteArray>() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
+ << "/usr/lib/ssl/certs/" // Gentoo, Mandrake
+ << "/usr/share/ssl/" // Centos, Redhat, SuSE
+ << "/usr/local/ssl/" // Normal OpenSSL Tarball
+ << "/var/ssl/certs/" // AIX
+ << "/usr/local/ssl/certs/" // Solaris
+ << "/opt/openssl/certs/"; // HP-UX
+}
+
QT_END_NAMESPACE
// For private slots
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index 703a1fb..648fd8c 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -106,6 +106,9 @@ public:
int peerVerifyDepth() const;
void setPeerVerifyDepth(int depth);
+ QString peerVerifyName() const;
+ void setPeerVerifyName(const QString &hostName);
+
// From QIODevice
qint64 bytesAvailable() const;
qint64 bytesToWrite() const;
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 2427193..10f1f30 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -60,6 +60,12 @@
#include <QtCore/qvarlengtharray.h>
#include <QLibrary> // for loading the security lib for the CA store
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+// Symbian does not seem to have the symbol for SNI defined
+#ifndef SSL_CTRL_SET_TLSEXT_HOSTNAME
+#define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
+#endif
+#endif
QT_BEGIN_NAMESPACE
#if defined(Q_OS_MAC)
@@ -80,6 +86,7 @@ QT_BEGIN_NAMESPACE
bool QSslSocketPrivate::s_libraryLoaded = false;
bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
+bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
/* \internal
@@ -252,6 +259,8 @@ init_context:
case QSsl::SslV3:
ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
break;
+ case QSsl::SecureProtocols: // SslV2 will be disabled below
+ case QSsl::TlsV1SslV3: // SslV2 will be disabled below
case QSsl::AnyProtocol:
default:
ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
@@ -277,7 +286,11 @@ init_context:
}
// Enable all bug workarounds.
- q_SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ if (configuration.protocol == QSsl::TlsV1SslV3 || configuration.protocol == QSsl::SecureProtocols) {
+ q_SSL_CTX_set_options(ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2);
+ } else {
+ q_SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ }
// Initialize ciphers
QByteArray cipherString;
@@ -326,6 +339,13 @@ init_context:
}
}
+ if (s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
+ // tell OpenSSL the directories where to look up the root certs on demand
+ QList<QByteArray> unixDirs = unixRootCertDirectories();
+ for (int a = 0; a < unixDirs.count(); ++a)
+ q_SSL_CTX_load_verify_locations(ctx, 0, unixDirs.at(a).constData());
+ }
+
// Register a custom callback to get all verification errors.
X509_STORE_set_verify_cb_func(ctx->cert_store, q_X509Callback);
@@ -387,6 +407,24 @@ init_context:
return false;
}
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ if ((configuration.protocol == QSsl::TlsV1SslV3 ||
+ configuration.protocol == QSsl::TlsV1 ||
+ configuration.protocol == QSsl::SecureProtocols ||
+ configuration.protocol == QSsl::AnyProtocol) &&
+ client && q_SSLeay() >= 0x00090806fL) {
+ // Set server hostname on TLS extension. RFC4366 section 3.1 requires it in ACE format.
+ QString tlsHostName = verificationPeerName.isEmpty() ? q->peerName() : verificationPeerName;
+ if (tlsHostName.isEmpty())
+ tlsHostName = hostName;
+ QByteArray ace = QUrl::toAce(tlsHostName);
+ if (!ace.isEmpty()) {
+ if (!q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, ace.constData()))
+ qWarning("could not set SSL_CTRL_SET_TLSEXT_HOSTNAME, Server Name Indication disabled");
+ }
+ }
+#endif
+
// Clear the session.
q_SSL_clear(ssl);
errorList.clear();
@@ -526,8 +564,22 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
} else {
qWarning("could not load crypt32 library"); // should never happen
}
+#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(Q_OS_MAC)
+ // check whether we can enable on-demand root-cert loading (i.e. check whether the sym links are there)
+ QList<QByteArray> dirs = unixRootCertDirectories();
+ QStringList symLinkFilter;
+ symLinkFilter << QLatin1String("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]");
+ for (int a = 0; a < dirs.count(); ++a) {
+ QDirIterator iterator(QLatin1String(dirs.at(a)), symLinkFilter, QDir::Files);
+ if (iterator.hasNext()) {
+ s_loadRootCertsOnDemand = true;
+ break;
+ }
+ }
#endif
- setDefaultCaCertificates(systemCaCertificates());
+ // if on-demand loading was not enabled, load the certs now
+ if (!s_loadRootCertsOnDemand)
+ setDefaultCaCertificates(systemCaCertificates());
}
/*!
@@ -823,15 +875,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
}
#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
QSet<QString> certFiles;
- QList<QByteArray> directories;
- directories << "/etc/ssl/certs/"; // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
- directories << "/usr/lib/ssl/certs/"; // Gentoo, Mandrake
- directories << "/usr/share/ssl/"; // Centos, Redhat, SuSE
- directories << "/usr/local/ssl/"; // Normal OpenSSL Tarball
- directories << "/var/ssl/certs/"; // AIX
- directories << "/usr/local/ssl/certs/"; // Solaris
- directories << "/opt/openssl/certs/"; // HP-UX
-
+ QList<QByteArray> directories = unixRootCertDirectories();
QDir currentDir;
QStringList nameFilters;
nameFilters << QLatin1String("*.pem") << QLatin1String("*.crt");
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 5a7963e..ca49fab 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -79,6 +79,10 @@
#include <openssl/x509_vfy.h>
#include <openssl/dsa.h>
#include <openssl/rsa.h>
+#include <openssl/crypto.h>
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+#include <openssl/tls1.h>
+#endif
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
typedef _STACK STACK;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 38598b6..b1310cc 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -208,6 +208,9 @@ DEFINEFUNC(long, SSL_get_verify_result, SSL *a, a, return -1, return)
DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return 0, return)
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, const void *parg, parg, return -1, return)
+#endif
DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
@@ -262,6 +265,8 @@ DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c,
#endif
DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
+DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
#ifdef Q_OS_SYMBIAN
#define RESOLVEFUNC(func, ordinal, lib) \
@@ -585,6 +590,9 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSL_library_init, 137, libs.first )
RESOLVEFUNC(SSL_load_error_strings, 139, libs.first )
RESOLVEFUNC(SSL_new, 140, libs.first )
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ RESOLVEFUNC(SSL_ctrl, 95, libs.first )
+#endif
RESOLVEFUNC(SSL_read, 143, libs.first )
RESOLVEFUNC(SSL_set_accept_state, 148, libs.first )
RESOLVEFUNC(SSL_set_bio, 149, libs.first )
@@ -599,6 +607,7 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSLv3_server_method, 197, libs.first )
RESOLVEFUNC(SSLv23_server_method, 191, libs.first )
RESOLVEFUNC(TLSv1_server_method, 200, libs.first )
+ RESOLVEFUNC(SSL_CTX_load_verify_locations, 34, libs.first )
RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second )
RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second )
RESOLVEFUNC(X509_STORE_free, 1939, libs.second )
@@ -630,6 +639,7 @@ bool q_resolveOpenSslSymbols()
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf, 1153, libs.second )
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf, 1152, libs.second )
+ RESOLVEFUNC(SSLeay, 1504, libs.second )
#else // Q_OS_SYMBIAN
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
@@ -709,6 +719,9 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSL_library_init)
RESOLVEFUNC(SSL_load_error_strings)
RESOLVEFUNC(SSL_new)
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ RESOLVEFUNC(SSL_ctrl)
+#endif
RESOLVEFUNC(SSL_read)
RESOLVEFUNC(SSL_set_accept_state)
RESOLVEFUNC(SSL_set_bio)
@@ -754,6 +767,8 @@ bool q_resolveOpenSslSymbols()
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
+ RESOLVEFUNC(SSL_CTX_load_verify_locations)
+ RESOLVEFUNC(SSLeay)
#endif // Q_OS_SYMBIAN
symbolsResolved = true;
delete libs.first;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index 954ffba..49830ac 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -316,6 +316,9 @@ long q_SSL_get_verify_result(SSL *a);
int q_SSL_library_init();
void q_SSL_load_error_strings();
SSL *q_SSL_new(SSL_CTX *a);
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+long q_SSL_ctrl(SSL *ssl,int cmd, long larg, const void *parg);
+#endif
int q_SSL_read(SSL *a, void *b, int c);
void q_SSL_set_bio(SSL *a, BIO *b, BIO *c);
void q_SSL_set_accept_state(SSL *a);
@@ -412,6 +415,8 @@ DSA *q_d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
#endif
void q_OPENSSL_add_all_algorithms_noconf();
void q_OPENSSL_add_all_algorithms_conf();
+int q_SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
+long q_SSLeay();
// Helper function
class QDateTime;
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 3a14488..7b92f95 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -112,6 +112,8 @@ public:
// that was used for connecting to.
QString verificationPeerName;
+ bool allowRootCertOnDemandLoading;
+
static bool supportsSsl();
static void ensureInitialized();
static void deinitialize();
@@ -168,6 +170,9 @@ private:
static bool s_libraryLoaded;
static bool s_loadedCiphersAndCerts;
+protected:
+ static bool s_loadRootCertsOnDemand;
+ static QList<QByteArray> unixRootCertDirectories();
};
QT_END_NAMESPACE
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 62bce96..8068aa8 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -42,29 +42,35 @@
#include "qglengineshadermanager_p.h"
#include "qglengineshadersource_p.h"
#include "qpaintengineex_opengl2_p.h"
+#include "qglshadercache_p.h"
#if defined(QT_DEBUG)
#include <QMetaEnum>
#endif
+// #define QT_GL_SHARED_SHADER_DEBUG
QT_BEGIN_NAMESPACE
-static void qt_shared_shaders_free(void *data)
+class QGLShaderStorage
{
- delete reinterpret_cast<QGLEngineSharedShaders *>(data);
-}
+public:
+ QGLEngineSharedShaders *shadersForThread(const QGLContext *context) {
+ QGLContextGroupResource<QGLEngineSharedShaders> *&shaders = m_storage.localData();
+ if (!shaders)
+ shaders = new QGLContextGroupResource<QGLEngineSharedShaders>();
+ return shaders->value(context);
+ }
+
+private:
+ QThreadStorage<QGLContextGroupResource<QGLEngineSharedShaders> *> m_storage;
+};
-Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_shaders, (qt_shared_shaders_free))
+Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage);
QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLContext *context)
{
- QGLEngineSharedShaders *p = reinterpret_cast<QGLEngineSharedShaders *>(qt_shared_shaders()->value(context));
- if (!p) {
- QGLShareContextScope scope(context);
- qt_shared_shaders()->insert(context, p = new QGLEngineSharedShaders(context));
- }
- return p;
+ return qt_shader_storage()->shadersForThread(context);
}
const char* QGLEngineSharedShaders::qShaderSnippets[] = {
@@ -165,69 +171,109 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context)
QGLShader* fragShader;
QGLShader* vertexShader;
- QByteArray source;
+ QByteArray vertexSource;
+ QByteArray fragSource;
// Compile up the simple shader:
- source.clear();
- source.append(qShaderSnippets[MainVertexShader]);
- source.append(qShaderSnippets[PositionOnlyVertexShader]);
- vertexShader = new QGLShader(QGLShader::Vertex, context, this);
- if (!vertexShader->compileSourceCode(source))
- qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
-
- source.clear();
- source.append(qShaderSnippets[MainFragmentShader]);
- source.append(qShaderSnippets[ShockingPinkSrcFragmentShader]);
- fragShader = new QGLShader(QGLShader::Fragment, context, this);
- if (!fragShader->compileSourceCode(source))
- qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
-
- simpleShaderProg = new QGLShaderProgram(context, this);
- simpleShaderProg->addShader(vertexShader);
- simpleShaderProg->addShader(fragShader);
- simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
- simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
- simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
- simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
+ vertexSource.append(qShaderSnippets[MainVertexShader]);
+ vertexSource.append(qShaderSnippets[PositionOnlyVertexShader]);
+
+ fragSource.append(qShaderSnippets[MainFragmentShader]);
+ fragSource.append(qShaderSnippets[ShockingPinkSrcFragmentShader]);
+
+ simpleShaderProg = new QGLShaderProgram(context, 0);
+
+ CachedShader simpleShaderCache(fragSource, vertexSource);
+
+ bool inCache = simpleShaderCache.load(simpleShaderProg, context);
+
+ if (!inCache) {
+ vertexShader = new QGLShader(QGLShader::Vertex, context, 0);
+ shaders.append(vertexShader);
+ if (!vertexShader->compileSourceCode(vertexSource))
+ qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
+
+ fragShader = new QGLShader(QGLShader::Fragment, context, 0);
+ shaders.append(fragShader);
+ if (!fragShader->compileSourceCode(fragSource))
+ qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
+
+ simpleShaderProg->addShader(vertexShader);
+ simpleShaderProg->addShader(fragShader);
+
+ simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
+ simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
+ simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
+ }
+
simpleShaderProg->link();
- if (!simpleShaderProg->isLinked()) {
+
+ if (simpleShaderProg->isLinked()) {
+ if (!inCache)
+ simpleShaderCache.store(simpleShaderProg, context);
+ } else {
qCritical() << "Errors linking simple shader:"
<< simpleShaderProg->log();
}
// Compile the blit shader:
- source.clear();
- source.append(qShaderSnippets[MainWithTexCoordsVertexShader]);
- source.append(qShaderSnippets[UntransformedPositionVertexShader]);
- vertexShader = new QGLShader(QGLShader::Vertex, context, this);
- if (!vertexShader->compileSourceCode(source))
- qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
-
- source.clear();
- source.append(qShaderSnippets[MainFragmentShader]);
- source.append(qShaderSnippets[ImageSrcFragmentShader]);
- fragShader = new QGLShader(QGLShader::Fragment, context, this);
- if (!fragShader->compileSourceCode(source))
- qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
-
- blitShaderProg = new QGLShaderProgram(context, this);
- blitShaderProg->addShader(vertexShader);
- blitShaderProg->addShader(fragShader);
- blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
- blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ vertexSource.clear();
+ vertexSource.append(qShaderSnippets[MainWithTexCoordsVertexShader]);
+ vertexSource.append(qShaderSnippets[UntransformedPositionVertexShader]);
+
+ fragSource.clear();
+ fragSource.append(qShaderSnippets[MainFragmentShader]);
+ fragSource.append(qShaderSnippets[ImageSrcFragmentShader]);
+
+ blitShaderProg = new QGLShaderProgram(context, 0);
+
+ CachedShader blitShaderCache(fragSource, vertexSource);
+
+ inCache = blitShaderCache.load(blitShaderProg, context);
+
+ if (!inCache) {
+ vertexShader = new QGLShader(QGLShader::Vertex, context, 0);
+ shaders.append(vertexShader);
+ if (!vertexShader->compileSourceCode(vertexSource))
+ qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
+
+ fragShader = new QGLShader(QGLShader::Fragment, context, 0);
+ shaders.append(fragShader);
+ if (!fragShader->compileSourceCode(fragSource))
+ qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
+
+ blitShaderProg->addShader(vertexShader);
+ blitShaderProg->addShader(fragShader);
+
+ blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
+ blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ }
+
blitShaderProg->link();
- if (!blitShaderProg->isLinked()) {
+ if (blitShaderProg->isLinked()) {
+ if (!inCache)
+ blitShaderCache.store(blitShaderProg, context);
+ } else {
qCritical() << "Errors linking blit shader:"
- << simpleShaderProg->log();
+ << blitShaderProg->log();
}
+#ifdef QT_GL_SHARED_SHADER_DEBUG
+ qDebug(" -> QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());
+#endif
}
QGLEngineSharedShaders::~QGLEngineSharedShaders()
{
- QList<QGLEngineShaderProg*>::iterator itr;
- for (itr = cachedPrograms.begin(); itr != cachedPrograms.end(); ++itr)
- delete *itr;
+#ifdef QT_GL_SHARED_SHADER_DEBUG
+ qDebug(" -> ~QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());
+#endif
+ qDeleteAll(shaders);
+ shaders.clear();
+
+ qDeleteAll(cachedPrograms);
+ cachedPrograms.clear();
if (blitShaderProg) {
delete blitShaderProg;
@@ -262,99 +308,110 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS
}
}
- QGLShader *vertexShader = 0;
- QGLShader *fragShader = 0;
- QGLEngineShaderProg *newProg = 0;
- bool success = false;
+ QScopedPointer<QGLEngineShaderProg> newProg;
do {
- QByteArray source;
+ QByteArray fragSource;
// Insert the custom stage before the srcPixel shader to work around an ATI driver bug
// where you cannot forward declare a function that takes a sampler as argument.
if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
- source.append(prog.customStageSource);
- source.append(qShaderSnippets[prog.mainFragShader]);
- source.append(qShaderSnippets[prog.srcPixelFragShader]);
+ fragSource.append(prog.customStageSource);
+ fragSource.append(qShaderSnippets[prog.mainFragShader]);
+ fragSource.append(qShaderSnippets[prog.srcPixelFragShader]);
if (prog.compositionFragShader)
- source.append(qShaderSnippets[prog.compositionFragShader]);
+ fragSource.append(qShaderSnippets[prog.compositionFragShader]);
if (prog.maskFragShader)
- source.append(qShaderSnippets[prog.maskFragShader]);
- fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this);
- QByteArray description;
+ fragSource.append(qShaderSnippets[prog.maskFragShader]);
+
+ QByteArray vertexSource;
+ vertexSource.append(qShaderSnippets[prog.mainVertexShader]);
+ vertexSource.append(qShaderSnippets[prog.positionVertexShader]);
+
+ QScopedPointer<QGLShaderProgram> shaderProgram(new QGLShaderProgram(ctxGuard.context(), 0));
+
+ CachedShader shaderCache(fragSource, vertexSource);
+ bool inCache = shaderCache.load(shaderProgram.data(), ctxGuard.context());
+
+ if (!inCache) {
+
+ QScopedPointer<QGLShader> fragShader(new QGLShader(QGLShader::Fragment, ctxGuard.context(), 0));
+ QByteArray description;
#if defined(QT_DEBUG)
- // Name the shader for easier debugging
- description.append("Fragment shader: main=");
- description.append(snippetNameStr(prog.mainFragShader));
- description.append(", srcPixel=");
- description.append(snippetNameStr(prog.srcPixelFragShader));
- if (prog.compositionFragShader) {
- description.append(", composition=");
- description.append(snippetNameStr(prog.compositionFragShader));
- }
- if (prog.maskFragShader) {
- description.append(", mask=");
- description.append(snippetNameStr(prog.maskFragShader));
- }
- fragShader->setObjectName(QString::fromLatin1(description));
+ // Name the shader for easier debugging
+ description.append("Fragment shader: main=");
+ description.append(snippetNameStr(prog.mainFragShader));
+ description.append(", srcPixel=");
+ description.append(snippetNameStr(prog.srcPixelFragShader));
+ if (prog.compositionFragShader) {
+ description.append(", composition=");
+ description.append(snippetNameStr(prog.compositionFragShader));
+ }
+ if (prog.maskFragShader) {
+ description.append(", mask=");
+ description.append(snippetNameStr(prog.maskFragShader));
+ }
+ fragShader->setObjectName(QString::fromLatin1(description));
#endif
- if (!fragShader->compileSourceCode(source)) {
- qWarning() << "Warning:" << description << "failed to compile!";
- break;
- }
+ if (!fragShader->compileSourceCode(fragSource)) {
+ qWarning() << "Warning:" << description << "failed to compile!";
+ break;
+ }
- source.clear();
- source.append(qShaderSnippets[prog.mainVertexShader]);
- source.append(qShaderSnippets[prog.positionVertexShader]);
- vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), this);
+ QScopedPointer<QGLShader> vertexShader(new QGLShader(QGLShader::Vertex, ctxGuard.context(), 0));
#if defined(QT_DEBUG)
- // Name the shader for easier debugging
- description.clear();
- description.append("Vertex shader: main=");
- description.append(snippetNameStr(prog.mainVertexShader));
- description.append(", position=");
- description.append(snippetNameStr(prog.positionVertexShader));
- vertexShader->setObjectName(QString::fromLatin1(description));
+ // Name the shader for easier debugging
+ description.clear();
+ description.append("Vertex shader: main=");
+ description.append(snippetNameStr(prog.mainVertexShader));
+ description.append(", position=");
+ description.append(snippetNameStr(prog.positionVertexShader));
+ vertexShader->setObjectName(QString::fromLatin1(description));
#endif
- if (!vertexShader->compileSourceCode(source)) {
- qWarning() << "Warning:" << description << "failed to compile!";
- break;
- }
+ if (!vertexShader->compileSourceCode(vertexSource)) {
+ qWarning() << "Warning:" << description << "failed to compile!";
+ break;
+ }
- newProg = new QGLEngineShaderProg(prog);
-
- // If the shader program's not found in the cache, create it now.
- newProg->program = new QGLShaderProgram(ctxGuard.context(), this);
- newProg->program->addShader(vertexShader);
- newProg->program->addShader(fragShader);
-
- // We have to bind the vertex attribute names before the program is linked:
- newProg->program->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
- if (newProg->useTextureCoords)
- newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
- if (newProg->useOpacityAttribute)
- newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
- if (newProg->usePmvMatrixAttribute) {
- newProg->program->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
- newProg->program->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
- newProg->program->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
+ shaders.append(vertexShader.data());
+ shaders.append(fragShader.data());
+ shaderProgram->addShader(vertexShader.take());
+ shaderProgram->addShader(fragShader.take());
+
+ // We have to bind the vertex attribute names before the program is linked:
+ shaderProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ if (prog.useTextureCoords)
+ shaderProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
+ if (prog.useOpacityAttribute)
+ shaderProgram->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
+ if (prog.usePmvMatrixAttribute) {
+ shaderProgram->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
+ shaderProgram->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
+ shaderProgram->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
+ }
}
+ newProg.reset(new QGLEngineShaderProg(prog));
+ newProg->program = shaderProgram.take();
+
newProg->program->link();
- if (!newProg->program->isLinked()) {
+ if (newProg->program->isLinked()) {
+ if (!inCache)
+ shaderCache.store(newProg->program, ctxGuard.context());
+ } else {
QLatin1String none("none");
QLatin1String br("\n");
QString error;
- error = QLatin1String("Shader program failed to link,")
+ error = QLatin1String("Shader program failed to link,");
#if defined(QT_DEBUG)
- + br
- + QLatin1String(" Shaders Used:") + br
- + QLatin1String(" ") + vertexShader->objectName() + QLatin1String(": ") + br
- + QLatin1String(vertexShader->sourceCode()) + br
- + QLatin1String(" ") + fragShader->objectName() + QLatin1String(": ") + br
- + QLatin1String(fragShader->sourceCode()) + br
+ error += QLatin1String("\n Shaders Used:\n");
+ for (int i = 0; i < newProg->program->shaders().count(); ++i) {
+ QGLShader *shader = newProg->program->shaders().at(i);
+ error += QLatin1String(" ") + shader->objectName() + QLatin1String(": \n")
+ + QLatin1String(shader->sourceCode()) + br;
+ }
#endif
- + QLatin1String(" Error Log:\n")
- + QLatin1String(" ") + newProg->program->log();
+ error += QLatin1String(" Error Log:\n")
+ + QLatin1String(" ") + newProg->program->log();
qWarning() << error;
break;
}
@@ -376,26 +433,10 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS
}
}
- cachedPrograms.insert(0, newProg);
-
- success = true;
+ cachedPrograms.insert(0, newProg.data());
} while (false);
- // Clean up everything if we weren't successful
- if (!success) {
- if (newProg) {
- delete newProg; // Also deletes the QGLShaderProgram which in turn deletes the QGLShaders
- newProg = 0;
- }
- else {
- if (vertexShader)
- delete vertexShader;
- if (fragShader)
- delete fragShader;
- }
- }
-
- return newProg;
+ return newProg.take();
}
void QGLEngineSharedShaders::cleanupCustomStage(QGLCustomShaderStage* stage)
@@ -424,7 +465,6 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context)
currentShaderProg(0)
{
sharedShaders = QGLEngineSharedShaders::shadersForContext(context);
- connect(sharedShaders, SIGNAL(shaderProgNeedsChanging()), this, SLOT(shaderProgNeedsChangingSlot()));
}
QGLEngineShaderManager::~QGLEngineShaderManager()
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 1afdd5b..7cc9dc3 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -259,9 +259,9 @@ static const GLuint QT_PMV_MATRIX_3_ATTR = 5;
class QGLEngineShaderProg;
-class QGLEngineSharedShaders : public QObject
+class Q_OPENGL_EXPORT QGLEngineSharedShaders
{
- Q_OBJECT
+ Q_GADGET
public:
enum SnippetName {
@@ -364,14 +364,12 @@ public:
// full.
void cleanupCustomStage(QGLCustomShaderStage* stage);
-signals:
- void shaderProgNeedsChanging();
-
private:
QGLSharedResourceGuard ctxGuard;
QGLShaderProgram *blitShaderProg;
QGLShaderProgram *simpleShaderProg;
QList<QGLEngineShaderProg*> cachedPrograms;
+ QList<QGLShader *> shaders;
static const char* qShaderSnippets[TotalSnippetCount];
};
@@ -492,9 +490,6 @@ public:
QGLEngineSharedShaders* sharedShaders;
-private slots:
- void shaderProgNeedsChangingSlot() { shaderProgNeedsChanging = true; }
-
private:
QGLContext* ctx;
bool shaderProgNeedsChanging;
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index 1aacc96..fc8b9ef 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -148,7 +148,7 @@ static const char* const qglslAffinePositionWithPatternBrushVertexShader
= qglslPositionWithPatternBrushVertexShader;
static const char* const qglslPatternBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform lowp vec4 patternColor; \n\
varying highp vec2 patternTexCoords;\n\
lowp vec4 srcPixel() \n\
@@ -183,7 +183,7 @@ static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader
= qglslPositionWithLinearGradientBrushVertexShader;
static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
varying mediump float index; \n\
lowp vec4 srcPixel() \n\
{ \n\
@@ -218,7 +218,7 @@ static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader
static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\
#define INVERSE_2PI 0.1591549430918953358 \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform mediump float angle; \n\
varying highp vec2 A; \n\
lowp vec4 srcPixel() \n\
@@ -260,7 +260,7 @@ static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader
= qglslPositionWithRadialGradientBrushVertexShader;
static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform highp float fmp2_m_radius2; \n\
uniform highp float inverse_2_fmp2_m_radius2; \n\
varying highp float b; \n\
@@ -304,14 +304,14 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader
// TODO: Special case POT textures which don't need this emulation
static const char* const qglslTextureBrushSrcFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() { \n\
return texture2D(brushTexture, fract(brushTextureCoords)); \n\
}\n";
#else
static const char* const qglslTextureBrushSrcFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return texture2D(brushTexture, brushTextureCoords); \n\
@@ -321,7 +321,7 @@ static const char* const qglslTextureBrushSrcFragmentShader = "\n\
static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
uniform lowp vec4 patternColor; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\
@@ -337,7 +337,7 @@ static const char* const qglslSolidBrushSrcFragmentShader = "\n\
static const char* const qglslImageSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n"
"return texture2D(imageTexture, textureCoords); \n"
@@ -345,7 +345,7 @@ static const char* const qglslImageSrcFragmentShader = "\n\
static const char* const qglslCustomSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return customShader(imageTexture, textureCoords); \n\
@@ -354,7 +354,7 @@ static const char* const qglslCustomSrcFragmentShader = "\n\
static const char* const qglslImageSrcWithPatternFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
uniform lowp vec4 patternColor; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\
@@ -362,7 +362,7 @@ static const char* const qglslImageSrcWithPatternFragmentShader = "\n\
static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\
@@ -454,7 +454,7 @@ static const char* const qglslMainFragmentShader = "\n\
static const char* const qglslMaskFragmentShader = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{\n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
@@ -478,7 +478,7 @@ static const char* const qglslMaskFragmentShader = "\n\
static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{ \n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
@@ -487,7 +487,7 @@ static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\
static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{ \n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp
index e84f9df..075f7d1 100644
--- a/src/opengl/gl2paintengineex/qglgradientcache.cpp
+++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp
@@ -42,29 +42,33 @@
#include "qglgradientcache_p.h"
#include <private/qdrawhelper_p.h>
#include <private/qgl_p.h>
-
+#include <QtCore/qmutex.h>
QT_BEGIN_NAMESPACE
-static void QGL2GradientCache_free(void *ptr)
+class QGL2GradientCacheWrapper
{
- delete reinterpret_cast<QGL2GradientCache *>(ptr);
-}
+public:
+ QGL2GradientCache *cacheForContext(const QGLContext *context) {
+ QMutexLocker lock(&m_mutex);
+ return m_resource.value(context);
+ }
-Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gradient_caches, (QGL2GradientCache_free))
+private:
+ QGLContextGroupResource<QGL2GradientCache> m_resource;
+ QMutex m_mutex;
+};
+
+Q_GLOBAL_STATIC(QGL2GradientCacheWrapper, qt_gradient_caches)
QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context)
{
- QGL2GradientCache *p = reinterpret_cast<QGL2GradientCache *>(qt_gradient_caches()->value(context));
- if (!p) {
- QGLShareContextScope scope(context);
- p = new QGL2GradientCache;
- qt_gradient_caches()->insert(context, p);
- }
- return p;
+ return qt_gradient_caches()->cacheForContext(context);
}
-void QGL2GradientCache::cleanCache() {
+void QGL2GradientCache::cleanCache()
+{
+ QMutexLocker lock(&m_mutex);
QGLGradientColorTableHash::const_iterator it = cache.constBegin();
for (; it != cache.constEnd(); ++it) {
const CacheInfo &cache_info = it.value();
@@ -75,6 +79,7 @@ void QGL2GradientCache::cleanCache() {
GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity)
{
+ QMutexLocker lock(&m_mutex);
quint64 hash_val = 0;
QGradientStops stops = gradient.stops();
@@ -88,7 +93,9 @@ GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity)
else {
do {
const CacheInfo &cache_info = it.value();
- if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode()) {
+ if (cache_info.stops == stops && cache_info.opacity == opacity
+ && cache_info.interpolationMode == gradient.interpolationMode())
+ {
return cache_info.texId;
}
++it;
diff --git a/src/opengl/gl2paintengineex/qglgradientcache_p.h b/src/opengl/gl2paintengineex/qglgradientcache_p.h
index fa8a60b..d1d56a1 100644
--- a/src/opengl/gl2paintengineex/qglgradientcache_p.h
+++ b/src/opengl/gl2paintengineex/qglgradientcache_p.h
@@ -54,6 +54,7 @@
#include <QObject>
#include <QtOpenGL/QtOpenGL>
#include <private/qgl_p.h>
+#include <QtCore/qmutex.h>
QT_BEGIN_NAMESPACE
@@ -75,22 +76,22 @@ class QGL2GradientCache
public:
static QGL2GradientCache *cacheForContext(const QGLContext *context);
- QGL2GradientCache() { }
- ~QGL2GradientCache() {cleanCache();}
+ QGL2GradientCache(const QGLContext *) {}
+ ~QGL2GradientCache() { cleanCache(); }
GLuint getBuffer(const QGradient &gradient, qreal opacity);
inline int paletteSize() const { return 1024; }
-protected:
+private:
inline int maxCacheSize() const { return 60; }
inline void generateGradientColorTable(const QGradient& gradient,
uint *colorTable,
int size, qreal opacity) const;
GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity);
-
void cleanCache();
QGLGradientColorTableHash cache;
+ QMutex m_mutex;
};
QT_END_NAMESPACE
diff --git a/src/opengl/gl2paintengineex/qglshadercache_meego_p.h b/src/opengl/gl2paintengineex/qglshadercache_meego_p.h
new file mode 100644
index 0000000..d20c731
--- /dev/null
+++ b/src/opengl/gl2paintengineex/qglshadercache_meego_p.h
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QGLSHADERCACHE_MEEGO_P_H
+#define QGLSHADERCACHE_MEEGO_P_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2)
+
+#include <QtCore/qcryptographichash.h>
+#include <QtCore/qsharedmemory.h>
+#include <QtCore/qsystemsemaphore.h>
+
+#ifndef QT_BOOTSTRAPPED
+# include <GLES2/gl2ext.h>
+#endif
+#if defined(QT_DEBUG) || defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE)
+# include <syslog.h>
+#endif
+
+QT_BEGIN_HEADER
+
+/*
+ This cache stores internal Qt shader programs in shared memory.
+
+ This header file is ugly on purpose and can only be included once. It is only to be used
+ for the internal shader cache, not as a generic cache for anyone's shaders.
+
+ The cache stores either ShaderCacheMaxEntries shader programs or ShaderCacheDataSize kilobytes
+ of shader programs, whatever limit is reached first.
+
+ The layout of the cache is as outlined in the CachedShaders struct. After some
+ integers, an array of headers is reserved, then comes the space for the actual binaries.
+
+ Shader Programs are identified by the md5sum of their frag and vertex shader source code.
+
+ Shader Programs are never removed. The cache never shrinks or re-shuffles. This is done
+ on purpose to ensure minimum amount of locking, no alignment problems and very few write
+ operations.
+
+ Note: Locking the shader cache could be expensive, because the entire system might hang.
+ That's why the cache is immutable to minimize the time we need to keep it locked.
+
+ Why is it Meego specific?
+
+ First, the size is chosen so that it fits to generic meego usage. Second, on Meego, there's
+ always at least one Qt application active (the launcher), so the cache will never be destroyed.
+ Only when the last Qt app exits, the cache dies, which should only be when someone kills the
+ X11 server. And last but not least it was only tested with Meego's SGX driver.
+
+ There's a small tool in src/opengl/util/meego that dumps the contents of the cache.
+ */
+
+// anonymous namespace, prevent exporting of the private symbols
+namespace
+{
+
+struct CachedShaderHeader
+{
+ /* the index in the data[] member of CachedShaders */
+ int index;
+ /* the size of the binary shader */
+ GLsizei size;
+ /* the format of the binary shader */
+ GLenum format;
+ /* the md5sum of the frag+vertex shaders */
+ char md5Sum[16];
+};
+
+enum
+{
+ /* The maximum amount of shader programs the cache can hold */
+ ShaderCacheMaxEntries = 20
+};
+
+typedef CachedShaderHeader CachedShaderHeaders[ShaderCacheMaxEntries];
+
+enum
+{
+ // ShaderCacheDataSize is 20k minus the other data members of CachedShaders
+ ShaderCacheDataSize = 1024 * ShaderCacheMaxEntries - sizeof(CachedShaderHeaders) - 2 * sizeof(int)
+};
+
+struct CachedShaders
+{
+ /* How much space is still available in the cache */
+ inline int availableSize() const { return ShaderCacheDataSize - dataSize; }
+
+ /* The current amount of cached shaders */
+ int shaderCount;
+
+ /* The current amount (in bytes) of cached data */
+ int dataSize;
+
+ /* The headers describing the shaders */
+ CachedShaderHeaders headers;
+
+ /* The actual binary data of the shader programs */
+ char data[ShaderCacheDataSize];
+};
+
+//#define QT_DEBUG_SHADER_CACHE
+#ifdef QT_DEBUG_SHADER_CACHE
+static QDebug shaderCacheDebug()
+{
+ return QDebug(QtDebugMsg);
+}
+#else
+static inline QNoDebug shaderCacheDebug() { return QNoDebug(); }
+#endif
+
+class ShaderCacheSharedMemory
+{
+public:
+ ShaderCacheSharedMemory()
+ : shm(QLatin1String("qt_gles2_shadercache_" QT_VERSION_STR))
+ {
+ // we need a system semaphore here, since cache creation and initialization must be atomic
+ QSystemSemaphore attachSemaphore(QLatin1String("qt_gles2_shadercache_mutex_" QT_VERSION_STR), 1);
+
+ if (!attachSemaphore.acquire()) {
+ shaderCacheDebug() << "Unable to require shader cache semaphore:" << attachSemaphore.errorString();
+ return;
+ }
+
+ if (shm.attach()) {
+ // success!
+ shaderCacheDebug() << "Attached to shader cache";
+ } else {
+
+ // no cache exists - create and initialize it
+ if (shm.create(sizeof(CachedShaders))) {
+ shaderCacheDebug() << "Created new shader cache";
+ initializeCache();
+ } else {
+ shaderCacheDebug() << "Unable to create shader cache:" << shm.errorString();
+ }
+ }
+
+ attachSemaphore.release();
+ }
+
+ inline bool isAttached() const { return shm.isAttached(); }
+
+ inline bool lock() { return shm.lock(); }
+ inline bool unlock() { return shm.unlock(); }
+ inline void *data() { return shm.data(); }
+ inline QString errorString() { return shm.errorString(); }
+
+ ~ShaderCacheSharedMemory()
+ {
+ if (!shm.detach())
+ shaderCacheDebug() << "Unable to detach shader cache" << shm.errorString();
+ }
+
+private:
+ void initializeCache()
+ {
+ // no need to lock the shared memory since we're already protected by the
+ // attach system semaphore.
+
+ void *data = shm.data();
+ Q_ASSERT(data);
+
+ memset(data, 0, sizeof(CachedShaders));
+ }
+
+ QSharedMemory shm;
+};
+
+class ShaderCacheLocker
+{
+public:
+ inline ShaderCacheLocker(ShaderCacheSharedMemory *cache)
+ : shm(cache->lock() ? cache : (ShaderCacheSharedMemory *)0)
+ {
+ if (!shm)
+ shaderCacheDebug() << "Unable to lock shader cache" << cache->errorString();
+ }
+
+ inline bool isLocked() const { return shm; }
+
+ inline ~ShaderCacheLocker()
+ {
+ if (!shm)
+ return;
+ if (!shm->unlock())
+ shaderCacheDebug() << "Unable to unlock shader cache" << shm->errorString();
+ }
+
+private:
+ ShaderCacheSharedMemory *shm;
+};
+
+#ifdef QT_BOOTSTRAPPED
+} // end namespace
+#else
+
+static void traceCacheOverflow(const char *message)
+{
+#if defined(QT_DEBUG) || defined (QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE)
+ openlog(qPrintable(QCoreApplication::applicationName()), LOG_PID | LOG_ODELAY, LOG_USER);
+ syslog(LOG_DEBUG, message);
+ closelog();
+#endif
+ shaderCacheDebug() << message;
+}
+
+Q_GLOBAL_STATIC(ShaderCacheSharedMemory, shaderCacheSharedMemory)
+
+/*
+ Finds the index of the shader program identified by md5Sum in the cache.
+ Note: Does NOT lock the cache for reading, the cache must already be locked!
+
+ Returns -1 when no shader was found.
+ */
+static int qt_cache_index_unlocked(const QByteArray &md5Sum, CachedShaders *cache)
+{
+ for (int i = 0; i < cache->shaderCount; ++i) {
+ if (qstrncmp(md5Sum.constData(), cache->headers[i].md5Sum, 16) == 0) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+/* Returns the index of the shader identified by md5Sum */
+static int qt_cache_index(const QByteArray &md5Sum)
+{
+ ShaderCacheSharedMemory *shm = shaderCacheSharedMemory();
+ if (!shm || !shm->isAttached())
+ return false;
+
+ Q_ASSERT(md5Sum.length() == 16);
+
+ ShaderCacheLocker locker(shm);
+ if (!locker.isLocked())
+ return false;
+
+ void *data = shm->data();
+ Q_ASSERT(data);
+
+ CachedShaders *cache = reinterpret_cast<CachedShaders *>(data);
+
+ return qt_cache_index_unlocked(md5Sum, cache);
+}
+
+/* Loads the cached shader at index \a shaderIndex into \a program
+ * Note: Since the cache is immutable, this operation doesn't lock the shared memory.
+ */
+static bool qt_cached_shader(QGLShaderProgram *program, const QGLContext *ctx, int shaderIndex)
+{
+ Q_ASSERT(shaderIndex >= 0 && shaderIndex <= ShaderCacheMaxEntries);
+ Q_ASSERT(program);
+
+ ShaderCacheSharedMemory *shm = shaderCacheSharedMemory();
+ if (!shm || !shm->isAttached())
+ return false;
+
+ void *data = shm->data();
+ Q_ASSERT(data);
+
+ CachedShaders *cache = reinterpret_cast<CachedShaders *>(data);
+
+ shaderCacheDebug() << "fetching cached shader at index" << shaderIndex
+ << "dataIndex" << cache->headers[shaderIndex].index
+ << "size" << cache->headers[shaderIndex].size
+ << "format" << cache->headers[shaderIndex].format;
+
+ // call program->programId first, since that resolves the glProgramBinaryOES symbol
+ GLuint programId = program->programId();
+ glProgramBinaryOES(programId, cache->headers[shaderIndex].format,
+ cache->data + cache->headers[shaderIndex].index,
+ cache->headers[shaderIndex].size);
+
+ return true;
+}
+
+/* Stores the shader program in the cache. Returns false if there's an error with the cache, or
+ if the cache is too small to hold the shader. */
+static bool qt_cache_shader(const QGLShaderProgram *shader, const QGLContext *ctx, const QByteArray &md5Sum)
+{
+ ShaderCacheSharedMemory *shm = shaderCacheSharedMemory();
+ if (!shm || !shm->isAttached())
+ return false;
+
+ void *data = shm->data();
+ Q_ASSERT(data);
+
+ CachedShaders *cache = reinterpret_cast<CachedShaders *>(data);
+
+ ShaderCacheLocker locker(shm);
+ if (!locker.isLocked())
+ return false;
+
+ int cacheIdx = cache->shaderCount;
+ if (cacheIdx >= ShaderCacheMaxEntries) {
+ traceCacheOverflow("Qt OpenGL shader cache index overflow!");
+ return false;
+ }
+
+ // now that we have the lock on the shared memory, make sure no one
+ // inserted the shader already while we were unlocked
+ if (qt_cache_index_unlocked(md5Sum, cache) != -1)
+ return true; // already cached
+
+ shaderCacheDebug() << "Caching shader at index" << cacheIdx;
+
+ GLint binaryLength = 0;
+ glGetProgramiv(shader->programId(), GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength);
+
+ if (!binaryLength) {
+ shaderCacheDebug() << "Unable to determine binary shader size!";
+ return false;
+ }
+
+ if (binaryLength > cache->availableSize()) {
+ traceCacheOverflow("Qt OpenGL shader cache data overflow!");
+ return false;
+ }
+
+ GLsizei size = 0;
+ GLenum format = 0;
+ glGetProgramBinaryOES(shader->programId(), binaryLength, &size, &format,
+ cache->data + cache->dataSize);
+
+ if (!size) {
+ shaderCacheDebug() << "Unable to get binary shader!";
+ return false;
+ }
+
+ cache->headers[cacheIdx].index = cache->dataSize;
+ cache->dataSize += binaryLength;
+ ++cache->shaderCount;
+ cache->headers[cacheIdx].size = binaryLength;
+ cache->headers[cacheIdx].format = format;
+
+ memcpy(cache->headers[cacheIdx].md5Sum, md5Sum.constData(), 16);
+
+ shaderCacheDebug() << "cached shader size" << size
+ << "format" << format
+ << "binarySize" << binaryLength
+ << "cache index" << cacheIdx
+ << "data index" << cache->headers[cacheIdx].index;
+
+ return true;
+}
+
+} // namespace
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(OpenGL)
+
+class CachedShader
+{
+public:
+ CachedShader(const QByteArray &fragSource, const QByteArray &vertexSource)
+ : cacheIdx(-1)
+ {
+ QCryptographicHash md5Hash(QCryptographicHash::Md5);
+
+ md5Hash.addData(fragSource);
+ md5Hash.addData(vertexSource);
+
+ md5Sum = md5Hash.result();
+ }
+
+ bool isCached()
+ {
+ return cacheIndex() != -1;
+ }
+
+ int cacheIndex()
+ {
+ if (cacheIdx != -1)
+ return cacheIdx;
+ cacheIdx = qt_cache_index(md5Sum);
+ return cacheIdx;
+ }
+
+ bool load(QGLShaderProgram *program, const QGLContext *ctx)
+ {
+ if (cacheIndex() == -1)
+ return false;
+ return qt_cached_shader(program, ctx, cacheIdx);
+ }
+
+ bool store(QGLShaderProgram *program, const QGLContext *ctx)
+ {
+ return qt_cache_shader(program, ctx, md5Sum);
+ }
+
+private:
+ QByteArray md5Sum;
+ int cacheIdx;
+};
+
+
+QT_END_NAMESPACE
+
+#endif
+
+QT_END_HEADER
+
+#endif
+#endif
diff --git a/src/opengl/gl2paintengineex/qglshadercache_p.h b/src/opengl/gl2paintengineex/qglshadercache_p.h
new file mode 100644
index 0000000..6e496ab
--- /dev/null
+++ b/src/opengl/gl2paintengineex/qglshadercache_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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$
+**
+****************************************************************************/
+
+//
+// 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.
+//
+
+#ifndef QGLSHADERCACHE_P_H
+#define QGLSHADERCACHE_P_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2)
+# include "qglshadercache_meego_p.h"
+#else
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(OpenGL)
+
+class QGLShaderProgram;
+class QGLContext;
+
+class CachedShader
+{
+public:
+ inline CachedShader(const QByteArray &, const QByteArray &)
+ {}
+
+ inline bool isCached()
+ {
+ return false;
+ }
+
+ inline bool load(QGLShaderProgram *, const QGLContext *)
+ {
+ return false;
+ }
+
+ inline bool store(QGLShaderProgram *, const QGLContext *)
+ {
+ return false;
+ }
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+#endif
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 5c8d2b6..6678522 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -333,7 +333,13 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
matrix.translate(brushOrigin.x(), brushOrigin.y());
QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y());
- QTransform gl_to_qt(1, 0, 0, -1, 0, height);
+ qreal m22 = -1;
+ qreal dy = height;
+ if (device->isFlipped()) {
+ m22 = 1;
+ dy = 0;
+ }
+ QTransform gl_to_qt(1, 0, 0, m22, 0, dy);
QTransform inv_matrix;
if (style == Qt::TexturePattern && textureInvertedY == -1)
inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
@@ -372,10 +378,16 @@ void QGL2PaintEngineExPrivate::updateMatrix()
// NOTE: The resultant matrix is also transposed, as GL expects column-major matracies
const GLfloat wfactor = 2.0f / width;
- const GLfloat hfactor = -2.0f / height;
+ GLfloat hfactor = -2.0f / height;
+
GLfloat dx = transform.dx();
GLfloat dy = transform.dy();
+ if (device->isFlipped()) {
+ hfactor *= -1;
+ dy -= height;
+ }
+
// Non-integer translates can have strange effects for some rendering operations such as
// anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
@@ -383,12 +395,6 @@ void QGL2PaintEngineExPrivate::updateMatrix()
dx = ceilf(dx - 0.5f);
dy = ceilf(dy - 0.5f);
}
-#ifndef Q_OS_SYMBIAN
- if (addOffset) {
- dx += 0.49f;
- dy += 0.49f;
- }
-#endif
pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13();
pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23();
pmvMatrix[2][0] = (wfactor * dx) - transform.m33();
@@ -490,11 +496,6 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
currentBrush = noBrush;
shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc);
- if (addOffset) {
- addOffset = false;
- matrixDirty = true;
- }
-
if (snapToPixelGrid) {
snapToPixelGrid = false;
matrixDirty = true;
@@ -677,16 +678,6 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
{
transferMode(BrushDrawingMode);
- const QOpenGL2PaintEngineState *s = q->state();
- const bool newAddOffset = !(s->renderHints & QPainter::Antialiasing) &&
- (qbrush_style(currentBrush) == Qt::SolidPattern) &&
- !multisamplingAlwaysEnabled;
-
- if (addOffset != newAddOffset) {
- addOffset = newAddOffset;
- matrixDirty = true;
- }
-
if (snapToPixelGrid) {
snapToPixelGrid = false;
matrixDirty = true;
@@ -874,6 +865,35 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
// Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable
path.makeCacheable();
+ if (!device->format().stencil()) {
+ // If there is no stencil buffer, triangulate the path instead.
+
+ QRectF bbox = path.controlPointRect();
+ // If the path doesn't fit within these limits, it is possible that the triangulation will fail.
+ bool withinLimits = (bbox.left() > -0x8000 * inverseScale)
+ && (bbox.right() < 0x8000 * inverseScale)
+ && (bbox.top() > -0x8000 * inverseScale)
+ && (bbox.bottom() < 0x8000 * inverseScale);
+ if (withinLimits) {
+ QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale));
+
+ QVarLengthArray<float> vertices(polys.vertices.size());
+ for (int i = 0; i < polys.vertices.size(); ++i)
+ vertices[i] = float(inverseScale * polys.vertices.at(i));
+
+ prepareForDraw(currentBrush.isOpaque());
+ setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData());
+ if (QGLExtensions::glExtensions() & QGLExtensions::ElementIndexUint)
+ glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_INT, polys.indices.data());
+ else
+ glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_SHORT, polys.indices.data());
+ } else {
+ // We can't handle big, concave painter paths with OpenGL without stencil buffer.
+ qWarning("Painter path exceeds +/-32767 pixels.");
+ }
+ return;
+ }
+
// The path is too complicated & needs the stencil technique
vertexCoordinateArray.clear();
vertexCoordinateArray.addPath(path, inverseScale, false);
@@ -1176,12 +1196,6 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)
{
const QOpenGL2PaintEngineState *s = q->state();
- const bool newAddOffset = !(s->renderHints & QPainter::Antialiasing) && !multisamplingAlwaysEnabled;
- if (addOffset != newAddOffset) {
- addOffset = newAddOffset;
- matrixDirty = true;
- }
-
if (snapToPixelGrid) {
snapToPixelGrid = false;
matrixDirty = true;
@@ -1531,13 +1545,15 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
QOpenGL2PaintEngineState *s = q->state();
+ void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context());
bool recreateVertexArrays = false;
QGLTextureGlyphCache *cache =
- (QGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(ctx, glyphType, QTransform());
+ (QGLTextureGlyphCache *) staticTextItem->fontEngine()->glyphCache(cacheKey, glyphType, QTransform());
if (!cache || cache->cacheType() != glyphType || cache->context() == 0) {
cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform());
- staticTextItem->fontEngine()->setGlyphCache(ctx, cache);
+ staticTextItem->fontEngine()->setGlyphCache(cacheKey, cache);
+ cache->insert(ctx, cache);
recreateVertexArrays = true;
}
@@ -1562,12 +1578,13 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
if (recreateVertexArrays) {
cache->setPaintEnginePrivate(this);
if (!cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs,
- staticTextItem->glyphs, staticTextItem->glyphPositions)) {
- // No space in cache. We need to clear the cache and try again
+ staticTextItem->glyphs, staticTextItem->glyphPositions)) {
+ // No space for glyphs in cache. We need to reset it and try again.
cache->clear();
cache->populate(staticTextItem->fontEngine(), staticTextItem->numGlyphs,
staticTextItem->glyphs, staticTextItem->glyphPositions);
}
+ cache->fillInPendingGlyphs();
}
if (cache->width() == 0 || cache->height() == 0)
@@ -1611,15 +1628,24 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
}
-
if (recreateVertexArrays) {
vertexCoordinates->clear();
textureCoordinates->clear();
+ bool supportsSubPixelPositions = staticTextItem->fontEngine()->supportsSubPixelPositions();
for (int i=0; i<staticTextItem->numGlyphs; ++i) {
- const QTextureGlyphCache::Coord &c = cache->coords.value(staticTextItem->glyphs[i]);
- int x = staticTextItem->glyphPositions[i].x.toInt() + c.baseLineX - margin;
- int y = staticTextItem->glyphPositions[i].y.toInt() - c.baseLineY - margin;
+ QFixed subPixelPosition;
+ if (supportsSubPixelPositions)
+ subPixelPosition = cache->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
+
+ QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition);
+
+ const QTextureGlyphCache::Coord &c = cache->coords[glyph];
+ if (c.isNull())
+ continue;
+
+ int x = qFloor(staticTextItem->glyphPositions[i].x) + c.baseLineX - margin;
+ int y = qFloor(staticTextItem->glyphPositions[i].y) - c.baseLineY - margin;
vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h));
textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy));
@@ -1628,10 +1654,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
staticTextItem->userDataNeedsUpdate = false;
}
- if (elementIndices.size() < staticTextItem->numGlyphs*6) {
+ int numGlyphs = vertexCoordinates->vertexCount() / 4;
+
+ if (elementIndices.size() < numGlyphs*6) {
Q_ASSERT(elementIndices.size() % 6 == 0);
int j = elementIndices.size() / 6 * 4;
- while (j < staticTextItem->numGlyphs*4) {
+ while (j < numGlyphs*4) {
elementIndices.append(j + 0);
elementIndices.append(j + 0);
elementIndices.append(j + 1);
@@ -1659,10 +1687,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());
setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());
- if (addOffset) {
- addOffset = false;
- matrixDirty = true;
- }
if (!snapToPixelGrid) {
snapToPixelGrid = true;
matrixDirty = true;
@@ -1724,9 +1748,9 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false);
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
- glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, 0);
+ glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
#else
- glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
+ glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2);
@@ -1774,10 +1798,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
- glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, 0);
+ glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#else
- glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
+ glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());
#endif
}
@@ -1813,11 +1837,6 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen
textureCoordinateArray.clear();
opacityArray.reset();
- if (addOffset) {
- addOffset = false;
- matrixDirty = true;
- }
-
if (snapToPixelGrid) {
snapToPixelGrid = false;
matrixDirty = true;
@@ -2080,7 +2099,10 @@ void QGL2PaintEngineExPrivate::setScissor(const QRect &rect)
{
const int left = rect.left();
const int width = rect.width();
- const int bottom = height - (rect.top() + rect.height());
+ int bottom = height - (rect.top() + rect.height());
+ if (device->isFlipped()) {
+ bottom = rect.top();
+ }
const int height = rect.height();
glScissor(left, bottom, width, height);
@@ -2114,10 +2136,6 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
{
transferMode(BrushDrawingMode);
- if (addOffset) {
- addOffset = false;
- matrixDirty = true;
- }
if (snapToPixelGrid) {
snapToPixelGrid = false;
matrixDirty = true;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index bb9d2e3..f7ec5f5 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -181,7 +181,6 @@ public:
elementIndicesVBOId(0),
opacityArray(0),
snapToPixelGrid(false),
- addOffset(false),
nativePaintingActive(false),
inverseScale(1),
lastMaskTextureUsed(0)
@@ -285,7 +284,6 @@ public:
GLfloat staticTextureCoordinateArray[8];
bool snapToPixelGrid;
- bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix
bool nativePaintingActive;
GLfloat pmvMatrix[3][3];
GLfloat inverseScale;
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 312d66f..c867d60 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -41,6 +41,7 @@
#include "qtextureglyphcache_gl_p.h"
#include "qpaintengineex_opengl2_p.h"
+#include "private/qglengineshadersource_p.h"
#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL)
#include "private/qeglcontext_p.h"
@@ -54,68 +55,59 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled;
QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
-QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix)
- : QImageTextureGlyphCache(type, matrix)
+QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix)
+ : QImageTextureGlyphCache(type, matrix), QGLContextGroupResourceBase()
, ctx(0)
- , m_width(0)
- , m_height(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);
+#endif
setContext(context);
-}
-
-void QGLTextureGlyphCache::setContext(QGLContext *context)
-{
- ctx = context;
- // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where
- // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The
- // workaround is to use a system-memory copy of the glyph cache for this device.
- // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and
- // be slower, so that is not desireable.
- if (!ctx->d_ptr->workaround_brokenFBOReadBack)
- glGenFramebuffers(1, &m_fbo);
-
- connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)),
- SLOT(contextDestroyed(const QGLContext*)));
+ m_vertexCoordinateArray[0] = -1.0f;
+ m_vertexCoordinateArray[1] = -1.0f;
+ m_vertexCoordinateArray[2] = 1.0f;
+ m_vertexCoordinateArray[3] = -1.0f;
+ m_vertexCoordinateArray[4] = 1.0f;
+ m_vertexCoordinateArray[5] = 1.0f;
+ m_vertexCoordinateArray[6] = -1.0f;
+ m_vertexCoordinateArray[7] = 1.0f;
+
+ m_textureCoordinateArray[0] = 0.0f;
+ m_textureCoordinateArray[1] = 0.0f;
+ m_textureCoordinateArray[2] = 1.0f;
+ m_textureCoordinateArray[3] = 0.0f;
+ m_textureCoordinateArray[4] = 1.0f;
+ m_textureCoordinateArray[5] = 1.0f;
+ m_textureCoordinateArray[6] = 0.0f;
+ m_textureCoordinateArray[7] = 1.0f;
}
-void QGLTextureGlyphCache::clear()
+QGLTextureGlyphCache::~QGLTextureGlyphCache()
{
- if (ctx) {
- QGLShareContextScope scope(ctx);
-
- if (m_width || m_height)
- glDeleteTextures(1, &m_texture);
-
- m_texture = 0;
- m_width = 0;
- m_height = 0;
- m_w = 0;
- m_h = 0;
- m_cx = 0;
- m_cy = 0;
- m_currentRowHeight = 0;
- coords.clear();
- }
-
+#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
+ qDebug(" -> ~QGLTextureGlyphCache() %p.", this);
+#endif
+ delete m_blitProgram;
}
-QGLTextureGlyphCache::~QGLTextureGlyphCache()
+void QGLTextureGlyphCache::setContext(const QGLContext *context)
{
- if (ctx) {
- QGLShareContextScope scope(ctx);
-
- if (!ctx->d_ptr->workaround_brokenFBOReadBack)
- glDeleteFramebuffers(1, &m_fbo);
- }
-
- clear();
+ ctx = context;
+ m_h = 0;
}
void QGLTextureGlyphCache::createTextureData(int width, int height)
{
+ if (ctx == 0) {
+ qWarning("QGLTextureGlyphCache::createTextureData: Called with no context");
+ return;
+ }
+
// create in QImageTextureGlyphCache baseclass is meant to be called
// only to create the initial image and does not preserve the content,
// so we don't call when this function is called from resize.
@@ -128,11 +120,12 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
if (height < 16)
height = 16;
- glGenTextures(1, &m_texture);
- glBindTexture(GL_TEXTURE_2D, m_texture);
+ QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx);
+ glGenTextures(1, &glyphTexture->m_texture);
+ glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture);
- m_width = width;
- m_height = height;
+ glyphTexture->m_width = width;
+ glyphTexture->m_height = height;
if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
QVarLengthArray<uchar> data(width * height * 4);
@@ -155,8 +148,14 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
void QGLTextureGlyphCache::resizeTextureData(int width, int height)
{
- int oldWidth = m_width;
- int oldHeight = m_height;
+ if (ctx == 0) {
+ qWarning("QGLTextureGlyphCache::resizeTextureData: Called with no context");
+ return;
+ }
+ QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx);
+
+ int oldWidth = glyphTexture->m_width;
+ int oldHeight = glyphTexture->m_height;
// Make the lower glyph texture size 16 x 16.
if (width < 16)
@@ -164,7 +163,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
if (height < 16)
height = 16;
- GLuint oldTexture = m_texture;
+ GLuint oldTexture = glyphTexture->m_texture;
createTextureData(width, height);
if (ctx->d_ptr->workaround_brokenFBOReadBack) {
@@ -178,7 +177,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
// ### the QTextureGlyphCache API needs to be reworked to allow
// ### resizeTextureData to fail
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, glyphTexture->m_fbo);
GLuint tmp_texture;
glGenTextures(1, &tmp_texture);
@@ -197,7 +196,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
glBindTexture(GL_TEXTURE_2D, oldTexture);
- pex->transferMode(BrushDrawingMode);
+ if (pex != 0)
+ pex->transferMode(BrushDrawingMode);
glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST);
@@ -206,35 +206,62 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glViewport(0, 0, oldWidth, oldHeight);
- GLfloat* vertexCoordinateArray = pex->staticVertexCoordinateArray;
- vertexCoordinateArray[0] = -1.0f;
- vertexCoordinateArray[1] = -1.0f;
- vertexCoordinateArray[2] = 1.0f;
- vertexCoordinateArray[3] = -1.0f;
- vertexCoordinateArray[4] = 1.0f;
- vertexCoordinateArray[5] = 1.0f;
- vertexCoordinateArray[6] = -1.0f;
- vertexCoordinateArray[7] = 1.0f;
-
- GLfloat* textureCoordinateArray = pex->staticTextureCoordinateArray;
- textureCoordinateArray[0] = 0.0f;
- textureCoordinateArray[1] = 0.0f;
- textureCoordinateArray[2] = 1.0f;
- textureCoordinateArray[3] = 0.0f;
- textureCoordinateArray[4] = 1.0f;
- textureCoordinateArray[5] = 1.0f;
- textureCoordinateArray[6] = 0.0f;
- textureCoordinateArray[7] = 1.0f;
-
- pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertexCoordinateArray);
- pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, textureCoordinateArray);
-
- pex->shaderManager->useBlitProgram();
- pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);
+ QGLShaderProgram *blitProgram = 0;
+ if (pex == 0) {
+ if (m_blitProgram == 0) {
+ m_blitProgram = new QGLShaderProgram(ctx);
+
+ {
+ QString source;
+ source.append(QLatin1String(qglslMainWithTexCoordsVertexShader));
+ source.append(QLatin1String(qglslUntransformedPositionVertexShader));
+
+ QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram);
+ vertexShader->compileSourceCode(source);
+
+ m_blitProgram->addShader(vertexShader);
+ }
+
+ {
+ QString source;
+ source.append(QLatin1String(qglslMainFragmentShader));
+ source.append(QLatin1String(qglslImageSrcFragmentShader));
+
+ QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram);
+ fragmentShader->compileSourceCode(source);
+
+ m_blitProgram->addShader(fragmentShader);
+ }
+
+ m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
+ m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
+
+ m_blitProgram->link();
+ }
+
+ glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray);
+ glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray);
+
+ m_blitProgram->bind();
+ m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
+ m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
+ m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR));
+
+ blitProgram = m_blitProgram;
+
+ } else {
+ pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray);
+ pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray);
+
+ pex->shaderManager->useBlitProgram();
+ blitProgram = pex->shaderManager->blitProgram();
+ }
+
+ blitProgram->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glBindTexture(GL_TEXTURE_2D, m_texture);
+ glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
@@ -245,16 +272,24 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
- glViewport(0, 0, pex->width, pex->height);
- pex->updateClipScissorTest();
+ if (pex != 0) {
+ glViewport(0, 0, pex->width, pex->height);
+ pex->updateClipScissorTest();
+ }
}
-void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)
+void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition)
{
+ if (ctx == 0) {
+ qWarning("QGLTextureGlyphCache::fillTexture: Called with no context");
+ return;
+ }
+
+ QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx);
if (ctx->d_ptr->workaround_brokenFBOReadBack) {
- QImageTextureGlyphCache::fillTexture(c, glyph);
+ QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition);
- glBindTexture(GL_TEXTURE_2D, m_texture);
+ glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture);
const QImage &texture = image();
const uchar *bits = texture.constBits();
bits += c.y * texture.bytesPerLine() + c.x;
@@ -262,11 +297,10 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)
glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, c.w, 1, GL_ALPHA, GL_UNSIGNED_BYTE, bits);
bits += texture.bytesPerLine();
}
-
return;
}
- QImage mask = textureMapForGlyph(glyph);
+ QImage mask = textureMapForGlyph(glyph, subPixelPosition);
const int maskWidth = mask.width();
const int maskHeight = mask.height();
@@ -292,7 +326,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)
}
}
- glBindTexture(GL_TEXTURE_2D, m_texture);
+ glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture);
if (mask.format() == QImage::Format_RGB32) {
glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits());
} else {
@@ -305,8 +339,19 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)
// by converting it to a format with four bytes per pixel. Another is to copy one line at a
// time.
- for (int i = 0; i < maskHeight; ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i));
+ if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) {
+ // don't know which driver versions exhibit this bug, so be conservative for now
+ const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
+ ctx->d_ptr->workaround_brokenAlphaTexSubImage = versionString.indexOf("NVIDIA") >= 0;
+ ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true;
+ }
+
+ if (ctx->d_ptr->workaround_brokenAlphaTexSubImage) {
+ for (int i = 0; i < maskHeight; ++i)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i));
+ } else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits());
+ }
}
}
@@ -317,14 +362,35 @@ int QGLTextureGlyphCache::glyphPadding() const
int QGLTextureGlyphCache::maxTextureWidth() const
{
- return ctx->d_ptr->maxTextureSize();
+ if (ctx == 0)
+ return QImageTextureGlyphCache::maxTextureWidth();
+ else
+ return ctx->d_ptr->maxTextureSize();
}
int QGLTextureGlyphCache::maxTextureHeight() const
{
+ if (ctx == 0)
+ return QImageTextureGlyphCache::maxTextureHeight();
+
if (ctx->d_ptr->workaround_brokenTexSubImage)
return qMin(1024, ctx->d_ptr->maxTextureSize());
else
return ctx->d_ptr->maxTextureSize();
}
+
+void QGLTextureGlyphCache::clear()
+{
+ if (ctx != 0) {
+ m_textureResource.cleanup(ctx);
+
+ m_w = 0;
+ m_h = 0;
+ m_cx = 0;
+ m_cy = 0;
+ m_currentRowHeight = 0;
+ coords.clear();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index 2eb4e65..133289e 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -57,32 +57,82 @@
#include <private/qgl_p.h>
#include <qglshaderprogram.h>
+// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
QT_BEGIN_NAMESPACE
class QGL2PaintEngineExPrivate;
-class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QImageTextureGlyphCache
+struct QGLGlyphTexture
+{
+ QGLGlyphTexture(const QGLContext *ctx)
+ : m_width(0)
+ , m_height(0)
+ {
+ if (ctx && !ctx->d_ptr->workaround_brokenFBOReadBack)
+ glGenFramebuffers(1, &m_fbo);
+
+#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
+ qDebug(" -> QGLGlyphTexture() %p for context %p.", this, ctx);
+#endif
+ }
+
+ ~QGLGlyphTexture() {
+ const QGLContext *ctx = QGLContext::currentContext();
+#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
+ qDebug("~QGLGlyphTexture() %p for context %p.", this, ctx);
+#endif
+ // At this point, the context group is made current, so it's safe to
+ // release resources without a makeCurrent() call
+ if (ctx) {
+ if (!ctx->d_ptr->workaround_brokenFBOReadBack)
+ glDeleteFramebuffers(1, &m_fbo);
+ if (m_width || m_height)
+ glDeleteTextures(1, &m_texture);
+ }
+ }
+
+ GLuint m_texture;
+ GLuint m_fbo;
+ int m_width;
+ int m_height;
+};
+
+class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache, public QGLContextGroupResourceBase
{
- Q_OBJECT
public:
- QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix);
+ QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix);
~QGLTextureGlyphCache();
virtual void createTextureData(int width, int height);
virtual void resizeTextureData(int width, int height);
- virtual void fillTexture(const Coord &c, glyph_t glyph);
+ virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition);
virtual int glyphPadding() const;
virtual int maxTextureWidth() const;
virtual int maxTextureHeight() const;
- inline GLuint texture() const { return m_texture; }
+ inline GLuint texture() const {
+ QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this);
+ QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx);
+ return glyphTexture ? glyphTexture->m_texture : 0;
+ }
- inline int width() const { return m_width; }
- inline int height() const { return m_height; }
+ inline int width() const {
+ QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this);
+ QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx);
+ return glyphTexture ? glyphTexture->m_width : 0;
+ }
+ inline int height() const {
+ QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this);
+ QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx);
+ return glyphTexture ? glyphTexture->m_height : 0;
+ }
inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; }
+ void setContext(const QGLContext *context);
+ inline const QGLContext *context() const { return ctx; }
+
inline int serialNumber() const { return m_serialNumber; }
enum FilterMode {
@@ -92,56 +142,21 @@ public:
FilterMode filterMode() const { return m_filterMode; }
void setFilterMode(FilterMode m) { m_filterMode = m; }
- void setContext(QGLContext *context);
- QGLContext *context() const { return ctx; }
-
-public Q_SLOTS:
- void contextDestroyed(const QGLContext *context) {
- if (context == ctx) {
- const QGLContext *nextCtx = qt_gl_transfer_context(ctx);
- if (!nextCtx) {
- // the context may not be current, so we cannot directly
- // destroy the fbo and texture here, but since the context
- // is about to be destroyed, the GL server will do the
- // clean up for us anyway. We reset everything, so that the
- // glyph cache object can be reused later by setting a new
- // context on it.
- m_fbo = 0;
- m_texture = 0;
- ctx = 0;
- m_width = 0;
- m_height = 0;
- m_w = 0;
- m_h = 0;
- m_cx = 0;
- m_cy = 0;
- m_currentRowHeight = 0;
- coords.clear();
- } else {
- // since the context holding the texture is shared, and
- // about to be destroyed, we have to transfer ownership
- // of the texture to one of the share contexts
- ctx = const_cast<QGLContext *>(nextCtx);
- }
- }
- }
-
void clear();
+ void freeResource(void *) { ctx = 0; }
+
private:
- QGLContext *ctx;
+ QGLContextGroupResource<QGLGlyphTexture> m_textureResource;
+ const QGLContext *ctx;
QGL2PaintEngineExPrivate *pex;
+ QGLShaderProgram *m_blitProgram;
+ FilterMode m_filterMode;
- GLuint m_texture;
- GLuint m_fbo;
-
- int m_width;
- int m_height;
-
- QGLShaderProgram *m_program;
+ GLfloat m_vertexCoordinateArray[8];
+ GLfloat m_textureCoordinateArray[8];
- FilterMode m_filterMode;
int m_serialNumber;
};
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 6d79584..5774bef 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -7,11 +7,11 @@ win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x63000000
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
include(../qbase.pri)
-!win32:!embedded:!mac:!symbian:CONFIG += x11
+!win32:!embedded:!mac:!symbian:!qpa:CONFIG += x11
contains(QT_CONFIG, opengl):CONFIG += opengl
contains(QT_CONFIG, opengles1):CONFIG += opengles1
contains(QT_CONFIG, opengles2):CONFIG += opengles2
@@ -20,6 +20,7 @@ contains(QT_CONFIG, egl):CONFIG += egl
HEADERS += qgl.h \
qgl_p.h \
qglcolormap.h \
+ qglfunctions.h \
qglpixelbuffer.h \
qglpixelbuffer_p.h \
qglframebufferobject.h \
@@ -29,8 +30,9 @@ HEADERS += qgl.h \
qglbuffer.h \
-SOURCES += qgl.cpp \
+SOURCES += qgl.cpp \
qglcolormap.cpp \
+ qglfunctions.cpp \
qglpixelbuffer.cpp \
qglframebufferobject.cpp \
qglextensions.cpp \
@@ -58,7 +60,9 @@ SOURCES += qgl.cpp \
gl2paintengineex/qglcustomshaderstage_p.h \
gl2paintengineex/qtriangulatingstroker_p.h \
gl2paintengineex/qtriangulator_p.h \
- gl2paintengineex/qtextureglyphcache_gl_p.h
+ gl2paintengineex/qtextureglyphcache_gl_p.h \
+ gl2paintengineex/qglshadercache_p.h \
+ gl2paintengineex/qglshadercache_meego_p.h
SOURCES += qglshaderprogram.cpp \
qglpixmapfilter.cpp \
@@ -77,6 +81,11 @@ SOURCES += qgl.cpp \
}
+qpa {
+ SOURCES += qgl_qpa.cpp \
+ qglpixelbuffer_stub.cpp
+}
+
x11 {
contains(QT_CONFIG, egl) {
SOURCES += qgl_x11egl.cpp \
@@ -159,6 +168,13 @@ symbian {
HEADERS += qgl_egl_p.h \
qgltexturepool_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/opengl.pro.user.2.1pre1 b/src/opengl/opengl.pro.user.2.1pre1
new file mode 100644
index 0000000..0c38724
--- /dev/null
+++ b/src/opengl/opengl.pro.user.2.1pre1
@@ -0,0 +1,83 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value key="EditorConfiguration.Codec" type="QByteArray">UTF-8</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList">
+ <value type="QString">QMAKE_ABSOLUTE_SOURCE_PATH=/home/jlind/dev/qt/lighthouse-master/src/opengl</value>
+ </valuelist>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">-j9</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/jlind/builds/master-lighthouse/src/opengl</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">23</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">1</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">headers</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">../../../../../builds/master-lighthouse/include/QtOpenGL/headers.pri</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">4</value>
+ </data>
+</qtcreator>
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index b755153..684116c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -80,6 +80,10 @@
#include <private/qglwindowsurface_qws_p.h>
#endif
+#ifdef Q_WS_QPA
+#include <QtGui/QPlatformGLContext>
+#endif
+
#include <qglpixelbuffer.h>
#include <qglframebufferobject.h>
@@ -93,14 +97,18 @@
#include "qlibrary.h"
#include <qmutex.h>
+#if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL)
+#include <EGL/egl.h>
+#endif
#ifdef QGL_USE_TEXTURE_POOL
#include <private/qgltexturepool_p.h>
#endif
+// #define QT_GL_CONTEXT_RESOURCE_DEBUG
QT_BEGIN_NAMESPACE
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs;
#endif
@@ -109,10 +117,16 @@ extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
#endif
struct QGLThreadContext {
+ ~QGLThreadContext() {
+ if (context)
+ context->doneCurrent();
+ }
QGLContext *context;
};
+#ifndef Q_WS_QPA
static QThreadStorage<QGLThreadContext *> qgl_context_storage;
+#endif
Q_GLOBAL_STATIC(QGLFormat, qgl_default_format)
@@ -1409,6 +1423,10 @@ QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags()
}
}
+#ifdef Q_WS_QPA
+ hasOpenGL(); // ### I have no idea why this is needed here, but it makes things work for testlite
+#endif
+
QString versionString(QLatin1String(reinterpret_cast<const char*>(glGetString(GL_VERSION))));
OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString);
if (currentCtx) {
@@ -1680,6 +1698,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
#if defined(Q_WS_WIN)
dc = 0;
win = 0;
+ threadId = 0;
pixelFormatId = 0;
cmap = 0;
hbitmap = 0;
@@ -1691,7 +1710,10 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
# endif
vi = 0;
#endif
-#ifndef QT_NO_EGL
+#if defined(Q_WS_QPA)
+ platformContext = 0;
+#endif
+#if !defined(QT_NO_EGL)
ownsEglContext = false;
eglContext = 0;
eglSurface = EGL_NO_SURFACE;
@@ -1716,6 +1738,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
workaround_brokenTextureFromPixmap = false;
workaround_brokenTextureFromPixmap_init = false;
+ workaround_brokenAlphaTexSubImage = false;
+ workaround_brokenAlphaTexSubImage_init = false;
+
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
vertexAttributeArraysEnabledState[i] = false;
}
@@ -1772,7 +1797,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();
@@ -1835,18 +1860,6 @@ QGLTextureCache::~QGLTextureCache()
void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost)
{
QWriteLocker locker(&m_lock);
- if (m_cache.totalCost() + cost > m_cache.maxCost()) {
- // the cache is full - make an attempt to remove something
- const QList<QGLTextureCacheKey> keys = m_cache.keys();
- int i = 0;
- while (i < m_cache.count()
- && (m_cache.totalCost() + cost > m_cache.maxCost())) {
- QGLTexture *tex = m_cache.object(keys.at(i));
- if (tex->context == ctx)
- m_cache.remove(keys.at(i));
- ++i;
- }
- }
const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)};
m_cache.insert(cacheKey, texture, cost);
}
@@ -2090,6 +2103,9 @@ QGLContext::~QGLContext()
// remove any textures cached in this context
QGLTextureCache::instance()->removeContextTextures(this);
+ // clean up resources specific to this context
+ d_ptr->cleanup();
+ // clean up resources belonging to this context's group
d_ptr->group->cleanupResources(this);
QGLSignalProxy::instance()->emitAboutToDestroyContext(this);
@@ -2098,6 +2114,10 @@ QGLContext::~QGLContext()
void QGLContextPrivate::cleanup()
{
+ QHash<QGLContextResourceBase *, void *>::ConstIterator it;
+ for (it = m_resources.begin(); it != m_resources.end(); ++it)
+ it.key()->freeResource(it.value());
+ m_resources.clear();
}
#define ctx q_ptr
@@ -2161,20 +2181,10 @@ void QGLContextPrivate::swapRegion(const QRegion &)
GLuint QGLContext::bindTexture(const QString &fileName)
{
- Q_D(QGLContext);
- QGLDDSCache *dds_cache = &(d->group->m_dds_cache);
- QGLDDSCache::const_iterator it = dds_cache->constFind(fileName);
- if (it != dds_cache->constEnd()) {
- glBindTexture(GL_TEXTURE_2D, it.value());
- return it.value();
- }
-
QGLTexture texture(this);
QSize size = texture.bindCompressedTexture(fileName);
if (!size.isValid())
return 0;
-
- dds_cache->insert(fileName, texture.id);
return texture.id;
}
@@ -2293,7 +2303,7 @@ static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum textu
}
}
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
QGLExtensionFuncs& QGLContextPrivate::extensionFuncs(const QGLContext *)
{
return qt_extensionFuncs;
@@ -2623,7 +2633,8 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
const QX11Info *xinfo = qt_x11Info(paintDevice);
if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType
&& xinfo && xinfo->screen() == pixmap.x11Info().screen()
- && target == GL_TEXTURE_2D)
+ && target == GL_TEXTURE_2D
+ && QApplication::instance()->thread() == QThread::currentThread())
{
if (!workaround_brokenTextureFromPixmap_init) {
workaround_brokenTextureFromPixmap_init = true;
@@ -2844,24 +2855,8 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, Q
*/
void QGLContext::deleteTexture(GLuint id)
{
- Q_D(QGLContext);
-
if (QGLTextureCache::instance()->remove(this, id))
return;
-
- // check the DDS cache if the texture wasn't found in the pixmap/image
- // cache
- QGLDDSCache *dds_cache = &(d->group->m_dds_cache);
- QList<QString> ddsKeys = dds_cache->keys();
- for (int i = 0; i < ddsKeys.size(); ++i) {
- GLuint texture = dds_cache->value(ddsKeys.at(i));
- if (id == texture) {
- dds_cache->remove(ddsKeys.at(i));
- break;
- }
- }
-
- // Finally, actually delete the texture ID
glDeleteTextures(1, &id);
}
@@ -3321,16 +3316,23 @@ bool QGLContext::areSharing(const QGLContext *context1, const QGLContext *contex
bool QGLContext::create(const QGLContext* shareContext)
{
Q_D(QGLContext);
+#ifdef Q_WS_QPA
+ if (!d->paintDevice && !d->platformContext)
+#else
if (!d->paintDevice)
+#endif
return false;
+
reset();
d->valid = chooseContext(shareContext);
- if (d->valid && d->paintDevice->devType() == QInternal::Widget) {
+ if (d->valid && d->paintDevice && d->paintDevice->devType() == QInternal::Widget) {
QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice));
wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer();
}
+#ifndef Q_WS_QPA //We do this in choose context->setupSharing()
if (d->sharing) // ok, we managed to share
QGLContextGroup::addShare(this, shareContext);
+#endif
return d->valid;
}
@@ -3404,14 +3406,24 @@ void QGLContext::setInitialized(bool on)
const QGLContext* QGLContext::currentContext()
{
+#ifdef Q_WS_QPA
+ if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) {
+ return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(threadContext));
+ }
+ return 0;
+#else
QGLThreadContext *threadContext = qgl_context_storage.localData();
if (threadContext)
return threadContext->context;
return 0;
+#endif //Q_WS_QPA
}
void QGLContextPrivate::setCurrentContext(QGLContext *context)
{
+#ifdef Q_WS_QPA
+ Q_UNUSED(context);
+#else
QGLThreadContext *threadContext = qgl_context_storage.localData();
if (!threadContext) {
if (!QThread::currentThread()) {
@@ -3424,6 +3436,7 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context)
}
threadContext->context = context;
QGLContext::currentCtx = context; // XXX: backwards-compat, not thread-safe
+#endif
}
/*!
@@ -3658,12 +3671,90 @@ void QGLContextPrivate::setCurrentContext(QGLContext *context)
\section1 Threading
- It is possible to render into a QGLWidget from another thread, but it
- requires that all access to the GL context is safe guarded. The Qt GUI
- thread will try to use the context in resizeEvent and paintEvent, so in
- order for threaded rendering using a GL widget to work, these functions
- need to be intercepted in the GUI thread and handled accordingly in the
- application.
+ As of Qt version 4.8, support for doing threaded GL rendering has
+ been improved. There are three scenarios that we currently support:
+ \list
+ \o 1. Buffer swapping in a thread.
+
+ Swapping buffers in a double buffered context may be a
+ synchronous, locking call that may be a costly operation in some
+ GL implementations. Especially so on embedded devices. It's not
+ optimal to have the CPU idling while the GPU is doing a buffer
+ swap. In those cases it is possible to do the rendering in the
+ main thread and do the actual buffer swap in a separate
+ thread. This can be done with the following steps:
+
+ 1. Call doneCurrent() in the main thread when the rendering is
+ finished.
+
+ 2. Notify the swapping thread that it can grab the context.
+
+ 3. Make the rendering context current in the swapping thread with
+ makeCurrent() and then call swapBuffers().
+
+ 4. Call doneCurrent() in the swapping thread and notify the main
+ thread that swapping is done.
+
+ Doing this will free up the main thread so that it can continue
+ with, for example, handling UI events or network requests. Even if
+ there is a context swap involved, it may be preferable compared to
+ having the main thread wait while the GPU finishes the swap
+ operation. Note that this is highly implementation dependent.
+
+ \o 2. Texture uploading in a thread.
+
+ Doing texture uploads in a thread may be very useful for
+ applications handling large amounts of images that needs to be
+ displayed, like for instance a photo gallery application. This is
+ supported in Qt through the existing bindTexture() API. A simple
+ way of doing this is to create two sharing QGLWidgets. One is made
+ current in the main GUI thread, while the other is made current in
+ the texture upload thread. The widget in the uploading thread is
+ never shown, it is only used for sharing textures with the main
+ thread. For each texture that is bound via bindTexture(), notify
+ the main thread so that it can start using the texture.
+
+ \o 3. Using QPainter to draw into a QGLWidget in a thread.
+
+ In Qt 4.8, it is possible to draw into a QGLWidget using a
+ QPainter in a separate thread. Note that this is also possible for
+ QGLPixelBuffers and QGLFramebufferObjects. Since this is only
+ supported in the GL 2 paint engine, OpenGL 2.0 or OpenGL ES 2.0 is
+ required.
+
+ QGLWidgets can only be created in the main GUI thread. This means
+ a call to doneCurrent() is necessary to release the GL context
+ from the main thread, before the widget can be drawn into by
+ another thread. Also, the main GUI thread will dispatch resize and
+ paint events to a QGLWidget when the widget is resized, or parts
+ of it becomes exposed or needs redrawing. It is therefore
+ necessary to handle those events because the default
+ implementations inside QGLWidget will try to make the QGLWidget's
+ context current, which again will interfere with any threads
+ rendering into the widget. Reimplement QGLWidget::paintEvent() and
+ QGLWidget::resizeEvent() to notify the rendering thread that a
+ resize or update is necessary, and be careful not to call the base
+ class implementation. If you are rendering an animation, it might
+ not be necessary to handle the paint event at all since the
+ rendering thread is doing regular updates. Then it would be enough
+ to reimplement QGLWidget::paintEvent() to do nothing.
+
+ \endlist
+
+ As a general rule when doing threaded rendering: be aware that
+ binding and releasing contexts in different threads have to be
+ synchronized by the user. A GL rendering context can only be
+ current in one thread at any time. If you try to open a QPainter
+ on a QGLWidget and the widget's rendering context is current in
+ another thread, it will fail.
+
+ Note that under X11 it is necessary to set the
+ Qt::AA_X11InitThreads application attribute to make the X11
+ library and GLX calls thread safe, otherwise the above scenarios
+ will fail.
+
+ In addition to this, rendering using raw GL calls in a separate
+ thread is supported.
\e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other
countries.}
@@ -4160,7 +4251,7 @@ void QGLWidget::resizeOverlayGL(int, int)
/*! \fn bool QGLWidget::event(QEvent *e)
\reimp
*/
-#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS)
+#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
bool QGLWidget::event(QEvent *e)
{
Q_D(QGLWidget);
@@ -4179,13 +4270,7 @@ bool QGLWidget::event(QEvent *e)
}
#if defined(Q_WS_X11)
- // prevents X errors on some systems, where we get a flush to a
- // hidden widget
- if (e->type() == QEvent::Hide) {
- makeCurrent();
- glFinish();
- doneCurrent();
- } else if (e->type() == QEvent::ParentChange) {
+ if (e->type() == QEvent::ParentChange) {
// if we've reparented a window that has the current context
// bound, we need to rebind that context to the new window id
if (d->glcx == QGLContext::currentContext())
@@ -5187,24 +5272,24 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM
#endif
#ifndef QT_OPENGL_ES_1
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_gl_2_engine)
#endif
#ifndef QT_OPENGL_ES_2
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QOpenGLPaintEngine>, qt_gl_engine)
#endif
Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine()
{
#if defined(QT_OPENGL_ES_1)
- return qt_gl_engine();
+ return qt_gl_engine()->engine();
#elif defined(QT_OPENGL_ES_2)
- return qt_gl_2_engine();
+ return qt_gl_2_engine()->engine();
#else
if (qt_gl_preferGL2Engine())
- return qt_gl_2_engine();
+ return qt_gl_2_engine()->engine();
else
- return qt_gl_engine();
+ return qt_gl_engine()->engine();
#endif
}
@@ -5412,7 +5497,7 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi
glcx = new QGLContext(QGLFormat::defaultFormat(), q);
}
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA)
Q_GLOBAL_STATIC(QString, qt_gl_lib_name)
Q_OPENGL_EXPORT void qt_set_gl_library_name(const QString& name)
@@ -5477,13 +5562,23 @@ void QGLContextGroup::removeShare(const QGLContext *context) {
group->m_shares.clear();
}
-QGLContextResource::QGLContextResource(FreeFunc f)
- : free(f), active(0)
+QGLContextGroupResourceBase::QGLContextGroupResourceBase()
+ : active(0)
{
+#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
+ qDebug("Creating context group resource object %p.", this);
+#endif
}
-QGLContextResource::~QGLContextResource()
+QGLContextGroupResourceBase::~QGLContextGroupResourceBase()
{
+#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
+ qDebug("Deleting context group resource %p. Group size: %d.", this, m_groups.size());
+#endif
+ for (int i = 0; i < m_groups.size(); ++i) {
+ m_groups.at(i)->m_resources.remove(this);
+ active.deref();
+ }
#ifndef QT_NO_DEBUG
if (active != 0) {
qWarning("QtOpenGL: Resources are still available at program shutdown.\n"
@@ -5493,37 +5588,62 @@ QGLContextResource::~QGLContextResource()
#endif
}
-void QGLContextResource::insert(const QGLContext *key, void *value)
+void QGLContextGroupResourceBase::insert(const QGLContext *context, void *value)
{
- QGLContextGroup *group = QGLContextPrivate::contextGroup(key);
+#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
+ qDebug("Inserting context group resource %p for context %p, managed by %p.", value, context, this);
+#endif
+ QGLContextGroup *group = QGLContextPrivate::contextGroup(context);
Q_ASSERT(!group->m_resources.contains(this));
group->m_resources.insert(this, value);
+ m_groups.append(group);
active.ref();
}
-void *QGLContextResource::value(const QGLContext *key)
+void *QGLContextGroupResourceBase::value(const QGLContext *context)
{
- QGLContextGroup *group = QGLContextPrivate::contextGroup(key);
+ QGLContextGroup *group = QGLContextPrivate::contextGroup(context);
return group->m_resources.value(this, 0);
}
-void QGLContextResource::cleanup(const QGLContext *ctx, void *value)
+void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx)
+{
+ void *resource = value(ctx);
+
+ if (resource != 0) {
+ QGLShareContextScope scope(ctx);
+ freeResource(resource);
+
+ QGLContextGroup *group = QGLContextPrivate::contextGroup(ctx);
+ group->m_resources.remove(this);
+ m_groups.removeOne(group);
+ active.deref();
+ }
+}
+
+void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value)
{
+#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG
+ qDebug("Cleaning up context group resource %p, for context %p in thread %p.", this, ctx, QThread::currentThread());
+#endif
QGLShareContextScope scope(ctx);
- free(value);
+ freeResource(value);
active.deref();
+
+ QGLContextGroup *group = QGLContextPrivate::contextGroup(ctx);
+ m_groups.removeOne(group);
}
-void QGLContextGroup::cleanupResources(const QGLContext *ctx)
+void QGLContextGroup::cleanupResources(const QGLContext *context)
{
// If there are still shares, then no cleanup to be done yet.
if (m_shares.size() > 1)
return;
// Iterate over all resources and free each in turn.
- QHash<QGLContextResource *, void *>::ConstIterator it;
+ QHash<QGLContextGroupResourceBase *, void *>::ConstIterator it;
for (it = m_resources.begin(); it != m_resources.end(); ++it)
- it.key()->cleanup(ctx, it.value());
+ it.key()->cleanup(context, it.value());
}
QGLSharedResourceGuard::~QGLSharedResourceGuard()
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 7d72c8a..ff73d88 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -48,6 +48,10 @@
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
+#ifdef Q_WS_QPA
+#include <QtGui/QPlatformWindowFormat>
+#endif
+
QT_BEGIN_HEADER
#if defined(Q_WS_WIN)
@@ -56,7 +60,6 @@ QT_BEGIN_HEADER
#if defined(Q_WS_MAC)
# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
#elif defined(QT_OPENGL_ES_1)
# include <GLES/gl.h>
#ifndef GL_DOUBLE
@@ -75,9 +78,6 @@ typedef GLfloat GLdouble;
#endif
#else
# include <GL/gl.h>
-# ifndef QT_LINUXBASE
-# include <GL/glu.h>
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -274,6 +274,10 @@ public:
static OpenGLVersionFlags openGLVersionFlags();
+#if defined(Q_WS_QPA)
+ static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format);
+ static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format);
+#endif
private:
QGLFormatPrivate *d;
@@ -380,6 +384,9 @@ public:
static const QGLContext* currentContext();
+#ifdef Q_WS_QPA
+ static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext);
+#endif
protected:
virtual bool chooseContext(const QGLContext* shareContext = 0);
@@ -409,6 +416,10 @@ protected:
static QGLContext* currentCtx;
private:
+#ifdef Q_WS_QPA
+ QGLContext(QPlatformGLContext *platformContext);
+#endif
+
QScopedPointer<QGLContextPrivate> d_ptr;
friend class QGLPixelBuffer;
@@ -425,6 +436,7 @@ private:
friend class QGLPixmapData;
friend class QGLPixmapFilterBase;
friend class QGLTextureGlyphCache;
+ friend struct QGLGlyphTexture;
friend class QGLContextGroup;
friend class QGLSharedResourceGuard;
friend class QGLPixmapBlurFilter;
@@ -445,6 +457,7 @@ private:
friend class QGLWidgetGLPaintDevice;
friend class QX11GLPixmapData;
friend class QX11GLSharedContexts;
+ friend class QGLContextResourceBase;
private:
Q_DISABLE_COPY(QGLContext)
};
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 68abf01..b2261a2 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -68,6 +68,10 @@
#include <QtGui/private/qegl_p.h>
#endif
+#if defined(Q_WS_QPA)
+#include <QtGui/QPlatformGLContext>
+#endif
+
QT_BEGIN_NAMESPACE
class QGLContext;
@@ -161,7 +165,7 @@ class QGLWidgetPrivate : public QWidgetPrivate
public:
QGLWidgetPrivate() : QWidgetPrivate()
, disable_clear_on_painter_begin(false)
-#ifdef Q_WS_QWS
+#if defined(Q_WS_QWS)
, wsurf(0)
#endif
#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
@@ -217,11 +221,9 @@ public:
#endif
};
-class QGLContextResource;
+class QGLContextGroupResourceBase;
class QGLSharedResourceGuard;
-typedef QHash<QString, GLuint> QGLDDSCache;
-
// QGLContextPrivate has the responsibility of creating context groups.
// QGLContextPrivate maintains the reference counter and destroys
// context groups when needed.
@@ -240,22 +242,22 @@ public:
static void addShare(const QGLContext *context, const QGLContext *share);
static void removeShare(const QGLContext *context);
+
private:
QGLContextGroup(const QGLContext *context);
QGLExtensionFuncs m_extensionFuncs;
const QGLContext *m_context; // context group's representative
QList<const QGLContext *> m_shares;
- QHash<QGLContextResource *, void *> m_resources;
+ QHash<QGLContextGroupResourceBase *, void *> m_resources;
QGLSharedResourceGuard *m_guards; // double-linked list of active guards.
QAtomicInt m_refs;
- QGLDDSCache m_dds_cache;
void cleanupResources(const QGLContext *ctx);
friend class QGLContext;
friend class QGLContextPrivate;
- friend class QGLContextResource;
+ friend class QGLContextGroupResourceBase;
};
// Get the context that resources for "ctx" will transfer to once
@@ -323,6 +325,8 @@ class QGLTextureDestroyer;
// all the GL2 engine uses:
#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3
+class QGLContextResourceBase;
+
class QGLContextPrivate
{
Q_DECLARE_PUBLIC(QGLContext)
@@ -358,13 +362,18 @@ public:
QGLCmap* cmap;
HBITMAP hbitmap;
HDC hbitmap_hdc;
+ Qt::HANDLE threadId;
#endif
#ifndef QT_NO_EGL
- uint ownsEglContext : 1;
QEglContext *eglContext;
EGLSurface eglSurface;
void destroyEglSurfaceForDevice();
EGLSurface eglSurfaceForDevice() const;
+#endif
+
+#if defined(Q_WS_QPA)
+ QPlatformGLContext *platformContext;
+ void setupSharing();
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
void* cx;
#endif
@@ -407,6 +416,13 @@ public:
uint workaround_brokenTextureFromPixmap : 1;
uint workaround_brokenTextureFromPixmap_init : 1;
+ uint workaround_brokenAlphaTexSubImage : 1;
+ uint workaround_brokenAlphaTexSubImage_init : 1;
+
+#ifndef QT_NO_EGL
+ uint ownsEglContext : 1;
+#endif
+
QPaintDevice *paintDevice;
QColor transpColor;
QGLContext *q_ptr;
@@ -419,6 +435,7 @@ public:
GLuint current_fbo;
GLuint default_fbo;
QPaintEngine *active_engine;
+ QHash<QGLContextResourceBase *, void *> m_resources;
QGLTextureDestroyer *texture_destroyer;
bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT];
@@ -429,8 +446,8 @@ public:
static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); }
#endif
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)
- static QGLExtensionFuncs qt_extensionFuncs;
+#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_SYMBIAN)
+ static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs;
static Q_OPENGL_EXPORT QGLExtensionFuncs& extensionFuncs(const QGLContext *);
#endif
@@ -497,6 +514,7 @@ Q_SIGNALS:
private slots:
void freeTexture_slot(QGLContext *context, QPixmapData *boundPixmap, GLuint id) {
+ Q_UNUSED(boundPixmap);
#if defined(Q_WS_X11)
if (boundPixmap) {
QGLContext *oldContext = const_cast<QGLContext *>(QGLContext::currentContext());
@@ -659,24 +677,131 @@ inline GLenum qt_gl_preferredTextureTarget()
#endif
}
-// One resource per group of shared contexts.
-class Q_OPENGL_EXPORT QGLContextResource
+/*
+ Base for resources that are shared in a context group.
+*/
+class Q_OPENGL_EXPORT QGLContextGroupResourceBase
{
public:
- typedef void (*FreeFunc)(void *);
- QGLContextResource(FreeFunc f);
- ~QGLContextResource();
- // Set resource 'value' for 'key' and all its shared contexts.
- void insert(const QGLContext *key, void *value);
- // Return resource for 'key' or a shared context.
- void *value(const QGLContext *key);
- // Cleanup 'value' in response to a context group being destroyed.
- void cleanup(const QGLContext *ctx, void *value);
+ QGLContextGroupResourceBase();
+ virtual ~QGLContextGroupResourceBase();
+ void insert(const QGLContext *context, void *value);
+ void *value(const QGLContext *context);
+ void cleanup(const QGLContext *context);
+ void cleanup(const QGLContext *context, void *value);
+ virtual void freeResource(void *value) = 0;
+
+protected:
+ QList<QGLContextGroup *> m_groups;
+
private:
- FreeFunc free;
QAtomicInt active;
};
+/*
+ The QGLContextGroupResource template is used to manage a resource
+ for a group of sharing GL contexts. When the last context in the
+ group is destroyed, or when the QGLContextGroupResource object
+ itself is destroyed (implies potential context switches), the
+ resource will be freed.
+
+ The class used as the template class type needs to have a
+ constructor with the following signature:
+ T(const QGLContext *);
+*/
+template <class T>
+class QGLContextGroupResource : public QGLContextGroupResourceBase
+{
+public:
+ ~QGLContextGroupResource() {
+ for (int i = 0; i < m_groups.size(); ++i) {
+ const QGLContext *context = m_groups.at(i)->context();
+ T *resource = reinterpret_cast<T *>(QGLContextGroupResourceBase::value(context));
+ if (resource) {
+ QGLShareContextScope scope(context);
+ delete resource;
+ }
+ }
+ }
+
+ T *value(const QGLContext *context) {
+ T *resource = reinterpret_cast<T *>(QGLContextGroupResourceBase::value(context));
+ if (!resource) {
+ resource = new T(context);
+ insert(context, resource);
+ }
+ return resource;
+ }
+
+protected:
+ void freeResource(void *resource) {
+ delete reinterpret_cast<T *>(resource);
+ }
+};
+
+/*
+ Base for resources that are context specific.
+*/
+class Q_OPENGL_EXPORT QGLContextResourceBase
+{
+public:
+ virtual ~QGLContextResourceBase() {
+ for (int i = 0; i < m_contexts.size(); ++i)
+ m_contexts.at(i)->d_ptr->m_resources.remove(this);
+ }
+
+ void insert(const QGLContext *context, void *value) {
+ context->d_ptr->m_resources.insert(this, value);
+ }
+
+ void *value(const QGLContext *context) {
+ return context->d_ptr->m_resources.value(this, 0);
+ }
+ virtual void freeResource(void *value) = 0;
+
+protected:
+ QList<const QGLContext *> m_contexts;
+};
+
+/*
+ The QGLContextResource template is used to manage a resource for a
+ single GL context. Just before the context is destroyed (while it's
+ still the current context), or when the QGLContextResource object
+ itself is destroyed (implies potential context switches), the
+ resource will be freed. The class used as the template class type
+ needs to have a constructor with the following signature: T(const
+ QGLContext *);
+*/
+template <class T>
+class QGLContextResource : public QGLContextResourceBase
+{
+public:
+ ~QGLContextResource() {
+ for (int i = 0; i < m_contexts.size(); ++i) {
+ const QGLContext *context = m_contexts.at(i);
+ T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context));
+ if (resource) {
+ QGLShareContextScope scope(context);
+ delete resource;
+ }
+ }
+ }
+
+ T *value(const QGLContext *context) {
+ T *resource = reinterpret_cast<T *>(QGLContextResourceBase::value(context));
+ if (!resource) {
+ resource = new T(context);
+ insert(context, resource);
+ }
+ return resource;
+ }
+
+protected:
+ void freeResource(void *resource) {
+ delete reinterpret_cast<T *>(resource);
+ }
+};
+
// Put a guard around a GL object identifier and its context.
// When the context goes away, a shared context will be used
// in its place. If there are no more shared contexts, then
@@ -766,6 +891,24 @@ private:
int gl_extensions_length;
};
+
+// this is a class that wraps a QThreadStorage object for storing
+// thread local instances of the GL 1 and GL 2 paint engines
+
+template <class T>
+class QGLEngineThreadStorage
+{
+public:
+ QPaintEngine *engine() {
+ QPaintEngine *&localEngine = storage.localData();
+ if (!localEngine)
+ localEngine = new T;
+ return localEngine;
+ }
+
+private:
+ QThreadStorage<QPaintEngine *> storage;
+};
QT_END_NAMESPACE
#endif // QGL_P_H
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
new file mode 100644
index 0000000..4bac1fb
--- /dev/null
+++ b/src/opengl/qgl_qpa.cpp
@@ -0,0 +1,393 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 <QApplication>
+#include <QtGui/private/qapplication_p.h>
+#include <QPixmap>
+#include <QDebug>
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/QPlatformWindow>
+
+#include "qgl.h"
+#include "qgl_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
+{
+ QGLFormat retFormat;
+ retFormat.setAccum(format.accum());
+ if (format.accumBufferSize() >= 0)
+ retFormat.setAccumBufferSize(format.accumBufferSize());
+ retFormat.setAlpha(format.alpha());
+ if (format.alphaBufferSize() >= 0)
+ retFormat.setAlphaBufferSize(format.alphaBufferSize());
+ if (format.blueBufferSize() >= 0)
+ retFormat.setBlueBufferSize(format.blueBufferSize());
+ retFormat.setDepth(format.depth());
+ if (format.depthBufferSize() >= 0)
+ retFormat.setDepthBufferSize(format.depthBufferSize());
+ retFormat.setDirectRendering(format.directRendering());
+ retFormat.setDoubleBuffer(format.doubleBuffer());
+ if (format.greenBufferSize() >= 0)
+ retFormat.setGreenBufferSize(format.greenBufferSize());
+ if (format.redBufferSize() >= 0)
+ retFormat.setRedBufferSize(format.redBufferSize());
+ retFormat.setRgba(format.rgba());
+ retFormat.setSampleBuffers(format.sampleBuffers());
+ retFormat.setSamples(format.sampleBuffers());
+ retFormat.setStencil(format.stencil());
+ if (format.stencilBufferSize() >= 0)
+ retFormat.setStencilBufferSize(format.stencilBufferSize());
+ retFormat.setStereo(format.stereo());
+ retFormat.setSwapInterval(format.swapInterval());
+ return retFormat;
+}
+
+QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
+{
+ QPlatformWindowFormat retFormat;
+ retFormat.setAccum(format.accum());
+ if (format.accumBufferSize() >= 0)
+ retFormat.setAccumBufferSize(format.accumBufferSize());
+ retFormat.setAlpha(format.alpha());
+ if (format.alphaBufferSize() >= 0)
+ retFormat.setAlphaBufferSize(format.alphaBufferSize());
+ if (format.blueBufferSize() >= 0)
+ retFormat.setBlueBufferSize(format.blueBufferSize());
+ retFormat.setDepth(format.depth());
+ if (format.depthBufferSize() >= 0)
+ retFormat.setDepthBufferSize(format.depthBufferSize());
+ retFormat.setDirectRendering(format.directRendering());
+ retFormat.setDoubleBuffer(format.doubleBuffer());
+ if (format.greenBufferSize() >= 0)
+ retFormat.setGreenBufferSize(format.greenBufferSize());
+ if (format.redBufferSize() >= 0)
+ retFormat.setRedBufferSize(format.redBufferSize());
+ retFormat.setRgba(format.rgba());
+ retFormat.setSampleBuffers(format.sampleBuffers());
+ if (format.samples() >= 0)
+ retFormat.setSamples(format.samples());
+ retFormat.setStencil(format.stencil());
+ if (format.stencilBufferSize() >= 0)
+ retFormat.setStencilBufferSize(format.stencilBufferSize());
+ retFormat.setStereo(format.stereo());
+ retFormat.setSwapInterval(format.swapInterval());
+ return retFormat;
+}
+
+void QGLContextPrivate::setupSharing() {
+ Q_Q(QGLContext);
+ QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
+ if (sharedPlatformGLContext) {
+ QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ sharing = true;
+ QGLContextGroup::addShare(q,actualSharedContext);
+ }
+}
+
+bool QGLFormat::hasOpenGL()
+{
+ return QApplicationPrivate::platformIntegration()->hasOpenGL();
+}
+
+void qDeleteQGLContext(void *handle)
+{
+ QGLContext *context = static_cast<QGLContext *>(handle);
+ delete context;
+}
+
+bool QGLContext::chooseContext(const QGLContext* shareContext)
+{
+ Q_D(QGLContext);
+ if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) {
+ d->valid = false;
+ }else {
+ QWidget *widget = static_cast<QWidget *>(d->paintDevice);
+ if (!widget->platformWindow()){
+ QGLFormat glformat = format();
+ QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
+ if (shareContext) {
+ winFormat.setSharedContext(shareContext->d_func()->platformContext);
+ }
+ winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
+ winFormat.setWindowSurface(false);
+ widget->setPlatformWindowFormat(winFormat);
+ widget->winId();//make window
+ }
+ d->platformContext = widget->platformWindow()->glContext();
+ Q_ASSERT(d->platformContext);
+ d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
+ d->valid =(bool) d->platformContext;
+ if (d->valid) {
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ }
+ d->setupSharing();
+ }
+
+
+ return d->valid;
+}
+
+void QGLContext::reset()
+{
+ Q_D(QGLContext);
+ if (!d->valid)
+ return;
+ d->cleanup();
+
+ d->crWin = false;
+ d->sharing = false;
+ d->valid = false;
+ d->transpColor = QColor();
+ d->initDone = false;
+ QGLContextGroup::removeShare(this);
+ if (d->platformContext) {
+ d->platformContext->setQGLContextHandle(0,0);
+ }
+}
+
+void QGLContext::makeCurrent()
+{
+ Q_D(QGLContext);
+ d->platformContext->makeCurrent();
+
+ if (!d->workaroundsCached) {
+ d->workaroundsCached = true;
+ const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+ if (renderer && strstr(renderer, "Mali")) {
+ d->workaround_brokenFBOReadBack = true;
+ }
+ }
+
+}
+
+void QGLContext::doneCurrent()
+{
+ Q_D(QGLContext);
+ d->platformContext->doneCurrent();
+}
+
+void QGLContext::swapBuffers() const
+{
+ Q_D(const QGLContext);
+ d->platformContext->swapBuffers();
+}
+
+void *QGLContext::getProcAddress(const QString &procName) const
+{
+ Q_D(const QGLContext);
+ return d->platformContext->getProcAddress(procName);
+}
+
+void QGLWidget::setContext(QGLContext *context,
+ const QGLContext* shareContext,
+ bool deleteOldContext)
+{
+ Q_D(QGLWidget);
+ if (context == 0) {
+ qWarning("QGLWidget::setContext: Cannot set null context");
+ return;
+ }
+
+ if (context->device() == 0) // a context may refere to more than 1 window.
+ context->setDevice(this); //but its better to point to 1 of them than none of them.
+
+ QGLContext* oldcx = d->glcx;
+ d->glcx = context;
+
+ if (!d->glcx->isValid())
+ d->glcx->create(shareContext ? shareContext : oldcx);
+
+ if (deleteOldContext)
+ delete oldcx;
+}
+
+void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget)
+{
+ initContext(context, shareWidget);
+}
+
+bool QGLFormat::hasOpenGLOverlays()
+{
+ return false;
+}
+
+QColor QGLContext::overlayTransparentColor() const
+{
+ return QColor(); // Invalid color
+}
+
+uint QGLContext::colorIndex(const QColor&) const
+{
+ return 0;
+}
+
+void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase)
+{
+ Q_UNUSED(fnt);
+ Q_UNUSED(listBase);
+}
+
+/*
+ QGLTemporaryContext implementation
+*/
+class QGLTemporaryContextPrivate
+{
+public:
+ QWidget *widget;
+ QPlatformGLContext *context;
+};
+
+QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
+ : d(new QGLTemporaryContextPrivate)
+{
+ d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
+ if (d->context)
+ d->context->doneCurrent();
+ d->widget = new QWidget;
+ d->widget->setGeometry(0,0,3,3);
+ QPlatformWindowFormat format = d->widget->platformWindowFormat();
+ format.setWindowApi(QPlatformWindowFormat::OpenGL);
+ format.setWindowSurface(false);
+ d->widget->setPlatformWindowFormat(format);
+ d->widget->winId();
+
+ d->widget->platformWindow()->glContext()->makeCurrent();
+}
+
+QGLTemporaryContext::~QGLTemporaryContext()
+{
+ d->widget->platformWindow()->glContext()->doneCurrent();
+ if (d->context)
+ d->context->makeCurrent();
+ delete d->widget;
+}
+
+
+bool QGLWidgetPrivate::renderCxPm(QPixmap*)
+{
+ return false;
+}
+
+/*! \internal
+ Free up any allocated colormaps. This fn is only called for
+ top-level widgets.
+*/
+void QGLWidgetPrivate::cleanupColormaps()
+{
+}
+
+void QGLWidget::setMouseTracking(bool enable)
+{
+ Q_UNUSED(enable);
+}
+
+bool QGLWidget::event(QEvent *e)
+{
+ return QWidget::event(e);
+}
+
+void QGLWidget::resizeEvent(QResizeEvent *e)
+{
+ Q_D(QGLWidget);
+
+ QWidget::resizeEvent(e);
+ if (!isValid())
+ return;
+ makeCurrent();
+ if (!d->glcx->initialized())
+ glInit();
+ resizeGL(width(), height());
+}
+
+
+const QGLContext* QGLWidget::overlayContext() const
+{
+ return 0;
+}
+
+void QGLWidget::makeOverlayCurrent()
+{
+}
+
+
+void QGLWidget::updateOverlayGL()
+{
+}
+
+const QGLColormap & QGLWidget::colormap() const
+{
+ Q_D(const QGLWidget);
+ return d->cmap;
+}
+
+void QGLWidget::setColormap(const QGLColormap & c)
+{
+ Q_UNUSED(c);
+}
+
+QGLContext::QGLContext(QPlatformGLContext *platformContext)
+ : d_ptr(new QGLContextPrivate(this))
+{
+ Q_D(QGLContext);
+ d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
+ d->platformContext = platformContext;
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->valid = true;
+ d->setupSharing();
+}
+
+QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
+{
+ if (!platformContext)
+ return 0;
+ if (platformContext->qGLContextHandle()) {
+ return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle());
+ }
+ QGLContext *glContext = new QGLContext(platformContext);
+ //Dont call create on context. This can cause the platformFormat to be set on the widget, which
+ //will cause the platformWindow to be recreated.
+ return glContext;
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp
index dbbdc0e..70016a0 100644
--- a/src/opengl/qgl_win.cpp
+++ b/src/opengl/qgl_win.cpp
@@ -1261,6 +1261,7 @@ void QGLContext::reset()
}
d->dc = 0;
d->win = 0;
+ d->threadId = 0;
d->pixelFormatId = 0;
d->sharing = false;
d->valid = false;
@@ -1283,8 +1284,9 @@ void QGLContext::makeCurrent()
if (d->rc == wglGetCurrentContext() || !d->valid) // already current
return;
- if (d->win) {
+ if (d->win && (!d->dc || d->threadId != QThread::currentThreadId())) {
d->dc = GetDC(d->win);
+ d->threadId = QThread::currentThreadId();
if (!d->dc) {
qwglError("QGLContext::makeCurrent()", "GetDC()");
return;
@@ -1322,6 +1324,7 @@ void QGLContext::doneCurrent()
if (d->win && d->dc) {
ReleaseDC(d->win, d->dc);
d->dc = 0;
+ d->threadId = 0;
}
}
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index cd4d8a2..93f17ae 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -345,7 +345,7 @@ void QGLWidgetPrivate::recreateEglSurface()
// old surface before re-creating a new one. Note: This should not be the case as the
// surface should be deleted before the old window id.
if (glcx->d_func()->eglSurface != EGL_NO_SURFACE && (currentId != eglSurfaceWindowId)) {
- qWarning("EGL surface for deleted window %x was not destroyed", uint(eglSurfaceWindowId));
+ qWarning("EGL surface for deleted window %lx was not destroyed", uint(eglSurfaceWindowId));
glcx->d_func()->destroyEglSurfaceForDevice();
}
diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h
index b521d26..529c7a1 100644
--- a/src/opengl/qglextensions_p.h
+++ b/src/opengl/qglextensions_p.h
@@ -879,10 +879,10 @@ struct QGLExtensionFuncs
#endif
extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx);
-bool qt_resolve_buffer_extensions(QGLContext *ctx);
+bool Q_OPENGL_EXPORT qt_resolve_buffer_extensions(QGLContext *ctx);
bool qt_resolve_version_1_3_functions(QGLContext *ctx);
-bool qt_resolve_version_2_0_functions(QGLContext *ctx);
+bool Q_OPENGL_EXPORT qt_resolve_version_2_0_functions(QGLContext *ctx);
bool qt_resolve_stencil_face_extension(QGLContext *ctx);
bool qt_resolve_frag_program_extensions(QGLContext *ctx);
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 6161d9b..cda1c79 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -202,6 +202,35 @@ int QGLFramebufferObjectFormat::samples() const
}
/*!
+ \since 4.8
+
+ Enables or disables mipmapping. Mipmapping is disabled by default.
+ If mipmapping is enabled, additional memory will be allocated for
+ the mipmap levels. The mipmap levels can be updated by binding the
+ texture and calling glGenerateMipmap(). Mipmapping cannot be enabled
+ for multisampled framebuffer objects.
+
+ \sa mipmap(), texture()
+*/
+void QGLFramebufferObjectFormat::setMipmap(bool enabled)
+{
+ detach();
+ d->mipmap = enabled;
+}
+
+/*!
+ \since 4.8
+
+ Returns true if mipmapping is enabled.
+
+ \sa setMipmap()
+*/
+bool QGLFramebufferObjectFormat::mipmap() const
+{
+ return d->mipmap;
+}
+
+/*!
Sets the attachment configuration of a framebuffer object to \a attachment.
\sa attachment()
@@ -324,6 +353,10 @@ void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f,
fboFormat.setStencil(true);
} else if (attachment == QGLFramebufferObject::Depth) {
fboFormat.setDepth(true);
+ fboFormat.setStencil(false);
+ } else {
+ fboFormat.setDepth(false);
+ fboFormat.setStencil(false);
}
GLenum format = f->format().internalTextureFormat();
@@ -394,7 +427,8 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const
void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
QGLFramebufferObject::Attachment attachment,
- GLenum texture_target, GLenum internal_format, GLint samples)
+ GLenum texture_target, GLenum internal_format,
+ GLint samples, bool mipmap)
{
QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
fbo_guard.setContext(ctx);
@@ -422,6 +456,8 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
glBindTexture(target, texture);
glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (mipmap)
+ glGenerateMipmap(GL_TEXTURE_2D);
#ifndef QT_OPENGL_ES
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -442,6 +478,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
color_buffer = 0;
} else {
+ mipmap = false;
GLint maxSamples;
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
@@ -602,6 +639,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
format.setSamples(int(samples));
format.setAttachment(fbo_attachment);
format.setInternalTextureFormat(internal_format);
+ format.setMipmap(mipmap);
}
/*!
@@ -674,6 +712,13 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
as a texture, you first need to copy from it to a regular framebuffer
object using QGLContext::blitFramebuffer().
+ \section Threading
+
+ As of Qt 4.8, it's possible to draw into a QGLFramebufferObject
+ using a QPainter in a separate thread. Note that OpenGL 2.0 or
+ OpenGL ES 2.0 is required for this to work. Also, under X11, it's
+ necessary to set the Qt::AA_X11InitThreads application attribute.
+
\sa {Framebuffer Object Example}
*/
@@ -766,7 +811,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebuff
{
Q_D(QGLFramebufferObject);
d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(),
- format.samples());
+ format.samples(), format.mipmap());
}
/*! \overload
@@ -780,7 +825,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFrame
{
Q_D(QGLFramebufferObject);
d->init(this, QSize(width, height), format.attachment(), format.textureTarget(),
- format.internalTextureFormat(), format.samples());
+ format.internalTextureFormat(), format.samples(), format.mipmap());
}
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS
@@ -1044,11 +1089,11 @@ QImage QGLFramebufferObject::toImage() const
}
#if !defined(QT_OPENGL_ES_1)
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_buffer_2_engine)
#endif
#ifndef QT_OPENGL_ES_2
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QOpenGLPaintEngine>, qt_buffer_engine)
#endif
/*! \reimp */
@@ -1062,7 +1107,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const
#if !defined (QT_OPENGL_ES_2)
if (qt_gl_preferGL2Engine()) {
#endif
- QPaintEngine *engine = qt_buffer_2_engine();
+ QPaintEngine *engine = qt_buffer_2_engine()->engine();
if (engine->isActive() && engine->paintDevice() != this) {
d->engine = new QGL2PaintEngineEx;
return d->engine;
@@ -1074,7 +1119,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const
#endif
#if !defined(QT_OPENGL_ES_2)
- QPaintEngine *engine = qt_buffer_engine();
+ QPaintEngine *engine = qt_buffer_engine()->engine();
if (engine->isActive() && engine->paintDevice() != this) {
d->engine = new QOpenGLPaintEngine;
return d->engine;
diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h
index 1ec506b..72ff279 100644
--- a/src/opengl/qglframebufferobject.h
+++ b/src/opengl/qglframebufferobject.h
@@ -148,6 +148,9 @@ public:
void setSamples(int samples);
int samples() const;
+ void setMipmap(bool enabled);
+ bool mipmap() const;
+
void setAttachment(QGLFramebufferObject::Attachment attachment);
QGLFramebufferObject::Attachment attachment() const;
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index eb476a9..4d19469 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -77,7 +77,8 @@ public:
samples(0),
attachment(QGLFramebufferObject::NoAttachment),
target(GL_TEXTURE_2D),
- internal_format(DEFAULT_FORMAT)
+ internal_format(DEFAULT_FORMAT),
+ mipmap(false)
{
}
QGLFramebufferObjectFormatPrivate
@@ -86,7 +87,8 @@ public:
samples(other->samples),
attachment(other->attachment),
target(other->target),
- internal_format(other->internal_format)
+ internal_format(other->internal_format),
+ mipmap(other->mipmap)
{
}
bool equals(const QGLFramebufferObjectFormatPrivate *other)
@@ -94,7 +96,8 @@ public:
return samples == other->samples &&
attachment == other->attachment &&
target == other->target &&
- internal_format == other->internal_format;
+ internal_format == other->internal_format &&
+ mipmap == other->mipmap;
}
QAtomicInt ref;
@@ -102,6 +105,7 @@ public:
QGLFramebufferObject::Attachment attachment;
GLenum target;
GLenum internal_format;
+ uint mipmap : 1;
};
class QGLFBOGLPaintDevice : public QGLPaintDevice
@@ -132,7 +136,8 @@ public:
void init(QGLFramebufferObject *q, const QSize& sz,
QGLFramebufferObject::Attachment attachment,
- GLenum internal_format, GLenum texture_target, GLint samples = 0);
+ GLenum internal_format, GLenum texture_target,
+ GLint samples = 0, bool mipmap = false);
bool checkFramebufferStatus() const;
QGLSharedResourceGuard fbo_guard;
GLuint texture;
diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp
new file mode 100644
index 0000000..29e32ff
--- /dev/null
+++ b/src/opengl/qglfunctions.cpp
@@ -0,0 +1,3705 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 "qglfunctions.h"
+#include "qgl_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QGLFunctions
+ \brief The QGLFunctions class provides cross-platform access to the OpenGL/ES 2.0 API.
+ \since 4.8
+ \ingroup painting-3D
+
+ OpenGL/ES 2.0 defines a subset of the OpenGL specification that is
+ common across many desktop and embedded OpenGL implementations.
+ However, it can be difficult to use the functions from that subset
+ because they need to be resolved manually on desktop systems.
+
+ QGLFunctions provides a guaranteed API that is available on all
+ OpenGL systems and takes care of function resolution on systems
+ that need it. The recommended way to use QGLFunctions is by
+ direct inheritance:
+
+ \code
+ class MyGLWidget : public QGLWidget, protected QGLFunctions
+ {
+ Q_OBJECT
+ public:
+ MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {}
+
+ protected:
+ void initializeGL();
+ void paintGL();
+ };
+
+ void MyGLWidget::initializeGL()
+ {
+ initializeGLFunctions();
+ }
+ \endcode
+
+ The \c{paintGL()} function can then use any of the OpenGL/ES 2.0
+ functions without explicit resolution, such as glActiveTexture()
+ in the following example:
+
+ \code
+ void MyGLWidget::paintGL()
+ {
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, textureId);
+ ...
+ }
+ \endcode
+
+ QGLFunctions can also be used directly for ad-hoc invocation
+ of OpenGL/ES 2.0 functions on all platforms:
+
+ \code
+ QGLFunctions glFuncs(QGLContext::currentContext());
+ glFuncs.glActiveTexture(GL_TEXTURE1);
+ \endcode
+
+ QGLFunctions provides wrappers for all OpenGL/ES 2.0 functions,
+ except those like \c{glDrawArrays()}, \c{glViewport()}, and
+ \c{glBindTexture()} that don't have portability issues.
+
+ Including the header for QGLFunctions will also define all of
+ the OpenGL/ES 2.0 macro constants that are not already defined by
+ the system's OpenGL headers, such as \c{GL_TEXTURE1} above.
+
+ The hasOpenGLFeature() and openGLFeatures() functions can be used
+ to determine if the OpenGL implementation has a major OpenGL/ES 2.0
+ feature. For example, the following checks if non power of two
+ textures are available:
+
+ \code
+ QGLFunctions funcs(QGLContext::currentContext());
+ bool npot = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures);
+ \endcode
+*/
+
+/*!
+ \enum QGLFunctions::OpenGLFeature
+ This enum defines OpenGL/ES 2.0 features that may be optional
+ on other platforms.
+
+ \value Multitexture glActiveTexture() function is available.
+ \value Shaders Shader functions are available.
+ \value Buffers Vertex and index buffer functions are available.
+ \value Framebuffers Framebuffer object functions are available.
+ \value BlendColor glBlendColor() is available.
+ \value BlendEquation glBlendEquation() is available.
+ \value BlendEquationSeparate glBlendEquationSeparate() is available.
+ \value BlendFuncSeparate glBlendFuncSeparate() is available.
+ \value BlendSubtract Blend subtract mode is available.
+ \value CompressedTextures Compressed texture functions are available.
+ \value Multisample glSampleCoverage() function is available.
+ \value StencilSeparate Separate stencil functions are available.
+ \value NPOTTextures Non power of two textures are available.
+*/
+
+// Hidden private fields for additional extension data.
+struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate
+{
+ QGLFunctionsPrivateEx(const QGLContext *context = 0)
+ : QGLFunctionsPrivate(context)
+ , m_features(-1) {}
+
+ int m_features;
+};
+
+#if QT_VERSION >= 0x040800
+Q_GLOBAL_STATIC(QGLContextGroupResource<QGLFunctionsPrivateEx>, qt_gl_functions_resource)
+#else
+static void qt_gl_functions_free(void *data)
+{
+ delete reinterpret_cast<QGLFunctionsPrivateEx *>(data);
+}
+
+Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gl_functions_resource, (qt_gl_functions_free))
+#endif
+static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0)
+{
+ if (!context)
+ context = QGLContext::currentContext();
+ Q_ASSERT(context);
+ QGLFunctionsPrivateEx *funcs =
+ reinterpret_cast<QGLFunctionsPrivateEx *>
+ (qt_gl_functions_resource()->value(context));
+#if QT_VERSION < 0x040800
+ if (!funcs) {
+ funcs = new QGLFunctionsPrivateEx();
+ qt_gl_functions_resource()->insert(context, funcs);
+ }
+#endif
+ return funcs;
+}
+
+/*!
+ Constructs a default function resolver. The resolver cannot
+ be used until initializeGLFunctions() is called to specify
+ the context.
+
+ \sa initializeGLFunctions()
+*/
+QGLFunctions::QGLFunctions()
+ : d_ptr(0)
+{
+}
+
+/*!
+ Constructs a function resolver for \a context. If \a context
+ is null, then the resolver will be created for the current QGLContext.
+
+ An object constructed in this way can only be used with \a context
+ and other contexts that share with it. Use initializeGLFunctions()
+ to change the object's context association.
+
+ \sa initializeGLFunctions()
+*/
+QGLFunctions::QGLFunctions(const QGLContext *context)
+ : d_ptr(qt_gl_functions(context))
+{
+}
+
+/*!
+ \fn QGLFunctions::~QGLFunctions()
+
+ Destroys this function resolver.
+*/
+
+static int qt_gl_resolve_features()
+{
+#if defined(QT_OPENGL_ES_2)
+ return QGLFunctions::Multitexture |
+ QGLFunctions::Shaders |
+ QGLFunctions::Buffers |
+ QGLFunctions::Framebuffers |
+ QGLFunctions::BlendColor |
+ QGLFunctions::BlendEquation |
+ QGLFunctions::BlendEquationSeparate |
+ QGLFunctions::BlendFuncSeparate |
+ QGLFunctions::BlendSubtract |
+ QGLFunctions::CompressedTextures |
+ QGLFunctions::Multisample |
+ QGLFunctions::StencilSeparate |
+ QGLFunctions::NPOTTextures;
+#elif defined(QT_OPENGL_ES)
+ int features = QGLFunctions::Multitexture |
+ QGLFunctions::Buffers |
+ QGLFunctions::CompressedTextures |
+ QGLFunctions::Multisample;
+ QGLExtensionMatcher extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
+ if (extensions.match("GL_OES_framebuffer_object"))
+ features |= QGLFunctions::Framebuffers;
+ if (extensions.match("GL_OES_blend_equation_separate"))
+ features |= QGLFunctions::BlendEquationSeparate;
+ if (extensions.match("GL_OES_blend_func_separate"))
+ features |= QGLFunctions::BlendFuncSeparate;
+ if (extensions.match("GL_OES_blend_subtract"))
+ features |= QGLFunctions::BlendSubtract;
+ if (extensions.match("GL_OES_texture_npot"))
+ features |= QGLFunctions::NPOTTextures;
+ return features;
+#else
+ int features = 0;
+ QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags();
+ QGLExtensionMatcher extensions(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
+
+ // Recognize features by extension name.
+ if (extensions.match("GL_ARB_multitexture"))
+ features |= QGLFunctions::Multitexture;
+ if (extensions.match("GL_ARB_shader_objects"))
+ features |= QGLFunctions::Shaders;
+ if (extensions.match("GL_EXT_framebuffer_object") ||
+ extensions.match("GL_ARB_framebuffer_object"))
+ features |= QGLFunctions::Framebuffers;
+ if (extensions.match("GL_EXT_blend_color"))
+ features |= QGLFunctions::BlendColor;
+ if (extensions.match("GL_EXT_blend_equation_separate"))
+ features |= QGLFunctions::BlendEquationSeparate;
+ if (extensions.match("GL_EXT_blend_func_separate"))
+ features |= QGLFunctions::BlendFuncSeparate;
+ if (extensions.match("GL_EXT_blend_subtract"))
+ features |= QGLFunctions::BlendSubtract;
+ if (extensions.match("GL_ARB_texture_compression"))
+ features |= QGLFunctions::CompressedTextures;
+ if (extensions.match("GL_ARB_multisample"))
+ features |= QGLFunctions::Multisample;
+ if (extensions.match("GL_ARB_texture_non_power_of_two"))
+ features |= QGLFunctions::NPOTTextures;
+
+ // Recognize features by minimum OpenGL version.
+ if (versions & QGLFormat::OpenGL_Version_1_2) {
+ features |= QGLFunctions::BlendColor |
+ QGLFunctions::BlendEquation;
+ }
+ if (versions & QGLFormat::OpenGL_Version_1_3) {
+ features |= QGLFunctions::Multitexture |
+ QGLFunctions::CompressedTextures |
+ QGLFunctions::Multisample;
+ }
+ if (versions & QGLFormat::OpenGL_Version_1_4)
+ features |= QGLFunctions::BlendFuncSeparate;
+ if (versions & QGLFormat::OpenGL_Version_1_5)
+ features |= QGLFunctions::Buffers;
+ if (versions & QGLFormat::OpenGL_Version_2_0) {
+ features |= QGLFunctions::Shaders |
+ QGLFunctions::StencilSeparate |
+ QGLFunctions::BlendEquationSeparate |
+ QGLFunctions::NPOTTextures;
+ }
+ return features;
+#endif
+}
+
+/*!
+ Returns the set of features that are present on this system's
+ OpenGL implementation.
+
+ It is assumed that the QGLContext associated with this function
+ resolver is current.
+
+ \sa hasOpenGLFeature()
+*/
+QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const
+{
+ QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr);
+ if (!d)
+ return 0;
+ if (d->m_features == -1)
+ d->m_features = qt_gl_resolve_features();
+ return QGLFunctions::OpenGLFeatures(d->m_features);
+}
+
+/*!
+ Returns true if \a feature is present on this system's OpenGL
+ implementation; false otherwise.
+
+ It is assumed that the QGLContext associated with this function
+ resolver is current.
+
+ \sa openGLFeatures()
+*/
+bool QGLFunctions::hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const
+{
+ QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr);
+ if (!d)
+ return false;
+ if (d->m_features == -1)
+ d->m_features = qt_gl_resolve_features();
+ return (d->m_features & int(feature)) != 0;
+}
+
+/*!
+ Initializes GL function resolution for \a context. If \a context
+ is null, then the current QGLContext will be used.
+
+ After calling this function, the QGLFunctions object can only be
+ used with \a context and other contexts that share with it.
+ Call initializeGLFunctions() again to change the object's context
+ association.
+*/
+void QGLFunctions::initializeGLFunctions(const QGLContext *context)
+{
+ d_ptr = qt_gl_functions(context);
+}
+
+/*!
+ \fn void QGLFunctions::glActiveTexture(GLenum texture)
+
+ Convenience function that calls glActiveTexture(\a texture).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glActiveTexture.xml}{glActiveTexture()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glAttachShader(GLuint program, GLuint shader)
+
+ Convenience function that calls glAttachShader(\a program, \a shader).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glAttachShader.xml}{glAttachShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
+
+ Convenience function that calls glBindAttribLocation(\a program, \a index, \a name).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBindAttribLocation.xml}{glBindAttribLocation()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
+
+ Convenience function that calls glBindBuffer(\a target, \a buffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBindBuffer.xml}{glBindBuffer()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
+
+ Convenience function that calls glBindFramebuffer(\a target, \a framebuffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBindFramebuffer.xml}{glBindFramebuffer()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+
+ Convenience function that calls glBindRenderbuffer(\a target, \a renderbuffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBindRenderbuffer.xml}{glBindRenderbuffer()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+
+ Convenience function that calls glBlendColor(\a red, \a green, \a blue, \a alpha).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendColor.xml}{glBlendColor()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBlendEquation(GLenum mode)
+
+ Convenience function that calls glBlendEquation(\a mode).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquation.xml}{glBlendEquation()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+
+ Convenience function that calls glBlendEquationSeparate(\a modeRGB, \a modeAlpha).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquationSeparate.xml}{glBlendEquationSeparate()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+
+ Convenience function that calls glBlendFuncSeparate(\a srcRGB, \a dstRGB, \a srcAlpha, \a dstAlpha).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendFuncSeparate.xml}{glBlendFuncSeparate()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
+
+ Convenience function that calls glBufferData(\a target, \a size, \a data, \a usage).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferData.xml}{glBufferData()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
+
+ Convenience function that calls glBufferSubData(\a target, \a offset, \a size, \a data).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferSubData.xml}{glBufferSubData()}.
+*/
+
+/*!
+ \fn GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target)
+
+ Convenience function that calls glCheckFramebufferStatus(\a target).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCheckFramebufferStatus.xml}{glCheckFramebufferStatus()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glClearDepthf(GLclampf depth)
+
+ Convenience function that calls glClearDepth(\a depth) on
+ desktop OpenGL systems and glClearDepthf(\a depth) on
+ embedded OpenGL/ES systems.
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glClearDepthf.xml}{glClearDepthf()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glCompileShader(GLuint shader)
+
+ Convenience function that calls glCompileShader(\a shader).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCompileShader.xml}{glCompileShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+
+ Convenience function that calls glCompressedTexImage2D(\a target, \a level, \a internalformat, \a width, \a height, \a border, \a imageSize, \a data).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexImage2D.xml}{glCompressedTexImage2D()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+
+ Convenience function that calls glCompressedTexSubImage2D(\a target, \a level, \a xoffset, \a yoffset, \a width, \a height, \a format, \a imageSize, \a data).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexSubImage2D.xml}{glCompressedTexSubImage2D()}.
+*/
+
+/*!
+ \fn GLuint QGLFunctions::glCreateProgram()
+
+ Convenience function that calls glCreateProgram().
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateProgram.xml}{glCreateProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn GLuint QGLFunctions::glCreateShader(GLenum type)
+
+ Convenience function that calls glCreateShader(\a type).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateShader.xml}{glCreateShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
+
+ Convenience function that calls glDeleteBuffers(\a n, \a buffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteBuffers.xml}{glDeleteBuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+
+ Convenience function that calls glDeleteFramebuffers(\a n, \a framebuffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteFramebuffers.xml}{glDeleteFramebuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glDeleteProgram(GLuint program)
+
+ Convenience function that calls glDeleteProgram(\a program).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteProgram.xml}{glDeleteProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+
+ Convenience function that calls glDeleteRenderbuffers(\a n, \a renderbuffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteRenderbuffers.xml}{glDeleteRenderbuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glDeleteShader(GLuint shader)
+
+ Convenience function that calls glDeleteShader(\a shader).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteShader.xml}{glDeleteShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
+
+ Convenience function that calls glDepthRange(\a zNear, \a zFar) on
+ desktop OpenGL systems and glDepthRangef(\a zNear, \a zFar) on
+ embedded OpenGL/ES systems.
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDepthRangef.xml}{glDepthRangef()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glDetachShader(GLuint program, GLuint shader)
+
+ Convenience function that calls glDetachShader(\a program, \a shader).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDetachShader.xml}{glDetachShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glDisableVertexAttribArray(GLuint index)
+
+ Convenience function that calls glDisableVertexAttribArray(\a index).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glDisableVertexAttribArray.xml}{glDisableVertexAttribArray()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glEnableVertexAttribArray(GLuint index)
+
+ Convenience function that calls glEnableVertexAttribArray(\a index).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glEnableVertexAttribArray.xml}{glEnableVertexAttribArray()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+
+ Convenience function that calls glFramebufferRenderbuffer(\a target, \a attachment, \a renderbuffertarget, \a renderbuffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferRenderbuffer.xml}{glFramebufferRenderbuffer()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+
+ Convenience function that calls glFramebufferTexture2D(\a target, \a attachment, \a textarget, \a texture, \a level).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferTexture2D.xml}{glFramebufferTexture2D()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
+
+ Convenience function that calls glGenBuffers(\a n, \a buffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGenBuffers.xml}{glGenBuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGenerateMipmap(GLenum target)
+
+ Convenience function that calls glGenerateMipmap(\a target).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGenerateMipmap.xml}{glGenerateMipmap()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+
+ Convenience function that calls glGenFramebuffers(\a n, \a framebuffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGenFramebuffers.xml}{glGenFramebuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+
+ Convenience function that calls glGenRenderbuffers(\a n, \a renderbuffers).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGenRenderbuffers.xml}{glGenRenderbuffers()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+
+ Convenience function that calls glGetActiveAttrib(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveAttrib.xml}{glGetActiveAttrib()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+
+ Convenience function that calls glGetActiveUniform(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveUniform.xml}{glGetActiveUniform()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+
+ Convenience function that calls glGetAttachedShaders(\a program, \a maxcount, \a count, \a shaders).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttachedShaders.xml}{glGetAttachedShaders()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn int QGLFunctions::glGetAttribLocation(GLuint program, const char* name)
+
+ Convenience function that calls glGetAttribLocation(\a program, \a name).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttribLocation.xml}{glGetAttribLocation()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetBufferParameteriv(\a target, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetBufferParameteriv.xml}{glGetBufferParameteriv()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetFramebufferAttachmentParameteriv(\a target, \a attachment, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetFramebufferAttachmentParameteriv.xml}{glGetFramebufferAttachmentParameteriv()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetProgramiv(\a program, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramiv.xml}{glGetProgramiv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+
+ Convenience function that calls glGetProgramInfoLog(\a program, \a bufsize, \a length, \a infolog).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramInfoLog.xml}{glGetProgramInfoLog()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetRenderbufferParameteriv(\a target, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetRenderbufferParameteriv.xml}{glGetRenderbufferParameteriv()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetShaderiv(\a shader, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderiv.xml}{glGetShaderiv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+
+ Convenience function that calls glGetShaderInfoLog(\a shader, \a bufsize, \a length, \a infolog).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderInfoLog.xml}{glGetShaderInfoLog()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+
+ Convenience function that calls glGetShaderPrecisionFormat(\a shadertype, \a precisiontype, \a range, \a precision).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderPrecisionFormat.xml}{glGetShaderPrecisionFormat()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+
+ Convenience function that calls glGetShaderSource(\a shader, \a bufsize, \a length, \a source).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderSource.xml}{glGetShaderSource()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+
+ Convenience function that calls glGetUniformfv(\a program, \a location, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformfv.xml}{glGetUniformfv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
+
+ Convenience function that calls glGetUniformiv(\a program, \a location, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformiv.xml}{glGetUniformiv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn int QGLFunctions::glGetUniformLocation(GLuint program, const char* name)
+
+ Convenience function that calls glGetUniformLocation(\a program, \a name).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformLocation.xml}{glGetUniformLocation()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+
+ Convenience function that calls glGetVertexAttribfv(\a index, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribfv.xml}{glGetVertexAttribfv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+
+ Convenience function that calls glGetVertexAttribiv(\a index, \a pname, \a params).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribiv.xml}{glGetVertexAttribiv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+
+ Convenience function that calls glGetVertexAttribPointerv(\a index, \a pname, \a pointer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribPointerv.xml}{glGetVertexAttribPointerv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn GLboolean QGLFunctions::glIsBuffer(GLuint buffer)
+
+ Convenience function that calls glIsBuffer(\a buffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glIsBuffer.xml}{glIsBuffer()}.
+*/
+
+/*!
+ \fn GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer)
+
+ Convenience function that calls glIsFramebuffer(\a framebuffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glIsFramebuffer.xml}{glIsFramebuffer()}.
+*/
+
+/*!
+ \fn GLboolean QGLFunctions::glIsProgram(GLuint program)
+
+ Convenience function that calls glIsProgram(\a program).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glIsProgram.xml}{glIsProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
+
+ Convenience function that calls glIsRenderbuffer(\a renderbuffer).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glIsRenderbuffer.xml}{glIsRenderbuffer()}.
+*/
+
+/*!
+ \fn GLboolean QGLFunctions::glIsShader(GLuint shader)
+
+ Convenience function that calls glIsShader(\a shader).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glIsShader.xml}{glIsShader()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glLinkProgram(GLuint program)
+
+ Convenience function that calls glLinkProgram(\a program).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glLinkProgram.xml}{glLinkProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glReleaseShaderCompiler()
+
+ Convenience function that calls glReleaseShaderCompiler().
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glReleaseShaderCompiler.xml}{glReleaseShaderCompiler()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+
+ Convenience function that calls glRenderbufferStorage(\a target, \a internalformat, \a width, \a height).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glRenderbufferStorage.xml}{glRenderbufferStorage()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
+
+ Convenience function that calls glSampleCoverage(\a value, \a invert).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glSampleCoverage.xml}{glSampleCoverage()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
+
+ Convenience function that calls glShaderBinary(\a n, \a shaders, \a binaryformat, \a binary, \a length).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderBinary.xml}{glShaderBinary()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
+
+ Convenience function that calls glShaderSource(\a shader, \a count, \a string, \a length).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderSource.xml}{glShaderSource()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+
+ Convenience function that calls glStencilFuncSeparate(\a face, \a func, \a ref, \a mask).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilFuncSeparate.xml}{glStencilFuncSeparate()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
+
+ Convenience function that calls glStencilMaskSeparate(\a face, \a mask).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilMaskSeparate.xml}{glStencilMaskSeparate()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+
+ Convenience function that calls glStencilOpSeparate(\a face, \a fail, \a zfail, \a zpass).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilOpSeparate.xml}{glStencilOpSeparate()}.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform1f(GLint location, GLfloat x)
+
+ Convenience function that calls glUniform1f(\a location, \a x).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1f.xml}{glUniform1f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+
+ Convenience function that calls glUniform1fv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1fv.xml}{glUniform1fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform1i(GLint location, GLint x)
+
+ Convenience function that calls glUniform1i(\a location, \a x).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1i.xml}{glUniform1i()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
+
+ Convenience function that calls glUniform1iv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1iv.xml}{glUniform1iv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
+
+ Convenience function that calls glUniform2f(\a location, \a x, \a y).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2f.xml}{glUniform2f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+
+ Convenience function that calls glUniform2fv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2fv.xml}{glUniform2fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
+
+ Convenience function that calls glUniform2i(\a location, \a x, \a y).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2i.xml}{glUniform2i()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
+
+ Convenience function that calls glUniform2iv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2iv.xml}{glUniform2iv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+
+ Convenience function that calls glUniform3f(\a location, \a x, \a y, \a z).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3f.xml}{glUniform3f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+
+ Convenience function that calls glUniform3fv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3fv.xml}{glUniform3fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
+
+ Convenience function that calls glUniform3i(\a location, \a x, \a y, \a z).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3i.xml}{glUniform3i()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
+
+ Convenience function that calls glUniform3iv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3iv.xml}{glUniform3iv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+
+ Convenience function that calls glUniform4f(\a location, \a x, \a y, \a z, \a w).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4f.xml}{glUniform4f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+
+ Convenience function that calls glUniform4fv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4fv.xml}{glUniform4fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+
+ Convenience function that calls glUniform4i(\a location, \a x, \a y, \a z, \a w).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4i.xml}{glUniform4i()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
+
+ Convenience function that calls glUniform4iv(\a location, \a count, \a v).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4iv.xml}{glUniform4iv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+
+ Convenience function that calls glUniformMatrix2fv(\a location, \a count, \a transpose, \a value).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix2fv.xml}{glUniformMatrix2fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+
+ Convenience function that calls glUniformMatrix3fv(\a location, \a count, \a transpose, \a value).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix3fv.xml}{glUniformMatrix3fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+
+ Convenience function that calls glUniformMatrix4fv(\a location, \a count, \a transpose, \a value).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix4fv.xml}{glUniformMatrix4fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glUseProgram(GLuint program)
+
+ Convenience function that calls glUseProgram(\a program).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glUseProgram.xml}{glUseProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glValidateProgram(GLuint program)
+
+ Convenience function that calls glValidateProgram(\a program).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glValidateProgram.xml}{glValidateProgram()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
+
+ Convenience function that calls glVertexAttrib1f(\a indx, \a x).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1f.xml}{glVertexAttrib1f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+
+ Convenience function that calls glVertexAttrib1fv(\a indx, \a values).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1fv.xml}{glVertexAttrib1fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+
+ Convenience function that calls glVertexAttrib2f(\a indx, \a x, \a y).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2f.xml}{glVertexAttrib2f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+
+ Convenience function that calls glVertexAttrib2fv(\a indx, \a values).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2fv.xml}{glVertexAttrib2fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+
+ Convenience function that calls glVertexAttrib3f(\a indx, \a x, \a y, \a z).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3f.xml}{glVertexAttrib3f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+
+ Convenience function that calls glVertexAttrib3fv(\a indx, \a values).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3fv.xml}{glVertexAttrib3fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+
+ Convenience function that calls glVertexAttrib4f(\a indx, \a x, \a y, \a z, \a w).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4f.xml}{glVertexAttrib4f()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+
+ Convenience function that calls glVertexAttrib4fv(\a indx, \a values).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4fv.xml}{glVertexAttrib4fv()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+/*!
+ \fn void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+
+ Convenience function that calls glVertexAttribPointer(\a indx, \a size, \a type, \a normalized, \a stride, \a ptr).
+
+ For more information, see the OpenGL/ES 2.0 documentation for
+ \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttribPointer.xml}{glVertexAttribPointer()}.
+
+ This convenience function will do nothing on OpenGL/ES 1.x systems.
+*/
+
+#ifndef QT_OPENGL_ES_2
+
+static void qglfResolveActiveTexture(GLenum texture)
+{
+ typedef void (QGLF_APIENTRYP type_glActiveTexture)(GLenum texture);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->activeTexture = (type_glActiveTexture)
+ context->getProcAddress(QLatin1String("glActiveTexture"));
+ if (!funcs->activeTexture) {
+ funcs->activeTexture = (type_glActiveTexture)
+ context->getProcAddress(QLatin1String("glActiveTextureARB"));
+ }
+
+ if (funcs->activeTexture)
+ funcs->activeTexture(texture);
+ else
+ funcs->activeTexture = qglfResolveActiveTexture;
+}
+
+static void qglfResolveAttachShader(GLuint program, GLuint shader)
+{
+ typedef void (QGLF_APIENTRYP type_glAttachShader)(GLuint program, GLuint shader);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->attachShader = (type_glAttachShader)
+ context->getProcAddress(QLatin1String("glAttachShader"));
+ if (!funcs->attachShader) {
+ funcs->attachShader = (type_glAttachShader)
+ context->getProcAddress(QLatin1String("glAttachObjectARB"));
+ }
+
+ if (funcs->attachShader)
+ funcs->attachShader(program, shader);
+ else
+ funcs->attachShader = qglfResolveAttachShader;
+}
+
+static void qglfResolveBindAttribLocation(GLuint program, GLuint index, const char* name)
+{
+ typedef void (QGLF_APIENTRYP type_glBindAttribLocation)(GLuint program, GLuint index, const char* name);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bindAttribLocation = (type_glBindAttribLocation)
+ context->getProcAddress(QLatin1String("glBindAttribLocation"));
+ if (!funcs->bindAttribLocation) {
+ funcs->bindAttribLocation = (type_glBindAttribLocation)
+ context->getProcAddress(QLatin1String("glBindAttribLocationARB"));
+ }
+
+ if (funcs->bindAttribLocation)
+ funcs->bindAttribLocation(program, index, name);
+ else
+ funcs->bindAttribLocation = qglfResolveBindAttribLocation;
+}
+
+static void qglfResolveBindBuffer(GLenum target, GLuint buffer)
+{
+ typedef void (QGLF_APIENTRYP type_glBindBuffer)(GLenum target, GLuint buffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bindBuffer = (type_glBindBuffer)
+ context->getProcAddress(QLatin1String("glBindBuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->bindBuffer) {
+ funcs->bindBuffer = (type_glBindBuffer)
+ context->getProcAddress(QLatin1String("glBindBufferOES"));
+ }
+#endif
+ if (!funcs->bindBuffer) {
+ funcs->bindBuffer = (type_glBindBuffer)
+ context->getProcAddress(QLatin1String("glBindBufferEXT"));
+ }
+ if (!funcs->bindBuffer) {
+ funcs->bindBuffer = (type_glBindBuffer)
+ context->getProcAddress(QLatin1String("glBindBufferARB"));
+ }
+
+ if (funcs->bindBuffer)
+ funcs->bindBuffer(target, buffer);
+ else
+ funcs->bindBuffer = qglfResolveBindBuffer;
+}
+
+static void qglfResolveBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+ typedef void (QGLF_APIENTRYP type_glBindFramebuffer)(GLenum target, GLuint framebuffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bindFramebuffer = (type_glBindFramebuffer)
+ context->getProcAddress(QLatin1String("glBindFramebuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->bindFramebuffer) {
+ funcs->bindFramebuffer = (type_glBindFramebuffer)
+ context->getProcAddress(QLatin1String("glBindFramebufferOES"));
+ }
+#endif
+ if (!funcs->bindFramebuffer) {
+ funcs->bindFramebuffer = (type_glBindFramebuffer)
+ context->getProcAddress(QLatin1String("glBindFramebufferEXT"));
+ }
+ if (!funcs->bindFramebuffer) {
+ funcs->bindFramebuffer = (type_glBindFramebuffer)
+ context->getProcAddress(QLatin1String("glBindFramebufferARB"));
+ }
+
+ if (funcs->bindFramebuffer)
+ funcs->bindFramebuffer(target, framebuffer);
+ else
+ funcs->bindFramebuffer = qglfResolveBindFramebuffer;
+}
+
+static void qglfResolveBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+ typedef void (QGLF_APIENTRYP type_glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bindRenderbuffer = (type_glBindRenderbuffer)
+ context->getProcAddress(QLatin1String("glBindRenderbuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->bindRenderbuffer) {
+ funcs->bindRenderbuffer = (type_glBindRenderbuffer)
+ context->getProcAddress(QLatin1String("glBindRenderbufferOES"));
+ }
+#endif
+ if (!funcs->bindRenderbuffer) {
+ funcs->bindRenderbuffer = (type_glBindRenderbuffer)
+ context->getProcAddress(QLatin1String("glBindRenderbufferEXT"));
+ }
+ if (!funcs->bindRenderbuffer) {
+ funcs->bindRenderbuffer = (type_glBindRenderbuffer)
+ context->getProcAddress(QLatin1String("glBindRenderbufferARB"));
+ }
+
+ if (funcs->bindRenderbuffer)
+ funcs->bindRenderbuffer(target, renderbuffer);
+ else
+ funcs->bindRenderbuffer = qglfResolveBindRenderbuffer;
+}
+
+static void qglfResolveBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ typedef void (QGLF_APIENTRYP type_glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->blendColor = (type_glBlendColor)
+ context->getProcAddress(QLatin1String("glBlendColor"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->blendColor) {
+ funcs->blendColor = (type_glBlendColor)
+ context->getProcAddress(QLatin1String("glBlendColorOES"));
+ }
+#endif
+ if (!funcs->blendColor) {
+ funcs->blendColor = (type_glBlendColor)
+ context->getProcAddress(QLatin1String("glBlendColorEXT"));
+ }
+ if (!funcs->blendColor) {
+ funcs->blendColor = (type_glBlendColor)
+ context->getProcAddress(QLatin1String("glBlendColorARB"));
+ }
+
+ if (funcs->blendColor)
+ funcs->blendColor(red, green, blue, alpha);
+ else
+ funcs->blendColor = qglfResolveBlendColor;
+}
+
+static void qglfResolveBlendEquation(GLenum mode)
+{
+ typedef void (QGLF_APIENTRYP type_glBlendEquation)(GLenum mode);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->blendEquation = (type_glBlendEquation)
+ context->getProcAddress(QLatin1String("glBlendEquation"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->blendEquation) {
+ funcs->blendEquation = (type_glBlendEquation)
+ context->getProcAddress(QLatin1String("glBlendEquationOES"));
+ }
+#endif
+ if (!funcs->blendEquation) {
+ funcs->blendEquation = (type_glBlendEquation)
+ context->getProcAddress(QLatin1String("glBlendEquationEXT"));
+ }
+ if (!funcs->blendEquation) {
+ funcs->blendEquation = (type_glBlendEquation)
+ context->getProcAddress(QLatin1String("glBlendEquationARB"));
+ }
+
+ if (funcs->blendEquation)
+ funcs->blendEquation(mode);
+ else
+ funcs->blendEquation = qglfResolveBlendEquation;
+}
+
+static void qglfResolveBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+ typedef void (QGLF_APIENTRYP type_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
+ context->getProcAddress(QLatin1String("glBlendEquationSeparate"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->blendEquationSeparate) {
+ funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
+ context->getProcAddress(QLatin1String("glBlendEquationSeparateOES"));
+ }
+#endif
+ if (!funcs->blendEquationSeparate) {
+ funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
+ context->getProcAddress(QLatin1String("glBlendEquationSeparateEXT"));
+ }
+ if (!funcs->blendEquationSeparate) {
+ funcs->blendEquationSeparate = (type_glBlendEquationSeparate)
+ context->getProcAddress(QLatin1String("glBlendEquationSeparateARB"));
+ }
+
+ if (funcs->blendEquationSeparate)
+ funcs->blendEquationSeparate(modeRGB, modeAlpha);
+ else
+ funcs->blendEquationSeparate = qglfResolveBlendEquationSeparate;
+}
+
+static void qglfResolveBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+ typedef void (QGLF_APIENTRYP type_glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
+ context->getProcAddress(QLatin1String("glBlendFuncSeparate"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->blendFuncSeparate) {
+ funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
+ context->getProcAddress(QLatin1String("glBlendFuncSeparateOES"));
+ }
+#endif
+ if (!funcs->blendFuncSeparate) {
+ funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
+ context->getProcAddress(QLatin1String("glBlendFuncSeparateEXT"));
+ }
+ if (!funcs->blendFuncSeparate) {
+ funcs->blendFuncSeparate = (type_glBlendFuncSeparate)
+ context->getProcAddress(QLatin1String("glBlendFuncSeparateARB"));
+ }
+
+ if (funcs->blendFuncSeparate)
+ funcs->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+ else
+ funcs->blendFuncSeparate = qglfResolveBlendFuncSeparate;
+}
+
+static void qglfResolveBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
+{
+ typedef void (QGLF_APIENTRYP type_glBufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bufferData = (type_glBufferData)
+ context->getProcAddress(QLatin1String("glBufferData"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->bufferData) {
+ funcs->bufferData = (type_glBufferData)
+ context->getProcAddress(QLatin1String("glBufferDataOES"));
+ }
+#endif
+ if (!funcs->bufferData) {
+ funcs->bufferData = (type_glBufferData)
+ context->getProcAddress(QLatin1String("glBufferDataEXT"));
+ }
+ if (!funcs->bufferData) {
+ funcs->bufferData = (type_glBufferData)
+ context->getProcAddress(QLatin1String("glBufferDataARB"));
+ }
+
+ if (funcs->bufferData)
+ funcs->bufferData(target, size, data, usage);
+ else
+ funcs->bufferData = qglfResolveBufferData;
+}
+
+static void qglfResolveBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
+{
+ typedef void (QGLF_APIENTRYP type_glBufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->bufferSubData = (type_glBufferSubData)
+ context->getProcAddress(QLatin1String("glBufferSubData"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->bufferSubData) {
+ funcs->bufferSubData = (type_glBufferSubData)
+ context->getProcAddress(QLatin1String("glBufferSubDataOES"));
+ }
+#endif
+ if (!funcs->bufferSubData) {
+ funcs->bufferSubData = (type_glBufferSubData)
+ context->getProcAddress(QLatin1String("glBufferSubDataEXT"));
+ }
+ if (!funcs->bufferSubData) {
+ funcs->bufferSubData = (type_glBufferSubData)
+ context->getProcAddress(QLatin1String("glBufferSubDataARB"));
+ }
+
+ if (funcs->bufferSubData)
+ funcs->bufferSubData(target, offset, size, data);
+ else
+ funcs->bufferSubData = qglfResolveBufferSubData;
+}
+
+static GLenum qglfResolveCheckFramebufferStatus(GLenum target)
+{
+ typedef GLenum (QGLF_APIENTRYP type_glCheckFramebufferStatus)(GLenum target);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
+ context->getProcAddress(QLatin1String("glCheckFramebufferStatus"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->checkFramebufferStatus) {
+ funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
+ context->getProcAddress(QLatin1String("glCheckFramebufferStatusOES"));
+ }
+#endif
+ if (!funcs->checkFramebufferStatus) {
+ funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
+ context->getProcAddress(QLatin1String("glCheckFramebufferStatusEXT"));
+ }
+ if (!funcs->checkFramebufferStatus) {
+ funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus)
+ context->getProcAddress(QLatin1String("glCheckFramebufferStatusARB"));
+ }
+
+ if (funcs->checkFramebufferStatus)
+ return funcs->checkFramebufferStatus(target);
+ funcs->checkFramebufferStatus = qglfResolveCheckFramebufferStatus;
+ return GLenum(0);
+}
+
+static void qglfResolveCompileShader(GLuint shader)
+{
+ typedef void (QGLF_APIENTRYP type_glCompileShader)(GLuint shader);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->compileShader = (type_glCompileShader)
+ context->getProcAddress(QLatin1String("glCompileShader"));
+ if (!funcs->compileShader) {
+ funcs->compileShader = (type_glCompileShader)
+ context->getProcAddress(QLatin1String("glCompileShader"));
+ }
+
+ if (funcs->compileShader)
+ funcs->compileShader(shader);
+ else
+ funcs->compileShader = qglfResolveCompileShader;
+}
+
+static void qglfResolveCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+{
+ typedef void (QGLF_APIENTRYP type_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexImage2D"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->compressedTexImage2D) {
+ funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexImage2DOES"));
+ }
+#endif
+ if (!funcs->compressedTexImage2D) {
+ funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexImage2DEXT"));
+ }
+ if (!funcs->compressedTexImage2D) {
+ funcs->compressedTexImage2D = (type_glCompressedTexImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexImage2DARB"));
+ }
+
+ if (funcs->compressedTexImage2D)
+ funcs->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+ else
+ funcs->compressedTexImage2D = qglfResolveCompressedTexImage2D;
+}
+
+static void qglfResolveCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+{
+ typedef void (QGLF_APIENTRYP type_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexSubImage2D"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->compressedTexSubImage2D) {
+ funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexSubImage2DOES"));
+ }
+#endif
+ if (!funcs->compressedTexSubImage2D) {
+ funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexSubImage2DEXT"));
+ }
+ if (!funcs->compressedTexSubImage2D) {
+ funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D)
+ context->getProcAddress(QLatin1String("glCompressedTexSubImage2DARB"));
+ }
+
+ if (funcs->compressedTexSubImage2D)
+ funcs->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+ else
+ funcs->compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D;
+}
+
+static GLuint qglfResolveCreateProgram()
+{
+ typedef GLuint (QGLF_APIENTRYP type_glCreateProgram)();
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->createProgram = (type_glCreateProgram)
+ context->getProcAddress(QLatin1String("glCreateProgram"));
+ if (!funcs->createProgram) {
+ funcs->createProgram = (type_glCreateProgram)
+ context->getProcAddress(QLatin1String("glCreateProgramObjectARB"));
+ }
+
+ if (funcs->createProgram)
+ return funcs->createProgram();
+ funcs->createProgram = qglfResolveCreateProgram;
+ return GLuint(0);
+}
+
+static GLuint qglfResolveCreateShader(GLenum type)
+{
+ typedef GLuint (QGLF_APIENTRYP type_glCreateShader)(GLenum type);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->createShader = (type_glCreateShader)
+ context->getProcAddress(QLatin1String("glCreateShader"));
+ if (!funcs->createShader) {
+ funcs->createShader = (type_glCreateShader)
+ context->getProcAddress(QLatin1String("glCreateShaderObjectARB"));
+ }
+
+ if (funcs->createShader)
+ return funcs->createShader(type);
+ funcs->createShader = qglfResolveCreateShader;
+ return GLuint(0);
+}
+
+static void qglfResolveDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+ typedef void (QGLF_APIENTRYP type_glDeleteBuffers)(GLsizei n, const GLuint* buffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->deleteBuffers = (type_glDeleteBuffers)
+ context->getProcAddress(QLatin1String("glDeleteBuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->deleteBuffers) {
+ funcs->deleteBuffers = (type_glDeleteBuffers)
+ context->getProcAddress(QLatin1String("glDeleteBuffersOES"));
+ }
+#endif
+ if (!funcs->deleteBuffers) {
+ funcs->deleteBuffers = (type_glDeleteBuffers)
+ context->getProcAddress(QLatin1String("glDeleteBuffersEXT"));
+ }
+ if (!funcs->deleteBuffers) {
+ funcs->deleteBuffers = (type_glDeleteBuffers)
+ context->getProcAddress(QLatin1String("glDeleteBuffersARB"));
+ }
+
+ if (funcs->deleteBuffers)
+ funcs->deleteBuffers(n, buffers);
+ else
+ funcs->deleteBuffers = qglfResolveDeleteBuffers;
+}
+
+static void qglfResolveDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+ typedef void (QGLF_APIENTRYP type_glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
+ context->getProcAddress(QLatin1String("glDeleteFramebuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->deleteFramebuffers) {
+ funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
+ context->getProcAddress(QLatin1String("glDeleteFramebuffersOES"));
+ }
+#endif
+ if (!funcs->deleteFramebuffers) {
+ funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
+ context->getProcAddress(QLatin1String("glDeleteFramebuffersEXT"));
+ }
+ if (!funcs->deleteFramebuffers) {
+ funcs->deleteFramebuffers = (type_glDeleteFramebuffers)
+ context->getProcAddress(QLatin1String("glDeleteFramebuffersARB"));
+ }
+
+ if (funcs->deleteFramebuffers)
+ funcs->deleteFramebuffers(n, framebuffers);
+ else
+ funcs->deleteFramebuffers = qglfResolveDeleteFramebuffers;
+}
+
+static void qglfResolveDeleteProgram(GLuint program)
+{
+ typedef void (QGLF_APIENTRYP type_glDeleteProgram)(GLuint program);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->deleteProgram = (type_glDeleteProgram)
+ context->getProcAddress(QLatin1String("glDeleteProgram"));
+ if (!funcs->deleteProgram) {
+ funcs->deleteProgram = (type_glDeleteProgram)
+ context->getProcAddress(QLatin1String("glDeleteObjectARB"));
+ }
+
+ if (funcs->deleteProgram)
+ funcs->deleteProgram(program);
+ else
+ funcs->deleteProgram = qglfResolveDeleteProgram;
+}
+
+static void qglfResolveDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+ typedef void (QGLF_APIENTRYP type_glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
+ context->getProcAddress(QLatin1String("glDeleteRenderbuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->deleteRenderbuffers) {
+ funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
+ context->getProcAddress(QLatin1String("glDeleteRenderbuffersOES"));
+ }
+#endif
+ if (!funcs->deleteRenderbuffers) {
+ funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
+ context->getProcAddress(QLatin1String("glDeleteRenderbuffersEXT"));
+ }
+ if (!funcs->deleteRenderbuffers) {
+ funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers)
+ context->getProcAddress(QLatin1String("glDeleteRenderbuffersARB"));
+ }
+
+ if (funcs->deleteRenderbuffers)
+ funcs->deleteRenderbuffers(n, renderbuffers);
+ else
+ funcs->deleteRenderbuffers = qglfResolveDeleteRenderbuffers;
+}
+
+static void qglfResolveDeleteShader(GLuint shader)
+{
+ typedef void (QGLF_APIENTRYP type_glDeleteShader)(GLuint shader);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->deleteShader = (type_glDeleteShader)
+ context->getProcAddress(QLatin1String("glDeleteShader"));
+ if (!funcs->deleteShader) {
+ funcs->deleteShader = (type_glDeleteShader)
+ context->getProcAddress(QLatin1String("glDeleteObjectARB"));
+ }
+
+ if (funcs->deleteShader)
+ funcs->deleteShader(shader);
+ else
+ funcs->deleteShader = qglfResolveDeleteShader;
+}
+
+static void qglfResolveDetachShader(GLuint program, GLuint shader)
+{
+ typedef void (QGLF_APIENTRYP type_glDetachShader)(GLuint program, GLuint shader);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->detachShader = (type_glDetachShader)
+ context->getProcAddress(QLatin1String("glDetachShader"));
+ if (!funcs->detachShader) {
+ funcs->detachShader = (type_glDetachShader)
+ context->getProcAddress(QLatin1String("glDetachObjectARB"));
+ }
+
+ if (funcs->detachShader)
+ funcs->detachShader(program, shader);
+ else
+ funcs->detachShader = qglfResolveDetachShader;
+}
+
+static void qglfResolveDisableVertexAttribArray(GLuint index)
+{
+ typedef void (QGLF_APIENTRYP type_glDisableVertexAttribArray)(GLuint index);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray)
+ context->getProcAddress(QLatin1String("glDisableVertexAttribArray"));
+ if (!funcs->disableVertexAttribArray) {
+ funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray)
+ context->getProcAddress(QLatin1String("glDisableVertexAttribArrayARB"));
+ }
+
+ if (funcs->disableVertexAttribArray)
+ funcs->disableVertexAttribArray(index);
+ else
+ funcs->disableVertexAttribArray = qglfResolveDisableVertexAttribArray;
+}
+
+static void qglfResolveEnableVertexAttribArray(GLuint index)
+{
+ typedef void (QGLF_APIENTRYP type_glEnableVertexAttribArray)(GLuint index);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray)
+ context->getProcAddress(QLatin1String("glEnableVertexAttribArray"));
+ if (!funcs->enableVertexAttribArray) {
+ funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray)
+ context->getProcAddress(QLatin1String("glEnableVertexAttribArrayARB"));
+ }
+
+ if (funcs->enableVertexAttribArray)
+ funcs->enableVertexAttribArray(index);
+ else
+ funcs->enableVertexAttribArray = qglfResolveEnableVertexAttribArray;
+}
+
+static void qglfResolveFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+ typedef void (QGLF_APIENTRYP type_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
+ context->getProcAddress(QLatin1String("glFramebufferRenderbuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->framebufferRenderbuffer) {
+ funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
+ context->getProcAddress(QLatin1String("glFramebufferRenderbufferOES"));
+ }
+#endif
+ if (!funcs->framebufferRenderbuffer) {
+ funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
+ context->getProcAddress(QLatin1String("glFramebufferRenderbufferEXT"));
+ }
+ if (!funcs->framebufferRenderbuffer) {
+ funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer)
+ context->getProcAddress(QLatin1String("glFramebufferRenderbufferARB"));
+ }
+
+ if (funcs->framebufferRenderbuffer)
+ funcs->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+ else
+ funcs->framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer;
+}
+
+static void qglfResolveFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ typedef void (QGLF_APIENTRYP type_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
+ context->getProcAddress(QLatin1String("glFramebufferTexture2D"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->framebufferTexture2D) {
+ funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
+ context->getProcAddress(QLatin1String("glFramebufferTexture2DOES"));
+ }
+#endif
+ if (!funcs->framebufferTexture2D) {
+ funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
+ context->getProcAddress(QLatin1String("glFramebufferTexture2DEXT"));
+ }
+ if (!funcs->framebufferTexture2D) {
+ funcs->framebufferTexture2D = (type_glFramebufferTexture2D)
+ context->getProcAddress(QLatin1String("glFramebufferTexture2DARB"));
+ }
+
+ if (funcs->framebufferTexture2D)
+ funcs->framebufferTexture2D(target, attachment, textarget, texture, level);
+ else
+ funcs->framebufferTexture2D = qglfResolveFramebufferTexture2D;
+}
+
+static void qglfResolveGenBuffers(GLsizei n, GLuint* buffers)
+{
+ typedef void (QGLF_APIENTRYP type_glGenBuffers)(GLsizei n, GLuint* buffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->genBuffers = (type_glGenBuffers)
+ context->getProcAddress(QLatin1String("glGenBuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->genBuffers) {
+ funcs->genBuffers = (type_glGenBuffers)
+ context->getProcAddress(QLatin1String("glGenBuffersOES"));
+ }
+#endif
+ if (!funcs->genBuffers) {
+ funcs->genBuffers = (type_glGenBuffers)
+ context->getProcAddress(QLatin1String("glGenBuffersEXT"));
+ }
+ if (!funcs->genBuffers) {
+ funcs->genBuffers = (type_glGenBuffers)
+ context->getProcAddress(QLatin1String("glGenBuffersARB"));
+ }
+
+ if (funcs->genBuffers)
+ funcs->genBuffers(n, buffers);
+ else
+ funcs->genBuffers = qglfResolveGenBuffers;
+}
+
+static void qglfResolveGenerateMipmap(GLenum target)
+{
+ typedef void (QGLF_APIENTRYP type_glGenerateMipmap)(GLenum target);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->generateMipmap = (type_glGenerateMipmap)
+ context->getProcAddress(QLatin1String("glGenerateMipmap"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->generateMipmap) {
+ funcs->generateMipmap = (type_glGenerateMipmap)
+ context->getProcAddress(QLatin1String("glGenerateMipmapOES"));
+ }
+#endif
+ if (!funcs->generateMipmap) {
+ funcs->generateMipmap = (type_glGenerateMipmap)
+ context->getProcAddress(QLatin1String("glGenerateMipmapEXT"));
+ }
+ if (!funcs->generateMipmap) {
+ funcs->generateMipmap = (type_glGenerateMipmap)
+ context->getProcAddress(QLatin1String("glGenerateMipmapARB"));
+ }
+
+ if (funcs->generateMipmap)
+ funcs->generateMipmap(target);
+ else
+ funcs->generateMipmap = qglfResolveGenerateMipmap;
+}
+
+static void qglfResolveGenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+ typedef void (QGLF_APIENTRYP type_glGenFramebuffers)(GLsizei n, GLuint* framebuffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->genFramebuffers = (type_glGenFramebuffers)
+ context->getProcAddress(QLatin1String("glGenFramebuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->genFramebuffers) {
+ funcs->genFramebuffers = (type_glGenFramebuffers)
+ context->getProcAddress(QLatin1String("glGenFramebuffersOES"));
+ }
+#endif
+ if (!funcs->genFramebuffers) {
+ funcs->genFramebuffers = (type_glGenFramebuffers)
+ context->getProcAddress(QLatin1String("glGenFramebuffersEXT"));
+ }
+ if (!funcs->genFramebuffers) {
+ funcs->genFramebuffers = (type_glGenFramebuffers)
+ context->getProcAddress(QLatin1String("glGenFramebuffersARB"));
+ }
+
+ if (funcs->genFramebuffers)
+ funcs->genFramebuffers(n, framebuffers);
+ else
+ funcs->genFramebuffers = qglfResolveGenFramebuffers;
+}
+
+static void qglfResolveGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+ typedef void (QGLF_APIENTRYP type_glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->genRenderbuffers = (type_glGenRenderbuffers)
+ context->getProcAddress(QLatin1String("glGenRenderbuffers"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->genRenderbuffers) {
+ funcs->genRenderbuffers = (type_glGenRenderbuffers)
+ context->getProcAddress(QLatin1String("glGenRenderbuffersOES"));
+ }
+#endif
+ if (!funcs->genRenderbuffers) {
+ funcs->genRenderbuffers = (type_glGenRenderbuffers)
+ context->getProcAddress(QLatin1String("glGenRenderbuffersEXT"));
+ }
+ if (!funcs->genRenderbuffers) {
+ funcs->genRenderbuffers = (type_glGenRenderbuffers)
+ context->getProcAddress(QLatin1String("glGenRenderbuffersARB"));
+ }
+
+ if (funcs->genRenderbuffers)
+ funcs->genRenderbuffers(n, renderbuffers);
+ else
+ funcs->genRenderbuffers = qglfResolveGenRenderbuffers;
+}
+
+static void qglfResolveGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+ typedef void (QGLF_APIENTRYP type_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getActiveAttrib = (type_glGetActiveAttrib)
+ context->getProcAddress(QLatin1String("glGetActiveAttrib"));
+ if (!funcs->getActiveAttrib) {
+ funcs->getActiveAttrib = (type_glGetActiveAttrib)
+ context->getProcAddress(QLatin1String("glGetActiveAttribARB"));
+ }
+
+ if (funcs->getActiveAttrib)
+ funcs->getActiveAttrib(program, index, bufsize, length, size, type, name);
+ else
+ funcs->getActiveAttrib = qglfResolveGetActiveAttrib;
+}
+
+static void qglfResolveGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+ typedef void (QGLF_APIENTRYP type_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getActiveUniform = (type_glGetActiveUniform)
+ context->getProcAddress(QLatin1String("glGetActiveUniform"));
+ if (!funcs->getActiveUniform) {
+ funcs->getActiveUniform = (type_glGetActiveUniform)
+ context->getProcAddress(QLatin1String("glGetActiveUniformARB"));
+ }
+
+ if (funcs->getActiveUniform)
+ funcs->getActiveUniform(program, index, bufsize, length, size, type, name);
+ else
+ funcs->getActiveUniform = qglfResolveGetActiveUniform;
+}
+
+static void qglfResolveGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+ typedef void (QGLF_APIENTRYP type_glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getAttachedShaders = (type_glGetAttachedShaders)
+ context->getProcAddress(QLatin1String("glGetAttachedShaders"));
+ if (!funcs->getAttachedShaders) {
+ funcs->getAttachedShaders = (type_glGetAttachedShaders)
+ context->getProcAddress(QLatin1String("glGetAttachedObjectsARB"));
+ }
+
+ if (funcs->getAttachedShaders)
+ funcs->getAttachedShaders(program, maxcount, count, shaders);
+ else
+ funcs->getAttachedShaders = qglfResolveGetAttachedShaders;
+}
+
+static int qglfResolveGetAttribLocation(GLuint program, const char* name)
+{
+ typedef int (QGLF_APIENTRYP type_glGetAttribLocation)(GLuint program, const char* name);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getAttribLocation = (type_glGetAttribLocation)
+ context->getProcAddress(QLatin1String("glGetAttribLocation"));
+ if (!funcs->getAttribLocation) {
+ funcs->getAttribLocation = (type_glGetAttribLocation)
+ context->getProcAddress(QLatin1String("glGetAttribLocationARB"));
+ }
+
+ if (funcs->getAttribLocation)
+ return funcs->getAttribLocation(program, name);
+ funcs->getAttribLocation = qglfResolveGetAttribLocation;
+ return int(0);
+}
+
+static void qglfResolveGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetBufferParameteriv"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->getBufferParameteriv) {
+ funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetBufferParameterivOES"));
+ }
+#endif
+ if (!funcs->getBufferParameteriv) {
+ funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetBufferParameterivEXT"));
+ }
+ if (!funcs->getBufferParameteriv) {
+ funcs->getBufferParameteriv = (type_glGetBufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetBufferParameterivARB"));
+ }
+
+ if (funcs->getBufferParameteriv)
+ funcs->getBufferParameteriv(target, pname, params);
+ else
+ funcs->getBufferParameteriv = qglfResolveGetBufferParameteriv;
+}
+
+static void qglfResolveGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
+ context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameteriv"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->getFramebufferAttachmentParameteriv) {
+ funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
+ context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivOES"));
+ }
+#endif
+ if (!funcs->getFramebufferAttachmentParameteriv) {
+ funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
+ context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivEXT"));
+ }
+ if (!funcs->getFramebufferAttachmentParameteriv) {
+ funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv)
+ context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivARB"));
+ }
+
+ if (funcs->getFramebufferAttachmentParameteriv)
+ funcs->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
+ else
+ funcs->getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv;
+}
+
+static void qglfResolveGetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetProgramiv)(GLuint program, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getProgramiv = (type_glGetProgramiv)
+ context->getProcAddress(QLatin1String("glGetProgramiv"));
+ if (!funcs->getProgramiv) {
+ funcs->getProgramiv = (type_glGetProgramiv)
+ context->getProcAddress(QLatin1String("glGetObjectParameterivARB"));
+ }
+
+ if (funcs->getProgramiv)
+ funcs->getProgramiv(program, pname, params);
+ else
+ funcs->getProgramiv = qglfResolveGetProgramiv;
+}
+
+static void qglfResolveGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+ typedef void (QGLF_APIENTRYP type_glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getProgramInfoLog = (type_glGetProgramInfoLog)
+ context->getProcAddress(QLatin1String("glGetProgramInfoLog"));
+ if (!funcs->getProgramInfoLog) {
+ funcs->getProgramInfoLog = (type_glGetProgramInfoLog)
+ context->getProcAddress(QLatin1String("glGetInfoLogARB"));
+ }
+
+ if (funcs->getProgramInfoLog)
+ funcs->getProgramInfoLog(program, bufsize, length, infolog);
+ else
+ funcs->getProgramInfoLog = qglfResolveGetProgramInfoLog;
+}
+
+static void qglfResolveGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetRenderbufferParameteriv"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->getRenderbufferParameteriv) {
+ funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetRenderbufferParameterivOES"));
+ }
+#endif
+ if (!funcs->getRenderbufferParameteriv) {
+ funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetRenderbufferParameterivEXT"));
+ }
+ if (!funcs->getRenderbufferParameteriv) {
+ funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv)
+ context->getProcAddress(QLatin1String("glGetRenderbufferParameterivARB"));
+ }
+
+ if (funcs->getRenderbufferParameteriv)
+ funcs->getRenderbufferParameteriv(target, pname, params);
+ else
+ funcs->getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv;
+}
+
+static void qglfResolveGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetShaderiv)(GLuint shader, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getShaderiv = (type_glGetShaderiv)
+ context->getProcAddress(QLatin1String("glGetShaderiv"));
+ if (!funcs->getShaderiv) {
+ funcs->getShaderiv = (type_glGetShaderiv)
+ context->getProcAddress(QLatin1String("glGetObjectParameterivARB"));
+ }
+
+ if (funcs->getShaderiv)
+ funcs->getShaderiv(shader, pname, params);
+ else
+ funcs->getShaderiv = qglfResolveGetShaderiv;
+}
+
+static void qglfResolveGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+ typedef void (QGLF_APIENTRYP type_glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getShaderInfoLog = (type_glGetShaderInfoLog)
+ context->getProcAddress(QLatin1String("glGetShaderInfoLog"));
+ if (!funcs->getShaderInfoLog) {
+ funcs->getShaderInfoLog = (type_glGetShaderInfoLog)
+ context->getProcAddress(QLatin1String("glGetInfoLogARB"));
+ }
+
+ if (funcs->getShaderInfoLog)
+ funcs->getShaderInfoLog(shader, bufsize, length, infolog);
+ else
+ funcs->getShaderInfoLog = qglfResolveGetShaderInfoLog;
+}
+
+static void qglfSpecialGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+ Q_UNUSED(shadertype);
+ Q_UNUSED(precisiontype);
+ range[0] = range[1] = precision[0] = 0;
+}
+
+static void qglfResolveGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+ typedef void (QGLF_APIENTRYP type_glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
+ context->getProcAddress(QLatin1String("glGetShaderPrecisionFormat"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->getShaderPrecisionFormat) {
+ funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
+ context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatOES"));
+ }
+#endif
+ if (!funcs->getShaderPrecisionFormat) {
+ funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
+ context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatEXT"));
+ }
+ if (!funcs->getShaderPrecisionFormat) {
+ funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat)
+ context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatARB"));
+ }
+
+ if (!funcs->getShaderPrecisionFormat)
+ funcs->getShaderPrecisionFormat = qglfSpecialGetShaderPrecisionFormat;
+
+ funcs->getShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+}
+
+static void qglfResolveGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+{
+ typedef void (QGLF_APIENTRYP type_glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getShaderSource = (type_glGetShaderSource)
+ context->getProcAddress(QLatin1String("glGetShaderSource"));
+ if (!funcs->getShaderSource) {
+ funcs->getShaderSource = (type_glGetShaderSource)
+ context->getProcAddress(QLatin1String("glGetShaderSourceARB"));
+ }
+
+ if (funcs->getShaderSource)
+ funcs->getShaderSource(shader, bufsize, length, source);
+ else
+ funcs->getShaderSource = qglfResolveGetShaderSource;
+}
+
+static void qglfResolveGetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetUniformfv)(GLuint program, GLint location, GLfloat* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getUniformfv = (type_glGetUniformfv)
+ context->getProcAddress(QLatin1String("glGetUniformfv"));
+ if (!funcs->getUniformfv) {
+ funcs->getUniformfv = (type_glGetUniformfv)
+ context->getProcAddress(QLatin1String("glGetUniformfvARB"));
+ }
+
+ if (funcs->getUniformfv)
+ funcs->getUniformfv(program, location, params);
+ else
+ funcs->getUniformfv = qglfResolveGetUniformfv;
+}
+
+static void qglfResolveGetUniformiv(GLuint program, GLint location, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetUniformiv)(GLuint program, GLint location, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getUniformiv = (type_glGetUniformiv)
+ context->getProcAddress(QLatin1String("glGetUniformiv"));
+ if (!funcs->getUniformiv) {
+ funcs->getUniformiv = (type_glGetUniformiv)
+ context->getProcAddress(QLatin1String("glGetUniformivARB"));
+ }
+
+ if (funcs->getUniformiv)
+ funcs->getUniformiv(program, location, params);
+ else
+ funcs->getUniformiv = qglfResolveGetUniformiv;
+}
+
+static int qglfResolveGetUniformLocation(GLuint program, const char* name)
+{
+ typedef int (QGLF_APIENTRYP type_glGetUniformLocation)(GLuint program, const char* name);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getUniformLocation = (type_glGetUniformLocation)
+ context->getProcAddress(QLatin1String("glGetUniformLocation"));
+ if (!funcs->getUniformLocation) {
+ funcs->getUniformLocation = (type_glGetUniformLocation)
+ context->getProcAddress(QLatin1String("glGetUniformLocationARB"));
+ }
+
+ if (funcs->getUniformLocation)
+ return funcs->getUniformLocation(program, name);
+ funcs->getUniformLocation = qglfResolveGetUniformLocation;
+ return int(0);
+}
+
+static void qglfResolveGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getVertexAttribfv = (type_glGetVertexAttribfv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribfv"));
+ if (!funcs->getVertexAttribfv) {
+ funcs->getVertexAttribfv = (type_glGetVertexAttribfv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribfvARB"));
+ }
+
+ if (funcs->getVertexAttribfv)
+ funcs->getVertexAttribfv(index, pname, params);
+ else
+ funcs->getVertexAttribfv = qglfResolveGetVertexAttribfv;
+}
+
+static void qglfResolveGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+ typedef void (QGLF_APIENTRYP type_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getVertexAttribiv = (type_glGetVertexAttribiv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribiv"));
+ if (!funcs->getVertexAttribiv) {
+ funcs->getVertexAttribiv = (type_glGetVertexAttribiv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribivARB"));
+ }
+
+ if (funcs->getVertexAttribiv)
+ funcs->getVertexAttribiv(index, pname, params);
+ else
+ funcs->getVertexAttribiv = qglfResolveGetVertexAttribiv;
+}
+
+static void qglfResolveGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+ typedef void (QGLF_APIENTRYP type_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribPointerv"));
+ if (!funcs->getVertexAttribPointerv) {
+ funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv)
+ context->getProcAddress(QLatin1String("glGetVertexAttribPointervARB"));
+ }
+
+ if (funcs->getVertexAttribPointerv)
+ funcs->getVertexAttribPointerv(index, pname, pointer);
+ else
+ funcs->getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv;
+}
+
+static GLboolean qglfResolveIsBuffer(GLuint buffer)
+{
+ typedef GLboolean (QGLF_APIENTRYP type_glIsBuffer)(GLuint buffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->isBuffer = (type_glIsBuffer)
+ context->getProcAddress(QLatin1String("glIsBuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->isBuffer) {
+ funcs->isBuffer = (type_glIsBuffer)
+ context->getProcAddress(QLatin1String("glIsBufferOES"));
+ }
+#endif
+ if (!funcs->isBuffer) {
+ funcs->isBuffer = (type_glIsBuffer)
+ context->getProcAddress(QLatin1String("glIsBufferEXT"));
+ }
+ if (!funcs->isBuffer) {
+ funcs->isBuffer = (type_glIsBuffer)
+ context->getProcAddress(QLatin1String("glIsBufferARB"));
+ }
+
+ if (funcs->isBuffer)
+ return funcs->isBuffer(buffer);
+ funcs->isBuffer = qglfResolveIsBuffer;
+ return GLboolean(0);
+}
+
+static GLboolean qglfResolveIsFramebuffer(GLuint framebuffer)
+{
+ typedef GLboolean (QGLF_APIENTRYP type_glIsFramebuffer)(GLuint framebuffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->isFramebuffer = (type_glIsFramebuffer)
+ context->getProcAddress(QLatin1String("glIsFramebuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->isFramebuffer) {
+ funcs->isFramebuffer = (type_glIsFramebuffer)
+ context->getProcAddress(QLatin1String("glIsFramebufferOES"));
+ }
+#endif
+ if (!funcs->isFramebuffer) {
+ funcs->isFramebuffer = (type_glIsFramebuffer)
+ context->getProcAddress(QLatin1String("glIsFramebufferEXT"));
+ }
+ if (!funcs->isFramebuffer) {
+ funcs->isFramebuffer = (type_glIsFramebuffer)
+ context->getProcAddress(QLatin1String("glIsFramebufferARB"));
+ }
+
+ if (funcs->isFramebuffer)
+ return funcs->isFramebuffer(framebuffer);
+ funcs->isFramebuffer = qglfResolveIsFramebuffer;
+ return GLboolean(0);
+}
+
+static GLboolean qglfSpecialIsProgram(GLuint program)
+{
+ return program != 0;
+}
+
+static GLboolean qglfResolveIsProgram(GLuint program)
+{
+ typedef GLboolean (QGLF_APIENTRYP type_glIsProgram)(GLuint program);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->isProgram = (type_glIsProgram)
+ context->getProcAddress(QLatin1String("glIsProgram"));
+ if (!funcs->isProgram) {
+ funcs->isProgram = (type_glIsProgram)
+ context->getProcAddress(QLatin1String("glIsProgramARB"));
+ }
+
+ if (!funcs->isProgram)
+ funcs->isProgram = qglfSpecialIsProgram;
+
+ return funcs->isProgram(program);
+}
+
+static GLboolean qglfResolveIsRenderbuffer(GLuint renderbuffer)
+{
+ typedef GLboolean (QGLF_APIENTRYP type_glIsRenderbuffer)(GLuint renderbuffer);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->isRenderbuffer = (type_glIsRenderbuffer)
+ context->getProcAddress(QLatin1String("glIsRenderbuffer"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->isRenderbuffer) {
+ funcs->isRenderbuffer = (type_glIsRenderbuffer)
+ context->getProcAddress(QLatin1String("glIsRenderbufferOES"));
+ }
+#endif
+ if (!funcs->isRenderbuffer) {
+ funcs->isRenderbuffer = (type_glIsRenderbuffer)
+ context->getProcAddress(QLatin1String("glIsRenderbufferEXT"));
+ }
+ if (!funcs->isRenderbuffer) {
+ funcs->isRenderbuffer = (type_glIsRenderbuffer)
+ context->getProcAddress(QLatin1String("glIsRenderbufferARB"));
+ }
+
+ if (funcs->isRenderbuffer)
+ return funcs->isRenderbuffer(renderbuffer);
+ funcs->isRenderbuffer = qglfResolveIsRenderbuffer;
+ return GLboolean(0);
+}
+
+static GLboolean qglfSpecialIsShader(GLuint shader)
+{
+ return shader != 0;
+}
+
+static GLboolean qglfResolveIsShader(GLuint shader)
+{
+ typedef GLboolean (QGLF_APIENTRYP type_glIsShader)(GLuint shader);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->isShader = (type_glIsShader)
+ context->getProcAddress(QLatin1String("glIsShader"));
+ if (!funcs->isShader) {
+ funcs->isShader = (type_glIsShader)
+ context->getProcAddress(QLatin1String("glIsShaderARB"));
+ }
+
+ if (!funcs->isShader)
+ funcs->isShader = qglfSpecialIsShader;
+
+ return funcs->isShader(shader);
+}
+
+static void qglfResolveLinkProgram(GLuint program)
+{
+ typedef void (QGLF_APIENTRYP type_glLinkProgram)(GLuint program);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->linkProgram = (type_glLinkProgram)
+ context->getProcAddress(QLatin1String("glLinkProgram"));
+ if (!funcs->linkProgram) {
+ funcs->linkProgram = (type_glLinkProgram)
+ context->getProcAddress(QLatin1String("glLinkProgramARB"));
+ }
+
+ if (funcs->linkProgram)
+ funcs->linkProgram(program);
+ else
+ funcs->linkProgram = qglfResolveLinkProgram;
+}
+
+static void qglfSpecialReleaseShaderCompiler()
+{
+}
+
+static void qglfResolveReleaseShaderCompiler()
+{
+ typedef void (QGLF_APIENTRYP type_glReleaseShaderCompiler)();
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler)
+ context->getProcAddress(QLatin1String("glReleaseShaderCompiler"));
+ if (!funcs->releaseShaderCompiler) {
+ funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler)
+ context->getProcAddress(QLatin1String("glReleaseShaderCompilerARB"));
+ }
+
+ if (!funcs->releaseShaderCompiler)
+ funcs->releaseShaderCompiler = qglfSpecialReleaseShaderCompiler;
+
+ funcs->releaseShaderCompiler();
+}
+
+static void qglfResolveRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ typedef void (QGLF_APIENTRYP type_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->renderbufferStorage = (type_glRenderbufferStorage)
+ context->getProcAddress(QLatin1String("glRenderbufferStorage"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->renderbufferStorage) {
+ funcs->renderbufferStorage = (type_glRenderbufferStorage)
+ context->getProcAddress(QLatin1String("glRenderbufferStorageOES"));
+ }
+#endif
+ if (!funcs->renderbufferStorage) {
+ funcs->renderbufferStorage = (type_glRenderbufferStorage)
+ context->getProcAddress(QLatin1String("glRenderbufferStorageEXT"));
+ }
+ if (!funcs->renderbufferStorage) {
+ funcs->renderbufferStorage = (type_glRenderbufferStorage)
+ context->getProcAddress(QLatin1String("glRenderbufferStorageARB"));
+ }
+
+ if (funcs->renderbufferStorage)
+ funcs->renderbufferStorage(target, internalformat, width, height);
+ else
+ funcs->renderbufferStorage = qglfResolveRenderbufferStorage;
+}
+
+static void qglfResolveSampleCoverage(GLclampf value, GLboolean invert)
+{
+ typedef void (QGLF_APIENTRYP type_glSampleCoverage)(GLclampf value, GLboolean invert);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->sampleCoverage = (type_glSampleCoverage)
+ context->getProcAddress(QLatin1String("glSampleCoverage"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->sampleCoverage) {
+ funcs->sampleCoverage = (type_glSampleCoverage)
+ context->getProcAddress(QLatin1String("glSampleCoverageOES"));
+ }
+#endif
+ if (!funcs->sampleCoverage) {
+ funcs->sampleCoverage = (type_glSampleCoverage)
+ context->getProcAddress(QLatin1String("glSampleCoverageEXT"));
+ }
+ if (!funcs->sampleCoverage) {
+ funcs->sampleCoverage = (type_glSampleCoverage)
+ context->getProcAddress(QLatin1String("glSampleCoverageARB"));
+ }
+
+ if (funcs->sampleCoverage)
+ funcs->sampleCoverage(value, invert);
+ else
+ funcs->sampleCoverage = qglfResolveSampleCoverage;
+}
+
+static void qglfResolveShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
+{
+ typedef void (QGLF_APIENTRYP type_glShaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->shaderBinary = (type_glShaderBinary)
+ context->getProcAddress(QLatin1String("glShaderBinary"));
+ if (!funcs->shaderBinary) {
+ funcs->shaderBinary = (type_glShaderBinary)
+ context->getProcAddress(QLatin1String("glShaderBinaryARB"));
+ }
+
+ if (funcs->shaderBinary)
+ funcs->shaderBinary(n, shaders, binaryformat, binary, length);
+ else
+ funcs->shaderBinary = qglfResolveShaderBinary;
+}
+
+static void qglfResolveShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
+{
+ typedef void (QGLF_APIENTRYP type_glShaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->shaderSource = (type_glShaderSource)
+ context->getProcAddress(QLatin1String("glShaderSource"));
+ if (!funcs->shaderSource) {
+ funcs->shaderSource = (type_glShaderSource)
+ context->getProcAddress(QLatin1String("glShaderSourceARB"));
+ }
+
+ if (funcs->shaderSource)
+ funcs->shaderSource(shader, count, string, length);
+ else
+ funcs->shaderSource = qglfResolveShaderSource;
+}
+
+static void qglfResolveStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ typedef void (QGLF_APIENTRYP type_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
+ context->getProcAddress(QLatin1String("glStencilFuncSeparate"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->stencilFuncSeparate) {
+ funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
+ context->getProcAddress(QLatin1String("glStencilFuncSeparateOES"));
+ }
+#endif
+ if (!funcs->stencilFuncSeparate) {
+ funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
+ context->getProcAddress(QLatin1String("glStencilFuncSeparateEXT"));
+ }
+ if (!funcs->stencilFuncSeparate) {
+ funcs->stencilFuncSeparate = (type_glStencilFuncSeparate)
+ context->getProcAddress(QLatin1String("glStencilFuncSeparateARB"));
+ }
+
+ if (funcs->stencilFuncSeparate)
+ funcs->stencilFuncSeparate(face, func, ref, mask);
+ else
+ funcs->stencilFuncSeparate = qglfResolveStencilFuncSeparate;
+}
+
+static void qglfResolveStencilMaskSeparate(GLenum face, GLuint mask)
+{
+ typedef void (QGLF_APIENTRYP type_glStencilMaskSeparate)(GLenum face, GLuint mask);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
+ context->getProcAddress(QLatin1String("glStencilMaskSeparate"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->stencilMaskSeparate) {
+ funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
+ context->getProcAddress(QLatin1String("glStencilMaskSeparateOES"));
+ }
+#endif
+ if (!funcs->stencilMaskSeparate) {
+ funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
+ context->getProcAddress(QLatin1String("glStencilMaskSeparateEXT"));
+ }
+ if (!funcs->stencilMaskSeparate) {
+ funcs->stencilMaskSeparate = (type_glStencilMaskSeparate)
+ context->getProcAddress(QLatin1String("glStencilMaskSeparateARB"));
+ }
+
+ if (funcs->stencilMaskSeparate)
+ funcs->stencilMaskSeparate(face, mask);
+ else
+ funcs->stencilMaskSeparate = qglfResolveStencilMaskSeparate;
+}
+
+static void qglfResolveStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ typedef void (QGLF_APIENTRYP type_glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->stencilOpSeparate = (type_glStencilOpSeparate)
+ context->getProcAddress(QLatin1String("glStencilOpSeparate"));
+#ifdef QT_OPENGL_ES
+ if (!funcs->stencilOpSeparate) {
+ funcs->stencilOpSeparate = (type_glStencilOpSeparate)
+ context->getProcAddress(QLatin1String("glStencilOpSeparateOES"));
+ }
+#endif
+ if (!funcs->stencilOpSeparate) {
+ funcs->stencilOpSeparate = (type_glStencilOpSeparate)
+ context->getProcAddress(QLatin1String("glStencilOpSeparateEXT"));
+ }
+ if (!funcs->stencilOpSeparate) {
+ funcs->stencilOpSeparate = (type_glStencilOpSeparate)
+ context->getProcAddress(QLatin1String("glStencilOpSeparateARB"));
+ }
+
+ if (funcs->stencilOpSeparate)
+ funcs->stencilOpSeparate(face, fail, zfail, zpass);
+ else
+ funcs->stencilOpSeparate = qglfResolveStencilOpSeparate;
+}
+
+static void qglfResolveUniform1f(GLint location, GLfloat x)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform1f)(GLint location, GLfloat x);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform1f = (type_glUniform1f)
+ context->getProcAddress(QLatin1String("glUniform1f"));
+ if (!funcs->uniform1f) {
+ funcs->uniform1f = (type_glUniform1f)
+ context->getProcAddress(QLatin1String("glUniform1fARB"));
+ }
+
+ if (funcs->uniform1f)
+ funcs->uniform1f(location, x);
+ else
+ funcs->uniform1f = qglfResolveUniform1f;
+}
+
+static void qglfResolveUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform1fv)(GLint location, GLsizei count, const GLfloat* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform1fv = (type_glUniform1fv)
+ context->getProcAddress(QLatin1String("glUniform1fv"));
+ if (!funcs->uniform1fv) {
+ funcs->uniform1fv = (type_glUniform1fv)
+ context->getProcAddress(QLatin1String("glUniform1fvARB"));
+ }
+
+ if (funcs->uniform1fv)
+ funcs->uniform1fv(location, count, v);
+ else
+ funcs->uniform1fv = qglfResolveUniform1fv;
+}
+
+static void qglfResolveUniform1i(GLint location, GLint x)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform1i)(GLint location, GLint x);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform1i = (type_glUniform1i)
+ context->getProcAddress(QLatin1String("glUniform1i"));
+ if (!funcs->uniform1i) {
+ funcs->uniform1i = (type_glUniform1i)
+ context->getProcAddress(QLatin1String("glUniform1iARB"));
+ }
+
+ if (funcs->uniform1i)
+ funcs->uniform1i(location, x);
+ else
+ funcs->uniform1i = qglfResolveUniform1i;
+}
+
+static void qglfResolveUniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform1iv)(GLint location, GLsizei count, const GLint* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform1iv = (type_glUniform1iv)
+ context->getProcAddress(QLatin1String("glUniform1iv"));
+ if (!funcs->uniform1iv) {
+ funcs->uniform1iv = (type_glUniform1iv)
+ context->getProcAddress(QLatin1String("glUniform1ivARB"));
+ }
+
+ if (funcs->uniform1iv)
+ funcs->uniform1iv(location, count, v);
+ else
+ funcs->uniform1iv = qglfResolveUniform1iv;
+}
+
+static void qglfResolveUniform2f(GLint location, GLfloat x, GLfloat y)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform2f)(GLint location, GLfloat x, GLfloat y);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform2f = (type_glUniform2f)
+ context->getProcAddress(QLatin1String("glUniform2f"));
+ if (!funcs->uniform2f) {
+ funcs->uniform2f = (type_glUniform2f)
+ context->getProcAddress(QLatin1String("glUniform2fARB"));
+ }
+
+ if (funcs->uniform2f)
+ funcs->uniform2f(location, x, y);
+ else
+ funcs->uniform2f = qglfResolveUniform2f;
+}
+
+static void qglfResolveUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform2fv)(GLint location, GLsizei count, const GLfloat* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform2fv = (type_glUniform2fv)
+ context->getProcAddress(QLatin1String("glUniform2fv"));
+ if (!funcs->uniform2fv) {
+ funcs->uniform2fv = (type_glUniform2fv)
+ context->getProcAddress(QLatin1String("glUniform2fvARB"));
+ }
+
+ if (funcs->uniform2fv)
+ funcs->uniform2fv(location, count, v);
+ else
+ funcs->uniform2fv = qglfResolveUniform2fv;
+}
+
+static void qglfResolveUniform2i(GLint location, GLint x, GLint y)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform2i)(GLint location, GLint x, GLint y);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform2i = (type_glUniform2i)
+ context->getProcAddress(QLatin1String("glUniform2i"));
+ if (!funcs->uniform2i) {
+ funcs->uniform2i = (type_glUniform2i)
+ context->getProcAddress(QLatin1String("glUniform2iARB"));
+ }
+
+ if (funcs->uniform2i)
+ funcs->uniform2i(location, x, y);
+ else
+ funcs->uniform2i = qglfResolveUniform2i;
+}
+
+static void qglfResolveUniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform2iv)(GLint location, GLsizei count, const GLint* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform2iv = (type_glUniform2iv)
+ context->getProcAddress(QLatin1String("glUniform2iv"));
+ if (!funcs->uniform2iv) {
+ funcs->uniform2iv = (type_glUniform2iv)
+ context->getProcAddress(QLatin1String("glUniform2ivARB"));
+ }
+
+ if (funcs->uniform2iv)
+ funcs->uniform2iv(location, count, v);
+ else
+ funcs->uniform2iv = qglfResolveUniform2iv;
+}
+
+static void qglfResolveUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform3f = (type_glUniform3f)
+ context->getProcAddress(QLatin1String("glUniform3f"));
+ if (!funcs->uniform3f) {
+ funcs->uniform3f = (type_glUniform3f)
+ context->getProcAddress(QLatin1String("glUniform3fARB"));
+ }
+
+ if (funcs->uniform3f)
+ funcs->uniform3f(location, x, y, z);
+ else
+ funcs->uniform3f = qglfResolveUniform3f;
+}
+
+static void qglfResolveUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform3fv)(GLint location, GLsizei count, const GLfloat* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform3fv = (type_glUniform3fv)
+ context->getProcAddress(QLatin1String("glUniform3fv"));
+ if (!funcs->uniform3fv) {
+ funcs->uniform3fv = (type_glUniform3fv)
+ context->getProcAddress(QLatin1String("glUniform3fvARB"));
+ }
+
+ if (funcs->uniform3fv)
+ funcs->uniform3fv(location, count, v);
+ else
+ funcs->uniform3fv = qglfResolveUniform3fv;
+}
+
+static void qglfResolveUniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform3i)(GLint location, GLint x, GLint y, GLint z);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform3i = (type_glUniform3i)
+ context->getProcAddress(QLatin1String("glUniform3i"));
+ if (!funcs->uniform3i) {
+ funcs->uniform3i = (type_glUniform3i)
+ context->getProcAddress(QLatin1String("glUniform3iARB"));
+ }
+
+ if (funcs->uniform3i)
+ funcs->uniform3i(location, x, y, z);
+ else
+ funcs->uniform3i = qglfResolveUniform3i;
+}
+
+static void qglfResolveUniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform3iv)(GLint location, GLsizei count, const GLint* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform3iv = (type_glUniform3iv)
+ context->getProcAddress(QLatin1String("glUniform3iv"));
+ if (!funcs->uniform3iv) {
+ funcs->uniform3iv = (type_glUniform3iv)
+ context->getProcAddress(QLatin1String("glUniform3ivARB"));
+ }
+
+ if (funcs->uniform3iv)
+ funcs->uniform3iv(location, count, v);
+ else
+ funcs->uniform3iv = qglfResolveUniform3iv;
+}
+
+static void qglfResolveUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform4f = (type_glUniform4f)
+ context->getProcAddress(QLatin1String("glUniform4f"));
+ if (!funcs->uniform4f) {
+ funcs->uniform4f = (type_glUniform4f)
+ context->getProcAddress(QLatin1String("glUniform4fARB"));
+ }
+
+ if (funcs->uniform4f)
+ funcs->uniform4f(location, x, y, z, w);
+ else
+ funcs->uniform4f = qglfResolveUniform4f;
+}
+
+static void qglfResolveUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform4fv)(GLint location, GLsizei count, const GLfloat* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform4fv = (type_glUniform4fv)
+ context->getProcAddress(QLatin1String("glUniform4fv"));
+ if (!funcs->uniform4fv) {
+ funcs->uniform4fv = (type_glUniform4fv)
+ context->getProcAddress(QLatin1String("glUniform4fvARB"));
+ }
+
+ if (funcs->uniform4fv)
+ funcs->uniform4fv(location, count, v);
+ else
+ funcs->uniform4fv = qglfResolveUniform4fv;
+}
+
+static void qglfResolveUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform4i = (type_glUniform4i)
+ context->getProcAddress(QLatin1String("glUniform4i"));
+ if (!funcs->uniform4i) {
+ funcs->uniform4i = (type_glUniform4i)
+ context->getProcAddress(QLatin1String("glUniform4iARB"));
+ }
+
+ if (funcs->uniform4i)
+ funcs->uniform4i(location, x, y, z, w);
+ else
+ funcs->uniform4i = qglfResolveUniform4i;
+}
+
+static void qglfResolveUniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+ typedef void (QGLF_APIENTRYP type_glUniform4iv)(GLint location, GLsizei count, const GLint* v);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniform4iv = (type_glUniform4iv)
+ context->getProcAddress(QLatin1String("glUniform4iv"));
+ if (!funcs->uniform4iv) {
+ funcs->uniform4iv = (type_glUniform4iv)
+ context->getProcAddress(QLatin1String("glUniform4ivARB"));
+ }
+
+ if (funcs->uniform4iv)
+ funcs->uniform4iv(location, count, v);
+ else
+ funcs->uniform4iv = qglfResolveUniform4iv;
+}
+
+static void qglfResolveUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ typedef void (QGLF_APIENTRYP type_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniformMatrix2fv = (type_glUniformMatrix2fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix2fv"));
+ if (!funcs->uniformMatrix2fv) {
+ funcs->uniformMatrix2fv = (type_glUniformMatrix2fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix2fvARB"));
+ }
+
+ if (funcs->uniformMatrix2fv)
+ funcs->uniformMatrix2fv(location, count, transpose, value);
+ else
+ funcs->uniformMatrix2fv = qglfResolveUniformMatrix2fv;
+}
+
+static void qglfResolveUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ typedef void (QGLF_APIENTRYP type_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniformMatrix3fv = (type_glUniformMatrix3fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix3fv"));
+ if (!funcs->uniformMatrix3fv) {
+ funcs->uniformMatrix3fv = (type_glUniformMatrix3fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix3fvARB"));
+ }
+
+ if (funcs->uniformMatrix3fv)
+ funcs->uniformMatrix3fv(location, count, transpose, value);
+ else
+ funcs->uniformMatrix3fv = qglfResolveUniformMatrix3fv;
+}
+
+static void qglfResolveUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ typedef void (QGLF_APIENTRYP type_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->uniformMatrix4fv = (type_glUniformMatrix4fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix4fv"));
+ if (!funcs->uniformMatrix4fv) {
+ funcs->uniformMatrix4fv = (type_glUniformMatrix4fv)
+ context->getProcAddress(QLatin1String("glUniformMatrix4fvARB"));
+ }
+
+ if (funcs->uniformMatrix4fv)
+ funcs->uniformMatrix4fv(location, count, transpose, value);
+ else
+ funcs->uniformMatrix4fv = qglfResolveUniformMatrix4fv;
+}
+
+static void qglfResolveUseProgram(GLuint program)
+{
+ typedef void (QGLF_APIENTRYP type_glUseProgram)(GLuint program);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->useProgram = (type_glUseProgram)
+ context->getProcAddress(QLatin1String("glUseProgram"));
+ if (!funcs->useProgram) {
+ funcs->useProgram = (type_glUseProgram)
+ context->getProcAddress(QLatin1String("glUseProgramObjectARB"));
+ }
+
+ if (funcs->useProgram)
+ funcs->useProgram(program);
+ else
+ funcs->useProgram = qglfResolveUseProgram;
+}
+
+static void qglfResolveValidateProgram(GLuint program)
+{
+ typedef void (QGLF_APIENTRYP type_glValidateProgram)(GLuint program);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->validateProgram = (type_glValidateProgram)
+ context->getProcAddress(QLatin1String("glValidateProgram"));
+ if (!funcs->validateProgram) {
+ funcs->validateProgram = (type_glValidateProgram)
+ context->getProcAddress(QLatin1String("glValidateProgramARB"));
+ }
+
+ if (funcs->validateProgram)
+ funcs->validateProgram(program);
+ else
+ funcs->validateProgram = qglfResolveValidateProgram;
+}
+
+static void qglfResolveVertexAttrib1f(GLuint indx, GLfloat x)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib1f)(GLuint indx, GLfloat x);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib1f = (type_glVertexAttrib1f)
+ context->getProcAddress(QLatin1String("glVertexAttrib1f"));
+ if (!funcs->vertexAttrib1f) {
+ funcs->vertexAttrib1f = (type_glVertexAttrib1f)
+ context->getProcAddress(QLatin1String("glVertexAttrib1fARB"));
+ }
+
+ if (funcs->vertexAttrib1f)
+ funcs->vertexAttrib1f(indx, x);
+ else
+ funcs->vertexAttrib1f = qglfResolveVertexAttrib1f;
+}
+
+static void qglfResolveVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib1fv)(GLuint indx, const GLfloat* values);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib1fv = (type_glVertexAttrib1fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib1fv"));
+ if (!funcs->vertexAttrib1fv) {
+ funcs->vertexAttrib1fv = (type_glVertexAttrib1fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib1fvARB"));
+ }
+
+ if (funcs->vertexAttrib1fv)
+ funcs->vertexAttrib1fv(indx, values);
+ else
+ funcs->vertexAttrib1fv = qglfResolveVertexAttrib1fv;
+}
+
+static void qglfResolveVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib2f = (type_glVertexAttrib2f)
+ context->getProcAddress(QLatin1String("glVertexAttrib2f"));
+ if (!funcs->vertexAttrib2f) {
+ funcs->vertexAttrib2f = (type_glVertexAttrib2f)
+ context->getProcAddress(QLatin1String("glVertexAttrib2fARB"));
+ }
+
+ if (funcs->vertexAttrib2f)
+ funcs->vertexAttrib2f(indx, x, y);
+ else
+ funcs->vertexAttrib2f = qglfResolveVertexAttrib2f;
+}
+
+static void qglfResolveVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib2fv)(GLuint indx, const GLfloat* values);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib2fv = (type_glVertexAttrib2fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib2fv"));
+ if (!funcs->vertexAttrib2fv) {
+ funcs->vertexAttrib2fv = (type_glVertexAttrib2fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib2fvARB"));
+ }
+
+ if (funcs->vertexAttrib2fv)
+ funcs->vertexAttrib2fv(indx, values);
+ else
+ funcs->vertexAttrib2fv = qglfResolveVertexAttrib2fv;
+}
+
+static void qglfResolveVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib3f = (type_glVertexAttrib3f)
+ context->getProcAddress(QLatin1String("glVertexAttrib3f"));
+ if (!funcs->vertexAttrib3f) {
+ funcs->vertexAttrib3f = (type_glVertexAttrib3f)
+ context->getProcAddress(QLatin1String("glVertexAttrib3fARB"));
+ }
+
+ if (funcs->vertexAttrib3f)
+ funcs->vertexAttrib3f(indx, x, y, z);
+ else
+ funcs->vertexAttrib3f = qglfResolveVertexAttrib3f;
+}
+
+static void qglfResolveVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib3fv)(GLuint indx, const GLfloat* values);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib3fv = (type_glVertexAttrib3fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib3fv"));
+ if (!funcs->vertexAttrib3fv) {
+ funcs->vertexAttrib3fv = (type_glVertexAttrib3fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib3fvARB"));
+ }
+
+ if (funcs->vertexAttrib3fv)
+ funcs->vertexAttrib3fv(indx, values);
+ else
+ funcs->vertexAttrib3fv = qglfResolveVertexAttrib3fv;
+}
+
+static void qglfResolveVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib4f = (type_glVertexAttrib4f)
+ context->getProcAddress(QLatin1String("glVertexAttrib4f"));
+ if (!funcs->vertexAttrib4f) {
+ funcs->vertexAttrib4f = (type_glVertexAttrib4f)
+ context->getProcAddress(QLatin1String("glVertexAttrib4fARB"));
+ }
+
+ if (funcs->vertexAttrib4f)
+ funcs->vertexAttrib4f(indx, x, y, z, w);
+ else
+ funcs->vertexAttrib4f = qglfResolveVertexAttrib4f;
+}
+
+static void qglfResolveVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttrib4fv)(GLuint indx, const GLfloat* values);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttrib4fv = (type_glVertexAttrib4fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib4fv"));
+ if (!funcs->vertexAttrib4fv) {
+ funcs->vertexAttrib4fv = (type_glVertexAttrib4fv)
+ context->getProcAddress(QLatin1String("glVertexAttrib4fvARB"));
+ }
+
+ if (funcs->vertexAttrib4fv)
+ funcs->vertexAttrib4fv(indx, values);
+ else
+ funcs->vertexAttrib4fv = qglfResolveVertexAttrib4fv;
+}
+
+static void qglfResolveVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+ typedef void (QGLF_APIENTRYP type_glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
+
+ const QGLContext *context = QGLContext::currentContext();
+ QGLFunctionsPrivate *funcs = qt_gl_functions(context);
+
+ funcs->vertexAttribPointer = (type_glVertexAttribPointer)
+ context->getProcAddress(QLatin1String("glVertexAttribPointer"));
+ if (!funcs->vertexAttribPointer) {
+ funcs->vertexAttribPointer = (type_glVertexAttribPointer)
+ context->getProcAddress(QLatin1String("glVertexAttribPointerARB"));
+ }
+
+ if (funcs->vertexAttribPointer)
+ funcs->vertexAttribPointer(indx, size, type, normalized, stride, ptr);
+ else
+ funcs->vertexAttribPointer = qglfResolveVertexAttribPointer;
+}
+
+#endif // !QT_OPENGL_ES_2
+
+QGLFunctionsPrivate::QGLFunctionsPrivate(const QGLContext *)
+{
+#ifndef QT_OPENGL_ES_2
+ activeTexture = qglfResolveActiveTexture;
+ attachShader = qglfResolveAttachShader;
+ bindAttribLocation = qglfResolveBindAttribLocation;
+ bindBuffer = qglfResolveBindBuffer;
+ bindFramebuffer = qglfResolveBindFramebuffer;
+ bindRenderbuffer = qglfResolveBindRenderbuffer;
+ blendColor = qglfResolveBlendColor;
+ blendEquation = qglfResolveBlendEquation;
+ blendEquationSeparate = qglfResolveBlendEquationSeparate;
+ blendFuncSeparate = qglfResolveBlendFuncSeparate;
+ bufferData = qglfResolveBufferData;
+ bufferSubData = qglfResolveBufferSubData;
+ checkFramebufferStatus = qglfResolveCheckFramebufferStatus;
+ compileShader = qglfResolveCompileShader;
+ compressedTexImage2D = qglfResolveCompressedTexImage2D;
+ compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D;
+ createProgram = qglfResolveCreateProgram;
+ createShader = qglfResolveCreateShader;
+ deleteBuffers = qglfResolveDeleteBuffers;
+ deleteFramebuffers = qglfResolveDeleteFramebuffers;
+ deleteProgram = qglfResolveDeleteProgram;
+ deleteRenderbuffers = qglfResolveDeleteRenderbuffers;
+ deleteShader = qglfResolveDeleteShader;
+ detachShader = qglfResolveDetachShader;
+ disableVertexAttribArray = qglfResolveDisableVertexAttribArray;
+ enableVertexAttribArray = qglfResolveEnableVertexAttribArray;
+ framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer;
+ framebufferTexture2D = qglfResolveFramebufferTexture2D;
+ genBuffers = qglfResolveGenBuffers;
+ generateMipmap = qglfResolveGenerateMipmap;
+ genFramebuffers = qglfResolveGenFramebuffers;
+ genRenderbuffers = qglfResolveGenRenderbuffers;
+ getActiveAttrib = qglfResolveGetActiveAttrib;
+ getActiveUniform = qglfResolveGetActiveUniform;
+ getAttachedShaders = qglfResolveGetAttachedShaders;
+ getAttribLocation = qglfResolveGetAttribLocation;
+ getBufferParameteriv = qglfResolveGetBufferParameteriv;
+ getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv;
+ getProgramiv = qglfResolveGetProgramiv;
+ getProgramInfoLog = qglfResolveGetProgramInfoLog;
+ getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv;
+ getShaderiv = qglfResolveGetShaderiv;
+ getShaderInfoLog = qglfResolveGetShaderInfoLog;
+ getShaderPrecisionFormat = qglfResolveGetShaderPrecisionFormat;
+ getShaderSource = qglfResolveGetShaderSource;
+ getUniformfv = qglfResolveGetUniformfv;
+ getUniformiv = qglfResolveGetUniformiv;
+ getUniformLocation = qglfResolveGetUniformLocation;
+ getVertexAttribfv = qglfResolveGetVertexAttribfv;
+ getVertexAttribiv = qglfResolveGetVertexAttribiv;
+ getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv;
+ isBuffer = qglfResolveIsBuffer;
+ isFramebuffer = qglfResolveIsFramebuffer;
+ isProgram = qglfResolveIsProgram;
+ isRenderbuffer = qglfResolveIsRenderbuffer;
+ isShader = qglfResolveIsShader;
+ linkProgram = qglfResolveLinkProgram;
+ releaseShaderCompiler = qglfResolveReleaseShaderCompiler;
+ renderbufferStorage = qglfResolveRenderbufferStorage;
+ sampleCoverage = qglfResolveSampleCoverage;
+ shaderBinary = qglfResolveShaderBinary;
+ shaderSource = qglfResolveShaderSource;
+ stencilFuncSeparate = qglfResolveStencilFuncSeparate;
+ stencilMaskSeparate = qglfResolveStencilMaskSeparate;
+ stencilOpSeparate = qglfResolveStencilOpSeparate;
+ uniform1f = qglfResolveUniform1f;
+ uniform1fv = qglfResolveUniform1fv;
+ uniform1i = qglfResolveUniform1i;
+ uniform1iv = qglfResolveUniform1iv;
+ uniform2f = qglfResolveUniform2f;
+ uniform2fv = qglfResolveUniform2fv;
+ uniform2i = qglfResolveUniform2i;
+ uniform2iv = qglfResolveUniform2iv;
+ uniform3f = qglfResolveUniform3f;
+ uniform3fv = qglfResolveUniform3fv;
+ uniform3i = qglfResolveUniform3i;
+ uniform3iv = qglfResolveUniform3iv;
+ uniform4f = qglfResolveUniform4f;
+ uniform4fv = qglfResolveUniform4fv;
+ uniform4i = qglfResolveUniform4i;
+ uniform4iv = qglfResolveUniform4iv;
+ uniformMatrix2fv = qglfResolveUniformMatrix2fv;
+ uniformMatrix3fv = qglfResolveUniformMatrix3fv;
+ uniformMatrix4fv = qglfResolveUniformMatrix4fv;
+ useProgram = qglfResolveUseProgram;
+ validateProgram = qglfResolveValidateProgram;
+ vertexAttrib1f = qglfResolveVertexAttrib1f;
+ vertexAttrib1fv = qglfResolveVertexAttrib1fv;
+ vertexAttrib2f = qglfResolveVertexAttrib2f;
+ vertexAttrib2fv = qglfResolveVertexAttrib2fv;
+ vertexAttrib3f = qglfResolveVertexAttrib3f;
+ vertexAttrib3fv = qglfResolveVertexAttrib3fv;
+ vertexAttrib4f = qglfResolveVertexAttrib4f;
+ vertexAttrib4fv = qglfResolveVertexAttrib4fv;
+ vertexAttribPointer = qglfResolveVertexAttribPointer;
+#endif // !QT_OPENGL_ES_2
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qglfunctions.h b/src/opengl/qglfunctions.h
new file mode 100644
index 0000000..44d9bad
--- /dev/null
+++ b/src/opengl/qglfunctions.h
@@ -0,0 +1,2295 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 QGLFUNCTIONS_H
+#define QGLFUNCTIONS_H
+
+#ifdef __GLEW_H__
+#warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
+#warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h
+#endif
+
+#include <QtOpenGL/qgl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(OpenGL)
+
+// Types that aren't defined in all system's gl.h files.
+typedef ptrdiff_t qgl_GLintptr;
+typedef ptrdiff_t qgl_GLsizeiptr;
+
+#ifndef Q_WS_MAC
+# ifndef QGLF_APIENTRYP
+# ifdef QGLF_APIENTRY
+# define QGLF_APIENTRYP QGLF_APIENTRY *
+# else
+# define QGLF_APIENTRY
+# define QGLF_APIENTRYP *
+# endif
+# endif
+#else
+# define QGLF_APIENTRY
+# define QGLF_APIENTRYP *
+#endif
+
+struct QGLFunctionsPrivate;
+
+// Undefine any macros from GLEW, qglextensions_p.h, etc that
+// may interfere with the definition of QGLFunctions.
+#undef glActiveTexture
+#undef glAttachShader
+#undef glBindAttribLocation
+#undef glBindBuffer
+#undef glBindFramebuffer
+#undef glBindRenderbuffer
+#undef glBlendColor
+#undef glBlendEquation
+#undef glBlendEquationSeparate
+#undef glBlendFuncSeparate
+#undef glBufferData
+#undef glBufferSubData
+#undef glCheckFramebufferStatus
+#undef glClearDepthf
+#undef glCompileShader
+#undef glCompressedTexImage2D
+#undef glCompressedTexSubImage2D
+#undef glCreateProgram
+#undef glCreateShader
+#undef glDeleteBuffers
+#undef glDeleteFramebuffers
+#undef glDeleteProgram
+#undef glDeleteRenderbuffers
+#undef glDeleteShader
+#undef glDepthRangef
+#undef glDetachShader
+#undef glDisableVertexAttribArray
+#undef glEnableVertexAttribArray
+#undef glFramebufferRenderbuffer
+#undef glFramebufferTexture2D
+#undef glGenBuffers
+#undef glGenerateMipmap
+#undef glGenFramebuffers
+#undef glGenRenderbuffers
+#undef glGetActiveAttrib
+#undef glGetActiveUniform
+#undef glGetAttachedShaders
+#undef glGetAttribLocation
+#undef glGetBufferParameteriv
+#undef glGetFramebufferAttachmentParameteriv
+#undef glGetProgramiv
+#undef glGetProgramInfoLog
+#undef glGetRenderbufferParameteriv
+#undef glGetShaderiv
+#undef glGetShaderInfoLog
+#undef glGetShaderPrecisionFormat
+#undef glGetShaderSource
+#undef glGetUniformfv
+#undef glGetUniformiv
+#undef glGetUniformLocation
+#undef glGetVertexAttribfv
+#undef glGetVertexAttribiv
+#undef glGetVertexAttribPointerv
+#undef glIsBuffer
+#undef glIsFramebuffer
+#undef glIsProgram
+#undef glIsRenderbuffer
+#undef glIsShader
+#undef glLinkProgram
+#undef glReleaseShaderCompiler
+#undef glRenderbufferStorage
+#undef glSampleCoverage
+#undef glShaderBinary
+#undef glShaderSource
+#undef glStencilFuncSeparate
+#undef glStencilMaskSeparate
+#undef glStencilOpSeparate
+#undef glUniform1f
+#undef glUniform1fv
+#undef glUniform1i
+#undef glUniform1iv
+#undef glUniform2f
+#undef glUniform2fv
+#undef glUniform2i
+#undef glUniform2iv
+#undef glUniform3f
+#undef glUniform3fv
+#undef glUniform3i
+#undef glUniform3iv
+#undef glUniform4f
+#undef glUniform4fv
+#undef glUniform4i
+#undef glUniform4iv
+#undef glUniformMatrix2fv
+#undef glUniformMatrix3fv
+#undef glUniformMatrix4fv
+#undef glUseProgram
+#undef glValidateProgram
+#undef glVertexAttrib1f
+#undef glVertexAttrib1fv
+#undef glVertexAttrib2f
+#undef glVertexAttrib2fv
+#undef glVertexAttrib3f
+#undef glVertexAttrib3fv
+#undef glVertexAttrib4f
+#undef glVertexAttrib4fv
+#undef glVertexAttribPointer
+
+class Q_OPENGL_EXPORT QGLFunctions
+{
+public:
+ QGLFunctions();
+ explicit QGLFunctions(const QGLContext *context);
+ ~QGLFunctions() {}
+
+ enum OpenGLFeature
+ {
+ Multitexture = 0x0001,
+ Shaders = 0x0002,
+ Buffers = 0x0004,
+ Framebuffers = 0x0008,
+ BlendColor = 0x0010,
+ BlendEquation = 0x0020,
+ BlendEquationSeparate = 0x0040,
+ BlendFuncSeparate = 0x0080,
+ BlendSubtract = 0x0100,
+ CompressedTextures = 0x0200,
+ Multisample = 0x0400,
+ StencilSeparate = 0x0800,
+ NPOTTextures = 0x1000
+ };
+ Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)
+
+ QGLFunctions::OpenGLFeatures openGLFeatures() const;
+ bool hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const;
+
+ void initializeGLFunctions(const QGLContext *context = 0);
+
+ void glActiveTexture(GLenum texture);
+ void glAttachShader(GLuint program, GLuint shader);
+ void glBindAttribLocation(GLuint program, GLuint index, const char* name);
+ void glBindBuffer(GLenum target, GLuint buffer);
+ void glBindFramebuffer(GLenum target, GLuint framebuffer);
+ void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
+ void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ void glBlendEquation(GLenum mode);
+ void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
+ void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+ void glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
+ void glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
+ GLenum glCheckFramebufferStatus(GLenum target);
+ void glClearDepthf(GLclampf depth);
+ void glCompileShader(GLuint shader);
+ void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
+ void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
+ GLuint glCreateProgram();
+ GLuint glCreateShader(GLenum type);
+ void glDeleteBuffers(GLsizei n, const GLuint* buffers);
+ void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
+ void glDeleteProgram(GLuint program);
+ void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers);
+ void glDeleteShader(GLuint shader);
+ void glDepthRangef(GLclampf zNear, GLclampf zFar);
+ void glDetachShader(GLuint program, GLuint shader);
+ void glDisableVertexAttribArray(GLuint index);
+ void glEnableVertexAttribArray(GLuint index);
+ void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+ void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+ void glGenBuffers(GLsizei n, GLuint* buffers);
+ void glGenerateMipmap(GLenum target);
+ void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
+ void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers);
+ void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+ void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+ void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+ int glGetAttribLocation(GLuint program, const char* name);
+ void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
+ void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+ void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
+ void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
+ void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params);
+ void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
+ void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
+ void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+ void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
+ void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
+ void glGetUniformiv(GLuint program, GLint location, GLint* params);
+ int glGetUniformLocation(GLuint program, const char* name);
+ void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
+ void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
+ void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer);
+ GLboolean glIsBuffer(GLuint buffer);
+ GLboolean glIsFramebuffer(GLuint framebuffer);
+ GLboolean glIsProgram(GLuint program);
+ GLboolean glIsRenderbuffer(GLuint renderbuffer);
+ GLboolean glIsShader(GLuint shader);
+ void glLinkProgram(GLuint program);
+ void glReleaseShaderCompiler();
+ void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+ void glSampleCoverage(GLclampf value, GLboolean invert);
+ void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
+ void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length);
+ void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
+ void glStencilMaskSeparate(GLenum face, GLuint mask);
+ void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+ void glUniform1f(GLint location, GLfloat x);
+ void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
+ void glUniform1i(GLint location, GLint x);
+ void glUniform1iv(GLint location, GLsizei count, const GLint* v);
+ void glUniform2f(GLint location, GLfloat x, GLfloat y);
+ void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
+ void glUniform2i(GLint location, GLint x, GLint y);
+ void glUniform2iv(GLint location, GLsizei count, const GLint* v);
+ void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
+ void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
+ void glUniform3i(GLint location, GLint x, GLint y, GLint z);
+ void glUniform3iv(GLint location, GLsizei count, const GLint* v);
+ void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
+ void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
+ void glUniform4iv(GLint location, GLsizei count, const GLint* v);
+ void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void glUseProgram(GLuint program);
+ void glValidateProgram(GLuint program);
+ void glVertexAttrib1f(GLuint indx, GLfloat x);
+ void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
+ void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
+ void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
+ void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+ void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
+ void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
+ void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
+
+private:
+ QGLFunctionsPrivate *d_ptr;
+ static bool isInitialized(const QGLFunctionsPrivate *d) { return d != 0; }
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFunctions::OpenGLFeatures)
+
+struct QGLFunctionsPrivate
+{
+ QGLFunctionsPrivate(const QGLContext *context = 0);
+
+#ifndef QT_OPENGL_ES_2
+ void (QGLF_APIENTRYP activeTexture)(GLenum texture);
+ void (QGLF_APIENTRYP attachShader)(GLuint program, GLuint shader);
+ void (QGLF_APIENTRYP bindAttribLocation)(GLuint program, GLuint index, const char* name);
+ void (QGLF_APIENTRYP bindBuffer)(GLenum target, GLuint buffer);
+ void (QGLF_APIENTRYP bindFramebuffer)(GLenum target, GLuint framebuffer);
+ void (QGLF_APIENTRYP bindRenderbuffer)(GLenum target, GLuint renderbuffer);
+ void (QGLF_APIENTRYP blendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+ void (QGLF_APIENTRYP blendEquation)(GLenum mode);
+ void (QGLF_APIENTRYP blendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha);
+ void (QGLF_APIENTRYP blendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+ void (QGLF_APIENTRYP bufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage);
+ void (QGLF_APIENTRYP bufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data);
+ GLenum (QGLF_APIENTRYP checkFramebufferStatus)(GLenum target);
+ void (QGLF_APIENTRYP compileShader)(GLuint shader);
+ void (QGLF_APIENTRYP compressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
+ void (QGLF_APIENTRYP compressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
+ GLuint (QGLF_APIENTRYP createProgram)();
+ GLuint (QGLF_APIENTRYP createShader)(GLenum type);
+ void (QGLF_APIENTRYP deleteBuffers)(GLsizei n, const GLuint* buffers);
+ void (QGLF_APIENTRYP deleteFramebuffers)(GLsizei n, const GLuint* framebuffers);
+ void (QGLF_APIENTRYP deleteProgram)(GLuint program);
+ void (QGLF_APIENTRYP deleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers);
+ void (QGLF_APIENTRYP deleteShader)(GLuint shader);
+ void (QGLF_APIENTRYP detachShader)(GLuint program, GLuint shader);
+ void (QGLF_APIENTRYP disableVertexAttribArray)(GLuint index);
+ void (QGLF_APIENTRYP enableVertexAttribArray)(GLuint index);
+ void (QGLF_APIENTRYP framebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+ void (QGLF_APIENTRYP framebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+ void (QGLF_APIENTRYP genBuffers)(GLsizei n, GLuint* buffers);
+ void (QGLF_APIENTRYP generateMipmap)(GLenum target);
+ void (QGLF_APIENTRYP genFramebuffers)(GLsizei n, GLuint* framebuffers);
+ void (QGLF_APIENTRYP genRenderbuffers)(GLsizei n, GLuint* renderbuffers);
+ void (QGLF_APIENTRYP getActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+ void (QGLF_APIENTRYP getActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name);
+ void (QGLF_APIENTRYP getAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+ int (QGLF_APIENTRYP getAttribLocation)(GLuint program, const char* name);
+ void (QGLF_APIENTRYP getBufferParameteriv)(GLenum target, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getProgramiv)(GLuint program, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog);
+ void (QGLF_APIENTRYP getRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getShaderiv)(GLuint shader, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog);
+ void (QGLF_APIENTRYP getShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+ void (QGLF_APIENTRYP getShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source);
+ void (QGLF_APIENTRYP getUniformfv)(GLuint program, GLint location, GLfloat* params);
+ void (QGLF_APIENTRYP getUniformiv)(GLuint program, GLint location, GLint* params);
+ int (QGLF_APIENTRYP getUniformLocation)(GLuint program, const char* name);
+ void (QGLF_APIENTRYP getVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params);
+ void (QGLF_APIENTRYP getVertexAttribiv)(GLuint index, GLenum pname, GLint* params);
+ void (QGLF_APIENTRYP getVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer);
+ GLboolean (QGLF_APIENTRYP isBuffer)(GLuint buffer);
+ GLboolean (QGLF_APIENTRYP isFramebuffer)(GLuint framebuffer);
+ GLboolean (QGLF_APIENTRYP isProgram)(GLuint program);
+ GLboolean (QGLF_APIENTRYP isRenderbuffer)(GLuint renderbuffer);
+ GLboolean (QGLF_APIENTRYP isShader)(GLuint shader);
+ void (QGLF_APIENTRYP linkProgram)(GLuint program);
+ void (QGLF_APIENTRYP releaseShaderCompiler)();
+ void (QGLF_APIENTRYP renderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+ void (QGLF_APIENTRYP sampleCoverage)(GLclampf value, GLboolean invert);
+ void (QGLF_APIENTRYP shaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
+ void (QGLF_APIENTRYP shaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length);
+ void (QGLF_APIENTRYP stencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask);
+ void (QGLF_APIENTRYP stencilMaskSeparate)(GLenum face, GLuint mask);
+ void (QGLF_APIENTRYP stencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+ void (QGLF_APIENTRYP uniform1f)(GLint location, GLfloat x);
+ void (QGLF_APIENTRYP uniform1fv)(GLint location, GLsizei count, const GLfloat* v);
+ void (QGLF_APIENTRYP uniform1i)(GLint location, GLint x);
+ void (QGLF_APIENTRYP uniform1iv)(GLint location, GLsizei count, const GLint* v);
+ void (QGLF_APIENTRYP uniform2f)(GLint location, GLfloat x, GLfloat y);
+ void (QGLF_APIENTRYP uniform2fv)(GLint location, GLsizei count, const GLfloat* v);
+ void (QGLF_APIENTRYP uniform2i)(GLint location, GLint x, GLint y);
+ void (QGLF_APIENTRYP uniform2iv)(GLint location, GLsizei count, const GLint* v);
+ void (QGLF_APIENTRYP uniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z);
+ void (QGLF_APIENTRYP uniform3fv)(GLint location, GLsizei count, const GLfloat* v);
+ void (QGLF_APIENTRYP uniform3i)(GLint location, GLint x, GLint y, GLint z);
+ void (QGLF_APIENTRYP uniform3iv)(GLint location, GLsizei count, const GLint* v);
+ void (QGLF_APIENTRYP uniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ void (QGLF_APIENTRYP uniform4fv)(GLint location, GLsizei count, const GLfloat* v);
+ void (QGLF_APIENTRYP uniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w);
+ void (QGLF_APIENTRYP uniform4iv)(GLint location, GLsizei count, const GLint* v);
+ void (QGLF_APIENTRYP uniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void (QGLF_APIENTRYP uniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void (QGLF_APIENTRYP uniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ void (QGLF_APIENTRYP useProgram)(GLuint program);
+ void (QGLF_APIENTRYP validateProgram)(GLuint program);
+ void (QGLF_APIENTRYP vertexAttrib1f)(GLuint indx, GLfloat x);
+ void (QGLF_APIENTRYP vertexAttrib1fv)(GLuint indx, const GLfloat* values);
+ void (QGLF_APIENTRYP vertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y);
+ void (QGLF_APIENTRYP vertexAttrib2fv)(GLuint indx, const GLfloat* values);
+ void (QGLF_APIENTRYP vertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+ void (QGLF_APIENTRYP vertexAttrib3fv)(GLuint indx, const GLfloat* values);
+ void (QGLF_APIENTRYP vertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ void (QGLF_APIENTRYP vertexAttrib4fv)(GLuint indx, const GLfloat* values);
+ void (QGLF_APIENTRYP vertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
+#endif
+};
+
+inline void QGLFunctions::glActiveTexture(GLenum texture)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glActiveTexture(texture);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->activeTexture(texture);
+#endif
+}
+
+inline void QGLFunctions::glAttachShader(GLuint program, GLuint shader)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glAttachShader(program, shader);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->attachShader(program, shader);
+#endif
+}
+
+inline void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBindAttribLocation(program, index, name);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bindAttribLocation(program, index, name);
+#endif
+}
+
+inline void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glBindBuffer(target, buffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bindBuffer(target, buffer);
+#endif
+}
+
+inline void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBindFramebuffer(target, framebuffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bindFramebuffer(target, framebuffer);
+#endif
+}
+
+inline void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBindRenderbuffer(target, renderbuffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bindRenderbuffer(target, renderbuffer);
+#endif
+}
+
+inline void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBlendColor(red, green, blue, alpha);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->blendColor(red, green, blue, alpha);
+#endif
+}
+
+inline void QGLFunctions::glBlendEquation(GLenum mode)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBlendEquation(mode);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->blendEquation(mode);
+#endif
+}
+
+inline void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBlendEquationSeparate(modeRGB, modeAlpha);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->blendEquationSeparate(modeRGB, modeAlpha);
+#endif
+}
+
+inline void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
+#endif
+}
+
+inline void QGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glBufferData(target, size, data, usage);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bufferData(target, size, data, usage);
+#endif
+}
+
+inline void QGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glBufferSubData(target, offset, size, data);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->bufferSubData(target, offset, size, data);
+#endif
+}
+
+inline GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glCheckFramebufferStatus(target);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->checkFramebufferStatus(target);
+#endif
+}
+
+inline void QGLFunctions::glClearDepthf(GLclampf depth)
+{
+#ifndef QT_OPENGL_ES
+ ::glClearDepth(depth);
+#else
+ ::glClearDepthf(depth);
+#endif
+}
+
+inline void QGLFunctions::glCompileShader(GLuint shader)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glCompileShader(shader);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->compileShader(shader);
+#endif
+}
+
+inline void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
+#endif
+}
+
+inline void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
+#endif
+}
+
+inline GLuint QGLFunctions::glCreateProgram()
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glCreateProgram();
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->createProgram();
+#endif
+}
+
+inline GLuint QGLFunctions::glCreateShader(GLenum type)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glCreateShader(type);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->createShader(type);
+#endif
+}
+
+inline void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glDeleteBuffers(n, buffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->deleteBuffers(n, buffers);
+#endif
+}
+
+inline void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDeleteFramebuffers(n, framebuffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->deleteFramebuffers(n, framebuffers);
+#endif
+}
+
+inline void QGLFunctions::glDeleteProgram(GLuint program)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDeleteProgram(program);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->deleteProgram(program);
+#endif
+}
+
+inline void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDeleteRenderbuffers(n, renderbuffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->deleteRenderbuffers(n, renderbuffers);
+#endif
+}
+
+inline void QGLFunctions::glDeleteShader(GLuint shader)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDeleteShader(shader);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->deleteShader(shader);
+#endif
+}
+
+inline void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar)
+{
+#ifndef QT_OPENGL_ES
+ ::glDepthRange(zNear, zFar);
+#else
+ ::glDepthRangef(zNear, zFar);
+#endif
+}
+
+inline void QGLFunctions::glDetachShader(GLuint program, GLuint shader)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDetachShader(program, shader);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->detachShader(program, shader);
+#endif
+}
+
+inline void QGLFunctions::glDisableVertexAttribArray(GLuint index)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glDisableVertexAttribArray(index);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->disableVertexAttribArray(index);
+#endif
+}
+
+inline void QGLFunctions::glEnableVertexAttribArray(GLuint index)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glEnableVertexAttribArray(index);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->enableVertexAttribArray(index);
+#endif
+}
+
+inline void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
+#endif
+}
+
+inline void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glFramebufferTexture2D(target, attachment, textarget, texture, level);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->framebufferTexture2D(target, attachment, textarget, texture, level);
+#endif
+}
+
+inline void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glGenBuffers(n, buffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->genBuffers(n, buffers);
+#endif
+}
+
+inline void QGLFunctions::glGenerateMipmap(GLenum target)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGenerateMipmap(target);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->generateMipmap(target);
+#endif
+}
+
+inline void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGenFramebuffers(n, framebuffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->genFramebuffers(n, framebuffers);
+#endif
+}
+
+inline void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGenRenderbuffers(n, renderbuffers);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->genRenderbuffers(n, renderbuffers);
+#endif
+}
+
+inline void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetActiveAttrib(program, index, bufsize, length, size, type, name);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getActiveAttrib(program, index, bufsize, length, size, type, name);
+#endif
+}
+
+inline void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetActiveUniform(program, index, bufsize, length, size, type, name);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getActiveUniform(program, index, bufsize, length, size, type, name);
+#endif
+}
+
+inline void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetAttachedShaders(program, maxcount, count, shaders);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getAttachedShaders(program, maxcount, count, shaders);
+#endif
+}
+
+inline int QGLFunctions::glGetAttribLocation(GLuint program, const char* name)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glGetAttribLocation(program, name);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->getAttribLocation(program, name);
+#endif
+}
+
+inline void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetBufferParameteriv(target, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getBufferParameteriv(target, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetProgramiv(program, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getProgramiv(program, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetProgramInfoLog(program, bufsize, length, infolog);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getProgramInfoLog(program, bufsize, length, infolog);
+#endif
+}
+
+inline void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetRenderbufferParameteriv(target, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getRenderbufferParameteriv(target, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetShaderiv(shader, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getShaderiv(shader, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetShaderInfoLog(shader, bufsize, length, infolog);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getShaderInfoLog(shader, bufsize, length, infolog);
+#endif
+}
+
+inline void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getShaderPrecisionFormat(shadertype, precisiontype, range, precision);
+#endif
+}
+
+inline void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetShaderSource(shader, bufsize, length, source);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getShaderSource(shader, bufsize, length, source);
+#endif
+}
+
+inline void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetUniformfv(program, location, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getUniformfv(program, location, params);
+#endif
+}
+
+inline void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetUniformiv(program, location, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getUniformiv(program, location, params);
+#endif
+}
+
+inline int QGLFunctions::glGetUniformLocation(GLuint program, const char* name)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glGetUniformLocation(program, name);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->getUniformLocation(program, name);
+#endif
+}
+
+inline void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetVertexAttribfv(index, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getVertexAttribfv(index, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetVertexAttribiv(index, pname, params);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getVertexAttribiv(index, pname, params);
+#endif
+}
+
+inline void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glGetVertexAttribPointerv(index, pname, pointer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->getVertexAttribPointerv(index, pname, pointer);
+#endif
+}
+
+inline GLboolean QGLFunctions::glIsBuffer(GLuint buffer)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ return ::glIsBuffer(buffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->isBuffer(buffer);
+#endif
+}
+
+inline GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glIsFramebuffer(framebuffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->isFramebuffer(framebuffer);
+#endif
+}
+
+inline GLboolean QGLFunctions::glIsProgram(GLuint program)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glIsProgram(program);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->isProgram(program);
+#endif
+}
+
+inline GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glIsRenderbuffer(renderbuffer);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->isRenderbuffer(renderbuffer);
+#endif
+}
+
+inline GLboolean QGLFunctions::glIsShader(GLuint shader)
+{
+#if defined(QT_OPENGL_ES_2)
+ return ::glIsShader(shader);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ return d_ptr->isShader(shader);
+#endif
+}
+
+inline void QGLFunctions::glLinkProgram(GLuint program)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glLinkProgram(program);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->linkProgram(program);
+#endif
+}
+
+inline void QGLFunctions::glReleaseShaderCompiler()
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glReleaseShaderCompiler();
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->releaseShaderCompiler();
+#endif
+}
+
+inline void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glRenderbufferStorage(target, internalformat, width, height);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->renderbufferStorage(target, internalformat, width, height);
+#endif
+}
+
+inline void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert)
+{
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2)
+ ::glSampleCoverage(value, invert);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->sampleCoverage(value, invert);
+#endif
+}
+
+inline void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glShaderBinary(n, shaders, binaryformat, binary, length);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->shaderBinary(n, shaders, binaryformat, binary, length);
+#endif
+}
+
+inline void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glShaderSource(shader, count, string, length);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->shaderSource(shader, count, string, length);
+#endif
+}
+
+inline void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glStencilFuncSeparate(face, func, ref, mask);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->stencilFuncSeparate(face, func, ref, mask);
+#endif
+}
+
+inline void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glStencilMaskSeparate(face, mask);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->stencilMaskSeparate(face, mask);
+#endif
+}
+
+inline void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glStencilOpSeparate(face, fail, zfail, zpass);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->stencilOpSeparate(face, fail, zfail, zpass);
+#endif
+}
+
+inline void QGLFunctions::glUniform1f(GLint location, GLfloat x)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform1f(location, x);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform1f(location, x);
+#endif
+}
+
+inline void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform1fv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform1fv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform1i(GLint location, GLint x)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform1i(location, x);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform1i(location, x);
+#endif
+}
+
+inline void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform1iv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform1iv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform2f(location, x, y);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform2f(location, x, y);
+#endif
+}
+
+inline void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform2fv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform2fv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform2i(location, x, y);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform2i(location, x, y);
+#endif
+}
+
+inline void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform2iv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform2iv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform3f(location, x, y, z);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform3f(location, x, y, z);
+#endif
+}
+
+inline void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform3fv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform3fv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform3i(location, x, y, z);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform3i(location, x, y, z);
+#endif
+}
+
+inline void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform3iv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform3iv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform4f(location, x, y, z, w);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform4f(location, x, y, z, w);
+#endif
+}
+
+inline void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform4fv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform4fv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform4i(location, x, y, z, w);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform4i(location, x, y, z, w);
+#endif
+}
+
+inline void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniform4iv(location, count, v);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniform4iv(location, count, v);
+#endif
+}
+
+inline void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniformMatrix2fv(location, count, transpose, value);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniformMatrix2fv(location, count, transpose, value);
+#endif
+}
+
+inline void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniformMatrix3fv(location, count, transpose, value);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniformMatrix3fv(location, count, transpose, value);
+#endif
+}
+
+inline void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUniformMatrix4fv(location, count, transpose, value);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->uniformMatrix4fv(location, count, transpose, value);
+#endif
+}
+
+inline void QGLFunctions::glUseProgram(GLuint program)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glUseProgram(program);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->useProgram(program);
+#endif
+}
+
+inline void QGLFunctions::glValidateProgram(GLuint program)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glValidateProgram(program);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->validateProgram(program);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib1f(indx, x);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib1f(indx, x);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib1fv(indx, values);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib1fv(indx, values);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib2f(indx, x, y);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib2f(indx, x, y);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib2fv(indx, values);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib2fv(indx, values);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib3f(indx, x, y, z);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib3f(indx, x, y, z);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib3fv(indx, values);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib3fv(indx, values);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib4f(indx, x, y, z, w);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib4f(indx, x, y, z, w);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttrib4fv(indx, values);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttrib4fv(indx, values);
+#endif
+}
+
+inline void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
+{
+#if defined(QT_OPENGL_ES_2)
+ ::glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
+#else
+ Q_ASSERT(QGLFunctions::isInitialized(d_ptr));
+ d_ptr->vertexAttribPointer(indx, size, type, normalized, stride, ptr);
+#endif
+}
+
+#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#endif
+#ifndef GL_ACTIVE_ATTRIBUTES
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#endif
+#ifndef GL_ACTIVE_TEXTURE
+#define GL_ACTIVE_TEXTURE 0x84E0
+#endif
+#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#endif
+#ifndef GL_ACTIVE_UNIFORMS
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#endif
+#ifndef GL_ALIASED_LINE_WIDTH_RANGE
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#endif
+#ifndef GL_ALIASED_POINT_SIZE_RANGE
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#endif
+#ifndef GL_ALPHA
+#define GL_ALPHA 0x1906
+#endif
+#ifndef GL_ALPHA_BITS
+#define GL_ALPHA_BITS 0x0D55
+#endif
+#ifndef GL_ALWAYS
+#define GL_ALWAYS 0x0207
+#endif
+#ifndef GL_ARRAY_BUFFER
+#define GL_ARRAY_BUFFER 0x8892
+#endif
+#ifndef GL_ARRAY_BUFFER_BINDING
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#endif
+#ifndef GL_ATTACHED_SHADERS
+#define GL_ATTACHED_SHADERS 0x8B85
+#endif
+#ifndef GL_BACK
+#define GL_BACK 0x0405
+#endif
+#ifndef GL_BLEND
+#define GL_BLEND 0x0BE2
+#endif
+#ifndef GL_BLEND_COLOR
+#define GL_BLEND_COLOR 0x8005
+#endif
+#ifndef GL_BLEND_DST_ALPHA
+#define GL_BLEND_DST_ALPHA 0x80CA
+#endif
+#ifndef GL_BLEND_DST_RGB
+#define GL_BLEND_DST_RGB 0x80C8
+#endif
+#ifndef GL_BLEND_EQUATION
+#define GL_BLEND_EQUATION 0x8009
+#endif
+#ifndef GL_BLEND_EQUATION_ALPHA
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#endif
+#ifndef GL_BLEND_EQUATION_RGB
+#define GL_BLEND_EQUATION_RGB 0x8009
+#endif
+#ifndef GL_BLEND_SRC_ALPHA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#endif
+#ifndef GL_BLEND_SRC_RGB
+#define GL_BLEND_SRC_RGB 0x80C9
+#endif
+#ifndef GL_BLUE_BITS
+#define GL_BLUE_BITS 0x0D54
+#endif
+#ifndef GL_BOOL
+#define GL_BOOL 0x8B56
+#endif
+#ifndef GL_BOOL_VEC2
+#define GL_BOOL_VEC2 0x8B57
+#endif
+#ifndef GL_BOOL_VEC3
+#define GL_BOOL_VEC3 0x8B58
+#endif
+#ifndef GL_BOOL_VEC4
+#define GL_BOOL_VEC4 0x8B59
+#endif
+#ifndef GL_BUFFER_SIZE
+#define GL_BUFFER_SIZE 0x8764
+#endif
+#ifndef GL_BUFFER_USAGE
+#define GL_BUFFER_USAGE 0x8765
+#endif
+#ifndef GL_BYTE
+#define GL_BYTE 0x1400
+#endif
+#ifndef GL_CCW
+#define GL_CCW 0x0901
+#endif
+#ifndef GL_CLAMP_TO_EDGE
+#define GL_CLAMP_TO_EDGE 0x812F
+#endif
+#ifndef GL_COLOR_ATTACHMENT0
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#endif
+#ifndef GL_COLOR_BUFFER_BIT
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#endif
+#ifndef GL_COLOR_CLEAR_VALUE
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#endif
+#ifndef GL_COLOR_WRITEMASK
+#define GL_COLOR_WRITEMASK 0x0C23
+#endif
+#ifndef GL_COMPILE_STATUS
+#define GL_COMPILE_STATUS 0x8B81
+#endif
+#ifndef GL_COMPRESSED_TEXTURE_FORMATS
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#endif
+#ifndef GL_CONSTANT_ALPHA
+#define GL_CONSTANT_ALPHA 0x8003
+#endif
+#ifndef GL_CONSTANT_COLOR
+#define GL_CONSTANT_COLOR 0x8001
+#endif
+#ifndef GL_CULL_FACE
+#define GL_CULL_FACE 0x0B44
+#endif
+#ifndef GL_CULL_FACE_MODE
+#define GL_CULL_FACE_MODE 0x0B45
+#endif
+#ifndef GL_CURRENT_PROGRAM
+#define GL_CURRENT_PROGRAM 0x8B8D
+#endif
+#ifndef GL_CURRENT_VERTEX_ATTRIB
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#endif
+#ifndef GL_CW
+#define GL_CW 0x0900
+#endif
+#ifndef GL_DECR
+#define GL_DECR 0x1E03
+#endif
+#ifndef GL_DECR_WRAP
+#define GL_DECR_WRAP 0x8508
+#endif
+#ifndef GL_DELETE_STATUS
+#define GL_DELETE_STATUS 0x8B80
+#endif
+#ifndef GL_DEPTH_ATTACHMENT
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#endif
+#ifndef GL_DEPTH_BITS
+#define GL_DEPTH_BITS 0x0D56
+#endif
+#ifndef GL_DEPTH_BUFFER_BIT
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#endif
+#ifndef GL_DEPTH_CLEAR_VALUE
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#endif
+#ifndef GL_DEPTH_COMPONENT
+#define GL_DEPTH_COMPONENT 0x1902
+#endif
+#ifndef GL_DEPTH_COMPONENT16
+#define GL_DEPTH_COMPONENT16 0x81A5
+#endif
+#ifndef GL_DEPTH_FUNC
+#define GL_DEPTH_FUNC 0x0B74
+#endif
+#ifndef GL_DEPTH_RANGE
+#define GL_DEPTH_RANGE 0x0B70
+#endif
+#ifndef GL_DEPTH_TEST
+#define GL_DEPTH_TEST 0x0B71
+#endif
+#ifndef GL_DEPTH_WRITEMASK
+#define GL_DEPTH_WRITEMASK 0x0B72
+#endif
+#ifndef GL_DITHER
+#define GL_DITHER 0x0BD0
+#endif
+#ifndef GL_DONT_CARE
+#define GL_DONT_CARE 0x1100
+#endif
+#ifndef GL_DST_ALPHA
+#define GL_DST_ALPHA 0x0304
+#endif
+#ifndef GL_DST_COLOR
+#define GL_DST_COLOR 0x0306
+#endif
+#ifndef GL_DYNAMIC_DRAW
+#define GL_DYNAMIC_DRAW 0x88E8
+#endif
+#ifndef GL_ELEMENT_ARRAY_BUFFER
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#endif
+#ifndef GL_ELEMENT_ARRAY_BUFFER_BINDING
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#endif
+#ifndef GL_EQUAL
+#define GL_EQUAL 0x0202
+#endif
+#ifndef GL_EXTENSIONS
+#define GL_EXTENSIONS 0x1F03
+#endif
+#ifndef GL_FALSE
+#define GL_FALSE 0
+#endif
+#ifndef GL_FASTEST
+#define GL_FASTEST 0x1101
+#endif
+#ifndef GL_FIXED
+#define GL_FIXED 0x140C
+#endif
+#ifndef GL_FLOAT
+#define GL_FLOAT 0x1406
+#endif
+#ifndef GL_FLOAT_MAT2
+#define GL_FLOAT_MAT2 0x8B5A
+#endif
+#ifndef GL_FLOAT_MAT3
+#define GL_FLOAT_MAT3 0x8B5B
+#endif
+#ifndef GL_FLOAT_MAT4
+#define GL_FLOAT_MAT4 0x8B5C
+#endif
+#ifndef GL_FLOAT_VEC2
+#define GL_FLOAT_VEC2 0x8B50
+#endif
+#ifndef GL_FLOAT_VEC3
+#define GL_FLOAT_VEC3 0x8B51
+#endif
+#ifndef GL_FLOAT_VEC4
+#define GL_FLOAT_VEC4 0x8B52
+#endif
+#ifndef GL_FRAGMENT_SHADER
+#define GL_FRAGMENT_SHADER 0x8B30
+#endif
+#ifndef GL_FRAMEBUFFER
+#define GL_FRAMEBUFFER 0x8D40
+#endif
+#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#endif
+#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#endif
+#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#endif
+#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#endif
+#ifndef GL_FRAMEBUFFER_BINDING
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#endif
+#ifndef GL_FRAMEBUFFER_COMPLETE
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#endif
+#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#endif
+#ifndef GL_FRAMEBUFFER_UNSUPPORTED
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#endif
+#ifndef GL_FRONT
+#define GL_FRONT 0x0404
+#endif
+#ifndef GL_FRONT_AND_BACK
+#define GL_FRONT_AND_BACK 0x0408
+#endif
+#ifndef GL_FRONT_FACE
+#define GL_FRONT_FACE 0x0B46
+#endif
+#ifndef GL_FUNC_ADD
+#define GL_FUNC_ADD 0x8006
+#endif
+#ifndef GL_FUNC_REVERSE_SUBTRACT
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#endif
+#ifndef GL_FUNC_SUBTRACT
+#define GL_FUNC_SUBTRACT 0x800A
+#endif
+#ifndef GL_GENERATE_MIPMAP_HINT
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#endif
+#ifndef GL_GEQUAL
+#define GL_GEQUAL 0x0206
+#endif
+#ifndef GL_GREATER
+#define GL_GREATER 0x0204
+#endif
+#ifndef GL_GREEN_BITS
+#define GL_GREEN_BITS 0x0D53
+#endif
+#ifndef GL_HIGH_FLOAT
+#define GL_HIGH_FLOAT 0x8DF2
+#endif
+#ifndef GL_HIGH_INT
+#define GL_HIGH_INT 0x8DF5
+#endif
+#ifndef GL_IMPLEMENTATION_COLOR_READ_FORMAT
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#endif
+#ifndef GL_IMPLEMENTATION_COLOR_READ_TYPE
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#endif
+#ifndef GL_INCR
+#define GL_INCR 0x1E02
+#endif
+#ifndef GL_INCR_WRAP
+#define GL_INCR_WRAP 0x8507
+#endif
+#ifndef GL_INFO_LOG_LENGTH
+#define GL_INFO_LOG_LENGTH 0x8B84
+#endif
+#ifndef GL_INT
+#define GL_INT 0x1404
+#endif
+#ifndef GL_INT_VEC2
+#define GL_INT_VEC2 0x8B53
+#endif
+#ifndef GL_INT_VEC3
+#define GL_INT_VEC3 0x8B54
+#endif
+#ifndef GL_INT_VEC4
+#define GL_INT_VEC4 0x8B55
+#endif
+#ifndef GL_INVALID_ENUM
+#define GL_INVALID_ENUM 0x0500
+#endif
+#ifndef GL_INVALID_FRAMEBUFFER_OPERATION
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#endif
+#ifndef GL_INVALID_OPERATION
+#define GL_INVALID_OPERATION 0x0502
+#endif
+#ifndef GL_INVALID_VALUE
+#define GL_INVALID_VALUE 0x0501
+#endif
+#ifndef GL_INVERT
+#define GL_INVERT 0x150A
+#endif
+#ifndef GL_KEEP
+#define GL_KEEP 0x1E00
+#endif
+#ifndef GL_LEQUAL
+#define GL_LEQUAL 0x0203
+#endif
+#ifndef GL_LESS
+#define GL_LESS 0x0201
+#endif
+#ifndef GL_LINEAR
+#define GL_LINEAR 0x2601
+#endif
+#ifndef GL_LINEAR_MIPMAP_LINEAR
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#endif
+#ifndef GL_LINEAR_MIPMAP_NEAREST
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#endif
+#ifndef GL_LINE_LOOP
+#define GL_LINE_LOOP 0x0002
+#endif
+#ifndef GL_LINES
+#define GL_LINES 0x0001
+#endif
+#ifndef GL_LINE_STRIP
+#define GL_LINE_STRIP 0x0003
+#endif
+#ifndef GL_LINE_WIDTH
+#define GL_LINE_WIDTH 0x0B21
+#endif
+#ifndef GL_LINK_STATUS
+#define GL_LINK_STATUS 0x8B82
+#endif
+#ifndef GL_LOW_FLOAT
+#define GL_LOW_FLOAT 0x8DF0
+#endif
+#ifndef GL_LOW_INT
+#define GL_LOW_INT 0x8DF3
+#endif
+#ifndef GL_LUMINANCE
+#define GL_LUMINANCE 0x1909
+#endif
+#ifndef GL_LUMINANCE_ALPHA
+#define GL_LUMINANCE_ALPHA 0x190A
+#endif
+#ifndef GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#endif
+#ifndef GL_MAX_CUBE_MAP_TEXTURE_SIZE
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#endif
+#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#endif
+#ifndef GL_MAX_RENDERBUFFER_SIZE
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#endif
+#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#endif
+#ifndef GL_MAX_TEXTURE_SIZE
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#endif
+#ifndef GL_MAX_VARYING_VECTORS
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#endif
+#ifndef GL_MAX_VERTEX_ATTRIBS
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#endif
+#ifndef GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#endif
+#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#endif
+#ifndef GL_MAX_VIEWPORT_DIMS
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#endif
+#ifndef GL_MEDIUM_FLOAT
+#define GL_MEDIUM_FLOAT 0x8DF1
+#endif
+#ifndef GL_MEDIUM_INT
+#define GL_MEDIUM_INT 0x8DF4
+#endif
+#ifndef GL_MIRRORED_REPEAT
+#define GL_MIRRORED_REPEAT 0x8370
+#endif
+#ifndef GL_NEAREST
+#define GL_NEAREST 0x2600
+#endif
+#ifndef GL_NEAREST_MIPMAP_LINEAR
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#endif
+#ifndef GL_NEAREST_MIPMAP_NEAREST
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#endif
+#ifndef GL_NEVER
+#define GL_NEVER 0x0200
+#endif
+#ifndef GL_NICEST
+#define GL_NICEST 0x1102
+#endif
+#ifndef GL_NO_ERROR
+#define GL_NO_ERROR 0
+#endif
+#ifndef GL_NONE
+#define GL_NONE 0
+#endif
+#ifndef GL_NOTEQUAL
+#define GL_NOTEQUAL 0x0205
+#endif
+#ifndef GL_NUM_COMPRESSED_TEXTURE_FORMATS
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#endif
+#ifndef GL_NUM_SHADER_BINARY_FORMATS
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#endif
+#ifndef GL_ONE
+#define GL_ONE 1
+#endif
+#ifndef GL_ONE_MINUS_CONSTANT_ALPHA
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#endif
+#ifndef GL_ONE_MINUS_CONSTANT_COLOR
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#endif
+#ifndef GL_ONE_MINUS_DST_ALPHA
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#endif
+#ifndef GL_ONE_MINUS_DST_COLOR
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#endif
+#ifndef GL_ONE_MINUS_SRC_ALPHA
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#endif
+#ifndef GL_ONE_MINUS_SRC_COLOR
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#endif
+#ifndef GL_OUT_OF_MEMORY
+#define GL_OUT_OF_MEMORY 0x0505
+#endif
+#ifndef GL_PACK_ALIGNMENT
+#define GL_PACK_ALIGNMENT 0x0D05
+#endif
+#ifndef GL_POINTS
+#define GL_POINTS 0x0000
+#endif
+#ifndef GL_POLYGON_OFFSET_FACTOR
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#endif
+#ifndef GL_POLYGON_OFFSET_FILL
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#endif
+#ifndef GL_POLYGON_OFFSET_UNITS
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#endif
+#ifndef GL_RED_BITS
+#define GL_RED_BITS 0x0D52
+#endif
+#ifndef GL_RENDERBUFFER
+#define GL_RENDERBUFFER 0x8D41
+#endif
+#ifndef GL_RENDERBUFFER_ALPHA_SIZE
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#endif
+#ifndef GL_RENDERBUFFER_BINDING
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#endif
+#ifndef GL_RENDERBUFFER_BLUE_SIZE
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#endif
+#ifndef GL_RENDERBUFFER_DEPTH_SIZE
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#endif
+#ifndef GL_RENDERBUFFER_GREEN_SIZE
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#endif
+#ifndef GL_RENDERBUFFER_HEIGHT
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#endif
+#ifndef GL_RENDERBUFFER_INTERNAL_FORMAT
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#endif
+#ifndef GL_RENDERBUFFER_RED_SIZE
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#endif
+#ifndef GL_RENDERBUFFER_STENCIL_SIZE
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#endif
+#ifndef GL_RENDERBUFFER_WIDTH
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#endif
+#ifndef GL_RENDERER
+#define GL_RENDERER 0x1F01
+#endif
+#ifndef GL_REPEAT
+#define GL_REPEAT 0x2901
+#endif
+#ifndef GL_REPLACE
+#define GL_REPLACE 0x1E01
+#endif
+#ifndef GL_RGB
+#define GL_RGB 0x1907
+#endif
+#ifndef GL_RGB565
+#define GL_RGB565 0x8D62
+#endif
+#ifndef GL_RGB5_A1
+#define GL_RGB5_A1 0x8057
+#endif
+#ifndef GL_RGBA
+#define GL_RGBA 0x1908
+#endif
+#ifndef GL_RGBA4
+#define GL_RGBA4 0x8056
+#endif
+#ifndef GL_SAMPLE_ALPHA_TO_COVERAGE
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#endif
+#ifndef GL_SAMPLE_BUFFERS
+#define GL_SAMPLE_BUFFERS 0x80A8
+#endif
+#ifndef GL_SAMPLE_COVERAGE
+#define GL_SAMPLE_COVERAGE 0x80A0
+#endif
+#ifndef GL_SAMPLE_COVERAGE_INVERT
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#endif
+#ifndef GL_SAMPLE_COVERAGE_VALUE
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#endif
+#ifndef GL_SAMPLER_2D
+#define GL_SAMPLER_2D 0x8B5E
+#endif
+#ifndef GL_SAMPLER_CUBE
+#define GL_SAMPLER_CUBE 0x8B60
+#endif
+#ifndef GL_SAMPLES
+#define GL_SAMPLES 0x80A9
+#endif
+#ifndef GL_SCISSOR_BOX
+#define GL_SCISSOR_BOX 0x0C10
+#endif
+#ifndef GL_SCISSOR_TEST
+#define GL_SCISSOR_TEST 0x0C11
+#endif
+#ifndef GL_SHADER_BINARY_FORMATS
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#endif
+#ifndef GL_SHADER_COMPILER
+#define GL_SHADER_COMPILER 0x8DFA
+#endif
+#ifndef GL_SHADER_SOURCE_LENGTH
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#endif
+#ifndef GL_SHADER_TYPE
+#define GL_SHADER_TYPE 0x8B4F
+#endif
+#ifndef GL_SHADING_LANGUAGE_VERSION
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#endif
+#ifndef GL_SHORT
+#define GL_SHORT 0x1402
+#endif
+#ifndef GL_SRC_ALPHA
+#define GL_SRC_ALPHA 0x0302
+#endif
+#ifndef GL_SRC_ALPHA_SATURATE
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#endif
+#ifndef GL_SRC_COLOR
+#define GL_SRC_COLOR 0x0300
+#endif
+#ifndef GL_STATIC_DRAW
+#define GL_STATIC_DRAW 0x88E4
+#endif
+#ifndef GL_STENCIL_ATTACHMENT
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#endif
+#ifndef GL_STENCIL_BACK_FAIL
+#define GL_STENCIL_BACK_FAIL 0x8801
+#endif
+#ifndef GL_STENCIL_BACK_FUNC
+#define GL_STENCIL_BACK_FUNC 0x8800
+#endif
+#ifndef GL_STENCIL_BACK_PASS_DEPTH_FAIL
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#endif
+#ifndef GL_STENCIL_BACK_PASS_DEPTH_PASS
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#endif
+#ifndef GL_STENCIL_BACK_REF
+#define GL_STENCIL_BACK_REF 0x8CA3
+#endif
+#ifndef GL_STENCIL_BACK_VALUE_MASK
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#endif
+#ifndef GL_STENCIL_BACK_WRITEMASK
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#endif
+#ifndef GL_STENCIL_BITS
+#define GL_STENCIL_BITS 0x0D57
+#endif
+#ifndef GL_STENCIL_BUFFER_BIT
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#endif
+#ifndef GL_STENCIL_CLEAR_VALUE
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#endif
+#ifndef GL_STENCIL_FAIL
+#define GL_STENCIL_FAIL 0x0B94
+#endif
+#ifndef GL_STENCIL_FUNC
+#define GL_STENCIL_FUNC 0x0B92
+#endif
+#ifndef GL_STENCIL_INDEX
+#define GL_STENCIL_INDEX 0x1901
+#endif
+#ifndef GL_STENCIL_INDEX8
+#define GL_STENCIL_INDEX8 0x8D48
+#endif
+#ifndef GL_STENCIL_PASS_DEPTH_FAIL
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#endif
+#ifndef GL_STENCIL_PASS_DEPTH_PASS
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#endif
+#ifndef GL_STENCIL_REF
+#define GL_STENCIL_REF 0x0B97
+#endif
+#ifndef GL_STENCIL_TEST
+#define GL_STENCIL_TEST 0x0B90
+#endif
+#ifndef GL_STENCIL_VALUE_MASK
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#endif
+#ifndef GL_STENCIL_WRITEMASK
+#define GL_STENCIL_WRITEMASK 0x0B98
+#endif
+#ifndef GL_STREAM_DRAW
+#define GL_STREAM_DRAW 0x88E0
+#endif
+#ifndef GL_SUBPIXEL_BITS
+#define GL_SUBPIXEL_BITS 0x0D50
+#endif
+#ifndef GL_TEXTURE0
+#define GL_TEXTURE0 0x84C0
+#endif
+#ifndef GL_TEXTURE
+#define GL_TEXTURE 0x1702
+#endif
+#ifndef GL_TEXTURE10
+#define GL_TEXTURE10 0x84CA
+#endif
+#ifndef GL_TEXTURE1
+#define GL_TEXTURE1 0x84C1
+#endif
+#ifndef GL_TEXTURE11
+#define GL_TEXTURE11 0x84CB
+#endif
+#ifndef GL_TEXTURE12
+#define GL_TEXTURE12 0x84CC
+#endif
+#ifndef GL_TEXTURE13
+#define GL_TEXTURE13 0x84CD
+#endif
+#ifndef GL_TEXTURE14
+#define GL_TEXTURE14 0x84CE
+#endif
+#ifndef GL_TEXTURE15
+#define GL_TEXTURE15 0x84CF
+#endif
+#ifndef GL_TEXTURE16
+#define GL_TEXTURE16 0x84D0
+#endif
+#ifndef GL_TEXTURE17
+#define GL_TEXTURE17 0x84D1
+#endif
+#ifndef GL_TEXTURE18
+#define GL_TEXTURE18 0x84D2
+#endif
+#ifndef GL_TEXTURE19
+#define GL_TEXTURE19 0x84D3
+#endif
+#ifndef GL_TEXTURE20
+#define GL_TEXTURE20 0x84D4
+#endif
+#ifndef GL_TEXTURE2
+#define GL_TEXTURE2 0x84C2
+#endif
+#ifndef GL_TEXTURE21
+#define GL_TEXTURE21 0x84D5
+#endif
+#ifndef GL_TEXTURE22
+#define GL_TEXTURE22 0x84D6
+#endif
+#ifndef GL_TEXTURE23
+#define GL_TEXTURE23 0x84D7
+#endif
+#ifndef GL_TEXTURE24
+#define GL_TEXTURE24 0x84D8
+#endif
+#ifndef GL_TEXTURE25
+#define GL_TEXTURE25 0x84D9
+#endif
+#ifndef GL_TEXTURE26
+#define GL_TEXTURE26 0x84DA
+#endif
+#ifndef GL_TEXTURE27
+#define GL_TEXTURE27 0x84DB
+#endif
+#ifndef GL_TEXTURE28
+#define GL_TEXTURE28 0x84DC
+#endif
+#ifndef GL_TEXTURE29
+#define GL_TEXTURE29 0x84DD
+#endif
+#ifndef GL_TEXTURE_2D
+#define GL_TEXTURE_2D 0x0DE1
+#endif
+#ifndef GL_TEXTURE30
+#define GL_TEXTURE30 0x84DE
+#endif
+#ifndef GL_TEXTURE3
+#define GL_TEXTURE3 0x84C3
+#endif
+#ifndef GL_TEXTURE31
+#define GL_TEXTURE31 0x84DF
+#endif
+#ifndef GL_TEXTURE4
+#define GL_TEXTURE4 0x84C4
+#endif
+#ifndef GL_TEXTURE5
+#define GL_TEXTURE5 0x84C5
+#endif
+#ifndef GL_TEXTURE6
+#define GL_TEXTURE6 0x84C6
+#endif
+#ifndef GL_TEXTURE7
+#define GL_TEXTURE7 0x84C7
+#endif
+#ifndef GL_TEXTURE8
+#define GL_TEXTURE8 0x84C8
+#endif
+#ifndef GL_TEXTURE9
+#define GL_TEXTURE9 0x84C9
+#endif
+#ifndef GL_TEXTURE_BINDING_2D
+#define GL_TEXTURE_BINDING_2D 0x8069
+#endif
+#ifndef GL_TEXTURE_BINDING_CUBE_MAP
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_X
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_X
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Y
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#endif
+#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Z
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#endif
+#ifndef GL_TEXTURE_MAG_FILTER
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#endif
+#ifndef GL_TEXTURE_MIN_FILTER
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#endif
+#ifndef GL_TEXTURE_WRAP_S
+#define GL_TEXTURE_WRAP_S 0x2802
+#endif
+#ifndef GL_TEXTURE_WRAP_T
+#define GL_TEXTURE_WRAP_T 0x2803
+#endif
+#ifndef GL_TRIANGLE_FAN
+#define GL_TRIANGLE_FAN 0x0006
+#endif
+#ifndef GL_TRIANGLES
+#define GL_TRIANGLES 0x0004
+#endif
+#ifndef GL_TRIANGLE_STRIP
+#define GL_TRIANGLE_STRIP 0x0005
+#endif
+#ifndef GL_TRUE
+#define GL_TRUE 1
+#endif
+#ifndef GL_UNPACK_ALIGNMENT
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#endif
+#ifndef GL_UNSIGNED_BYTE
+#define GL_UNSIGNED_BYTE 0x1401
+#endif
+#ifndef GL_UNSIGNED_INT
+#define GL_UNSIGNED_INT 0x1405
+#endif
+#ifndef GL_UNSIGNED_SHORT
+#define GL_UNSIGNED_SHORT 0x1403
+#endif
+#ifndef GL_UNSIGNED_SHORT_4_4_4_4
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#endif
+#ifndef GL_UNSIGNED_SHORT_5_5_5_1
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#endif
+#ifndef GL_UNSIGNED_SHORT_5_6_5
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#endif
+#ifndef GL_VALIDATE_STATUS
+#define GL_VALIDATE_STATUS 0x8B83
+#endif
+#ifndef GL_VENDOR
+#define GL_VENDOR 0x1F00
+#endif
+#ifndef GL_VERSION
+#define GL_VERSION 0x1F02
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_ENABLED
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_NORMALIZED
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_POINTER
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_SIZE
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_STRIDE
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#endif
+#ifndef GL_VERTEX_ATTRIB_ARRAY_TYPE
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#endif
+#ifndef GL_VERTEX_SHADER
+#define GL_VERTEX_SHADER 0x8B31
+#endif
+#ifndef GL_VIEWPORT
+#define GL_VIEWPORT 0x0BA2
+#endif
+#ifndef GL_ZERO
+#define GL_ZERO 0
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 0e879df..61d8f26 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -145,8 +145,10 @@ bool QGLPaintDevice::alphaRequested() const
return context()->d_func()->reqFormat.alpha();
}
-
-
+bool QGLPaintDevice::isFlipped() const
+{
+ return false;
+}
////////////////// QGLWidgetGLPaintDevice //////////////////
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index f90edf4..f4176fb 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -76,6 +76,7 @@ public:
virtual QGLFormat format() const;
virtual QSize size() const = 0;
virtual bool alphaRequested() const;
+ virtual bool isFlipped() const;
// returns the QGLPaintDevice for the given QPaintDevice
static QGLPaintDevice* getDevice(QPaintDevice*);
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 61bce23..ec6ac4c 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -76,6 +76,14 @@
\endlist
+
+ \section Threading
+
+ As of Qt 4.8, it's possible to render into a QGLPixelBuffer using
+ a QPainter in a separate thread. Note that OpenGL 2.0 or OpenGL ES
+ 2.0 is required for this to work. Also, under X11, it's necessary
+ to set the Qt::AA_X11InitThreads application attribute.
+
Pbuffers are provided by the OpenGL \c pbuffer extension; call
hasOpenGLPbuffer() to find out if the system provides pbuffers.
@@ -394,25 +402,25 @@ bool QGLPixelBuffer::isValid() const
}
#if !defined(QT_OPENGL_ES_1)
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_buffer_2_engine)
#endif
#ifndef QT_OPENGL_ES_2
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine)
+Q_GLOBAL_STATIC(QGLEngineThreadStorage<QOpenGLPaintEngine>, qt_buffer_engine)
#endif
/*! \reimp */
QPaintEngine *QGLPixelBuffer::paintEngine() const
{
#if defined(QT_OPENGL_ES_1)
- return qt_buffer_engine();
+ return qt_buffer_engine()->engine();
#elif defined(QT_OPENGL_ES_2)
- return qt_buffer_2_engine();
+ return qt_buffer_2_engine()->engine();
#else
if (qt_gl_preferGL2Engine())
- return qt_buffer_2_engine();
+ return qt_buffer_2_engine()->engine();
else
- return qt_buffer_engine();
+ return qt_buffer_engine()->engine();
#endif
}
diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h
index 0e8ccd0..65bbd26 100644
--- a/src/opengl/qglpixelbuffer_p.h
+++ b/src/opengl/qglpixelbuffer_p.h
@@ -197,6 +197,10 @@ public:
EGLSurface pbuf;
QEglContext *ctx;
int textureFormat;
+#elif defined(Q_WS_QPA)
+ //stubs
+ void *pbuf;
+ void *ctx;
#endif
};
diff --git a/src/opengl/qglpixelbuffer_stub.cpp b/src/opengl/qglpixelbuffer_stub.cpp
new file mode 100644
index 0000000..98203fd
--- /dev/null
+++ b/src/opengl/qglpixelbuffer_stub.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 QtOpenGL 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 <qdebug.h>
+#include "qglpixelbuffer.h"
+#include "qglpixelbuffer_p.h"
+
+#include <qimage.h>
+#include <private/qgl_p.h>
+
+QT_BEGIN_NAMESPACE
+
+bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
+{
+ Q_UNUSED(size);
+ Q_UNUSED(f);
+ Q_UNUSED(shareWidget);
+ return false;
+}
+
+bool QGLPixelBufferPrivate::cleanup()
+{
+ return false;
+}
+
+bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id)
+{
+ Q_UNUSED(texture_id);
+ return false;
+}
+
+void QGLPixelBuffer::releaseFromDynamicTexture()
+{
+}
+
+GLuint QGLPixelBuffer::generateDynamicTexture() const
+{
+ return 0;
+}
+
+bool QGLPixelBuffer::hasOpenGLPbuffers()
+{
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index 2187deb..aa07561 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -125,7 +125,7 @@ protected:
bool processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &srcRect) const;
};
-extern QGLWidget *qt_gl_share_widget();
+extern const QGLContext *qt_gl_share_context();
QPixmapFilter *QGL2PaintEngineEx::pixmapFilter(int type, const QPixmapFilter *prototype)
{
@@ -315,7 +315,7 @@ class QGLBlurTextureCache : public QObject
public:
static QGLBlurTextureCache *cacheForContext(const QGLContext *context);
- QGLBlurTextureCache();
+ QGLBlurTextureCache(const QGLContext *);
~QGLBlurTextureCache();
QGLBlurTextureInfo *takeBlurTextureInfo(const QPixmap &pixmap);
@@ -336,15 +336,9 @@ private:
};
QList<QGLBlurTextureCache *> QGLBlurTextureCache::blurTextureCaches;
+Q_GLOBAL_STATIC(QGLContextGroupResource<QGLBlurTextureCache>, qt_blur_texture_caches)
-static void QGLBlurTextureCache_free(void *ptr)
-{
- delete reinterpret_cast<QGLBlurTextureCache *>(ptr);
-}
-
-Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_blur_texture_caches, (QGLBlurTextureCache_free))
-
-QGLBlurTextureCache::QGLBlurTextureCache()
+QGLBlurTextureCache::QGLBlurTextureCache(const QGLContext *)
: timerId(0)
{
cache.setMaxCost(4 * 1024 * 1024);
@@ -366,12 +360,7 @@ void QGLBlurTextureCache::timerEvent(QTimerEvent *)
QGLBlurTextureCache *QGLBlurTextureCache::cacheForContext(const QGLContext *context)
{
- QGLBlurTextureCache *p = reinterpret_cast<QGLBlurTextureCache *>(qt_blur_texture_caches()->value(context));
- if (!p) {
- p = new QGLBlurTextureCache;
- qt_blur_texture_caches()->insert(context, p);
- }
- return p;
+ return qt_blur_texture_caches()->value(context);
}
QGLBlurTextureInfo *QGLBlurTextureCache::takeBlurTextureInfo(const QPixmap &pixmap)
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index a2cf8df..4598bff 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -260,10 +260,27 @@ bool QGLShaderPrivate::compile(QGLShader *q)
glGetShaderInfoLog(shader, value, &len, logbuf);
log = QString::fromLatin1(logbuf);
QString name = q->objectName();
+
+ const char *types[] = {
+ "Fragment",
+ "Vertex",
+ "Geometry",
+ ""
+ };
+
+ const char *type = types[3];
+ if (shaderType == QGLShader::Fragment)
+ type = types[0];
+ else if (shaderType == QGLShader::Vertex)
+ type = types[1];
+ else if (shaderType == QGLShader::Geometry)
+ type = types[2];
+
if (name.isEmpty())
- qWarning() << "QGLShader::compile:" << log;
+ qWarning("QGLShader::compile(%s): %s", type, qPrintable(log));
else
- qWarning() << "QGLShader::compile[" << name << "]:" << log;
+ qWarning("QGLShader::compile(%s)[%s]: %s", type, qPrintable(name), qPrintable(log));
+
delete [] logbuf;
}
return compiled;
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 70427d5..db9f8c8 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -59,7 +59,7 @@
QT_BEGIN_NAMESPACE
-Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget();
+Q_OPENGL_EXPORT extern const QGLContext* qt_gl_share_context();
/*!
\class QGLFramebufferObjectPool
@@ -262,14 +262,14 @@ QGLPixmapData::QGLPixmapData(PixelType type)
QGLPixmapData::~QGLPixmapData()
{
- QGLWidget *shareWidget = qt_gl_share_widget();
- if (!shareWidget)
+ const QGLContext *shareContext = qt_gl_share_context();
+ if (!shareContext)
return;
delete m_engine;
if (m_texture.id) {
- QGLShareContextScope ctx(shareWidget->context());
+ QGLShareContextScope ctx(shareContext);
glDeleteTextures(1, &m_texture.id);
}
}
@@ -289,7 +289,7 @@ bool QGLPixmapData::isValidContext(const QGLContext *ctx) const
if (ctx == m_ctx)
return true;
- const QGLContext *share_ctx = qt_gl_share_widget()->context();
+ const QGLContext *share_ctx = qt_gl_share_context();
return ctx == share_ctx || QGLContext::areSharing(ctx, share_ctx);
}
@@ -309,7 +309,7 @@ void QGLPixmapData::resize(int width, int height)
d = pixelType() == QPixmapData::PixmapType ? 32 : 1;
if (m_texture.id) {
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
glDeleteTextures(1, &m_texture.id);
m_texture.id = 0;
}
@@ -326,7 +326,7 @@ void QGLPixmapData::ensureCreated() const
m_dirty = false;
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
m_ctx = ctx;
const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB;
@@ -398,7 +398,7 @@ bool QGLPixmapData::fromFile(const QString &filename, const char *format,
resize(0, 0);
data = file.readAll();
file.close();
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
QSize size = m_texture.bindCompressedTexture
(data.constData(), data.size(), format);
if (!size.isEmpty()) {
@@ -431,7 +431,7 @@ bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
const char *buf = reinterpret_cast<const char *>(buffer);
if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) {
resize(0, 0);
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
QSize size = m_texture.bindCompressedTexture(buf, int(len), format);
if (!size.isEmpty()) {
w = size.width();
@@ -501,7 +501,7 @@ void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags
d = m_source.depth();
if (m_texture.id) {
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
glDeleteTextures(1, &m_texture.id);
m_texture.id = 0;
}
@@ -524,7 +524,7 @@ void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect)
const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data);
if (other->m_renderFbo) {
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
resize(rect.width(), rect.height());
m_hasAlpha = other->m_hasAlpha;
@@ -644,7 +644,7 @@ QImage QGLPixmapData::toImage() const
ensureCreated();
}
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QGLShareContextScope ctx(qt_gl_share_context());
glBindTexture(GL_TEXTURE_2D, m_texture.id);
return qt_gl_read_texture(QSize(w, h), true, true);
}
@@ -668,7 +668,7 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
m_hasFillColor = false;
- const QGLContext *share_ctx = qt_gl_share_widget()->context();
+ const QGLContext *share_ctx = qt_gl_share_context();
QGLShareContextScope ctx(share_ctx);
ensureCreated();
@@ -723,8 +723,8 @@ QPaintEngine* QGLPixmapData::paintEngine() const
extern QGLWidget* qt_gl_share_widget();
if (!QGLContext::currentContext())
- qt_gl_share_widget()->makeCurrent();
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ const_cast<QGLContext *>(qt_gl_share_context())->makeCurrent();
+ QGLShareContextScope ctx(qt_gl_share_context());
QGLFramebufferObjectFormat format;
format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index ed541ce..eae1c9b 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -181,6 +181,7 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
//
// QGLWindowSurface
//
+#ifndef Q_WS_QPA
class QGLGlobalShareWidget
{
public:
@@ -256,6 +257,23 @@ void qt_destroy_gl_share_widget()
{
_qt_gl_share_widget()->destroy();
}
+#endif//Q_WS_QPA
+
+const QGLContext *qt_gl_share_context()
+{
+#ifdef Q_WS_QPA
+ //make it possible to have an assesor to defaultSharedGLContext.
+ const QPlatformGLContext *platformContext = QPlatformGLContext::defaultSharedContext();
+ if (!platformContext)
+ qDebug() << "Please implement a defaultSharedContext for your platformplugin";
+ return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(platformContext));
+#else
+ QGLWidget *widget = qt_gl_share_widget();
+ if (widget)
+ return widget->context();
+ return 0;
+#endif
+}
#ifdef QGL_USE_TEXTURE_POOL
void qt_gl_register_pixmap(QGLPixmapData *pd)
@@ -319,6 +337,8 @@ struct QGLWindowSurfacePrivate
QList<QImage> buffers;
QGLWindowSurfaceGLPaintDevice glDevice;
QGLWindowSurface* q_ptr;
+
+ bool partialUpdateSupport;
};
QGLFormat QGLWindowSurface::surfaceFormat;
@@ -354,7 +374,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
QGLWindowSurface::QGLWindowSurface(QWidget *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
- Q_ASSERT(window->isTopLevel());
+// Q_ASSERT(window->isTopLevel());
d_ptr->pb = 0;
d_ptr->fbo = 0;
d_ptr->ctx = 0;
@@ -371,21 +391,19 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window)
d_ptr->q_ptr = this;
d_ptr->geometry_updated = false;
d_ptr->did_paint = false;
-
-#ifdef QGL_NO_PRESERVED_SWAP
- setPartialUpdateSupport(false);
-#endif
+ d_ptr->partialUpdateSupport = false;
}
QGLWindowSurface::~QGLWindowSurface()
{
if (d_ptr->ctx)
glDeleteTextures(1, &d_ptr->tex_id);
+#ifndef Q_WS_QPA // Dont delete the contexts. Destroying the window does that for us
foreach(QGLContext **ctx, d_ptr->contexts) {
delete *ctx;
*ctx = 0;
}
-
+#endif
delete d_ptr->pb;
delete d_ptr->fbo;
delete d_ptr;
@@ -422,17 +440,19 @@ void QGLWindowSurface::deleted(QObject *object)
d_ptr->fbo = 0;
}
+#ifndef Q_WS_QPA //no need to specifically delete the QGLContext as it will be deleted by QWidget
QWidgetPrivate *widgetPrivate = widget->d_func();
if (widgetPrivate->extraData()) {
- union { QGLContext **ctxPtr; void **voidPtr; };
- voidPtr = &widgetPrivate->extraData()->glContext;
- int index = d_ptr->contexts.indexOf(ctxPtr);
+ union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
+ voidPtrPtr = &widgetPrivate->extraData()->glContext;
+ int index = d_ptr->contexts.indexOf(ctxPtrPtr);
if (index != -1) {
- delete *ctxPtr;
- *ctxPtr = 0;
+ delete *ctxPtrPtr;
+ *ctxPtrPtr = 0;
d_ptr->contexts.removeAt(index);
}
}
+#endif
}
}
@@ -455,7 +475,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
} else
ctx = new QGLContext(surfaceFormat, widget);
- ctx->create(qt_gl_share_widget()->context());
+ ctx->create(qt_gl_share_context());
if (widget != qt_gl_share_widget())
++(_qt_gl_share_widget()->widgetRefCount);
@@ -471,8 +491,8 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (haveNOKSwapRegion)
qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates.";
}
-
- bool swapBehaviourPreserved = ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR);
+ bool swapBehaviourPreserved = (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED)
+ || (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
if (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT) {
EGLint swapBehavior;
if (eglQuerySurface(ctx->d_func()->eglContext->display(), ctx->d_func()->eglSurface
@@ -482,19 +502,21 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
}
if (!swapBehaviourPreserved && !haveNOKSwapRegion)
- setPartialUpdateSupport(false); // Force full-screen updates
+ d_ptr->partialUpdateSupport = false; // Force full-screen updates
else
- setPartialUpdateSupport(true);
+ d_ptr->partialUpdateSupport = true;
+#else
+ d_ptr->partialUpdateSupport = false;
#endif
widgetPrivate->extraData()->glContext = ctx;
- union { QGLContext **ctxPtr; void **voidPtr; };
+ union { QGLContext **ctxPtrPtr; void **voidPtrPtr; };
connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(deleted(QObject*)));
- voidPtr = &widgetPrivate->extraData()->glContext;
- d_ptr->contexts << ctxPtr;
+ voidPtrPtr = &widgetPrivate->extraData()->glContext;
+ d_ptr->contexts << ctxPtrPtr;
#ifndef Q_OS_SYMBIAN
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
#endif
@@ -526,6 +548,7 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
void QGLWindowSurface::beginPaint(const QRegion &)
{
+ d_ptr->did_paint = true;
updateGeometry();
if (!context())
@@ -542,8 +565,6 @@ void QGLWindowSurface::beginPaint(const QRegion &)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
}
-
- d_ptr->did_paint = true;
}
void QGLWindowSurface::endPaint(const QRegion &rgn)
@@ -607,8 +628,13 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
Q_ASSERT(parent);
+#if !defined(Q_WS_QPA)
if (!geometry().isValid())
return;
+#else
+ if (!size().isValid())
+ return;
+#endif
// Needed to support native child-widgets...
hijackWindow(parent);
@@ -842,12 +868,19 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
}
+#if !defined(Q_WS_QPA)
void QGLWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
d_ptr->geometry_updated = true;
}
-
+#else
+void QGLWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+ d_ptr->geometry_updated = true;
+}
+#endif
void QGLWindowSurface::updateGeometry() {
if (!d_ptr->geometry_updated)
@@ -947,7 +980,7 @@ void QGLWindowSurface::updateGeometry() {
}
}
-#if !defined(QT_OPENGL_ES_2)
+#if !defined(QT_OPENGL_ES_2) && !defined(Q_WS_QPA) //QPA doesn't support pixelbuffers
if (d_ptr->destructive_swap_buffers && (d_ptr->pb || !d_ptr->tried_pb)) {
d_ptr->tried_pb = true;
@@ -986,7 +1019,7 @@ void QGLWindowSurface::updateGeometry() {
d_ptr->pb = 0;
}
}
-#endif // !defined(QT_OPENGL_ES_2)
+#endif // !defined(QT_OPENGL_ES_2) !defined(Q_WS_QPA)
ctx->makeCurrent();
@@ -1133,6 +1166,11 @@ QImage *QGLWindowSurface::buffer(const QWidget *widget)
return &d_ptr->buffers.last();
}
+bool QGLWindowSurface::hasPartialUpdateSupport() const
+{
+ return d_ptr->partialUpdateSupport;
+}
+
QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index 4af5492..e1689bf 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -66,8 +66,12 @@ class QRegion;
class QWidget;
struct QGLWindowSurfacePrivate;
+#ifdef Q_WS_QPA
+Q_OPENGL_EXPORT const QGLContext* qt_gl_share_context();
+#else
Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
Q_OPENGL_EXPORT void qt_destroy_gl_share_widget();
+#endif
class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice
{
@@ -89,7 +93,13 @@ public:
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+
+#if !defined(Q_WS_QPA)
void setGeometry(const QRect &rect);
+#else
+ virtual void resize(const QSize &size);
+#endif
+
void updateGeometry();
bool scroll(const QRegion &area, int dx, int dy);
@@ -98,6 +108,8 @@ public:
QImage *buffer(const QWidget *widget);
+ bool hasPartialUpdateSupport() const;
+
QGLContext *context() const;
static QGLFormat surfaceFormat;
diff --git a/src/opengl/util/meego/main.cpp b/src/opengl/util/meego/main.cpp
new file mode 100644
index 0000000..65d6e57
--- /dev/null
+++ b/src/opengl/util/meego/main.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 <QtCore/qdebug.h>
+
+#define QT_DEBUG_SHADER_CACHE
+#define QT_MEEGO_EXPERIMENTAL_SHADERCACHE
+#define QT_OPENGL_ES_2
+#define QT_BOOTSTRAPPED
+
+typedef int GLsizei;
+typedef unsigned int GLenum;
+
+#include "../../gl2paintengineex/qglshadercache_meego_p.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+ ShaderCacheSharedMemory shm;
+
+ if (!shm.isAttached()) {
+ fprintf(stderr, "Unable to attach to shared memory\n");
+ return EXIT_FAILURE;
+ }
+
+ ShaderCacheLocker locker(&shm);
+ if (!locker.isLocked()) {
+ fprintf(stderr, "Unable to lock shared memory\n");
+ return EXIT_FAILURE;
+ }
+
+ void *data = shm.data();
+ Q_ASSERT(data);
+
+ CachedShaders *cache = reinterpret_cast<CachedShaders *>(data);
+
+ for (int i = 0; i < cache->shaderCount; ++i) {
+ printf("Shader %d: %d bytes\n", i, cache->headers[i].size);
+ }
+
+ printf("\nSummary:\n\n"
+ " Amount of cached shaders: %d\n"
+ " Bytes used: %d\n"
+ " Bytes available: %d\n",
+ cache->shaderCount, cache->dataSize, cache->availableSize());
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/src/opengl/util/meego/shader-cache-introspector.pro b/src/opengl/util/meego/shader-cache-introspector.pro
new file mode 100644
index 0000000..520e9a5
--- /dev/null
+++ b/src/opengl/util/meego/shader-cache-introspector.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+
+SOURCES += main.cpp
+
+TARGET = shader-cache-introspector
+
+QT = core
diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro
index c05af90..e185949 100644
--- a/src/openvg/openvg.pro
+++ b/src/openvg/openvg.pro
@@ -38,11 +38,18 @@ 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)
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
symbian:TARGET.UID3 = 0x2001E62F
!isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index 9ce7f9a..6f99de4 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -57,7 +57,6 @@ QVGWindowSurface::QVGWindowSurface(QWidget *window)
{
// Create the default type of EGL window surface for windows.
d_ptr = new QVGEGLWindowSurfaceDirect(this);
- setStaticContentsSupport(d_ptr->supportsStaticContents());
}
QVGWindowSurface::QVGWindowSurface
@@ -120,6 +119,11 @@ QPaintEngine *QVGWindowSurface::paintEngine() const
return d_ptr->paintEngine();
}
+bool QVGWindowSurface::hasStaticContentsSupport() const
+{
+ d_ptr->supportsStaticContents();
+}
+
int QVGWindowSurface::metric(PaintDeviceMetric met) const
{
return qt_paint_device_metric(window(), met);
diff --git a/src/openvg/qwindowsurface_vg_p.h b/src/openvg/qwindowsurface_vg_p.h
index 06b16d0..2d6b4f9 100644
--- a/src/openvg/qwindowsurface_vg_p.h
+++ b/src/openvg/qwindowsurface_vg_p.h
@@ -78,6 +78,8 @@ public:
QPaintEngine *paintEngine() const;
+ bool hasStaticContentsSupport() const;
+
protected:
int metric(PaintDeviceMetric metric) const;
diff --git a/src/phonon/phonon.pro b/src/phonon/phonon.pro
index 7f79d0b..b16c5a1 100644
--- a/src/phonon/phonon.pro
+++ b/src/phonon/phonon.pro
@@ -11,7 +11,7 @@ DEFINES += MAKE_PHONON_LIB
PHONON_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/phonon
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
# Input
HEADERS += $$PHONON_DIR/abstractaudiooutput.h \
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index 45257dd..09b5015 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -348,7 +348,7 @@ QVariant QAccessibleTextEdit::invokeMethodEx(QAccessible::Method method, int chi
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
- return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
}
case SetCursorPosition:
diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp
index b8e3e4e..1f5407a 100644
--- a/src/plugins/accessible/widgets/rangecontrols.cpp
+++ b/src/plugins/accessible/widgets/rangecontrols.cpp
@@ -233,7 +233,7 @@ QVariant QAccessibleAbstractSpinBox::invokeMethodEx(Method method, int child, co
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods;
- return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
}
default:
@@ -814,7 +814,7 @@ QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, con
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods;
- return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
}
default:
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp
index 58408c8..21d2d67 100644
--- a/src/plugins/accessible/widgets/simplewidgets.cpp
+++ b/src/plugins/accessible/widgets/simplewidgets.cpp
@@ -732,7 +732,7 @@ QVariant QAccessibleLineEdit::invokeMethodEx(QAccessible::Method method, int chi
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
- return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
+ return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
}
case SetCursorPosition:
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
index ac88a1c..02b5eb9 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -870,7 +870,6 @@ quint64 QConnmanCounterInterface::getTimeOnline()
return 0;
}
-
/////////////////////////////////////////
QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent)
: QObject(parent)
diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp
index 2a22280..e3fb2c6 100644
--- a/src/plugins/bearer/connman/qofonoservice_linux.cpp
+++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp
@@ -53,6 +53,8 @@
#include "qofonoservice_linux_p.h"
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
static QDBusConnection dbusConnection = QDBusConnection::systemBus();
@@ -938,3 +940,6 @@ void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message)
}
QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h
index 4db08f5..af54ba0 100644
--- a/src/plugins/bearer/connman/qofonoservice_linux_p.h
+++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h
@@ -65,6 +65,9 @@
#include <QtDBus/QDBusContext>
#include <QMap>
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
#define OFONO_SERVICE "org.ofono"
#define OFONO_MANAGER_INTERFACE "org.ofono.Manager"
#define OFONO_MANAGER_PATH "/"
@@ -331,4 +334,7 @@ Q_SIGNALS:
QT_END_NAMESPACE
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
#endif //QOFONOSERVICE_H
diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro
index 9cb3955..90078e9 100644
--- a/src/plugins/bearer/corewlan/corewlan.pro
+++ b/src/plugins/bearer/corewlan/corewlan.pro
@@ -16,9 +16,10 @@ HEADERS += qcorewlanengine.h \
../qbearerengine_impl.h
SOURCES += main.cpp \
- qcorewlanengine.mm \
../qnetworksession_impl.cpp
+OBJECTIVE_SOURCES += qcorewlanengine.mm
+
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
target.path += $$[QT_INSTALL_PLUGINS]/bearer
INSTALLS += target
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 533a7cd..07e74fe 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -864,7 +864,7 @@ quint64 QCoreWlanEngine::bytesReceived(const QString &id)
return getBytes(interfaceStr,true);
}
-quint64 QCoreWlanEngine::startTime(const QString &id)
+quint64 QCoreWlanEngine::startTime(const QString &identifier)
{
QMutexLocker locker(&mutex);
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
@@ -899,7 +899,7 @@ quint64 QCoreWlanEngine::startTime(const QString &id)
for(int i = 0; i < dictSize; i++) {
if([ssidStr isEqualToString:keys[i]]) {
const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString(objects[i])));
- if(ident == id) {
+ if(ident == identifier) {
ok = true;
}
}
diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h
index 89d3384..b102183 100644
--- a/src/plugins/bearer/platformdefs_win.h
+++ b/src/plugins/bearer/platformdefs_win.h
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
#define NS_NLA 15
+#ifndef NLA_NAMESPACE_GUID
enum NLA_BLOB_DATA_TYPE {
NLA_RAW_DATA = 0,
NLA_INTERFACE = 1,
@@ -115,6 +116,8 @@ struct NLA_BLOB {
} ICS;
} data;
};
+#endif // NLA_NAMESPACE_GUID
+
#endif
enum NDIS_MEDIUM {
@@ -135,4 +138,4 @@ enum NDIS_PHYSICAL_MEDIUM {
QT_END_NAMESPACE
-#endif
+#endif // QPLATFORMDEFS_WIN_H
diff --git a/src/plugins/bearer/qbearerengine_impl.h b/src/plugins/bearer/qbearerengine_impl.h
index 601143e..ac96207 100644
--- a/src/plugins/bearer/qbearerengine_impl.h
+++ b/src/plugins/bearer/qbearerengine_impl.h
@@ -60,8 +60,8 @@ public:
DisconnectionError,
};
- QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) { }
- ~QBearerEngineImpl() { }
+ QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) {}
+ ~QBearerEngineImpl() {}
virtual void connectToId(const QString &id) = 0;
virtual void disconnectFromId(const QString &id) = 0;
@@ -81,4 +81,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+
+#endif // QBEARERENGINE_IMPL_H
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index 5c9e234..c41e3e0 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -45,9 +45,10 @@
#include <QtNetwork/qnetworksession.h>
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
-#include <QtCore/qstringlist.h>
+#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmutex.h>
+#include <QtCore/qstringlist.h>
#ifndef QT_NO_BEARERMANAGEMENT
@@ -71,10 +72,11 @@ class QNetworkSessionManagerPrivate : public QObject
Q_OBJECT
public:
- QNetworkSessionManagerPrivate(QObject *parent = 0);
- ~QNetworkSessionManagerPrivate();
+ QNetworkSessionManagerPrivate(QObject *parent = 0) : QObject(parent) {}
+ ~QNetworkSessionManagerPrivate() {}
- void forceSessionClose(const QNetworkConfiguration &config);
+ inline void forceSessionClose(const QNetworkConfiguration &config)
+ { emit forcedSessionClose(config); }
Q_SIGNALS:
void forcedSessionClose(const QNetworkConfiguration &config);
@@ -84,20 +86,6 @@ Q_SIGNALS:
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
-QNetworkSessionManagerPrivate::QNetworkSessionManagerPrivate(QObject *parent)
-: QObject(parent)
-{
-}
-
-QNetworkSessionManagerPrivate::~QNetworkSessionManagerPrivate()
-{
-}
-
-void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguration &config)
-{
- emit forcedSessionClose(config);
-}
-
void QNetworkSessionPrivateImpl::syncStateWithInterface()
{
connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
@@ -108,8 +96,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
state = QNetworkSession::Invalid;
lastError = QNetworkSession::UnknownSessionError;
- qRegisterMetaType<QBearerEngineImpl::ConnectionError>
- ("QBearerEngineImpl::ConnectionError");
+ qRegisterMetaType<QBearerEngineImpl::ConnectionError>("QBearerEngineImpl::ConnectionError");
switch (publicConfig.type()) {
case QNetworkConfiguration::InternetAccessPoint:
@@ -145,9 +132,8 @@ void QNetworkSessionPrivateImpl::open()
lastError = QNetworkSession::OperationNotSupportedError;
emit QNetworkSessionPrivate::error(lastError);
} else if (!isOpen) {
- if ((activeConfig.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- lastError =QNetworkSession::InvalidConfigurationError;
+ if ((activeConfig.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
+ lastError = QNetworkSession::InvalidConfigurationError;
state = QNetworkSession::Invalid;
emit stateChanged(state);
emit QNetworkSessionPrivate::error(lastError);
@@ -221,11 +207,10 @@ void QNetworkSessionPrivateImpl::reject()
#ifndef QT_NO_NETWORKINTERFACE
QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
{
- if (!publicConfig.isValid() || !engine || state != QNetworkSession::Connected)
+ if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid())
return QNetworkInterface();
QString interface = engine->getInterfaceFromId(activeConfig.identifier());
-
if (interface.isEmpty())
return QNetworkInterface();
return QNetworkInterface::interfaceFromName(interface);
@@ -237,10 +222,7 @@ QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
if (key == QLatin1String("AutoCloseSessionTimeout")) {
if (engine && engine->requiresPolling() &&
!(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
- if (sessionTimeout >= 0)
- return sessionTimeout * 10000;
- else
- return -1;
+ return sessionTimeout >= 0 ? sessionTimeout * 10000 : -1;
}
}
@@ -278,7 +260,8 @@ QString QNetworkSessionPrivateImpl::errorString() const
return tr("The specified configuration cannot be used.");
case QNetworkSession::RoamingError:
return tr("Roaming was aborted or is not possible.");
-
+ default:
+ break;
}
return QString();
@@ -293,24 +276,21 @@ quint64 QNetworkSessionPrivateImpl::bytesWritten() const
{
if (engine && state == QNetworkSession::Connected)
return engine->bytesWritten(activeConfig.identifier());
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
quint64 QNetworkSessionPrivateImpl::bytesReceived() const
{
if (engine && state == QNetworkSession::Connected)
return engine->bytesReceived(activeConfig.identifier());
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
quint64 QNetworkSessionPrivateImpl::activeTime() const
{
if (state == QNetworkSession::Connected && startTime != Q_UINT64_C(0))
return QDateTime::currentDateTime().toTime_t() - startTime;
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
@@ -323,17 +303,15 @@ void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
if (activeConfig != config) {
if (engine) {
- disconnect(engine,
- SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this,
- SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
+ disconnect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
+ this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
}
activeConfig = config;
engine = getEngineFromId(activeConfig.identifier());
+
if (engine) {
- connect(engine,
- SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
+ connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
Qt::QueuedConnection);
}
@@ -362,7 +340,6 @@ void QNetworkSessionPrivateImpl::updateStateFromActiveConfig()
return;
QNetworkSession::State oldState = state;
-
state = engine->sessionStateForId(activeConfig.identifier());
bool oldActive = isOpen;
@@ -410,8 +387,7 @@ void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration
}
}
-void QNetworkSessionPrivateImpl::connectionError(const QString &id,
- QBearerEngineImpl::ConnectionError error)
+void QNetworkSessionPrivateImpl::connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
{
if (activeConfig.identifier() == id) {
networkConfigurationsChanged();
@@ -443,4 +419,3 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-
diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h
index ab85869..644565a 100644
--- a/src/plugins/bearer/qnetworksession_impl.h
+++ b/src/plugins/bearer/qnetworksession_impl.h
@@ -58,8 +58,6 @@
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
#include <QtNetwork/private/qnetworksession_p.h>
-#include <QtCore/qdatetime.h>
-
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
@@ -69,15 +67,13 @@ class QBearerEngineImpl;
class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
{
Q_OBJECT
+
public:
QNetworkSessionPrivateImpl()
- : startTime(0), sessionTimeout(-1)
- {
- }
-
+ : startTime(0), sessionTimeout(-1)
+ {}
~QNetworkSessionPrivateImpl()
- {
- }
+ {}
//called by QNetworkSession constructor and ensures
//that the state is immediately updated (w/o actually opening
@@ -106,10 +102,6 @@ public:
quint64 bytesReceived() const;
quint64 activeTime() const;
-private:
- void updateStateFromServiceNetwork();
- void updateStateFromActiveConfig();
-
private Q_SLOTS:
void networkConfigurationsChanged();
void configurationChanged(QNetworkConfigurationPrivatePointer config);
@@ -118,6 +110,10 @@ private Q_SLOTS:
void decrementTimeout();
private:
+ void updateStateFromServiceNetwork();
+ void updateStateFromActiveConfig();
+
+private:
QBearerEngineImpl *engine;
quint64 startTime;
@@ -133,5 +129,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSION_IMPL_H
-
+#endif // QNETWORKSESSION_IMPL_H
diff --git a/src/plugins/codecs/kr/qeuckrcodec.cpp b/src/plugins/codecs/kr/qeuckrcodec.cpp
index fb27587..f490a82 100644
--- a/src/plugins/codecs/kr/qeuckrcodec.cpp
+++ b/src/plugins/codecs/kr/qeuckrcodec.cpp
@@ -67,11 +67,6 @@
#include "qeuckrcodec.h"
#include "cp949codetbl.h"
-#include <stdlib.h>
-
-#if defined(Q_OS_WINCE)
-# include <qfunctions_wince.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -3402,11 +3397,6 @@ QByteArray QCP949Codec::_name()
return "cp949";
}
-int compare_ushort(const void *a, const void *b)
-{
- return *(unsigned short *)a - *(unsigned short *)b;
-}
-
/*!
\reimp
*/
@@ -3434,10 +3424,8 @@ QByteArray QCP949Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt
*cursor++ = (j >> 8) | 0x80;
*cursor++ = (j & 0xff) | 0x80;
} else {
- unsigned short *ptr = (unsigned short *)bsearch(&ch, cp949_icode_to_unicode, 8822,
- sizeof(unsigned short), compare_ushort);
-
- if(!ptr) {
+ const unsigned short *ptr = qBinaryFind(cp949_icode_to_unicode, cp949_icode_to_unicode + 8822, ch);
+ if (ptr == cp949_icode_to_unicode + 8822) {
// Error
*cursor++ = replacement;
++invalid;
diff --git a/src/plugins/generic/linuxinput/linuxinput.pro b/src/plugins/generic/linuxinput/linuxinput.pro
new file mode 100644
index 0000000..ad9f6a9
--- /dev/null
+++ b/src/plugins/generic/linuxinput/linuxinput.pro
@@ -0,0 +1,18 @@
+TARGET = qlinuxinputplugin
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic
+target.path = $$[QT_INSTALL_PLUGINS]/generic
+INSTALLS += target
+
+DEFINES += QT_QWS_KBD_LINUXINPUT
+
+HEADERS = qlinuxinput.h
+
+SOURCES = main.cpp \
+ qlinuxinput.cpp
+
+HEADERS += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.h \
+ $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws_p.h
+
+SOURCES += $$QT_SOURCE_TREE/src/gui/embedded/qkbd_qws.cpp
diff --git a/src/plugins/generic/linuxinput/main.cpp b/src/plugins/generic/linuxinput/main.cpp
new file mode 100644
index 0000000..dc05254
--- /dev/null
+++ b/src/plugins/generic/linuxinput/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qgenericplugin_qpa.h>
+#include "qlinuxinput.h"
+
+QT_BEGIN_NAMESPACE
+
+class QLinuxInputPlugin : public QGenericPlugin
+{
+public:
+ QLinuxInputPlugin();
+
+ QStringList keys() const;
+ QObject* create(const QString &key, const QString &specification);
+};
+
+QLinuxInputPlugin::QLinuxInputPlugin()
+ : QGenericPlugin()
+{
+}
+
+QStringList QLinuxInputPlugin::keys() const
+{
+ return (QStringList()
+ << QLatin1String("LinuxInputMouse")
+ << QLatin1String("LinuxInputKeyboard"));
+}
+
+QObject* QLinuxInputPlugin::create(const QString &key,
+ const QString &specification)
+{
+ if (!key.compare(QLatin1String("LinuxInputMouse"), Qt::CaseInsensitive))
+ return new QLinuxInputMouseHandler(key, specification);
+ if (!key.compare(QLatin1String("LinuxInputKeyboard"), Qt::CaseInsensitive))
+ return new QLinuxInputKeyboardHandler(key, specification);
+ return 0;
+ }
+
+Q_EXPORT_PLUGIN2(qlinuxinputplugin, QLinuxInputPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/linuxinput/qlinuxinput.cpp b/src/plugins/generic/linuxinput/qlinuxinput.cpp
new file mode 100644
index 0000000..c5bfd33
--- /dev/null
+++ b/src/plugins/generic/linuxinput/qlinuxinput.cpp
@@ -0,0 +1,557 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qlinuxinput.h"
+
+
+#include <QSocketNotifier>
+#include <QStringList>
+#include <QPoint>
+#include <QWindowSystemInterface>
+
+#include <qkbd_qws.h>
+
+
+#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
+#include <errno.h>
+#include <termios.h>
+
+#include <linux/kd.h>
+#include <linux/input.h>
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+
+//#define QT_QPA_EXPERIMENTAL_TOUCHEVENT
+
+#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT
+class QLinuxInputMouseHandlerData
+{
+public:
+ QLinuxInputMouseHandlerData() :seenMT(false), state(QEvent::TouchBegin), currentIdx(0) {}
+
+ void ensureCurrentPoint() {
+ if (currentIdx >= touchPoints.size()) {
+ Q_ASSERT(currentIdx == touchPoints.size());
+ QWindowSystemInterface::TouchPoint tp;
+ tp.id = currentIdx;
+ tp.isPrimary = (currentIdx == 0);
+ tp.pressure = 1;
+ tp.area = QRectF(0,0,1,1);
+ tp.state = Qt::TouchPointReleased; // init in neutral state
+ touchPoints.append(tp);
+ }
+ }
+ void setCurrentPoint(int i) {
+ currentIdx = i;
+ if (currentIdx < touchPoints.size()) {
+ currentX = int(touchPoints[currentIdx].area.left());
+ currentY = int(touchPoints[currentIdx].area.top());
+ } else {
+ currentY = currentX = -999;
+ }
+ }
+ void advanceCurrentPoint() {
+ setCurrentPoint(currentIdx + 1);
+ }
+ int currentPoint() { return currentIdx; }
+ void setCurrentX(int value) {
+ ensureCurrentPoint();
+ touchPoints[currentIdx].area.moveLeft(value);
+ }
+ bool currentMoved() {
+ return currentX != touchPoints[currentIdx].area.left() || currentY != touchPoints[currentIdx].area.top();
+ }
+ void updateCurrentPos() {
+ ensureCurrentPoint();
+ touchPoints[currentIdx].area.moveTopLeft(QPointF(currentX, currentY));
+ }
+ void setCurrentState(Qt::TouchPointState state) {
+ ensureCurrentPoint();
+ touchPoints[currentIdx].state = state;
+ }
+ Qt::TouchPointState currentState() const {
+ if (currentIdx < touchPoints.size())
+ return touchPoints[currentIdx].state;
+ return Qt::TouchPointReleased;
+ }
+ QList<QWindowSystemInterface::TouchPoint> touchPoints;
+ int currentX;
+ int currentY;
+ bool seenMT;
+ QEvent::Type state;
+private:
+ int currentIdx;
+};
+#endif
+
+
+QLinuxInputMouseHandler::QLinuxInputMouseHandler(const QString &key,
+ const QString &specification)
+ : m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), m_xoffset(0), m_yoffset(0), m_buttons(0), d(0)
+{
+ qDebug() << "QLinuxInputMouseHandler" << key << specification;
+
+
+ setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler"));
+
+ QString dev = QLatin1String("/dev/input/event0");
+ m_compression = true;
+ m_smooth = false;
+ int jitterLimit = 0;
+
+ QStringList args = specification.split(QLatin1Char(':'));
+ foreach (const QString &arg, args) {
+ if (arg == "nocompress")
+ m_compression = false;
+ else if (arg.startsWith("dejitter="))
+ jitterLimit = arg.mid(9).toInt();
+ else if (arg.startsWith("xoffset="))
+ m_xoffset = arg.mid(8).toInt();
+ else if (arg.startsWith("yoffset="))
+ m_yoffset = arg.mid(8).toInt();
+ else if (arg.startsWith(QLatin1String("/dev/")))
+ dev = arg;
+ }
+ m_jitterLimitSquared = jitterLimit*jitterLimit;
+
+ m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
+ if (m_fd >= 0) {
+ m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
+ } else {
+ qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
+ }
+#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT
+ d = new QLinuxInputMouseHandlerData;
+#endif
+}
+
+
+QLinuxInputMouseHandler::~QLinuxInputMouseHandler()
+{
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
+#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT
+ delete d;
+#endif
+}
+
+void QLinuxInputMouseHandler::sendMouseEvent(int x, int y, Qt::MouseButtons buttons)
+{
+ QPoint pos(x+m_xoffset, y+m_yoffset);
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons);
+ m_prevx = x;
+ m_prevy = y;
+}
+
+void QLinuxInputMouseHandler::readMouseData()
+{
+ struct ::input_event buffer[32];
+ int n = 0;
+ bool posChanged = false;
+ bool pendingMouseEvent = false;
+ int eventCompressCount = 0;
+ forever {
+ n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+
+ if (n == 0) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ } else if (n % sizeof(buffer[0]) == 0) {
+ break;
+ }
+ }
+
+ n /= sizeof(buffer[0]);
+
+ for (int i = 0; i < n; ++i) {
+ struct ::input_event *data = &buffer[i];
+ //qDebug() << ">>" << hex << data->type << data->code << dec << data->value;
+ bool unknown = false;
+ if (data->type == EV_ABS) {
+ if (data->code == ABS_X && m_x != data->value) {
+ m_x = data->value;
+ posChanged = true;
+ } else if (data->code == ABS_Y && m_y != data->value) {
+ m_y = data->value;
+ posChanged = true;
+ } else if (data->code == ABS_PRESSURE) {
+ //ignore for now...
+ } else if (data->code == ABS_TOOL_WIDTH) {
+ //ignore for now...
+ } else if (data->code == ABS_HAT0X) {
+ //ignore for now...
+ } else if (data->code == ABS_HAT0Y) {
+ //ignore for now...
+#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT
+ } else if (data->code == ABS_MT_POSITION_X) {
+ d->currentX = data->value;
+ d->seenMT = true;
+ } else if (data->code == ABS_MT_POSITION_Y) {
+ d->currentY = data->value;
+ d->seenMT = true;
+ } else if (data->code == ABS_MT_TOUCH_MAJOR) {
+ if (data->value == 0)
+ d->setCurrentState(Qt::TouchPointReleased);
+ //otherwise, ignore for now...
+ } else if (data->code == ABS_MT_TOUCH_MINOR) {
+ //ignore for now...
+#endif
+ } else {
+ unknown = true;
+ }
+ } else if (data->type == EV_REL) {
+ if (data->code == REL_X) {
+ m_x += data->value;
+ posChanged = true;
+ } else if (data->code == REL_Y) {
+ m_y += data->value;
+ posChanged = true;
+ } else if (data->code == ABS_WHEEL) { // vertical scroll
+ // data->value: 1 == up, -1 == down
+ int delta = 120 * data->value;
+ QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
+ QPoint(m_x, m_y),
+ delta, Qt::Vertical);
+ } else if (data->code == ABS_THROTTLE) { // horizontal scroll
+ // data->value: 1 == right, -1 == left
+ int delta = 120 * -data->value;
+ QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
+ QPoint(m_x, m_y),
+ delta, Qt::Horizontal);
+ } else {
+ unknown = true;
+ }
+ } else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
+ m_buttons = data->value ? Qt::LeftButton : Qt::NoButton;
+
+ sendMouseEvent(m_x, m_y, m_buttons);
+ pendingMouseEvent = false;
+ } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_MIDDLE) {
+ Qt::MouseButton button = Qt::NoButton;
+ switch (data->code) {
+ case BTN_LEFT: button = Qt::LeftButton; break;
+ case BTN_MIDDLE: button = Qt::MidButton; break;
+ case BTN_RIGHT: button = Qt::RightButton; break;
+ }
+ if (data->value)
+ m_buttons |= button;
+ else
+ m_buttons &= ~button;
+ sendMouseEvent(m_x, m_y, m_buttons);
+ pendingMouseEvent = false;
+ } else if (data->type == EV_SYN && data->code == SYN_REPORT) {
+ if (posChanged) {
+ posChanged = false;
+ if (m_compression) {
+ pendingMouseEvent = true;
+ eventCompressCount++;
+ } else {
+ sendMouseEvent(m_x, m_y, m_buttons);
+ }
+ }
+#ifdef QT_QPA_EXPERIMENTAL_TOUCHEVENT
+ if (d->state == QEvent::TouchBegin && !d->seenMT) {
+ //no multipoint-touch events to send
+ } else {
+ if (!d->seenMT)
+ d->state = QEvent::TouchEnd;
+
+ for (int i = d->currentPoint(); i < d->touchPoints.size(); ++i) {
+ d->touchPoints[i].pressure = 0;
+ d->touchPoints[i].state = Qt::TouchPointReleased;
+ }
+ //qDebug() << "handleTouchEvent" << d->state << d->touchPoints.size() << d->touchPoints[0].state;
+ QWindowSystemInterface::handleTouchEvent(0, d->state, QTouchEvent::TouchScreen, d->touchPoints);
+ if (d->seenMT) {
+ d->state = QEvent::TouchUpdate;
+ } else {
+ d->state = QEvent::TouchBegin;
+ d->touchPoints.clear();
+ }
+ d->setCurrentPoint(0);
+ d->seenMT = false;
+ }
+ } else if (data->type == EV_SYN && data->code == SYN_MT_REPORT) {
+ //store data for this touch point
+
+ if (!d->seenMT) {
+ d->setCurrentState(Qt::TouchPointReleased);
+ } else if (d->currentState() == Qt::TouchPointReleased) {
+ d->updateCurrentPos();
+ d->setCurrentState(Qt::TouchPointPressed);
+ } else if (d->currentMoved()) {
+ d->updateCurrentPos();
+ d->setCurrentState(Qt::TouchPointMoved);
+ } else {
+ d->setCurrentState(Qt::TouchPointStationary);
+ }
+ //qDebug() << "end of point" << d->currentPoint() << d->currentX << d->currentY << d->currentState();
+
+ //advance to next tp:
+ d->advanceCurrentPoint();
+#endif
+ } else if (data->type == EV_MSC && data->code == MSC_SCAN) {
+ // kernel encountered an unmapped key - just ignore it
+ continue;
+ } else {
+ unknown = true;
+ }
+#ifdef QLINUXINPUT_EXTRA_DEBUG
+ if (unknown) {
+ qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value);
+ }
+#endif
+ }
+ if (m_compression && pendingMouseEvent) {
+ int distanceSquared = (m_x - m_prevx)*(m_x - m_prevx) + (m_y - m_prevy)*(m_y - m_prevy);
+ if (distanceSquared > m_jitterLimitSquared)
+ sendMouseEvent(m_x, m_y, m_buttons);
+ }
+}
+
+
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//Keyboard handler
+
+
+
+
+class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler
+{
+public:
+ QWSLinuxInputKeyboardHandler(const QString&);
+ ~QWSLinuxInputKeyboardHandler();
+
+ virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value);
+
+//private:
+// QWSLinuxInputKbPrivate *d;
+};
+
+
+QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device)
+ : QWSKeyboardHandler(device)
+{
+}
+
+QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler()
+{
+}
+
+bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &)
+{
+ return false;
+}
+
+
+QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(const QString &key, const QString &specification)
+ : m_handler(0), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE)
+{
+ setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler"));
+
+ QString dev = QLatin1String("/dev/input/event1");
+ int repeat_delay = -1;
+ int repeat_rate = -1;
+
+ bool ttymode = false;
+
+ QStringList args = specification.split(QLatin1Char(':'));
+ foreach (const QString &arg, args) {
+ if (arg.startsWith(QLatin1String("repeat-delay=")))
+ repeat_delay = arg.mid(13).toInt();
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
+ repeat_rate = arg.mid(12).toInt();
+ else if (arg.startsWith(QLatin1String("ttymode")))
+ ttymode = true;
+ else if (arg.startsWith(QLatin1String("/dev/")))
+ dev = arg;
+ }
+
+ m_handler = new QWSLinuxInputKeyboardHandler(dev); //This is a hack to avoid copying all the QWS code
+
+ m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
+ if (m_fd >= 0) {
+ if (repeat_delay > 0 && repeat_rate > 0) {
+ int kbdrep[2] = { repeat_delay, repeat_rate };
+ ::ioctl(m_fd, EVIOCSREP, kbdrep);
+ }
+
+ QSocketNotifier *notifier;
+ notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
+
+ if (ttymode) {
+ // play nice in case we are started from a shell (e.g. for debugging)
+ m_tty_fd = isatty(0) ? 0 : -1;
+
+ if (m_tty_fd >= 0) {
+ // save tty config for restore.
+ tcgetattr(m_tty_fd, &m_tty_attr);
+
+ struct ::termios termdata;
+ tcgetattr(m_tty_fd, &termdata);
+
+ // record the original mode so we can restore it again in the destructor.
+ ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
+
+ // setting this translation mode is even needed in INPUT mode to prevent
+ // the shell from also interpreting codes, if the process has a tty
+ // attached: e.g. Ctrl+C wouldn't copy, but kill the application.
+ ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
+
+ // set the tty layer to pass-through
+ termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ termdata.c_oflag = 0;
+ termdata.c_cflag = CREAD | CS8;
+ termdata.c_lflag = 0;
+ termdata.c_cc[VTIME]=0;
+ termdata.c_cc[VMIN]=1;
+ cfsetispeed(&termdata, 9600);
+ cfsetospeed(&termdata, 9600);
+ tcsetattr(m_tty_fd, TCSANOW, &termdata);
+ }
+ }
+ } else {
+ qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
+ }
+}
+
+QLinuxInputKeyboardHandler::~QLinuxInputKeyboardHandler()
+{
+ if (m_tty_fd >= 0) {
+ ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
+ tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
+ }
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
+ delete m_handler;
+}
+
+void QLinuxInputKeyboardHandler::switchLed(int led, bool state)
+{
+ struct ::input_event led_ie;
+ ::gettimeofday(&led_ie.time, 0);
+ led_ie.type = EV_LED;
+ led_ie.code = led;
+ led_ie.value = state;
+
+ QT_WRITE(m_fd, &led_ie, sizeof(led_ie));
+}
+
+
+
+void QLinuxInputKeyboardHandler::readKeycode()
+{
+ struct ::input_event buffer[32];
+ int n = 0;
+
+ forever {
+ n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
+
+ if (n == 0) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ } else if (n % sizeof(buffer[0]) == 0) {
+ break;
+ }
+ }
+
+ n /= sizeof(buffer[0]);
+
+ for (int i = 0; i < n; ++i) {
+ if (buffer[i].type != EV_KEY)
+ continue;
+
+ quint16 code = buffer[i].code;
+ qint32 value = buffer[i].value;
+
+ if (m_handler->filterInputEvent(code, value))
+ continue;
+
+ QWSKeyboardHandler::KeycodeAction ka;
+ ka = m_handler->processKeycode(code, value != 0, value == 2);
+
+ switch (ka) {
+ case QWSKeyboardHandler::CapsLockOn:
+ case QWSKeyboardHandler::CapsLockOff:
+ switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn);
+ break;
+
+ case QWSKeyboardHandler::NumLockOn:
+ case QWSKeyboardHandler::NumLockOff:
+ switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn);
+ break;
+
+ case QWSKeyboardHandler::ScrollLockOn:
+ case QWSKeyboardHandler::ScrollLockOff:
+ switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn);
+ break;
+
+ default:
+ // ignore console switching and reboot
+ break;
+ }
+ }
+}
+
+
+
+
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/generic/linuxinput/qlinuxinput.h b/src/plugins/generic/linuxinput/qlinuxinput.h
new file mode 100644
index 0000000..c94c0f4
--- /dev/null
+++ b/src/plugins/generic/linuxinput/qlinuxinput.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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 QLINUXINPUT_H
+#define QLINUXINPUT_H
+
+#include <qobject.h>
+#include <Qt>
+#include <termios.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+
+class QLinuxInputMouseHandlerData;
+
+class QLinuxInputMouseHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QLinuxInputMouseHandler(const QString &key, const QString &specification);
+ ~QLinuxInputMouseHandler();
+
+private slots:
+ void readMouseData();
+
+private:
+ void sendMouseEvent(int x, int y, Qt::MouseButtons buttons);
+ QSocketNotifier * m_notify;
+ int m_fd;
+ int m_x, m_y;
+ int m_prevx, m_prevy;
+ int m_xoffset, m_yoffset;
+ int m_smoothx, m_smoothy;
+ Qt::MouseButtons m_buttons;
+ bool m_compression;
+ bool m_smooth;
+ int m_jitterLimitSquared;
+ QLinuxInputMouseHandlerData *d;
+};
+
+
+class QWSLinuxInputKeyboardHandler;
+
+class QLinuxInputKeyboardHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QLinuxInputKeyboardHandler(const QString &key, const QString &specification);
+ ~QLinuxInputKeyboardHandler();
+
+
+private:
+ void switchLed(int, bool);
+
+private slots:
+ void readKeycode();
+
+private:
+ QWSLinuxInputKeyboardHandler *m_handler;
+ int m_fd;
+ int m_tty_fd;
+ struct termios m_tty_attr;
+ int m_orig_kbmode;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLINUXINPUT_H
diff --git a/src/plugins/generic/tslib/main.cpp b/src/plugins/generic/tslib/main.cpp
new file mode 100644
index 0000000..3c2d21c
--- /dev/null
+++ b/src/plugins/generic/tslib/main.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qgenericplugin_qpa.h>
+#include "qtslib.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTsLibPlugin : public QGenericPlugin
+{
+public:
+ QTsLibPlugin();
+
+ QStringList keys() const;
+ QObject* create(const QString &key, const QString &specification);
+};
+
+QTsLibPlugin::QTsLibPlugin()
+ : QGenericPlugin()
+{
+}
+
+QStringList QTsLibPlugin::keys() const
+{
+ return (QStringList()
+ << QLatin1String("Tslib")
+ << QLatin1String("TslibRaw"));
+}
+
+QObject* QTsLibPlugin::create(const QString &key,
+ const QString &specification)
+{
+ if (!key.compare(QLatin1String("Tslib"), Qt::CaseInsensitive) || !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive))
+ return new QTsLibMouseHandler(key, specification);
+ return 0;
+ }
+
+Q_EXPORT_PLUGIN2(qtslibplugin, QTsLibPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/tslib/qtslib.cpp b/src/plugins/generic/tslib/qtslib.cpp
new file mode 100644
index 0000000..0143db4
--- /dev/null
+++ b/src/plugins/generic/tslib/qtslib.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qtslib.h"
+
+
+#include <QSocketNotifier>
+#include <QStringList>
+#include <QPoint>
+#include <QWindowSystemInterface>
+
+#include <Qt>
+
+#include <errno.h>
+#include <tslib.h>
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
+ const QString &specification)
+ : m_notify(0), m_x(0), m_y(0), m_pressed(0), m_rawMode(false)
+{
+ qDebug() << "QTsLibMouseHandler" << key << specification;
+ setObjectName(QLatin1String("TSLib Mouse Handler"));
+
+ QByteArray device = "/dev/input/event1";
+ if (specification.startsWith("/dev/"))
+ device = specification.toLocal8Bit();
+
+ m_dev = ts_open(device.constData(), 1);
+
+ if (ts_config(m_dev)) {
+ perror("Error configuring\n");
+ }
+
+
+ m_rawMode = !key.compare(QLatin1String("TslibRaw"), Qt::CaseInsensitive);
+
+ int fd = ts_fd(m_dev);
+ if (fd >= 0) {
+ m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this);
+ connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
+ } else {
+ qWarning("Cannot open mouse input device '%s': %s", device.constData(), strerror(errno));
+ return;
+ }
+}
+
+
+QTsLibMouseHandler::~QTsLibMouseHandler()
+{
+ if (m_dev)
+ ts_close(m_dev);
+}
+
+
+static bool get_sample(struct tsdev *dev, struct ts_sample *sample, bool rawMode)
+{
+ if (rawMode) {
+ return (ts_read_raw(dev, sample, 1) == 1);
+ } else {
+ int ret = ts_read(dev, sample, 1);
+ return ( ret == 1);
+ }
+}
+
+
+void QTsLibMouseHandler::readMouseData()
+{
+ ts_sample sample;
+ while (get_sample(m_dev, &sample, m_rawMode)) {
+
+ bool pressed = sample.pressure;
+ int x = sample.x;
+ int y = sample.y;
+
+
+ if (!m_rawMode) {
+ //filtering: ignore movements of 2 pixels or less
+ int dx = x - m_x;
+ int dy = y - m_y;
+ if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed)
+ continue;
+ } else {
+ // work around missing coordinates on mouse release in raw mode
+ if (sample.pressure == 0 && sample.x == 0 && sample.y == 0) {
+ x = m_x;
+ y = m_y;
+ }
+ }
+ QPoint pos(x, y);
+
+ //printf("handleMouseEvent %d %d %d %ld\n", m_x, m_y, pressed, sample.tv.tv_usec);
+
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
+
+ m_x = x;
+ m_y = y;
+ m_pressed = pressed;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/tslib/qtslib.h b/src/plugins/generic/tslib/qtslib.h
new file mode 100644
index 0000000..4309185
--- /dev/null
+++ b/src/plugins/generic/tslib/qtslib.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the 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 QTSLIB_H
+#define QTSLIB_H
+
+#include <qobject.h>
+//#include <Qt>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+struct tsdev;
+
+class QTsLibMouseHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QTsLibMouseHandler(const QString &key, const QString &specification);
+ ~QTsLibMouseHandler();
+
+private slots:
+ void readMouseData();
+
+private:
+ QSocketNotifier * m_notify;
+ tsdev *m_dev;
+ int m_x, m_y;
+ bool m_pressed;
+ bool m_rawMode;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTSLIB_H
diff --git a/src/plugins/generic/tslib/tslib.pro b/src/plugins/generic/tslib/tslib.pro
new file mode 100644
index 0000000..74c7fd2
--- /dev/null
+++ b/src/plugins/generic/tslib/tslib.pro
@@ -0,0 +1,13 @@
+TARGET = qlinuxinputplugin
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic
+target.path = $$[QT_INSTALL_PLUGINS]/generic
+INSTALLS += target
+
+HEADERS = qtslib.h
+
+SOURCES = main.cpp \
+ qtslib.cpp
+
+LIBS += -lts
diff --git a/src/plugins/gfxdrivers/eglnullws/README b/src/plugins/gfxdrivers/eglnullws/README
new file mode 100644
index 0000000..80b88c7
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/README
@@ -0,0 +1,48 @@
+EGL NullWS QScreen Driver
+=========================
+
+If your application draws everything within a single full-screen QGLWidget then
+you may wish to use this QScreen plugin driver. This driver simply returns 0
+(as a EGLNativeWindowType value) when asked by the QtOpenGl module to create a
+native window. Some OpenGL ES implementations (including PowerVR) interpret this
+to mean that a full-screen OpenGL context is desired without any windowing
+support (NullWS).
+
+To tell a Qt/Embedded application to use this driver use the -display command
+line option or the QWS_DISPLAY environment variable. The following driver
+options are supported:
+
+size=WIDTHxHEIGHT Screen size reported by the driver
+format=FORMAT Screen format
+
+Run with '-display eglnullws:help' to get a full list of options (including a
+list of supported format strings).
+
+If you choose a screen format that is not supported by the hardware then the
+QtOpenGl module will write out a list of supported EGL configurations. Use
+one of the supported screen formats from this list.
+
+Using this driver with PowerVR hardware
+---------------------------------------
+
+Using this plugin with PowerVR hardware should give a significant speedup
+compared to running with the Qt powervr driver (with a full-screen QGLWidget).
+This is because sacrificing the window system allows less work to be done in
+order to get graphics on the screen. Using this driver also avoids the memory
+fragmentation issues present in the powervr driver and avoids any direct
+dependencies on the deprecated PVR2D API from Imagination Technologies.
+
+To use this driver ensure you have /etc/powervr.ini with contents similar to
+this:
+
+[default]
+WindowSystem=libpvrPVR2D_FLIPWSEGL.so
+
+This driver will also function with libpvrPVR2D_FRONTWSEGL.so, but that draws
+straight into the framebuffer and will therefore cause flickering (it can be
+useful for performance testing though). The flip plugin uses triple buffering,
+so you will need to set the virtual vertical resolution of your framebuffer to
+be three times the physical vertical resolution of your screen. This can be
+done with 'fbset -vyres'. Failure to do this can cause system crashes. You
+should also ensure that the plugin you choose in powervr.ini is in your library
+path (it may just silently default to the flip plugin if not).
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
new file mode 100644
index 0000000..242ab07
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
@@ -0,0 +1,18 @@
+TARGET = qeglnullws
+include(../../qpluginbase.pri)
+
+CONFIG += warn_on
+QT += opengl
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers
+
+target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
+INSTALLS += target
+
+HEADERS = eglnullwsscreen.h \
+ eglnullwsscreenplugin.h \
+ eglnullwswindowsurface.h
+
+SOURCES = eglnullwsscreen.cpp \
+ eglnullwsscreenplugin.cpp \
+ eglnullwswindowsurface.cpp
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
new file mode 100644
index 0000000..d090e85
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "eglnullwsscreen.h"
+#include "eglnullwswindowsurface.h"
+#include "eglnullwsscreenplugin.h"
+
+#include <QHash>
+#include <QDebug>
+
+namespace
+{
+ class EGLNullWSScreenSurfaceFunctions : public QGLScreenSurfaceFunctions
+ {
+ public:
+ virtual bool createNativeWindow(QWidget *, EGLNativeWindowType *native)
+ { *native = 0; return true; }
+ };
+}
+
+EGLNullWSScreen::EGLNullWSScreen(int displayId) : QGLScreen(displayId) {}
+
+EGLNullWSScreen::~EGLNullWSScreen() {}
+
+bool EGLNullWSScreen::initDevice()
+{
+ setSurfaceFunctions(new EGLNullWSScreenSurfaceFunctions);
+ return true;
+}
+
+static const QHash<QString, QImage::Format> formatDictionary()
+{
+ QHash<QString, QImage::Format> dictionary;
+ dictionary["rgb32"] = QImage::Format_RGB32;
+ dictionary["argb32"] = QImage::Format_ARGB32;
+ dictionary["rgb16"] = QImage::Format_RGB16;
+ dictionary["rgb666"] = QImage::Format_RGB666;
+ dictionary["rgb555"] = QImage::Format_RGB555;
+ dictionary["rgb888"] = QImage::Format_RGB888;
+ dictionary["rgb444"] = QImage::Format_RGB444;
+ return dictionary;
+}
+
+static int depthForFormat(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_RGB32: return 32;
+ case QImage::Format_ARGB32: return 32;
+ case QImage::Format_RGB16: return 16;
+ case QImage::Format_RGB666: return 24;
+ case QImage::Format_RGB555: return 16;
+ case QImage::Format_RGB888: return 24;
+ case QImage::Format_RGB444: return 16;
+ default:
+ Q_ASSERT_X(false, "EGLNullWSScreen", "Unknown format");
+ return -1;
+ }
+}
+
+static void printHelp(const QHash<QString, QImage::Format> &formatDictionary)
+{
+ QByteArray formatsBuf;
+ QTextStream(&formatsBuf) << QStringList(formatDictionary.keys()).join(", ");
+ qWarning(
+ "%s: Valid options are:\n"
+ "size=WIDTHxHEIGHT Screen size reported by this driver\n"
+ "format=FORMAT Screen format, where FORMAT is one of the following:\n"
+ " %s\n",
+ PluginName,
+ formatsBuf.constData());
+}
+
+bool EGLNullWSScreen::connect(const QString &displaySpec)
+{
+ const QStringList args = displaySpec.section(':', 1).split(':', QString::SkipEmptyParts);
+ const QHash<QString, QImage::Format> formatDict = formatDictionary();
+ Q_FOREACH(const QString arg, args) {
+ const QString optionName = arg.section('=', 0, 0);
+ const QString optionArg = arg.section('=', 1);
+ if (optionName == QLatin1String("size")) {
+ w = optionArg.section('x', 0, 0).toInt();
+ h = optionArg.section('x', 1, 1).toInt();
+ } else if (optionName == QLatin1String("format")) {
+ if (formatDict.contains(optionArg))
+ setPixelFormat(formatDict.value(optionArg));
+ else
+ printHelp(formatDict);
+ } else {
+ printHelp(formatDict);
+ }
+ }
+
+ if (w == 0 || h == 0) {
+ w = 640;
+ h = 480;
+ qWarning("%s: Using default screen size %dx%d", PluginName, w, h);
+ }
+ dw = w;
+ dh = h;
+
+ if (pixelFormat() == QImage::Format_Invalid) {
+ qWarning("%s: Using default screen format argb32", PluginName);
+ setPixelFormat(QImage::Format_ARGB32);
+ }
+ d = depthForFormat(pixelFormat());
+
+ static const int Dpi = 120;
+ static const qreal ScalingFactor = static_cast<qreal>(25.4) / Dpi;
+ physWidth = qRound(dw * ScalingFactor);
+ physHeight = qRound(dh * ScalingFactor);
+
+ return true;
+}
+
+void EGLNullWSScreen::disconnect() {}
+
+void EGLNullWSScreen::shutdownDevice() {}
+
+void EGLNullWSScreen::setMode(int /*width*/, int /*height*/, int /*depth*/) {}
+
+void EGLNullWSScreen::blank(bool /*on*/) {}
+
+void EGLNullWSScreen::exposeRegion(QRegion /*r*/, int /*changing*/) {}
+
+QWSWindowSurface* EGLNullWSScreen::createSurface(QWidget *widget) const
+{
+ if (qobject_cast<QGLWidget*>(widget)) {
+ return new EGLNullWSWindowSurface(widget);
+ } else {
+ qWarning("%s: Creating non-GL surface", PluginName);
+ return QScreen::createSurface(widget);
+ }
+}
+
+QWSWindowSurface* EGLNullWSScreen::createSurface(const QString &key) const
+{
+ if (key == QLatin1String("eglnullws")) {
+ return new EGLNullWSWindowSurface;
+ } else {
+ qWarning("%s: Creating non-GL surface", PluginName);
+ return QScreen::createSurface(key);
+ }
+}
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
new file mode 100644
index 0000000..08ba2fa
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EGLNULLWSSCREEN
+#define EGLNULLWSSCREEN
+
+#include <QGLScreen>
+
+class EGLNullWSScreen : public QGLScreen
+{
+public:
+ EGLNullWSScreen(int displayId);
+ ~EGLNullWSScreen();
+
+ bool initDevice();
+ bool connect(const QString &displaySpec);
+ void disconnect();
+ void shutdownDevice();
+
+ void setMode(int width, int height, int depth);
+ void blank(bool on);
+
+ void exposeRegion(QRegion r, int changing);
+
+ QWSWindowSurface* createSurface(QWidget *widget) const;
+ QWSWindowSurface* createSurface(const QString &key) const;
+
+ bool hasOpenGL() { return true; }
+};
+
+#endif // EGLNULLWSSCREEN
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
new file mode 100644
index 0000000..f708033
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "eglnullwsscreenplugin.h"
+#include "eglnullwsscreen.h"
+
+#include <QScreenDriverPlugin>
+#include <QStringList>
+
+class EGLNullWSScreenPlugin : public QScreenDriverPlugin
+{
+public:
+ virtual QStringList keys() const;
+ virtual QScreen *create(const QString& driver, int displayId);
+};
+
+QStringList EGLNullWSScreenPlugin::keys() const
+{
+ return QStringList() << QLatin1String(PluginName);
+}
+
+QScreen *EGLNullWSScreenPlugin::create(const QString& driver, int displayId)
+{
+ return (driver.toLower() == QLatin1String(PluginName) ?
+ new EGLNullWSScreen(displayId) : 0);
+}
+
+Q_EXPORT_PLUGIN2(qeglnullws, EGLNullWSScreenPlugin)
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
new file mode 100644
index 0000000..64a3623
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EGLNULLWSSCREENPLUGIN_H
+#define EGLNULLWSSCREENPLUGIN_H
+
+const char *const PluginName = "eglnullws";
+
+#endif // EGLNULLWSSCREENPLUGIN_H
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp
new file mode 100644
index 0000000..8af4d40
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "eglnullwswindowsurface.h"
+#include "eglnullwsscreenplugin.h"
+
+#include <QGLWidget>
+
+static const QWSWindowSurface::SurfaceFlags Flags
+ = QWSWindowSurface::RegionReserved | QWSWindowSurface::RegionReserved;
+
+EGLNullWSWindowSurface::EGLNullWSWindowSurface(QWidget *w)
+ :
+ QWSGLWindowSurface(w),
+ widget(w)
+{
+ setSurfaceFlags(Flags);
+}
+
+EGLNullWSWindowSurface::EGLNullWSWindowSurface()
+ : widget(0)
+{
+ setSurfaceFlags(Flags);
+}
+
+EGLNullWSWindowSurface::~EGLNullWSWindowSurface() {}
+
+QString EGLNullWSWindowSurface::key() const
+{
+ return QLatin1String(PluginName);
+}
+
+QPaintDevice *EGLNullWSWindowSurface::paintDevice()
+{
+ return widget;
+}
+
+bool EGLNullWSWindowSurface::isValid() const
+{
+ return qobject_cast<QGLWidget *>(window());
+}
+
+QImage EGLNullWSWindowSurface::image() const
+{
+ return QImage();
+}
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h
new file mode 100644
index 0000000..793d325
--- /dev/null
+++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EGLNULLWSWINDOWSURFACE_H
+#define EGLNULLWSWINDOWSURFACE_H
+
+#include <private/qglwindowsurface_qws_p.h>
+
+class EGLNullWSWindowSurface : public QWSGLWindowSurface
+{
+public:
+ EGLNullWSWindowSurface(QWidget *widget);
+ EGLNullWSWindowSurface();
+ virtual ~EGLNullWSWindowSurface();
+
+ virtual QString key() const;
+ virtual QPaintDevice *paintDevice();
+ virtual bool isValid() const;
+ virtual QImage image() const;
+
+private:
+ QWidget *widget;
+};
+
+#endif // EGLNULLWSWINDOWSURFACE_H
diff --git a/src/plugins/gfxdrivers/gfxdrivers.pro b/src/plugins/gfxdrivers/gfxdrivers.pro
index d1ee3f2..1f38942 100644
--- a/src/plugins/gfxdrivers/gfxdrivers.pro
+++ b/src/plugins/gfxdrivers/gfxdrivers.pro
@@ -7,3 +7,4 @@ contains(gfx-plugins, vnc) :SUBDIRS += vnc
contains(gfx-plugins, transformed) :SUBDIRS += transformed
contains(gfx-plugins, svgalib) :SUBDIRS += svgalib
contains(gfx-plugins, powervr) :SUBDIRS += powervr
+contains(gfx-plugins, eglnullws) :SUBDIRS += eglnullws
diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro
index 29a1f34..5c99291 100644
--- a/src/plugins/graphicssystems/graphicssystems.pro
+++ b/src/plugins/graphicssystems/graphicssystems.pro
@@ -1,7 +1,9 @@
TEMPLATE = subdirs
SUBDIRS += trace
!wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl
-contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl):SUBDIRS += openvg
+contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) {
+ SUBDIRS += openvg
+}
contains(QT_CONFIG, shivavg) {
# Only works under X11 at present
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
index adc4bbe..62b6992 100644
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
+++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
@@ -98,7 +98,11 @@ QPaintDevice *QTraceWindowSurface::paintDevice()
{
if (!buffer) {
buffer = new QPaintBuffer;
+#ifdef Q_WS_QPA
+ buffer->setBoundingRect(QRect(QPoint(), size()));
+#else
buffer->setBoundingRect(geometry());
+#endif
}
return buffer;
}
diff --git a/src/plugins/phonon/gstreamer/gstreamer.pro b/src/plugins/phonon/gstreamer/gstreamer.pro
index 1013205..c0d2604 100644
--- a/src/plugins/phonon/gstreamer/gstreamer.pro
+++ b/src/plugins/phonon/gstreamer/gstreamer.pro
@@ -58,7 +58,7 @@ SOURCES += $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \
$$PHONON_GSTREAMER_DIR/volumefadereffect.cpp \
$$PHONON_GSTREAMER_DIR/widgetrenderer.cpp
-!embedded {
+!qpa:!embedded{
HEADERS += $$PHONON_GSTREAMER_DIR/x11renderer.h
SOURCES += $$PHONON_GSTREAMER_DIR/x11renderer.cpp
}
diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro
index a9e5746..7c7c1d7 100644
--- a/src/plugins/phonon/mmf/mmf.pro
+++ b/src/plugins/phonon/mmf/mmf.pro
@@ -125,7 +125,11 @@ symbian {
LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream
# These are for effects.
- LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerbase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect
+ is_using_gnupoc {
+ LIBS += -laudioequalizereffect -lbassboosteffect -ldistanceattenuationeffect -ldopplerbase -leffectbase -lenvironmentalreverbeffect -llistenerdopplereffect -llistenerlocationeffect -llistenerorientationeffect -llocationbase -lloudnesseffect -lorientationbase -lsourcedopplereffect -lsourcelocationeffect -lsourceorientationeffect -lstereowideningeffect
+ } else {
+ LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerbase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect
+ }
# This is to allow IAP to be specified
LIBS += -lcommdb
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
new file mode 100644
index 0000000..1633ee4
--- /dev/null
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -0,0 +1,29 @@
+TARGET = qcocoa
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+OBJECTIVE_SOURCES = main.mm \
+ qcocoaintegration.mm \
+ qcocoawindowsurface.mm \
+ qcocoawindow.mm \
+ qnsview.mm \
+ qcocoaeventloopintegration.mm \
+ qcocoaautoreleasepool.mm \
+ qnswindowdelegate.mm
+
+OBJECTIVE_HEADERS = qcocoaintegration.h \
+ qcocoawindowsurface.h \
+ qcocoawindow.h \
+ qnsview.h \
+ qcocoaeventloopintegration.h \
+ qcocoaautoreleasepool.h \
+ qnswindowdelegate.h
+
+#add libz for freetype.
+LIBS += -lz
+LIBS += -framework cocoa
+
+include(../fontdatabases/coretext/coretext.pri)
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
+
diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm
new file mode 100644
index 0000000..da7af3f
--- /dev/null
+++ b/src/plugins/platforms/cocoa/main.mm
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Cocoa/Cocoa.h>
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qcocoaintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QCocoaIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "Cocoa";
+ return list;
+}
+
+QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "cocoa")
+ return new QCocoaIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(Cocoa, QCocoaIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
new file mode 100644
index 0000000..6e41e9a
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOCOAAUTORELEASEPOOL_H
+#define QCOCOAAUTORELEASEPOOL_H
+
+#include <Cocoa/Cocoa.h>
+
+class QCocoaAutoReleasePool
+{
+public:
+ QCocoaAutoReleasePool();
+ ~QCocoaAutoReleasePool();
+
+private:
+ NSAutoreleasePool *pool;
+};
+
+#endif // QCOCOAAUTORELEASEPOOL_H
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
new file mode 100644
index 0000000..35750cd
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcocoaautoreleasepool.h"
+
+QCocoaAutoReleasePool::QCocoaAutoReleasePool()
+{
+ pool = [[NSAutoreleasePool alloc] init];
+}
+
+QCocoaAutoReleasePool::~QCocoaAutoReleasePool()
+{
+ [pool release];
+}
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
new file mode 100644
index 0000000..81e272e
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOCAEVENTLOOPINTEGRATION_H
+#define QCOCAEVENTLOOPINTEGRATION_H
+
+#include <Cocoa/Cocoa.h>
+
+#include <QPlatformEventLoopIntegration>
+
+
+class QCocoaEventLoopIntegration : public QPlatformEventLoopIntegration
+{
+public:
+ QCocoaEventLoopIntegration();
+ void startEventLoop();
+ void quitEventLoop();
+ void qtNeedsToProcessEvents();
+
+private:
+ CFRunLoopSourceContext m_sourceContext;
+ CFRunLoopTimerContext m_timerContext;
+ CFRunLoopSourceRef m_source;
+};
+
+#endif // QCOCAEVENTLOOPINTEGRATION_H
+
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
new file mode 100644
index 0000000..885916e
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcocoaeventloopintegration.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "qcocoaautoreleasepool.h"
+
+#include <QtCore/QElapsedTimer>
+
+#include <QDebug>
+#include <QApplication>
+
+void wakeupCallback ( void * ) {
+ QPlatformEventLoopIntegration::processEvents();
+}
+
+void timerCallback( CFRunLoopTimerRef timer, void *info)
+{
+ QPlatformEventLoopIntegration::processEvents();
+ QCocoaEventLoopIntegration *eventLoopIntegration =
+ static_cast<QCocoaEventLoopIntegration *>(info);
+ qint64 nextTime = eventLoopIntegration->nextTimerEvent();
+ CFAbsoluteTime nexttime = CFAbsoluteTimeGetCurrent();
+ nexttime = nexttime + (double(nextTime)/1000);
+ CFRunLoopTimerSetNextFireDate(timer,nexttime);
+}
+
+QCocoaEventLoopIntegration::QCocoaEventLoopIntegration() :
+ QPlatformEventLoopIntegration()
+{
+ [NSApplication sharedApplication];
+ m_sourceContext.version = 0;
+ m_sourceContext.info = this;
+ m_sourceContext.retain = 0;
+ m_sourceContext.release = 0;
+ m_sourceContext.copyDescription = 0;
+ m_sourceContext.equal = 0;
+ m_sourceContext.hash = 0;
+ m_sourceContext.schedule = 0;
+ m_sourceContext.cancel = 0;
+ m_sourceContext.perform = wakeupCallback;
+
+ m_source = CFRunLoopSourceCreate(0,0,&m_sourceContext);
+ CFRunLoopAddSource(CFRunLoopGetMain(),m_source,kCFRunLoopCommonModes);
+
+ m_timerContext.version = 0;
+ m_timerContext.info = this;
+ m_timerContext.retain = 0;
+ m_timerContext.release = 0;
+ m_timerContext.copyDescription = 0;
+ CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent ();
+ CFTimeInterval interval = 30;
+
+ CFRunLoopTimerRef m_timerSource = CFRunLoopTimerCreate(0,fireDate,interval,0,0,timerCallback,&m_timerContext);
+ CFRunLoopAddTimer(CFRunLoopGetMain(),m_timerSource,kCFRunLoopCommonModes);
+}
+
+void QCocoaEventLoopIntegration::startEventLoop()
+{
+ [[NSApplication sharedApplication] run];
+}
+
+void QCocoaEventLoopIntegration::quitEventLoop()
+{
+ [[NSApplication sharedApplication] terminate:nil];
+}
+
+void QCocoaEventLoopIntegration::qtNeedsToProcessEvents()
+{
+ CFRunLoopSourceSignal(m_source);
+}
+
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
new file mode 100644
index 0000000..2a04e8c
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_COCOA_H
+#define QPLATFORMINTEGRATION_COCOA_H
+
+#include <Cocoa/Cocoa.h>
+
+#include "qcocoaautoreleasepool.h"
+
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaScreen : public QPlatformScreen
+{
+public:
+ QCocoaScreen(int screenIndex);
+ ~QCocoaScreen();
+
+ QRect geometry() const { return m_geometry; }
+ int depth() const { return m_depth; }
+ QImage::Format format() const { return m_format; }
+ QSize physicalSize() const { return m_physicalSize; }
+
+public:
+ NSScreen *m_screen;
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QSize m_physicalSize;
+};
+
+class QCocoaIntegration : public QPlatformIntegration
+{
+public:
+ QCocoaIntegration();
+ ~QCocoaIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+ QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+private:
+ QList<QPlatformScreen *> mScreens;
+ QPlatformFontDatabase *mFontDb;
+
+ QCocoaAutoReleasePool *mPool;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
new file mode 100644
index 0000000..7c4319c
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcocoaintegration.h"
+
+#include "qcocoawindow.h"
+#include "qcocoawindowsurface.h"
+#include "qcocoaeventloopintegration.h"
+
+#include "qcoretextfontdatabase.h"
+
+#include <QtGui/QApplication>
+
+#include <private/qpixmap_raster_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QCocoaScreen::QCocoaScreen(int screenIndex)
+ :QPlatformScreen()
+{
+ m_screen = [[NSScreen screens] objectAtIndex:screenIndex];
+ NSRect rect = [m_screen frame];
+ m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
+
+ m_format = QImage::Format_ARGB32;
+
+ m_depth = NSBitsPerPixelFromDepth([m_screen depth]);
+
+ const int dpi = 72;
+ const qreal inch = 25.4;
+ m_physicalSize = QSize(qRound(m_geometry.width() * inch / dpi), qRound(m_geometry.height() *inch / dpi));
+}
+
+QCocoaScreen::~QCocoaScreen()
+{
+}
+
+QCocoaIntegration::QCocoaIntegration()
+ : mFontDb(new QCoreTextFontDatabase())
+{
+ mPool = new QCocoaAutoReleasePool;
+
+ //Make sure we have a nsapplication :)
+ [NSApplication sharedApplication];
+// [[OurApplication alloc] init];
+
+ NSArray *screens = [NSScreen screens];
+ for (uint i = 0; i < [screens count]; i++) {
+ QCocoaScreen *screen = new QCocoaScreen(i);
+ mScreens.append(screen);
+ }
+}
+
+QCocoaIntegration::~QCocoaIntegration()
+{
+ delete mPool;
+}
+
+bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
+
+QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QCocoaWindow(widget);
+}
+
+QWindowSurface *QCocoaIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ return new QCocoaWindowSurface(widget,winId);
+}
+
+QPlatformFontDatabase *QCocoaIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QPlatformEventLoopIntegration *QCocoaIntegration::createEventLoopIntegration() const
+{
+ return new QCocoaEventLoopIntegration();
+}
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
new file mode 100644
index 0000000..b71879d
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOCOAWINDOW_H
+#define QCOCOAWINDOW_H
+
+#include <Cocoa/Cocoa.h>
+
+#include <QPlatformWindow>
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaWindow : public QPlatformWindow
+{
+public:
+ QCocoaWindow(QWidget *tlw);
+ ~QCocoaWindow();
+
+ void setGeometry(const QRect &rect);
+
+ void setVisible(bool visible);
+
+ WId winId() const;
+
+ NSView *contentView() const;
+ void setContentView(NSView *contentView);
+
+ void windowDidResize();
+
+private:
+ NSWindow *m_nsWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif // QCOCOAWINDOW_H
+
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
new file mode 100644
index 0000000..aa54fe9
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qcocoawindow.h"
+#include "qnswindowdelegate.h"
+#include "qcocoaautoreleasepool.h"
+
+#include <QWidget>
+
+#include <QtGui/QApplication>
+
+#include <QWindowSystemInterface>
+
+#include <QDebug>
+
+QCocoaWindow::QCocoaWindow(QWidget *tlw)
+ : QPlatformWindow(tlw)
+{
+ QCocoaAutoReleasePool pool;
+ const QRect geo = tlw->geometry();
+ NSRect frame = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
+
+ m_nsWindow = [[NSWindow alloc] initWithContentRect:frame
+ styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
+ backing:NSBackingStoreBuffered
+ defer:YES];
+
+ QNSWindowDelegate *delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
+ [m_nsWindow setDelegate:delegate];
+
+ [m_nsWindow makeKeyAndOrderFront:nil];
+ [m_nsWindow setAcceptsMouseMovedEvents:YES];
+}
+
+QCocoaWindow::~QCocoaWindow()
+{
+}
+
+void QCocoaWindow::setGeometry(const QRect &rect)
+{
+ QPlatformWindow::setGeometry(rect);
+
+ NSRect bounds = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
+ [[m_nsWindow contentView]setFrameSize:bounds.size];
+}
+
+void QCocoaWindow::setVisible(bool visible)
+{
+ Q_UNUSED(visible);
+}
+
+WId QCocoaWindow::winId() const
+{
+ return WId([m_nsWindow windowNumber]);
+}
+
+NSView *QCocoaWindow::contentView() const
+{
+ return [m_nsWindow contentView];
+}
+
+void QCocoaWindow::setContentView(NSView *contentView)
+{
+ [m_nsWindow setContentView:contentView];
+}
+
+void QCocoaWindow::windowDidResize()
+{
+ //jlind: XXX This isn't ideal. Eventdispatcher does not run when resizing...
+ NSRect rect = [[m_nsWindow contentView]frame];
+ QRect geo(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
+ QWindowSystemInterface::handleGeometryChange(widget(),geo);
+}
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoawindowsurface.h
new file mode 100644
index 0000000..5ae7be1
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_COCOA_H
+#define QWINDOWSURFACE_COCOA_H
+
+#include <Cocoa/Cocoa.h>
+
+#include "qcocoawindow.h"
+#include "qnsview.h"
+
+#include <QtGui/private/qwindowsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaWindowSurface : public QWindowSurface
+{
+public:
+ QCocoaWindowSurface(QWidget *window, WId wid);
+ ~QCocoaWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize (const QSize &size);
+
+private:
+
+ QCocoaWindow *m_cocoaWindow;
+ QImage *m_image;
+ QNSView *m_contentView;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
new file mode 100644
index 0000000..ecf6879
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcocoawindowsurface.h"
+
+#include <QtCore/qdebug.h>
+
+#include <QtGui/QPainter>
+
+QT_BEGIN_NAMESPACE
+
+QRect flipedRect(const QRect &sourceRect,int height)
+{
+ if (!sourceRect.isValid())
+ return QRect();
+ QRect flippedRect = sourceRect;
+ flippedRect.moveTop(height - sourceRect.y());
+ return flippedRect;
+}
+
+QCocoaWindowSurface::QCocoaWindowSurface(QWidget *window, WId wId)
+ : QWindowSurface(window)
+{
+ m_cocoaWindow = static_cast<QCocoaWindow *>(window->platformWindow());
+
+ const QRect geo = window->geometry();
+ NSRect rect = NSMakeRect(geo.x(),geo.y(),geo.width(),geo.height());
+ m_contentView = [[QNSView alloc] initWithWidget:window];
+ m_cocoaWindow->setContentView(m_contentView);
+
+ m_image = new QImage(window->size(),QImage::Format_ARGB32);
+}
+
+QCocoaWindowSurface::~QCocoaWindowSurface()
+{
+ delete m_image;
+}
+
+QPaintDevice *QCocoaWindowSurface::paintDevice()
+{
+ return m_image;
+}
+
+void QCocoaWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+
+ QRect geo = region.boundingRect();
+
+ NSRect rect = NSMakeRect(geo.x(), geo.y(), geo.width(), geo.height());
+ [m_contentView displayRect:rect];
+}
+
+void QCocoaWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+ delete m_image;
+ m_image = new QImage(size,QImage::Format_ARGB32_Premultiplied);
+ NSSize newSize = NSMakeSize(size.width(),size.height());
+ [m_contentView setImage:m_image];
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
new file mode 100644
index 0000000..fc946e2
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNSVIEW_H
+#define QNSVIEW_H
+
+#include <Cocoa/Cocoa.h>
+
+#include <QtGui/QImage>
+
+@interface QNSView : NSView {
+ CGImageRef m_cgImage;
+ QWidget *m_widget;
+ Qt::MouseButtons m_buttons;
+}
+
+- (id)init;
+- (id)initWithWidget:(QWidget *)widget;
+
+- (void)setImage:(QImage *)image;
+- (void)drawRect:(NSRect)dirtyRect;
+
+- (BOOL)isFlipped;
+
+- (void)handleMouseEvent:(NSEvent *)theEvent;
+- (void)mouseDown:(NSEvent *)theEvent;
+- (void)mouseDragged:(NSEvent *)theEvent;
+- (void)mouseUp:(NSEvent *)theEvent;
+- (void)mouseMoved:(NSEvent *)theEvent;
+- (void)mouseEntered:(NSEvent *)theEvent;
+- (void)mouseExited:(NSEvent *)theEvent;
+- (void)rightMouseDown:(NSEvent *)theEvent;
+- (void)rightMouseDragged:(NSEvent *)theEvent;
+- (void)rightMouseUp:(NSEvent *)theEvent;
+- (void)otherMouseDown:(NSEvent *)theEvent;
+- (void)otherMouseDragged:(NSEvent *)theEvent;
+- (void)otherMouseUp:(NSEvent *)theEvent;
+
+@end
+
+#endif //QNSVIEW_H
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
new file mode 100644
index 0000000..6fda27b
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnsview.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <QtCore/QDebug>
+
+@implementation QNSView
+
+- (id) init
+{
+ self = [super init];
+ if (self) {
+ m_cgImage = 0;
+ m_widget = 0;
+ m_buttons = Qt::NoButton;
+ }
+ return self;
+}
+
+- (id)initWithWidget:(QWidget *)widget {
+ self = [self init];
+ if (self) {
+ m_widget = widget;
+ }
+ return self;
+}
+
+- (void) setImage:(QImage *)image
+{
+ CGImageRelease(m_cgImage);
+
+ const uchar *imageData = image->bits();
+ int bitDepth = image->depth();
+ int colorBufferSize = 8;
+ int bytesPrLine = image->bytesPerLine();
+ int width = image->width();
+ int height = image->height();
+
+ CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
+
+ CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData(
+ NULL,
+ imageData,
+ image->byteCount(),
+ NULL);
+
+ m_cgImage = CGImageCreate(width,
+ height,
+ colorBufferSize,
+ bitDepth,
+ bytesPrLine,
+ cgColourSpaceRef,
+ kCGImageAlphaNone,
+ cgDataProviderRef,
+ NULL,
+ false,
+ kCGRenderingIntentDefault);
+
+ CGColorSpaceRelease(cgColourSpaceRef);
+
+}
+
+- (void) drawRect:(NSRect)dirtyRect
+{
+ if (!m_cgImage)
+ return;
+
+ CGRect dirtyCGRect = NSRectToCGRect(dirtyRect);
+
+ NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
+ CGContextRef cgContext = (CGContextRef) [nsGraphicsContext graphicsPort];
+
+ CGContextSaveGState( cgContext );
+ int dy = dirtyCGRect.origin.y + CGRectGetMaxY(dirtyCGRect);
+ CGContextTranslateCTM(cgContext, 0, dy);
+ CGContextScaleCTM(cgContext, 1, -1);
+
+ CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, dirtyCGRect);
+ CGContextDrawImage(cgContext,dirtyCGRect,subImage);
+
+ CGContextRestoreGState(cgContext);
+
+ CGImageRelease(subImage);
+
+}
+
+- (BOOL) isFlipped
+{
+ return YES;
+}
+
+- (void)handleMouseEvent:(NSEvent *)theEvent;
+{
+ NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil];
+ QPoint qt_localPoint(point.x,point.y);
+
+ NSTimeInterval timestamp = [theEvent timestamp];
+ ulong qt_timestamp = timestamp * 1000;
+
+ QWindowSystemInterface::handleMouseEvent(m_widget,qt_timestamp,qt_localPoint,QPoint(),m_buttons);
+
+}
+ - (void)mouseDown:(NSEvent *)theEvent
+ {
+ m_buttons |= Qt::LeftButton;
+ [self handleMouseEvent:theEvent];
+ }
+ - (void)mouseDragged:(NSEvent *)theEvent
+ {
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
+ }
+ - (void)mouseUp:(NSEvent *)theEvent
+ {
+ m_buttons &= QFlag(~int(Qt::LeftButton));
+ [self handleMouseEvent:theEvent];
+ }
+
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ qDebug() << "mouseMove";
+ [self handleMouseEvent:theEvent];
+}
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+ Q_UNUSED(theEvent);
+ QWindowSystemInterface::handleEnterEvent(m_widget);
+}
+- (void)mouseExited:(NSEvent *)theEvent
+{
+ Q_UNUSED(theEvent);
+ QWindowSystemInterface::handleLeaveEvent(m_widget);
+}
+- (void)rightMouseDown:(NSEvent *)theEvent
+{
+ m_buttons |= Qt::RightButton;
+ [self handleMouseEvent:theEvent];
+}
+- (void)rightMouseDragged:(NSEvent *)theEvent
+{
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
+}
+- (void)rightMouseUp:(NSEvent *)theEvent
+{
+ m_buttons &= QFlag(~int(Qt::RightButton));
+ [self handleMouseEvent:theEvent];
+}
+- (void)otherMouseDown:(NSEvent *)theEvent
+{
+ m_buttons |= Qt::RightButton;
+ [self handleMouseEvent:theEvent];
+}
+- (void)otherMouseDragged:(NSEvent *)theEvent
+{
+ if (!(m_buttons & Qt::LeftButton))
+ qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ [self handleMouseEvent:theEvent];
+}
+- (void)otherMouseUp:(NSEvent *)theEvent
+{
+ m_buttons &= QFlag(~int(Qt::MiddleButton));
+ [self handleMouseEvent:theEvent];
+}
+
+
+
+@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
new file mode 100644
index 0000000..f4dcec7
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNSWINDOWDELEGATE_H
+#define QNSWINDOWDELEGATE_H
+
+#include <Cocoa/Cocoa.h>
+
+#include "qcocoawindow.h"
+
+@interface QNSWindowDelegate : NSObject <NSWindowDelegate>
+{
+ QCocoaWindow *m_cocoaWindow;
+}
+
+- (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow;
+
+- (void)windowDidResize:(NSNotification *)notification;
+- (void)windowWillClose:(NSNotification *)notification;
+
+@end
+
+#endif // QNSWINDOWDELEGATE_H
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
new file mode 100644
index 0000000..58dffb7
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnswindowdelegate.h"
+
+#include <QDebug>
+#include <QWindowSystemInterface>
+
+@implementation QNSWindowDelegate
+
+- (id) initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow
+{
+ self = [super init];
+
+ if (self) {
+ m_cocoaWindow = cocoaWindow;
+ }
+ return self;
+}
+
+- (void)windowDidResize:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ if (m_cocoaWindow) {
+ m_cocoaWindow->windowDidResize();
+ }
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ QWindowSystemInterface::handleCloseEvent(m_cocoaWindow->widget());
+}
+
+@end
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro
new file mode 100644
index 0000000..65c49e3
--- /dev/null
+++ b/src/plugins/platforms/directfb/directfb.pro
@@ -0,0 +1,35 @@
+TARGET = qdirectfb
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+isEmpty(DIRECTFB_LIBS) {
+ DIRECTFB_LIBS = -ldirectfb -lfusion -ldirect -lpthread
+}
+isEmpty(DIRECTFB_INCLUDEPATH) {
+ DIRECTFB_INCLUDEPATH = /usr/include/directfb
+}
+
+INCLUDEPATH += $$DIRECTFB_INCLUDEPATH
+LIBS += $$DIRECTFB_LIBS
+
+SOURCES = main.cpp \
+ qdirectfbintegration.cpp \
+ qdirectfbwindowsurface.cpp \
+ qdirectfbblitter.cpp \
+ qdirectfbconvenience.cpp \
+ qdirectfbinput.cpp \
+ qdirectfbcursor.cpp \
+ qdirectfbwindow.cpp \
+ qdirectfbglcontext.cpp
+HEADERS = qdirectfbintegration.h \
+ qdirectfbwindowsurface.h \
+ qdirectfbblitter.h \
+ qdirectfbconvenience.h \
+ qdirectfbinput.h \
+ qdirectfbcursor.h \
+ qdirectfbwindow.h \
+ qdirectfbglcontext.h
+
+include(../fontdatabases/genericunix/genericunix.pri)
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp
new file mode 100644
index 0000000..d9caa70
--- /dev/null
+++ b/src/plugins/platforms/directfb/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qdirectfbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDirectFbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QDirectFbIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "directfb";
+ return list;
+}
+
+QPlatformIntegration * QDirectFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "directfb")
+ return new QDirectFbIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(directfb, QDirectFbIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
new file mode 100644
index 0000000..19998ce
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbblitter.h"
+#include "qdirectfbconvenience.h"
+
+#include <QtGui/private/qpixmap_blitter_p.h>
+
+#include <QDebug>
+
+#include <directfb.h>
+
+QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface)
+ : QBlittable(rect, QBlittable::Capabilities(QBlittable::SolidRectCapability
+ |QBlittable::SourcePixmapCapability
+ |QBlittable::SourceOverPixmapCapability
+ |QBlittable::SourceOverScaledPixmapCapability))
+{
+ if (surface) {
+ m_surface = surface;
+ } else {
+ DFBSurfaceDescription surfaceDesc;
+ memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription));
+ surfaceDesc.width = rect.width();
+ surfaceDesc.height = rect.height();
+ surfaceDesc.caps = DSCAPS_PREMULTIPLIED;
+ surfaceDesc.pixelformat = DSPF_ARGB;
+ surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT);
+
+ IDirectFB *dfb = QDirectFbConvenience::dfbInterface();
+ dfb->CreateSurface(dfb,&surfaceDesc, &m_surface);
+ m_surface->Clear(m_surface,0,0,0,0);
+ }
+
+}
+
+QDirectFbBlitter::~QDirectFbBlitter()
+{
+ unlock();
+ m_surface->Release(m_surface);
+}
+
+void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color)
+{
+ m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha());
+// When the blitter api supports non opaque blits, also remember to change
+// qpixmap_blitter.cpp::fill
+// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX;
+// m_surface->SetDrawingFlags(m_surface, drawingFlags);
+ m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX);
+ m_surface->FillRectangle(m_surface, rect.x(), rect.y(),
+ rect.width(), rect.height());
+}
+
+void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect)
+{
+ QPixmapData *data = pixmap.pixmapData();
+ Q_ASSERT(data->width() && data->height());
+ Q_ASSERT(data->classId() == QPixmapData::BlitterClass);
+ QBlittablePixmapData *blitPm = static_cast<QBlittablePixmapData*>(data);
+ QDirectFbBlitter *dfbBlitter = static_cast<QDirectFbBlitter *>(blitPm->blittable());
+ dfbBlitter->unlock();
+
+ IDirectFBSurface *s = dfbBlitter->m_surface;
+
+ DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX;
+ DFBSurfacePorterDuffRule porterDuff = DSPD_SRC;
+ if (pixmap.hasAlpha()) {
+ blittingFlags = DSBLIT_BLEND_ALPHACHANNEL;
+ porterDuff = DSPD_SRC_OVER;
+ }
+
+ m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags));
+ m_surface->SetPorterDuff(m_surface,porterDuff);
+ m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA);
+
+ const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() };
+
+ DFBResult result;
+ if (rect.width() == srcRect.width() && rect.height() == srcRect.height())
+ result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y());
+ else {
+ const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() };
+ result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect);
+ }
+ if (result != DFB_OK)
+ DirectFBError("QDirectFBBlitter::drawPixmap()", result);
+}
+
+QImage *QDirectFbBlitter::doLock()
+{
+ Q_ASSERT(m_surface);
+ Q_ASSERT(size().isValid());
+
+ void *mem;
+ int bpl;
+ const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast<void**>(&mem), &bpl);
+ if (result == DFB_OK) {
+ DFBSurfacePixelFormat dfbFormat;
+ DFBSurfaceCapabilities dfbCaps;
+ m_surface->GetPixelFormat(m_surface,&dfbFormat);
+ m_surface->GetCapabilities(m_surface,&dfbCaps);
+ QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps);
+ int w, h;
+ m_surface->GetSize(m_surface,&w,&h);
+ m_image = QImage(static_cast<uchar *>(mem),w,h,bpl,format);
+ } else {
+ DirectFBError("Failed to lock image", result);
+ }
+
+ return &m_image;
+}
+
+void QDirectFbBlitter::doUnlock()
+{
+ m_surface->Unlock(m_surface);
+}
diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.h b/src/plugins/platforms/directfb/qdirectfbblitter.h
new file mode 100644
index 0000000..bd5dbda
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbblitter.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBBLITTER_H
+#define QDIRECTFBBLITTER_H
+
+#include "qdirectfbconvenience.h"
+
+#include <private/qblittable_p.h>
+
+#include <directfb.h>
+
+class QDirectFbBlitter : public QBlittable
+{
+public:
+ QDirectFbBlitter(const QSize &size, IDirectFBSurface *surface = 0);
+ virtual ~QDirectFbBlitter();
+
+ virtual void fillRect(const QRectF &rect, const QColor &color);
+ virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect);
+
+protected:
+ virtual QImage *doLock();
+ virtual void doUnlock();
+
+ IDirectFBSurface *m_surface;
+ QImage m_image;
+
+ friend class QDirectFbConvenience;
+};
+
+class QDirectFbBlitterPixmapData : public QBlittablePixmapData
+{
+public:
+ QBlittable *createBlittable(const QSize &size) const { return new QDirectFbBlitter(size); }
+};
+
+#endif // QDIRECTFBBLITTER_H
diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.cpp b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
new file mode 100644
index 0000000..01cef83
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbconvenience.cpp
@@ -0,0 +1,376 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbconvenience.h"
+#include "qdirectfbblitter.h"
+
+#include <private/qpixmap_blitter_p.h>
+
+IDirectFB *QDirectFbConvenience::dfbInterface()
+{
+ static IDirectFB *dfb = 0;
+ if (!dfb) {
+ DFBResult result = DirectFBCreate(&dfb);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBConvenience: error creating DirectFB interface",result);
+ return 0;
+ }
+ }
+ return dfb;
+}
+
+IDirectFBDisplayLayer *QDirectFbConvenience::dfbDisplayLayer(int display)
+{
+ IDirectFBDisplayLayer *layer;
+ DFBResult result = QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),display,&layer);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFbConvenience: "
+ "Unable to get primary display layer!", result);
+ }
+ return layer;
+}
+
+QImage::Format QDirectFbConvenience::imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps)
+{
+ switch (format) {
+ case DSPF_LUT8:
+ return QImage::Format_Indexed8;
+ case DSPF_RGB24:
+ return QImage::Format_RGB888;
+ case DSPF_ARGB4444:
+ return QImage::Format_ARGB4444_Premultiplied;
+ case DSPF_RGB444:
+ return QImage::Format_RGB444;
+ case DSPF_RGB555:
+ case DSPF_ARGB1555:
+ return QImage::Format_RGB555;
+ case DSPF_RGB16:
+ return QImage::Format_RGB16;
+ case DSPF_ARGB6666:
+ return QImage::Format_ARGB6666_Premultiplied;
+ case DSPF_RGB18:
+ return QImage::Format_RGB666;
+ case DSPF_RGB32:
+ return QImage::Format_RGB32;
+ case DSPF_ARGB: {
+ if (caps & DSCAPS_PREMULTIPLIED)
+ return QImage::Format_ARGB32_Premultiplied;
+ else return QImage::Format_ARGB32; }
+ default:
+ break;
+ }
+ return QImage::Format_Invalid;
+
+}
+
+int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat format)
+{
+ return ((0x1f << 7) & format) >> 7;
+}
+
+IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPixmapData(QPixmapData *pixmapData)
+{
+ QBlittablePixmapData *blittablePmData = static_cast<QBlittablePixmapData *>(pixmapData);
+ if (blittablePmData) {
+ QBlittable *blittable = blittablePmData->blittable();
+ QDirectFbBlitter *dfbBlitter = static_cast<QDirectFbBlitter *>(blittable);
+ return dfbBlitter->m_surface;
+ }
+ return 0;
+}
+
+Qt::MouseButton QDirectFbConvenience::mouseButton(DFBInputDeviceButtonIdentifier identifier)
+{
+ switch (identifier){
+ case DIBI_LEFT:
+ return Qt::LeftButton;
+ case DIBI_MIDDLE:
+ return Qt::MidButton;
+ case DIBI_RIGHT:
+ return Qt::RightButton;
+ default:
+ return Qt::NoButton;
+ }
+}
+
+Qt::MouseButtons QDirectFbConvenience::mouseButtons(DFBInputDeviceButtonMask mask)
+{
+ Qt::MouseButtons buttons = Qt::NoButton;
+
+ if (mask & DIBM_LEFT) {
+ buttons |= Qt::LeftButton;
+ }
+ if (mask & DIBM_MIDDLE) {
+ buttons |= Qt::MidButton;
+ }
+ if (mask & DIBM_RIGHT) {
+ buttons |= Qt::RightButton;
+ }
+ return buttons;
+}
+
+Qt::KeyboardModifiers QDirectFbConvenience::keyboardModifiers(DFBInputDeviceModifierMask mask)
+{
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ if (mask & DIMM_SHIFT) {
+ modifiers |= Qt::ShiftModifier;
+ }
+ if (mask & DIMM_ALT) {
+ modifiers |= Qt::AltModifier;
+ }
+ if (mask & DIMM_ALTGR) {
+ modifiers |= Qt::MetaModifier;
+ }
+ if (mask & DIMM_CONTROL) {
+ modifiers |= Qt::ControlModifier;
+ }
+ if (mask & DIMM_META) {
+ modifiers | Qt::MetaModifier;
+ }
+ return modifiers;
+}
+
+QEvent::Type QDirectFbConvenience::eventType(DFBWindowEventType type)
+{
+ switch(type) {
+ case DWET_BUTTONDOWN:
+ return QEvent::MouseButtonPress;
+ case DWET_BUTTONUP:
+ return QEvent::MouseButtonRelease;
+ case DWET_MOTION:
+ return QEvent::MouseMove;
+ case DWET_WHEEL:
+ return QEvent::Wheel;
+ case DWET_KEYDOWN:
+ return QEvent::KeyPress;
+ case DWET_KEYUP:
+ return QEvent::KeyRelease;
+ default:
+ return QEvent::None;
+ }
+}
+QDirectFbKeyMap *QDirectFbConvenience::dfbKeymap = 0;
+QDirectFbKeyMap *QDirectFbConvenience::keyMap()
+{
+ if (!dfbKeymap)
+ dfbKeymap = new QDirectFbKeyMap();
+ return dfbKeymap;
+}
+
+QDirectFbKeyMap::QDirectFbKeyMap()
+{
+ insert(DIKS_BACKSPACE , Qt::Key_Backspace);
+ insert(DIKS_TAB , Qt::Key_Tab);
+ insert(DIKS_RETURN , Qt::Key_Return);
+ insert(DIKS_ESCAPE , Qt::Key_Escape);
+ insert(DIKS_DELETE , Qt::Key_Delete);
+
+ insert(DIKS_CURSOR_LEFT , Qt::Key_Left);
+ insert(DIKS_CURSOR_RIGHT , Qt::Key_Right);
+ insert(DIKS_CURSOR_UP , Qt::Key_Up);
+ insert(DIKS_CURSOR_DOWN , Qt::Key_Down);
+ insert(DIKS_INSERT , Qt::Key_Insert);
+ insert(DIKS_HOME , Qt::Key_Home);
+ insert(DIKS_END , Qt::Key_End);
+ insert(DIKS_PAGE_UP , Qt::Key_PageUp);
+ insert(DIKS_PAGE_DOWN , Qt::Key_PageDown);
+ insert(DIKS_PRINT , Qt::Key_Print);
+ insert(DIKS_PAUSE , Qt::Key_Pause);
+ insert(DIKS_SELECT , Qt::Key_Select);
+ insert(DIKS_GOTO , Qt::Key_OpenUrl);
+ insert(DIKS_CLEAR , Qt::Key_Clear);
+ insert(DIKS_MENU , Qt::Key_Menu);
+ insert(DIKS_HELP , Qt::Key_Help);
+
+ insert(DIKS_INTERNET , Qt::Key_HomePage);
+ insert(DIKS_MAIL , Qt::Key_LaunchMail);
+ insert(DIKS_FAVORITES , Qt::Key_Favorites);
+
+ insert(DIKS_BACK , Qt::Key_Back);
+ insert(DIKS_FORWARD , Qt::Key_Forward);
+ insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp);
+ insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown);
+ insert(DIKS_MUTE , Qt::Key_VolumeMute);
+ insert(DIKS_PLAYPAUSE , Qt::Key_Pause);
+ insert(DIKS_PLAY , Qt::Key_MediaPlay);
+ insert(DIKS_STOP , Qt::Key_MediaStop);
+ insert(DIKS_RECORD , Qt::Key_MediaRecord);
+ insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious);
+ insert(DIKS_NEXT , Qt::Key_MediaNext);
+
+ insert(DIKS_F1 , Qt::Key_F1);
+ insert(DIKS_F2 , Qt::Key_F2);
+ insert(DIKS_F3 , Qt::Key_F3);
+ insert(DIKS_F4 , Qt::Key_F4);
+ insert(DIKS_F5 , Qt::Key_F5);
+ insert(DIKS_F6 , Qt::Key_F6);
+ insert(DIKS_F7 , Qt::Key_F7);
+ insert(DIKS_F8 , Qt::Key_F8);
+ insert(DIKS_F9 , Qt::Key_F9);
+ insert(DIKS_F10 , Qt::Key_F10);
+ insert(DIKS_F11 , Qt::Key_F11);
+ insert(DIKS_F12 , Qt::Key_F12);
+
+ insert(DIKS_SHIFT , Qt::Key_Shift);
+ insert(DIKS_CONTROL , Qt::Key_Control);
+ insert(DIKS_ALT , Qt::Key_Alt);
+ insert(DIKS_ALTGR , Qt::Key_AltGr);
+
+ insert(DIKS_META , Qt::Key_Meta);
+ insert(DIKS_SUPER , Qt::Key_Super_L); // ???
+ insert(DIKS_HYPER , Qt::Key_Hyper_L); // ???
+
+ insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock);
+ insert(DIKS_NUM_LOCK , Qt::Key_NumLock);
+ insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock);
+
+ insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot);
+ insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering);
+ insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute);
+ insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve);
+ insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron);
+ insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla);
+ insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex);
+ insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis);
+ insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute);
+ insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave);
+ insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota);
+ insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron);
+ insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek);
+ insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound);
+ insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde);
+ insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound);
+ insert(DIKS_SPACE , Qt::Key_Space);
+ insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam);
+ insert(DIKS_QUOTATION , Qt::Key_QuoteDbl);
+ insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign);
+ insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar);
+ insert(DIKS_PERCENT_SIGN , Qt::Key_Percent);
+ insert(DIKS_AMPERSAND , Qt::Key_Ampersand);
+ insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe);
+ insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft);
+ insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight);
+ insert(DIKS_ASTERISK , Qt::Key_Asterisk);
+ insert(DIKS_PLUS_SIGN , Qt::Key_Plus);
+ insert(DIKS_COMMA , Qt::Key_Comma);
+ insert(DIKS_MINUS_SIGN , Qt::Key_Minus);
+ insert(DIKS_PERIOD , Qt::Key_Period);
+ insert(DIKS_SLASH , Qt::Key_Slash);
+ insert(DIKS_0 , Qt::Key_0);
+ insert(DIKS_1 , Qt::Key_1);
+ insert(DIKS_2 , Qt::Key_2);
+ insert(DIKS_3 , Qt::Key_3);
+ insert(DIKS_4 , Qt::Key_4);
+ insert(DIKS_5 , Qt::Key_5);
+ insert(DIKS_6 , Qt::Key_6);
+ insert(DIKS_7 , Qt::Key_7);
+ insert(DIKS_8 , Qt::Key_8);
+ insert(DIKS_9 , Qt::Key_9);
+ insert(DIKS_COLON , Qt::Key_Colon);
+ insert(DIKS_SEMICOLON , Qt::Key_Semicolon);
+ insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less);
+ insert(DIKS_EQUALS_SIGN , Qt::Key_Equal);
+ insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater);
+ insert(DIKS_QUESTION_MARK , Qt::Key_Question);
+ insert(DIKS_AT , Qt::Key_At);
+ insert(DIKS_CAPITAL_A , Qt::Key_A);
+ insert(DIKS_CAPITAL_B , Qt::Key_B);
+ insert(DIKS_CAPITAL_C , Qt::Key_C);
+ insert(DIKS_CAPITAL_D , Qt::Key_D);
+ insert(DIKS_CAPITAL_E , Qt::Key_E);
+ insert(DIKS_CAPITAL_F , Qt::Key_F);
+ insert(DIKS_CAPITAL_G , Qt::Key_G);
+ insert(DIKS_CAPITAL_H , Qt::Key_H);
+ insert(DIKS_CAPITAL_I , Qt::Key_I);
+ insert(DIKS_CAPITAL_J , Qt::Key_J);
+ insert(DIKS_CAPITAL_K , Qt::Key_K);
+ insert(DIKS_CAPITAL_L , Qt::Key_L);
+ insert(DIKS_CAPITAL_M , Qt::Key_M);
+ insert(DIKS_CAPITAL_N , Qt::Key_N);
+ insert(DIKS_CAPITAL_O , Qt::Key_O);
+ insert(DIKS_CAPITAL_P , Qt::Key_P);
+ insert(DIKS_CAPITAL_Q , Qt::Key_Q);
+ insert(DIKS_CAPITAL_R , Qt::Key_R);
+ insert(DIKS_CAPITAL_S , Qt::Key_S);
+ insert(DIKS_CAPITAL_T , Qt::Key_T);
+ insert(DIKS_CAPITAL_U , Qt::Key_U);
+ insert(DIKS_CAPITAL_V , Qt::Key_V);
+ insert(DIKS_CAPITAL_W , Qt::Key_W);
+ insert(DIKS_CAPITAL_X , Qt::Key_X);
+ insert(DIKS_CAPITAL_Y , Qt::Key_Y);
+ insert(DIKS_CAPITAL_Z , Qt::Key_Z);
+ insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft);
+ insert(DIKS_BACKSLASH , Qt::Key_Backslash);
+ insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight);
+ insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum);
+ insert(DIKS_UNDERSCORE , Qt::Key_Underscore);
+ insert(DIKS_SMALL_A , Qt::Key_A);
+ insert(DIKS_SMALL_B , Qt::Key_B);
+ insert(DIKS_SMALL_C , Qt::Key_C);
+ insert(DIKS_SMALL_D , Qt::Key_D);
+ insert(DIKS_SMALL_E , Qt::Key_E);
+ insert(DIKS_SMALL_F , Qt::Key_F);
+ insert(DIKS_SMALL_G , Qt::Key_G);
+ insert(DIKS_SMALL_H , Qt::Key_H);
+ insert(DIKS_SMALL_I , Qt::Key_I);
+ insert(DIKS_SMALL_J , Qt::Key_J);
+ insert(DIKS_SMALL_K , Qt::Key_K);
+ insert(DIKS_SMALL_L , Qt::Key_L);
+ insert(DIKS_SMALL_M , Qt::Key_M);
+ insert(DIKS_SMALL_N , Qt::Key_N);
+ insert(DIKS_SMALL_O , Qt::Key_O);
+ insert(DIKS_SMALL_P , Qt::Key_P);
+ insert(DIKS_SMALL_Q , Qt::Key_Q);
+ insert(DIKS_SMALL_R , Qt::Key_R);
+ insert(DIKS_SMALL_S , Qt::Key_S);
+ insert(DIKS_SMALL_T , Qt::Key_T);
+ insert(DIKS_SMALL_U , Qt::Key_U);
+ insert(DIKS_SMALL_V , Qt::Key_V);
+ insert(DIKS_SMALL_W , Qt::Key_W);
+ insert(DIKS_SMALL_X , Qt::Key_X);
+ insert(DIKS_SMALL_Y , Qt::Key_Y);
+ insert(DIKS_SMALL_Z , Qt::Key_Z);
+ insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft);
+ insert(DIKS_VERTICAL_BAR , Qt::Key_Bar);
+ insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight);
+ insert(DIKS_TILDE , Qt::Key_AsciiTilde);
+}
diff --git a/src/plugins/platforms/directfb/qdirectfbconvenience.h b/src/plugins/platforms/directfb/qdirectfbconvenience.h
new file mode 100644
index 0000000..e85c502
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbconvenience.h
@@ -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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBCONVENIENCE_H
+#define QDIRECTFBCONVENIENCE_H
+
+#include <QtGui/qimage.h>
+#include <QtCore/QHash>
+#include <QtCore/QEvent>
+#include <QtGui/QPixmap>
+
+#include <directfb.h>
+
+class QDirectFbKeyMap: public QHash<DFBInputDeviceKeySymbol, Qt::Key>
+{
+public:
+ QDirectFbKeyMap();
+};
+
+
+class QDirectFbConvenience
+{
+public:
+ static QImage::Format imageFormatFromSurfaceFormat(const DFBSurfacePixelFormat format, const DFBSurfaceCapabilities caps);
+ static bool pixelFomatHasAlpha(const DFBSurfacePixelFormat format) { return (1 << 16) & format; }
+ static int colorDepthForSurface(const DFBSurfacePixelFormat format);
+
+ //This is set by the graphicssystem constructor
+ static IDirectFB *dfbInterface();
+ static IDirectFBDisplayLayer *dfbDisplayLayer(int display = DLID_PRIMARY);
+
+ static IDirectFBSurface *dfbSurfaceForPixmapData(QPixmapData *);
+
+ static Qt::MouseButton mouseButton(DFBInputDeviceButtonIdentifier identifier);
+ static Qt::MouseButtons mouseButtons(DFBInputDeviceButtonMask mask);
+ static Qt::KeyboardModifiers keyboardModifiers(DFBInputDeviceModifierMask mask);
+ static QEvent::Type eventType(DFBWindowEventType type);
+
+ static QDirectFbKeyMap *keyMap();
+
+private:
+ static QDirectFbKeyMap *dfbKeymap;
+ friend class QDirectFbIntegration;
+};
+
+#endif // QDIRECTFBCONVENIENCE_H
diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.cpp b/src/plugins/platforms/directfb/qdirectfbcursor.cpp
new file mode 100644
index 0000000..3cd81ac
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbcursor.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbcursor.h"
+#include "qdirectfbconvenience.h"
+
+
+QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) :
+ QPlatformCursor(screen), surface(0)
+{
+ QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer);
+ image = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+}
+
+void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget)
+{
+ Q_UNUSED(widget);
+ int xSpot;
+ int ySpot;
+ QPixmap map;
+
+ if (cursor->shape() != Qt::BitmapCursor) {
+ image->set(cursor->shape());
+ xSpot = image->hotspot().x();
+ ySpot = image->hotspot().y();
+ QImage *i = image->image();
+ map = QPixmap::fromImage(*i);
+ } else {
+ QPoint point = cursor->hotSpot();
+ xSpot = point.x();
+ ySpot = point.y();
+ map = cursor->pixmap();
+ }
+
+ IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPixmapData(map.pixmapData());
+
+ if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) {
+ return;
+ }
+ m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot);
+ m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED);
+}
diff --git a/src/plugins/platforms/directfb/qdirectfbcursor.h b/src/plugins/platforms/directfb/qdirectfbcursor.h
new file mode 100644
index 0000000..f37bbed
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbcursor.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBCURSOR_H
+#define QDIRECTFBCURSOR_H
+
+#include <QPlatformCursor>
+#include <directfb.h>
+class QDirectFbScreen;
+class QDirectFbBlitter;
+
+class QDirectFBCursor : public QPlatformCursor
+{
+public:
+ QDirectFBCursor(QPlatformScreen *screem);
+ void changeCursor(QCursor * cursor, QWidget * widget);
+
+private:
+ IDirectFBDisplayLayer * m_layer;
+ IDirectFBSurface * surface;
+ QPlatformCursorImage * image;
+ QDirectFbBlitter *blitter;
+};
+
+#endif // QDIRECTFBCURSOR_H
diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.cpp b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp
new file mode 100644
index 0000000..ee46691
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbglcontext.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbglcontext.h"
+
+#include <directfb/directfbgl.h>
+
+#include <QDebug>
+
+QDirectFbGLContext::QDirectFbGLContext(IDirectFBGL *glContext)
+ : m_dfbGlContext(glContext)
+{
+ DFBResult result;
+ DFBGLAttributes glAttribs;
+ result = m_dfbGlContext->GetAttributes(glContext, &glAttribs);
+ if (result == DFB_OK) {
+ m_windowFormat.setDepthBufferSize(glAttribs.depth_size);
+ m_windowFormat.setStencilBufferSize(glAttribs.stencil_size);
+
+ m_windowFormat.setRedBufferSize(glAttribs.red_size);
+ m_windowFormat.setGreenBufferSize(glAttribs.green_size);
+ m_windowFormat.setBlueBufferSize(glAttribs.blue_size);
+ m_windowFormat.setAlphaBufferSize(glAttribs.alpha_size);
+
+ m_windowFormat.setAccumBufferSize(glAttribs.accum_red_size);
+ m_windowFormat.setAlpha(glAttribs.accum_alpha_size);
+
+ m_windowFormat.setDoubleBuffer(glAttribs.double_buffer);
+ m_windowFormat.setStereo(glAttribs.stereo);
+ }
+}
+
+void QDirectFbGLContext::makeCurrent()
+{
+ m_dfbGlContext->Lock(m_dfbGlContext);
+}
+
+void QDirectFbGLContext::doneCurrent()
+{
+ m_dfbGlContext->Unlock(m_dfbGlContext);
+}
+
+void *QDirectFbGLContext::getProcAddress(const QString &procName)
+{
+ void *proc;
+ DFBResult result = m_dfbGlContext->GetProcAddress(m_dfbGlContext,qPrintable(procName),&proc);
+ if (result == DFB_OK)
+ return proc;
+ return 0;
+}
+
+void QDirectFbGLContext::swapBuffers()
+{
+// m_dfbGlContext->Unlock(m_dfbGlContext); //maybe not in doneCurrent()
+ qDebug() << "Swap buffers";
+}
+
+QPlatformWindowFormat QDirectFbGLContext::platformWindowFormat() const
+{
+ return m_windowFormat;
+}
diff --git a/src/plugins/platforms/directfb/qdirectfbglcontext.h b/src/plugins/platforms/directfb/qdirectfbglcontext.h
new file mode 100644
index 0000000..f25b1a7
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbglcontext.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBGLCONTEXT_H
+#define QDIRECTFBGLCONTEXT_H
+
+#include <QPlatformGLContext>
+
+#include "qdirectfbconvenience.h"
+
+class QDirectFbGLContext : public QPlatformGLContext
+{
+public:
+ explicit QDirectFbGLContext(IDirectFBGL *glContext);
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void *getProcAddress(const QString &procName);
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+
+private:
+ IDirectFBGL *m_dfbGlContext;
+
+ QPlatformWindowFormat m_windowFormat;
+
+};
+
+#endif // QDIRECTFBGLCONTEXT_H
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.cpp b/src/plugins/platforms/directfb/qdirectfbinput.cpp
new file mode 100644
index 0000000..30654bf
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbinput.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbinput.h"
+#include "qdirectfbconvenience.h"
+
+#include <QThread>
+#include <QDebug>
+#include <QWindowSystemInterface>
+#include <QMouseEvent>
+#include <QEvent>
+#include <QApplication>
+
+#include <directfb.h>
+
+QDirectFbInput::QDirectFbInput(QObject *parent)
+ : QObject(parent), m_shouldStop(false)
+{
+ m_dfbInterface = QDirectFbConvenience::dfbInterface();
+
+ DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer);
+ if (ok != DFB_OK)
+ DirectFBError("Failed to initialise eventbuffer", ok);
+
+ m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer);
+
+}
+
+void QDirectFbInput::runInputEventLoop()
+{
+ while (true) {
+ m_eventBuffer->WaitForEvent(m_eventBuffer);
+ if (m_shouldStop) {
+ m_waitStop.release();
+ break;
+ }
+ handleEvents();
+ }
+}
+
+void QDirectFbInput::stopInputEventLoop()
+{
+ m_shouldStop = true;
+ m_waitStop.acquire();
+}
+
+void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw)
+{
+ m_tlwMap.insert(id,tlw);
+ IDirectFBWindow *window;
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window);
+
+ window->AttachEventBuffer(window,m_eventBuffer);
+}
+
+void QDirectFbInput::removeWindow(WId wId)
+{
+ IDirectFBWindow *window;
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window);
+
+ window->DetachEventBuffer(window,m_eventBuffer);
+ m_tlwMap.remove(wId);
+}
+
+void QDirectFbInput::handleEvents()
+{
+ DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
+ while(hasEvent == DFB_OK){
+ DFBEvent event;
+ DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event);
+ if (ok != DFB_OK)
+ DirectFBError("Failed to get event",ok);
+ if (event.clazz == DFEC_WINDOW) {
+ switch (event.window.type) {
+ case DWET_BUTTONDOWN:
+ case DWET_BUTTONUP:
+ case DWET_MOTION:
+ handleMouseEvents(event);
+ break;
+ case DWET_WHEEL:
+ handleWheelEvent(event);
+ break;
+ case DWET_KEYDOWN:
+ case DWET_KEYUP:
+ handleKeyEvents(event);
+ break;
+ case DWET_ENTER:
+ case DWET_LEAVE:
+ handleEnterLeaveEvents(event);
+ default:
+ break;
+ }
+
+ }
+
+ hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
+ }
+}
+
+void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
+{
+ QPoint p(event.window.x, event.window.y);
+ QPoint globalPos = globalPoint(event);
+ Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons);
+
+ IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
+ IDirectFBWindow *window;
+ layer->GetWindow(layer,event.window.window_id,&window);
+
+ long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
+
+ if (event.window.type == DWET_BUTTONDOWN) {
+ window->GrabPointer(window);
+ } else if (event.window.type == DWET_BUTTONUP) {
+ window->UngrabPointer(window);
+ }
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
+}
+
+void QDirectFbInput::handleWheelEvent(const DFBEvent &event)
+{
+ QPoint p(event.window.cx, event.window.cy);
+ QPoint globalPos = globalPoint(event);
+ long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos,
+ event.window.step*120,
+ Qt::Vertical);
+}
+
+void QDirectFbInput::handleKeyEvents(const DFBEvent &event)
+{
+ QEvent::Type type = QDirectFbConvenience::eventType(event.window.type);
+ Qt::Key key = QDirectFbConvenience::keyMap()->value(event.window.key_symbol);
+ Qt::KeyboardModifiers modifiers = QDirectFbConvenience::keyboardModifiers(event.window.modifiers);
+
+ long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
+
+ QChar character;
+ if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE)
+ character = QChar(event.window.key_symbol);
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
+ QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character);
+}
+
+void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
+{
+ QWidget *tlw = m_tlwMap.value(event.window.window_id);
+ switch (event.window.type) {
+ case DWET_ENTER:
+ QWindowSystemInterface::handleEnterEvent(tlw);
+ break;
+ case DWET_LEAVE:
+ QWindowSystemInterface::handleLeaveEvent(tlw);
+ break;
+ default:
+ break;
+ }
+}
+
+inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const
+{
+ IDirectFBWindow *window;
+ m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window);
+ int x,y;
+ window->GetPosition(window,&x,&y);
+ return QPoint(event.window.cx +x, event.window.cy + y);
+}
+
diff --git a/src/plugins/platforms/directfb/qdirectfbinput.h b/src/plugins/platforms/directfb/qdirectfbinput.h
new file mode 100644
index 0000000..35a345c
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbinput.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBINPUT_H
+#define QDIRECTFBINPUT_H
+
+#include <QSemaphore>
+#include <QObject>
+#include <QHash>
+#include <QPoint>
+#include <QEvent>
+
+#include <QtGui/qwindowdefs.h>
+
+#include <directfb.h>
+
+class QDirectFbInput : public QObject
+{
+ Q_OBJECT
+public:
+ QDirectFbInput(QObject *parent);
+ void addWindow(DFBWindowID id, QWidget *tlw);
+ void removeWindow(WId wId);
+
+public slots:
+ void runInputEventLoop();
+ void stopInputEventLoop();
+ void handleEvents();
+
+private:
+ void handleMouseEvents(const DFBEvent &event);
+ void handleWheelEvent(const DFBEvent &event);
+ void handleKeyEvents(const DFBEvent &event);
+ void handleEnterLeaveEvents(const DFBEvent &event);
+ inline QPoint globalPoint(const DFBEvent &event) const;
+
+
+ IDirectFB *m_dfbInterface;
+ IDirectFBDisplayLayer *m_dfbDisplayLayer;
+ IDirectFBEventBuffer *m_eventBuffer;
+
+ bool m_shouldStop;
+ QSemaphore m_waitStop;
+
+ QHash<DFBWindowID,QWidget *>m_tlwMap;
+};
+
+#endif // QDIRECTFBINPUT_H
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
new file mode 100644
index 0000000..52b7774
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbintegration.h"
+#include "qdirectfbwindowsurface.h"
+#include "qdirectfbblitter.h"
+#include "qdirectfbconvenience.h"
+#include "qdirectfbcursor.h"
+#include "qdirectfbwindow.h"
+
+#include "qgenericunixfontdatabase.h"
+
+#include <private/qwindowsurface_raster_p.h>
+#include <private/qpixmap_raster_p.h>
+
+#include <QtGui/private/qpixmap_blitter_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QThread>
+
+QT_BEGIN_NAMESPACE
+
+QDirectFbScreen::QDirectFbScreen(int display)
+ :QPlatformScreen()
+{
+ m_layer = QDirectFbConvenience::dfbDisplayLayer(display);
+ m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED);
+
+ DFBDisplayLayerConfig config;
+ m_layer->GetConfiguration(m_layer, &config);
+
+ m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps);
+ m_geometry = QRect(0,0,config.width,config.height);
+ const int dpi = 72;
+ const qreal inch = 25.4;
+ m_depth = QDirectFbConvenience::colorDepthForSurface(config.pixelformat);
+ m_physicalSize = QSize(qRound(config.width * inch / dpi), qRound(config.height *inch / dpi));
+
+ cursor = new QDirectFBCursor(this);
+}
+
+QDirectFbScreen::~QDirectFbScreen()
+{
+}
+
+QDirectFbIntegration::QDirectFbIntegration()
+ : mFontDb(new QGenericUnixFontDatabase())
+{
+ const QStringList args = QCoreApplication::arguments();
+ int argc = args.size();
+ char **argv = new char*[argc];
+
+ for (int i = 0; i < argc; ++i)
+ argv[i] = qstrdup(args.at(i).toLocal8Bit().constData());
+
+ DFBResult result = DirectFBInit(&argc, &argv);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreen: error initializing DirectFB",
+ result);
+ }
+ delete[] argv;
+
+
+ QDirectFbScreen *primaryScreen = new QDirectFbScreen(0);
+ mScreens.append(primaryScreen);
+
+ mInputRunner = new QThread;
+ mInput = new QDirectFbInput(0);
+ mInput->moveToThread(mInputRunner);
+ QObject::connect(mInputRunner,SIGNAL(started()),mInput,SLOT(runInputEventLoop()));
+ mInputRunner->start();
+}
+
+QDirectFbIntegration::~QDirectFbIntegration()
+{
+ mInput->stopInputEventLoop();
+ delete mInputRunner;
+ delete mInput;
+}
+
+QPixmapData *QDirectFbIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ if (type == QPixmapData::BitmapType)
+ return new QRasterPixmapData(type);
+ else
+ return new QDirectFbBlitterPixmapData;
+}
+
+QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ QDirectFbInput *input = const_cast<QDirectFbInput *>(mInput);//gah
+ return new QDirectFbWindow(widget,input);
+}
+
+QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ return new QDirectFbWindowSurface(widget,winId);
+}
+
+QPlatformFontDatabase *QDirectFbIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.h b/src/plugins/platforms/directfb/qdirectfbintegration.h
new file mode 100644
index 0000000..bfd4af4
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbintegration.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_DIRECTFB_H
+#define QPLATFORMINTEGRATION_DIRECTFB_H
+
+#include "qdirectfbinput.h"
+
+#include <QtGui/QPlatformIntegration>
+#include <directfb.h>
+#include <directfb_version.h>
+
+QT_BEGIN_NAMESPACE
+
+class QThread;
+class QDirectFBCursor;
+
+class QDirectFbScreen : public QPlatformScreen
+{
+Q_OBJECT
+public:
+ QDirectFbScreen(int display);
+ ~QDirectFbScreen();
+
+ QRect geometry() const { return m_geometry; }
+ int depth() const { return m_depth; }
+ QImage::Format format() const { return m_format; }
+ QSize physicalSize() const { return m_physicalSize; }
+
+public:
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QSize m_physicalSize;
+
+ IDirectFBDisplayLayer *m_layer;
+
+private:
+ QDirectFBCursor * cursor;
+
+};
+
+class QDirectFbIntegration : public QPlatformIntegration
+{
+public:
+ QDirectFbIntegration();
+ ~QDirectFbIntegration();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QList<QPlatformScreen *> mScreens;
+ QDirectFbInput *mInput;
+ QThread *mInputRunner;
+ QPlatformFontDatabase *mFontDb;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.cpp b/src/plugins/platforms/directfb/qdirectfbwindow.cpp
new file mode 100644
index 0000000..040580b
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbwindow.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbwindow.h"
+#include "qdirectfbinput.h"
+#include "qdirectfbglcontext.h"
+
+#include <QWidget>
+
+#include "qdirectfbwindowsurface.h"
+
+#include <directfb.h>
+
+QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler)
+ : QPlatformWindow(tlw), m_inputHandler(inputhandler), m_context(0)
+{
+ IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
+ DFBDisplayLayerConfig layerConfig;
+ layer->GetConfiguration(layer,&layerConfig);
+
+ DFBWindowDescription description;
+ memset(&description,0,sizeof(DFBWindowDescription));
+ description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS
+#if DIRECTFB_MINOR_VERSION >= 1
+ |DWDESC_OPTIONS
+#endif
+ |DWDESC_CAPS);
+ description.width = tlw->rect().width();
+ description.height = tlw->rect().height();
+ description.posx = tlw->rect().x();
+ description.posy = tlw->rect().y();
+
+ if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
+ description.surface_caps = DSCAPS_PREMULTIPLIED;
+ description.pixelformat = layerConfig.pixelformat;
+
+#if DIRECTFB_MINOR_VERSION >= 1
+ description.options = DFBWindowOptions(DWOP_ALPHACHANNEL);
+#endif
+ description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);
+ description.surface_caps = DSCAPS_PREMULTIPLIED;
+
+ DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result);
+ }
+
+ m_dfbWindow->SetOpacity(m_dfbWindow,0xff);
+
+ setVisible(widget()->isVisible());
+
+ DFBWindowID id;
+ m_dfbWindow->GetID(m_dfbWindow, &id);
+ m_inputHandler->addWindow(id,tlw);
+}
+
+QDirectFbWindow::~QDirectFbWindow()
+{
+ m_inputHandler->removeWindow(winId());
+ m_dfbWindow->Destroy(m_dfbWindow);
+}
+
+void QDirectFbWindow::setGeometry(const QRect &rect)
+{
+ bool isMoveOnly = (rect.topLeft() != geometry().topLeft()) && (rect.size() == geometry().size());
+ QPlatformWindow::setGeometry(rect);
+ if (widget()->isVisible() && !(widget()->testAttribute(Qt::WA_DontShowOnScreen))) {
+ m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(),
+ rect.width(), rect.height());
+
+ //Hack. When moving since the WindowSurface of a window becomes invalid when moved
+ if (isMoveOnly) { //if resize then windowsurface is updated.
+ widget()->windowSurface()->resize(rect.size());
+ widget()->update();
+ }
+ }
+}
+
+void QDirectFbWindow::setOpacity(qreal level)
+{
+ const quint8 windowOpacity = quint8(level * 0xff);
+ m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity);
+}
+
+void QDirectFbWindow::setVisible(bool visible)
+{
+ if (visible) {
+ int x = geometry().x();
+ int y = geometry().y();
+ m_dfbWindow->MoveTo(m_dfbWindow,x,y);
+ } else {
+ IDirectFBDisplayLayer *displayLayer;
+ QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer);
+
+ DFBDisplayLayerConfig config;
+ displayLayer->GetConfiguration(displayLayer,&config);
+ m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1);
+ }
+}
+
+Qt::WindowFlags QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ switch (flags & Qt::WindowType_Mask) {
+ case Qt::ToolTip: {
+ DFBWindowOptions options;
+ m_dfbWindow->GetOptions(m_dfbWindow,&options);
+ options = DFBWindowOptions(options | DWOP_GHOST);
+ m_dfbWindow->SetOptions(m_dfbWindow,options);
+ break; }
+ default:
+ break;
+ }
+
+ m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
+ return flags;
+}
+
+void QDirectFbWindow::raise()
+{
+ m_dfbWindow->RaiseToTop(m_dfbWindow);
+}
+
+void QDirectFbWindow::lower()
+{
+ m_dfbWindow->LowerToBottom(m_dfbWindow);
+}
+
+WId QDirectFbWindow::winId() const
+{
+ DFBWindowID id;
+ m_dfbWindow->GetID(m_dfbWindow, &id);
+ return WId(id);
+}
+
+QPlatformGLContext *QDirectFbWindow::glContext() const
+{
+ if (!m_context) {
+ IDirectFBSurface *surface;
+ DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&surface);
+ if (result != DFB_OK) {
+ qWarning("could not retrieve surface in QDirectFbWindow::glContext()");
+ return 0;
+ }
+ IDirectFBGL *gl;
+ result = surface->GetGL(surface,&gl);
+ if (result != DFB_OK) {
+ qWarning("could not retrieve IDirectFBGL in QDirectFbWindow::glContext()");
+ return 0;
+ }
+ const_cast<QDirectFbWindow *>(this)->m_context = new QDirectFbGLContext(gl);
+ }
+ return m_context;
+}
diff --git a/src/plugins/platforms/directfb/qdirectfbwindow.h b/src/plugins/platforms/directfb/qdirectfbwindow.h
new file mode 100644
index 0000000..4c6476a
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbwindow.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRECTFBWINDOW_H
+#define QDIRECTFBWINDOW_H
+
+#include <QPlatformWindow>
+
+#include "qdirectfbconvenience.h"
+#include "qdirectfbinput.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDirectFbWindow : public QPlatformWindow
+{
+public:
+ QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler);
+ ~QDirectFbWindow();
+
+ void setGeometry(const QRect &rect);
+ void setOpacity(qreal level);
+
+ void setVisible(bool visible);
+
+ Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ void raise();
+ void lower();
+ WId winId() const;
+
+ QPlatformGLContext *glContext() const;
+
+private:
+ IDirectFBWindow *m_dfbWindow;
+ QDirectFbInput *m_inputHandler;
+
+ QPlatformGLContext *m_context;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDIRECTFBWINDOW_H
diff --git a/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp
new file mode 100644
index 0000000..81f989d
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.cpp
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdirectfbwindowsurface.h"
+#include "qdirectfbintegration.h"
+#include "qdirectfbblitter.h"
+#include "qdirectfbconvenience.h"
+#include <private/qpixmap_blitter_p.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId)
+ : QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0)
+{
+
+ IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
+
+ DFBWindowID id(wId);
+ IDirectFBWindow *dfbWindow;
+
+ layer->GetWindow(layer,id,&dfbWindow);
+
+ dfbWindow->GetSurface(dfbWindow,&m_dfbSurface);
+//WRONGSIZE
+ QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface);
+ m_pmdata = new QDirectFbBlitterPixmapData;
+ m_pmdata->setBlittable(blitter);
+ m_pixmap = new QPixmap(m_pmdata);
+}
+
+QDirectFbWindowSurface::~QDirectFbWindowSurface()
+{
+ delete m_pixmap;
+}
+
+QPaintDevice *QDirectFbWindowSurface::paintDevice()
+{
+ return m_pixmap;
+}
+
+void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ m_pmdata->blittable()->unlock();
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0 ; i < rects.size(); i++) {
+ const QRect rect = rects.at(i);
+ DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()};
+ m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
+ }
+}
+
+void QDirectFbWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+
+ //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable
+ m_dfbSurface->AddRef(m_dfbSurface);
+ QDirectFbBlitter *blitter = new QDirectFbBlitter(size,m_dfbSurface);
+ m_pmdata->setBlittable(blitter);
+}
+
+static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
+{
+ const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
+ surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy);
+ const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy };
+ surface->Flip(surface, &region, DFBSurfaceFlipFlags(DSFLIP_BLIT));
+}
+
+bool QDirectFbWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ m_pmdata->blittable()->unlock();
+
+ if (!m_dfbSurface || area.isEmpty())
+ return false;
+ m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX);
+ if (area.rectCount() == 1) {
+ scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy);
+ } else {
+ const QVector<QRect> rects = area.rects();
+ const int n = rects.size();
+ for (int i=0; i<n; ++i) {
+ scrollSurface(m_dfbSurface, rects.at(i), dx, dy);
+ }
+ }
+ return true;
+}
+
+void QDirectFbWindowSurface::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+void QDirectFbWindowSurface::endPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbwindowsurface.h b/src/plugins/platforms/directfb/qdirectfbwindowsurface.h
new file mode 100644
index 0000000..a762bf6
--- /dev/null
+++ b/src/plugins/platforms/directfb/qdirectfbwindowsurface.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_DIRECTFB_H
+#define QWINDOWSURFACE_DIRECTFB_H
+
+#include <QtGui/private/qwindowsurface_p.h>
+#include <private/qpixmap_blitter_p.h>
+
+#include <directfb.h>
+
+QT_BEGIN_NAMESPACE
+
+class QDirectFbWindowSurface : public QWindowSurface
+{
+public:
+ QDirectFbWindowSurface(QWidget *window, WId wid);
+ ~QDirectFbWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize (const QSize &size);
+ bool scroll(const QRegion &area, int dx, int dy);
+
+ void beginPaint(const QRegion &region);
+ void endPaint(const QRegion &region);
+
+private:
+ void lockSurfaceToImage();
+
+ QPixmap *m_pixmap;
+ QBlittablePixmapData *m_pmdata;
+
+ IDirectFBSurface *m_dfbSurface;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
new file mode 100644
index 0000000..ec4577a
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglconvenience.h"
+
+QT_BEGIN_NAMESPACE
+
+QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
+{
+ int redSize = format.redBufferSize();
+ int greenSize = format.greenBufferSize();
+ int blueSize = format.blueBufferSize();
+ int alphaSize = format.alphaBufferSize();
+ int depthSize = format.depthBufferSize();
+ int stencilSize = format.stencilBufferSize();
+ int sampleCount = format.samples();
+
+ // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
+ // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1:
+ if (format.alpha() && alphaSize <= 0)
+ alphaSize = 1;
+ if (format.depth() && depthSize <= 0)
+ depthSize = 1;
+ if (format.stencil() && stencilSize <= 0)
+ stencilSize = 1;
+ if (format.sampleBuffers() && sampleCount <= 0)
+ sampleCount = 1;
+
+ // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
+ // the best performance. The EGL config selection algorithm is a bit stange in this regard:
+ // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
+ // 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
+ // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
+ // order is special and described as "by larger _total_ number of color bits.". So EGL will
+ // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
+ // to say "If the requested number of bits in attrib_list for a particular component is 0,
+ // then the number of bits for that component is not considered". This part of the spec also
+ // seems to imply that setting the red/green/blue bits to zero means none of the components
+ // are considered and EGL disregards the entire sorting rule. It then looks to the next
+ // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
+ // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
+ // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
+ // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
+ // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat,
+ // they will probably get a 32-bit config, even when there's an RGB565 config available.
+
+ // Now normalize the values so -1 becomes 0
+ redSize = redSize > 0 ? redSize : 0;
+ greenSize = greenSize > 0 ? greenSize : 0;
+ blueSize = blueSize > 0 ? blueSize : 0;
+ alphaSize = alphaSize > 0 ? alphaSize : 0;
+ depthSize = depthSize > 0 ? depthSize : 0;
+ stencilSize = stencilSize > 0 ? stencilSize : 0;
+ sampleCount = sampleCount > 0 ? sampleCount : 0;
+
+ QVector<EGLint> configAttributes;
+
+ configAttributes.append(EGL_RED_SIZE);
+ configAttributes.append(redSize);
+
+ configAttributes.append(EGL_GREEN_SIZE);
+ configAttributes.append(greenSize);
+
+ configAttributes.append(EGL_BLUE_SIZE);
+ configAttributes.append(blueSize);
+
+ configAttributes.append(EGL_ALPHA_SIZE);
+ configAttributes.append(alphaSize);
+
+ configAttributes.append(EGL_DEPTH_SIZE);
+ configAttributes.append(depthSize);
+
+ configAttributes.append(EGL_STENCIL_SIZE);
+ configAttributes.append(stencilSize);
+
+ configAttributes.append(EGL_SAMPLES);
+ configAttributes.append(sampleCount);
+
+ configAttributes.append(EGL_SAMPLE_BUFFERS);
+ configAttributes.append(sampleCount? 1:0);
+
+ return configAttributes;
+}
+
+bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes)
+{
+ int i = -1;
+ // Reduce the complexity of a configuration request to ask for less
+ // because the previous request did not result in success. Returns
+ // true if the complexity was reduced, or false if no further
+ // reductions in complexity are possible.
+
+ i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ }
+
+#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
+ // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't
+ // find a config which supports pre-multiplied formats, remove the flag on the surface type:
+
+ i = configAttributes->indexOf(EGL_SURFACE_TYPE);
+ if (i >= 0) {
+ EGLint surfaceType = configAttributes->at(i +1);
+ if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) {
+ surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT;
+ configAttributes->replace(i+1,surfaceType);
+ return true;
+ }
+ }
+#endif
+
+ // EGL chooses configs with the highest color depth over
+ // those with smaller (but faster) lower color depths. One
+ // way around this is to set EGL_BUFFER_SIZE to 16, which
+ // trumps the others. Of course, there may not be a 16-bit
+ // config available, so it's the first restraint we remove.
+ i = configAttributes->indexOf(EGL_BUFFER_SIZE);
+ if (i >= 0) {
+ if (configAttributes->at(i+1) == 16) {
+ configAttributes->remove(i,2);
+ return true;
+ }
+ }
+
+ i = configAttributes->indexOf(EGL_SAMPLE_BUFFERS);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ i = configAttributes->indexOf(EGL_SAMPLES);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ }
+ return true;
+ }
+
+ i = configAttributes->indexOf(EGL_ALPHA_SIZE);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB)
+ i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGBA);
+ if (i >= 0) {
+ configAttributes->replace(i,EGL_BIND_TO_TEXTURE_RGB);
+ configAttributes->replace(i+1,TRUE);
+
+ }
+#endif
+ return true;
+ }
+
+ i = configAttributes->indexOf(EGL_STENCIL_SIZE);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ return true;
+ }
+ i = configAttributes->indexOf(EGL_DEPTH_SIZE);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ return true;
+ }
+#ifdef EGL_BIND_TO_TEXTURE_RGB
+ i = configAttributes->indexOf(EGL_BIND_TO_TEXTURE_RGB);
+ if (i >= 0) {
+ configAttributes->remove(i,2);
+ return true;
+ }
+#endif
+
+ return false;
+}
+
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat)
+{
+ EGLConfig cfg = 0;
+ QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
+ configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now
+ configureAttributes.append(EGL_WINDOW_BIT);
+
+ configureAttributes.append(EGL_RENDERABLE_TYPE);
+ if (format.windowApi() == QPlatformWindowFormat::OpenVG) {
+ configureAttributes.append(EGL_OPENVG_BIT);
+ } else {
+ configureAttributes.append(EGL_OPENGL_ES2_BIT);
+ }
+ configureAttributes.append(EGL_NONE);
+
+ do {
+ // Get the number of matching configurations for this set of properties.
+ EGLint matching = 0;
+ if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
+ continue;
+
+ // If we want the best pixel format, then return the first
+ // matching configuration.
+ if (highestPixelFormat) {
+ eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
+ if (matching < 1)
+ continue;
+ return cfg;
+ }
+
+ // Fetch all of the matching configurations and find the
+ // first that matches the pixel format we wanted.
+ int i = configureAttributes.indexOf(EGL_RED_SIZE);
+ int confAttrRed = configureAttributes.at(i+1);
+ i = configureAttributes.indexOf(EGL_GREEN_SIZE);
+ int confAttrGreen = configureAttributes.at(i+1);
+ i = configureAttributes.indexOf(EGL_BLUE_SIZE);
+ int confAttrBlue = configureAttributes.at(i+1);
+ i = configureAttributes.indexOf(EGL_ALPHA_SIZE);
+ int confAttrAlpha = configureAttributes.at(i+1);
+
+ EGLint size = matching;
+ EGLConfig *configs = new EGLConfig [size];
+ eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching);
+ for (EGLint index = 0; index < size; ++index) {
+ EGLint red, green, blue, alpha;
+ eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
+ eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
+ eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
+ if (red == confAttrRed &&
+ green == confAttrGreen &&
+ blue == confAttrBlue &&
+ (confAttrAlpha == 0 ||
+ alpha == confAttrAlpha)) {
+ cfg = configs[index];
+ delete [] configs;
+ return cfg;
+ }
+ }
+ delete [] configs;
+ } while (q_reduceConfigAttributes(&configureAttributes));
+ qWarning("Cant find EGLConfig, returning null config");
+ return 0;
+}
+
+QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
+{
+ QPlatformWindowFormat format;
+ EGLint redSize = 0;
+ EGLint greenSize = 0;
+ EGLint blueSize = 0;
+ EGLint alphaSize = 0;
+ EGLint depthSize = 0;
+ EGLint stencilSize = 0;
+ EGLint sampleCount = 0;
+ EGLint level = 0;
+
+ eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
+ eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
+ eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize);
+ eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize);
+ eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
+ eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
+ eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
+ eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSamples(sampleCount);
+ format.setDirectRendering(true); // All EGL contexts are direct-rendered
+ format.setRgba(true); // EGL doesn't support colour index rendering
+ format.setStereo(false); // EGL doesn't support stereo buffers
+ format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
+
+ // Clear the EGL error state because some of the above may
+ // have errored out because the attribute is not applicable
+ // to the surface type. Such errors don't matter.
+ eglGetError();
+
+ return format;
+}
+
+bool q_hasEglExtension(EGLDisplay display, const char* extensionName)
+{
+ QList<QByteArray> extensions =
+ QByteArray(reinterpret_cast<const char *>
+ (eglQueryString(display, EGL_EXTENSIONS))).split(' ');
+ return extensions.contains(extensionName);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
new file mode 100644
index 0000000..8668095
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLCONVENIENCE_H
+#define QEGLCONVENIENCE_H
+
+
+#include <QtGui/QPlatformWindowFormat>
+#include <QtCore/QVector>
+
+#ifdef Q_PLATFORM_WAYLAND
+#include "qwaylandinclude.h"
+#else
+#include <EGL/egl.h>
+#endif
+QT_BEGIN_NAMESPACE
+
+QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
+bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false);
+QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config);
+bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
+
+QT_END_NAMESPACE
+
+#endif //QEGLCONVENIENCE_H
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
new file mode 100644
index 0000000..9a2bc61
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglplatformcontext.h"
+
+
+#include <QtGui/QPlatformWindow>
+
+#include "qeglconvenience.h"
+
+#include <EGL/egl.h>
+
+QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi)
+ : QPlatformGLContext()
+ , m_eglDisplay(display)
+ , m_eglSurface(surface)
+ , m_eglApi(eglApi)
+{
+ if (m_eglSurface == EGL_NO_SURFACE) {
+ qWarning("Createing QEGLPlatformContext with no surface");
+ }
+
+ eglBindAPI(m_eglApi);
+ m_eglContext = eglCreateContext(m_eglDisplay,config, 0,contextAttrs);
+ if (m_eglContext == EGL_NO_CONTEXT) {
+ qWarning("Could not create the egl context\n");
+ eglTerminate(m_eglDisplay);
+ qFatal("EGL error");
+ }
+
+ m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config);
+}
+
+QEGLPlatformContext::~QEGLPlatformContext()
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglContext::~QEglContext(): %p\n",this);
+#endif
+ if (m_eglSurface != EGL_NO_SURFACE) {
+ doneCurrent();
+ eglDestroySurface(m_eglDisplay, m_eglSurface);
+ m_eglSurface = EGL_NO_SURFACE;
+ }
+
+ if (m_eglContext != EGL_NO_CONTEXT) {
+ eglDestroyContext(m_eglDisplay, m_eglContext);
+ m_eglContext = EGL_NO_CONTEXT;
+ }
+}
+
+void QEGLPlatformContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglContext::makeCurrent: %p\n",this);
+#endif
+ eglBindAPI(m_eglApi);
+ bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
+ if (!ok)
+ qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this);
+#ifdef QEGL_EXTRA_DEBUG
+ static bool showDebug = true;
+ if (showDebug) {
+ showDebug = false;
+ const char *str = (const char*)glGetString(GL_VENDOR);
+ qWarning("Vendor %s\n", str);
+ str = (const char*)glGetString(GL_RENDERER);
+ qWarning("Renderer %s\n", str);
+ str = (const char*)glGetString(GL_VERSION);
+ qWarning("Version %s\n", str);
+
+ str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
+ qWarning("Extensions %s\n",str);
+
+ str = (const char*)glGetString(GL_EXTENSIONS);
+ qWarning("Extensions %s\n", str);
+
+ }
+#endif
+}
+void QEGLPlatformContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglContext::doneCurrent:%p\n",this);
+#endif
+ eglBindAPI(m_eglApi);
+ bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (!ok)
+ qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
+}
+void QEGLPlatformContext::swapBuffers()
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglContext::swapBuffers:%p\n",this);
+#endif
+ eglBindAPI(m_eglApi);
+ bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface);
+ if (!ok)
+ qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this);
+}
+void* QEGLPlatformContext::getProcAddress(const QString& procName)
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglContext::getProcAddress%p\n",this);
+#endif
+ eglBindAPI(m_eglApi);
+ return (void *)eglGetProcAddress(qPrintable(procName));
+}
+
+void QEGLPlatformContext::makeDefaultSharedContext()
+{
+ setDefaultSharedContext(this);
+}
+
+QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const
+{
+ return m_windowFormat;
+}
+
+EGLContext QEGLPlatformContext::eglContext() const
+{
+ return m_eglContext;
+}
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
new file mode 100644
index 0000000..d688660
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENKODEGLINTEGRATION_H
+#define QOPENKODEGLINTEGRATION_H
+
+#include <QtGui/QPlatformGLContext>
+#include <EGL/egl.h>
+
+class QEGLPlatformContext : public QPlatformGLContext
+{
+public:
+ QEGLPlatformContext(EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi);
+ ~QEGLPlatformContext();
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString& procName);
+
+ void makeDefaultSharedContext();
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ EGLContext eglContext() const;
+private:
+ EGLContext m_eglContext;
+ EGLDisplay m_eglDisplay;
+ EGLSurface m_eglSurface;
+ EGLenum m_eglApi;
+
+ QPlatformWindowFormat m_windowFormat;
+};
+
+#endif //QOPENKODEGLINTEGRATION_H
diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
new file mode 100644
index 0000000..7f296c5
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibeglintegration.h"
+
+static int countBits(unsigned long mask)
+{
+ int count = 0;
+ while (mask != 0) {
+ if (mask & 1)
+ ++count;
+ mask >>= 1;
+ }
+ return count;
+}
+
+VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config)
+{
+ VisualID visualId = 0;
+ EGLint eglValue = 0;
+
+ EGLDisplay eglDisplay = eglGetDisplay(display);
+
+ EGLint configRedSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize);
+
+ EGLint configGreenSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize);
+
+ EGLint configBlueSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize);
+
+ EGLint configAlphaSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize);
+
+ eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue);
+ int configId = eglValue;
+
+ // See if EGL provided a valid VisualID:
+ eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
+ visualId = (VisualID)eglValue;
+ if (visualId) {
+ // EGL has suggested a visual id, so get the rest of the visual info for that id:
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+
+ XVisualInfo *chosenVisualInfo;
+ int matchingCount = 0;
+ chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount);
+ if (chosenVisualInfo) {
+ // Skip size checks if implementation supports non-matching visual
+ // and config (http://bugreports.qt.nokia.com/browse/QTBUG-9444).
+ if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) {
+ XFree(chosenVisualInfo);
+ return visualId;
+ }
+
+ int visualRedSize = countBits(chosenVisualInfo->red_mask);
+ int visualGreenSize = countBits(chosenVisualInfo->green_mask);
+ int visualBlueSize = countBits(chosenVisualInfo->blue_mask);
+ int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size
+
+ bool visualMatchesConfig = false;
+ if ( visualRedSize == configRedSize &&
+ visualGreenSize == configGreenSize &&
+ visualBlueSize == configBlueSize )
+ {
+ // We need XRender to check the alpha channel size of the visual. If we don't have
+ // the alpha size, we don't check it against the EGL config's alpha size.
+ if (visualAlphaSize >= 0)
+ visualMatchesConfig = visualAlphaSize == configAlphaSize;
+ else
+ visualMatchesConfig = true;
+ }
+
+ if (!visualMatchesConfig) {
+ if (visualAlphaSize >= 0) {
+ qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable",
+ (int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize,
+ configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize);
+ } else {
+ qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable",
+ (int)visualId, visualRedSize, visualGreenSize, visualBlueSize,
+ configId, configRedSize, configGreenSize, configBlueSize);
+ }
+ visualId = 0;
+ }
+ } else {
+ qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
+ (int)visualId, configId);
+ visualId = 0;
+ }
+ XFree(chosenVisualInfo);
+ }
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ else
+ qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
+#endif
+
+ if (visualId) {
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ if (configAlphaSize > 0)
+ qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
+ else
+ qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
+#endif
+ return visualId;
+ }
+
+ // Finally, try to
+ // use XGetVisualInfo and only use the bit depths to match on:
+ if (!visualId) {
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ XVisualInfo *matchingVisuals;
+ int matchingCount = 0;
+
+ visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;
+ matchingVisuals = XGetVisualInfo(display,
+ VisualDepthMask,
+ &visualInfoTemplate,
+ &matchingCount);
+ if (!matchingVisuals) {
+ // Try again without taking the alpha channel into account:
+ visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;
+ matchingVisuals = XGetVisualInfo(display,
+ VisualDepthMask,
+ &visualInfoTemplate,
+ &matchingCount);
+ }
+
+ if (matchingVisuals) {
+ visualId = matchingVisuals[0].visualid;
+ XFree(matchingVisuals);
+ }
+ }
+
+ if (visualId) {
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ qDebug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
+#endif
+ return visualId;
+ }
+
+ qWarning("Unable to find an X11 visual which matches EGL config %d", configId);
+ return (VisualID)0;
+}
diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
new file mode 100644
index 0000000..51996da
--- /dev/null
+++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEEGLINTEGRATION_H
+#define QTESTLITEEGLINTEGRATION_H
+
+#include "qeglconvenience.h"
+
+class QXlibEglIntegration
+{
+public:
+ static VisualID getCompatibleVisualId(Display *display, EGLConfig config);
+};
+
+#endif // QTESTLITEEGLINTEGRATION_H
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro
new file mode 100644
index 0000000..7ad8fd9
--- /dev/null
+++ b/src/plugins/platforms/eglfs/eglfs.pro
@@ -0,0 +1,31 @@
+TARGET = qeglfs
+TEMPLATE = lib
+CONFIG += plugin
+
+QT += opengl
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+#DEFINES += QEGL_EXTRA_DEBUG
+
+#DEFINES += Q_OPENKODE
+
+SOURCES = main.cpp \
+ qeglfsintegration.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ qeglfswindow.cpp \
+ qeglfswindowsurface.cpp \
+ qeglfsscreen.cpp
+
+HEADERS = qeglfsintegration.h \
+ ../eglconvenience/qeglconvenience.h \
+ ../eglconvenience/qeglplatformcontext.h \
+ qeglfswindow.h \
+ qeglfswindowsurface.h \
+ qeglfsscreen.h
+
+include(../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/eglfs/main.cpp b/src/plugins/platforms/eglfs/main.cpp
new file mode 100644
index 0000000..c07e546
--- /dev/null
+++ b/src/plugins/platforms/eglfs/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qeglfsintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEglIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QEglIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "EglFS";
+ return list;
+}
+
+QPlatformIntegration* QEglIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "eglfs")
+ return new QEglFSIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(eglintegration, QEglIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
new file mode 100644
index 0000000..78981f9
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsintegration.h"
+
+#include "qeglfswindow.h"
+#include "qeglfswindowsurface.h"
+
+#include <QtGui/QPlatformWindow>
+#include <QtGui/QPlatformWindowFormat>
+#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+
+#include "qgenericunixfontdatabase.h"
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+QEglFSIntegration::QEglFSIntegration()
+ : mFontDb(new QGenericUnixFontDatabase())
+{
+ m_primaryScreen = new QEglFSScreen(EGL_DEFAULT_DISPLAY);
+
+ mScreens.append(m_primaryScreen);
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglIntegration\n");
+#endif
+}
+
+bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPixmapData *QEglFSIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglIntegration::createPixmapData %d\n", type);
+#endif
+ return new QGLPixmapData(type);
+}
+
+QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglIntegration::createPlatformWindow %p\n",widget);
+#endif
+ return new QEglFSWindow(widget, m_primaryScreen);
+}
+
+
+QWindowSurface *QEglFSIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglIntegration::createWindowSurface %p\n",widget);
+#endif
+ return new QEglFSWindowSurface(m_primaryScreen,widget);
+}
+
+QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
new file mode 100644
index 0000000..65b834f
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EGLINTEGRATION_H
+#define EGLINTEGRATION_H
+
+#include "qeglfsscreen.h"
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSIntegration : public QPlatformIntegration
+{
+public:
+ QEglFSIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QPlatformFontDatabase *mFontDb;
+ QList<QPlatformScreen *> mScreens;
+ QEglFSScreen *m_primaryScreen;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
new file mode 100644
index 0000000..2200d1d
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsscreen.h"
+
+#include "../eglconvenience/qeglconvenience.h"
+#include "../eglconvenience/qeglplatformcontext.h"
+
+#ifdef Q_OPENKODE
+#include <KD/kd.h>
+#include <KD/NV_initialize.h>
+#endif //Q_OPENKODE
+
+QT_BEGIN_NAMESPACE
+
+// #define QEGL_EXTRA_DEBUG
+
+#ifdef QEGL_EXTRA_DEBUG
+struct AttrInfo { EGLint attr; const char *name; };
+static struct AttrInfo attrs[] = {
+ {EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE"},
+ {EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE"},
+ {EGL_BLUE_SIZE, "EGL_BLUE_SIZE"},
+ {EGL_GREEN_SIZE, "EGL_GREEN_SIZE"},
+ {EGL_RED_SIZE, "EGL_RED_SIZE"},
+ {EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE"},
+ {EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE"},
+ {EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT"},
+ {EGL_CONFIG_ID, "EGL_CONFIG_ID"},
+ {EGL_LEVEL, "EGL_LEVEL"},
+ {EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT"},
+ {EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS"},
+ {EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH"},
+ {EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE"},
+ {EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID"},
+ {EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE"},
+ {EGL_SAMPLES, "EGL_SAMPLES"},
+ {EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS"},
+ {EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE"},
+ {EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE"},
+ {EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE"},
+ {EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE"},
+ {EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE"},
+ {EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB"},
+ {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"},
+ {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"},
+ {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"},
+ {-1, 0}};
+#endif //QEGL_EXTRA_DEBUG
+
+QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display)
+ : m_depth(32)
+ , m_format(QImage::Format_Invalid)
+ , m_platformContext(0)
+ , m_surface(0)
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglScreen %p\n", this);
+#endif
+
+ EGLint major, minor;
+#ifdef QEGL_EXTRA_DEBUG
+ EGLint index;
+#endif
+ if (!eglBindAPI(EGL_OPENGL_ES_API)) {
+ qWarning("Could not bind GL_ES API\n");
+ qFatal("EGL error");
+ }
+
+ m_dpy = eglGetDisplay(display);
+ if (m_dpy == EGL_NO_DISPLAY) {
+ qWarning("Could not open egl display\n");
+ qFatal("EGL error");
+ }
+ qWarning("Opened display %p\n", m_dpy);
+
+ if (!eglInitialize(m_dpy, &major, &minor)) {
+ qWarning("Could not initialize egl display\n");
+ qFatal("EGL error");
+ }
+
+ qWarning("Initialized display %d %d\n", major, minor);
+
+ int swapInterval = 1;
+ QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
+ if (!swapIntervalString.isEmpty()) {
+ bool ok;
+ swapInterval = swapIntervalString.toInt(&ok);
+ if (!ok)
+ swapInterval = 1;
+ }
+ eglSwapInterval(m_dpy, swapInterval);
+}
+
+void QEglFSScreen::createAndSetPlatformContext() const {
+ const_cast<QEglFSScreen *>(this)->createAndSetPlatformContext();
+}
+
+void QEglFSScreen::createAndSetPlatformContext()
+{
+ QPlatformWindowFormat platformFormat = QPlatformWindowFormat::defaultFormat();
+
+ platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
+
+ QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
+ if (depthString.toInt() == 16) {
+ platformFormat.setDepth(16);
+ platformFormat.setRedBufferSize(5);
+ platformFormat.setGreenBufferSize(6);
+ platformFormat.setBlueBufferSize(5);
+ m_depth = 16;
+ m_format = QImage::Format_RGB16;
+ } else {
+ platformFormat.setDepth(32);
+ platformFormat.setRedBufferSize(8);
+ platformFormat.setGreenBufferSize(8);
+ platformFormat.setBlueBufferSize(8);
+ m_depth = 32;
+ m_format = QImage::Format_RGB32;
+ }
+ if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) {
+ platformFormat.setSampleBuffers(true);
+ }
+
+
+ EGLConfig config = q_configFromQPlatformWindowFormat(m_dpy, platformFormat);
+
+ EGLNativeWindowType eglWindow = 0;
+#ifdef Q_OPENKODE
+ if (kdInitializeNV() == KD_ENOTINITIALIZED) {
+ qFatal("Did not manage to initialize openkode");
+ }
+ KDWindow *window = kdCreateWindow(m_dpy,config,0);
+
+ kdRealizeWindow(window,&eglWindow);
+#endif
+
+ m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
+ if (m_surface == EGL_NO_SURFACE) {
+ qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
+ eglTerminate(m_dpy);
+ qFatal("EGL error");
+ }
+ // qWarning("Created surface %dx%d\n", w, h);
+
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("Configuration %d matches requirements\n", (int)config);
+
+ for (index = 0; attrs[index].attr != -1; ++index) {
+ EGLint value;
+ if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) {
+ qWarning("\t%s: %d\n", attrs[index].name, (int)value);
+ }
+ }
+ qWarning("\n");
+#endif
+
+ EGLint temp;
+ EGLint attribList[32];
+
+ temp = 0;
+
+ attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION;
+ attribList[temp++] = 2; // GLES version 2
+ attribList[temp++] = EGL_NONE;
+
+ QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API);
+ platformContext->makeDefaultSharedContext();
+ m_platformContext = platformContext;
+
+ EGLint w,h; // screen size detection
+ eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
+ eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);
+
+ m_geometry = QRect(0,0,w,h);
+
+}
+
+QRect QEglFSScreen::geometry() const
+{
+ if (m_geometry.isNull()) {
+ createAndSetPlatformContext();
+ }
+ return m_geometry;
+}
+
+int QEglFSScreen::depth() const
+{
+ return m_depth;
+}
+
+QImage::Format QEglFSScreen::format() const
+{
+ if (m_format == QImage::Format_Invalid)
+ createAndSetPlatformContext();
+ return m_format;
+}
+QPlatformGLContext *QEglFSScreen::platformContext() const
+{
+ if (!m_platformContext) {
+ QEglFSScreen *that = const_cast<QEglFSScreen *>(this);
+ that->createAndSetPlatformContext();
+ }
+ return m_platformContext;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
new file mode 100644
index 0000000..6a2a504
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLSCREEN_H
+#define QEGLSCREEN_H
+
+#include <QPlatformScreen>
+
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformGLContext;
+
+class QEglFSScreen : public QPlatformScreen //huh: FullScreenScreen ;) just to follow namespace
+{
+public:
+ QEglFSScreen(EGLNativeDisplayType display);
+ ~QEglFSScreen() {}
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+
+ QPlatformGLContext *platformContext() const;
+
+private:
+ void createAndSetPlatformContext() const;
+ void createAndSetPlatformContext();
+
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QPlatformGLContext *m_platformContext;
+ EGLDisplay m_dpy;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+#endif // QEGLSCREEN_H
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
new file mode 100644
index 0000000..2ef12aa
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfswindow.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+QT_BEGIN_NAMESPACE
+
+QEglFSWindow::QEglFSWindow(QWidget *w, QEglFSScreen *screen)
+ : QPlatformWindow(w), m_screen(screen)
+{
+ static int serialNo = 0;
+ m_winid = ++serialNo;
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglWindow %p: %p %p 0x%x\n", this, w, screen, uint(m_winid));
+#endif
+}
+
+
+void QEglFSWindow::setGeometry(const QRect &)
+{
+ // We only support full-screen windows
+ QRect rect(m_screen->availableGeometry());
+ QWindowSystemInterface::handleGeometryChange(this->widget(), rect);
+
+ // Since toplevels are fullscreen, propegate the screen size back to the widget
+ widget()->setGeometry(rect);
+
+ QPlatformWindow::setGeometry(rect);
+}
+
+WId QEglFSWindow::winId() const
+{
+ return m_winid;
+}
+
+
+
+QPlatformGLContext *QEglFSWindow::glContext() const
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglWindow::glContext %p\n", m_screen->platformContext());
+#endif
+ Q_ASSERT(m_screen);
+ return m_screen->platformContext();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
new file mode 100644
index 0000000..ad51114
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLWINDOW_H
+#define QEGLWINDOW_H
+
+#include "qeglfsintegration.h"
+#include "qeglfsscreen.h"
+
+
+#include <QPlatformWindow>
+#include <QtGui/QWidget>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSWindow : public QPlatformWindow
+{
+public:
+ QEglFSWindow(QWidget *w, QEglFSScreen *screen);
+
+ void setGeometry(const QRect &);
+ WId winId() const;
+
+ QPlatformGLContext *glContext() const;
+
+private:
+ QEglFSScreen *m_screen;
+ WId m_winid;
+};
+QT_END_NAMESPACE
+#endif // QEGLWINDOW_H
diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp
new file mode 100644
index 0000000..393e646
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfswindowsurface.h"
+
+#include <QtGui/QPlatformGLContext>
+
+#include <QtOpenGL/private/qgl_p.h>
+#include <QtOpenGL/private/qglpaintdevice_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSPaintDevice : public QGLPaintDevice
+{
+public:
+ QEglFSPaintDevice(QEglFSScreen *screen, QWidget *widget)
+ :QGLPaintDevice(), m_screen(screen)
+ {
+ #ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglPaintDevice %p, %p, %p",this, screen, widget);
+ #endif
+ }
+
+ QSize size() const { return m_screen->geometry().size(); }
+ QGLContext* context() const { return QGLContext::fromPlatformGLContext(m_screen->platformContext());}
+
+ QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); }
+
+ void beginPaint(){
+ QGLPaintDevice::beginPaint();
+ }
+private:
+ QEglFSScreen *m_screen;
+ QGLContext *m_context;
+};
+
+
+QEglFSWindowSurface::QEglFSWindowSurface( QEglFSScreen *screen, QWidget *window )
+ :QWindowSurface(window)
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglWindowSurface %p, %p", window, screen);
+#endif
+ m_paintDevice = new QEglFSPaintDevice(screen,window);
+}
+
+void QEglFSWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglWindowSurface::flush %p",widget);
+#endif
+ widget->platformWindow()->glContext()->swapBuffers();
+}
+
+void QEglFSWindowSurface::resize(const QSize &size)
+{
+ Q_UNUSED(size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindowsurface.h b/src/plugins/platforms/eglfs/qeglfswindowsurface.h
new file mode 100644
index 0000000..2fa655b
--- /dev/null
+++ b/src/plugins/platforms/eglfs/qeglfswindowsurface.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLWINDOWSURFACE_H
+#define QEGLWINDOWSURFACE_H
+
+#include "qeglfsintegration.h"
+#include "qeglfswindow.h"
+
+#include <QtGui/private/qwindowsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSWindowSurface : public QWindowSurface
+{
+public:
+ QEglFSWindowSurface(QEglFSScreen *screen, QWidget *window);
+ ~QEglFSWindowSurface() {}
+
+ QPaintDevice *paintDevice() { return m_paintDevice; }
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+private:
+ QPaintDevice *m_paintDevice;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEGLWINDOWSURFACE_H
diff --git a/src/plugins/platforms/externalplugin.pri b/src/plugins/platforms/externalplugin.pri
new file mode 100644
index 0000000..54da4d9
--- /dev/null
+++ b/src/plugins/platforms/externalplugin.pri
@@ -0,0 +1,29 @@
+#
+# Lighthouse now has preliminarily support for building and
+# loading platform plugins from outside the Qt source/build
+# tree.
+#
+# 1) Building external plugins:
+# Set QTDIR to the Qt build directory, copy this file to
+# the plugin source repository and include it at the top
+# of the plugin's pro file. Use QT_SOURCE_TREE if you
+# want to pull in source code from Qt:
+#
+# include($$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri)
+#
+# 2) Loading external plugins:
+# Specify the path to the directory containing the
+# plugin on the command line, in addition to the
+# platform name.
+#
+# ./wiggly -platformPluginPath /path/to/myPlugin -platform gullfaksA
+#
+
+!exists($$(QTDIR)/.qmake.cache) {
+ error("Please set QTDIR to the Qt build directory")
+}
+
+QT_SOURCE_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE)
+QT_BUILD_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_BUILD_TREE)
+
+include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri)
diff --git a/src/plugins/platforms/fb_base/fb_base.cpp b/src/plugins/platforms/fb_base/fb_base.cpp
new file mode 100644
index 0000000..e118ce8
--- /dev/null
+++ b/src/plugins/platforms/fb_base/fb_base.cpp
@@ -0,0 +1,507 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fb_base.h"
+#include <qpainter.h>
+#include <qdebug.h>
+#include <qbitmap.h>
+#include <QPlatformCursor>
+#include <QWindowSystemInterface>
+
+QPlatformSoftwareCursor::QPlatformSoftwareCursor(QPlatformScreen *scr)
+ : QPlatformCursor(scr), currentRect(QRect()), prevRect(QRect())
+{
+ graphic = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+ setCursor(Qt::ArrowCursor);
+}
+
+QRect QPlatformSoftwareCursor::getCurrentRect()
+{
+ QRect rect = graphic->image()->rect().translated(-graphic->hotspot().x(),
+ -graphic->hotspot().y());
+ rect.translate(QCursor::pos());
+ QPoint screenOffset = screen->geometry().topLeft();
+ rect.translate(-screenOffset); // global to local translation
+ return rect;
+}
+
+
+void QPlatformSoftwareCursor::pointerEvent(const QMouseEvent & e)
+{
+ Q_UNUSED(e);
+ QPoint screenOffset = screen->geometry().topLeft();
+ currentRect = getCurrentRect();
+ // global to local translation
+ if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset))) {
+ setDirty();
+ }
+}
+
+QRect QPlatformSoftwareCursor::drawCursor(QPainter & painter)
+{
+ dirty = false;
+ if (currentRect.isNull())
+ return QRect();
+
+ // We need this because the cursor might be dirty due to moving off screen
+ QPoint screenOffset = screen->geometry().topLeft();
+ // global to local translation
+ if (!currentRect.translated(screenOffset).intersects(screen->geometry()))
+ return QRect();
+
+ prevRect = currentRect;
+ painter.drawImage(prevRect, *graphic->image());
+ onScreen = true;
+ return prevRect;
+}
+
+QRect QPlatformSoftwareCursor::dirtyRect()
+{
+ if (onScreen) {
+ onScreen = false;
+ return prevRect;
+ }
+ return QRect();
+}
+
+void QPlatformSoftwareCursor::setCursor(Qt::CursorShape shape)
+{
+ graphic->set(shape);
+}
+
+void QPlatformSoftwareCursor::setCursor(const QImage &image, int hotx, int hoty)
+{
+ graphic->set(image, hotx, hoty);
+}
+
+void QPlatformSoftwareCursor::setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+{
+ graphic->set(data, mask, width, height, hotX, hotY);
+}
+
+void QPlatformSoftwareCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+{
+ Q_UNUSED(widget);
+ Qt::CursorShape shape = widgetCursor->shape();
+
+ if (shape == Qt::BitmapCursor) {
+ // application supplied cursor
+ QPoint spot = widgetCursor->hotSpot();
+ setCursor(widgetCursor->pixmap().toImage(), spot.x(), spot.y());
+ } else {
+ // system cursor
+ setCursor(shape);
+ }
+ currentRect = getCurrentRect();
+ QPoint screenOffset = screen->geometry().topLeft(); // global to local translation
+ if (onScreen || screen->geometry().intersects(currentRect.translated(screenOffset)))
+ setDirty();
+}
+
+QFbScreen::QFbScreen() : cursor(0), mGeometry(), mDepth(16), mFormat(QImage::Format_RGB16), mScreenImage(0), compositePainter(0), isUpToDate(false)
+{
+ mScreenImage = new QImage(mGeometry.size(), mFormat);
+ redrawTimer.setSingleShot(true);
+ redrawTimer.setInterval(0);
+ QObject::connect(&redrawTimer, SIGNAL(timeout()), this, SLOT(doRedraw()));
+}
+
+void QFbScreen::setGeometry(QRect rect)
+{
+ delete mScreenImage;
+ mGeometry = rect;
+ mScreenImage = new QImage(mGeometry.size(), mFormat);
+ delete compositePainter;
+ compositePainter = 0;
+ invalidateRectCache();
+}
+
+void QFbScreen::setDepth(int depth)
+{
+ mDepth = depth;
+}
+
+void QFbScreen::setPhysicalSize(QSize size)
+{
+ mPhysicalSize = size;
+}
+
+void QFbScreen::setFormat(QImage::Format format)
+{
+ mFormat = format;
+ delete mScreenImage;
+ mScreenImage = new QImage(mGeometry.size(), mFormat);
+ delete compositePainter;
+ compositePainter = 0;
+}
+
+QFbScreen::~QFbScreen()
+{
+ delete compositePainter;
+ delete mScreenImage;
+}
+
+void QFbScreen::setDirty(const QRect &rect)
+{
+ QRect intersection = rect.intersected(mGeometry);
+ QPoint screenOffset = mGeometry.topLeft();
+ repaintRegion += intersection.translated(-screenOffset); // global to local translation
+ if (!redrawTimer.isActive()) {
+ redrawTimer.start();
+ }
+}
+
+void QFbScreen::generateRects()
+{
+ cachedRects.clear();
+ QPoint screenOffset = mGeometry.topLeft();
+ QRegion remainingScreen(mGeometry.translated(-screenOffset)); // global to local translation
+
+ for (int i = 0; i < windowStack.length(); i++) {
+ if (remainingScreen.isEmpty())
+ break;
+ if (!windowStack[i]->visible())
+ continue;
+ if (windowStack[i]->widget()->isMinimized())
+ continue;
+
+ if (!windowStack[i]->widget()->testAttribute(Qt::WA_TranslucentBackground)) {
+ QRect localGeometry = windowStack.at(i)->geometry().translated(-screenOffset); // global to local translation
+ remainingScreen -= localGeometry;
+ QRegion windowRegion(localGeometry);
+ windowRegion -= remainingScreen;
+ foreach(QRect rect, windowRegion.rects()) {
+ cachedRects += QPair<QRect, int>(rect, i);
+ }
+ }
+ }
+ foreach (QRect rect, remainingScreen.rects())
+ cachedRects += QPair<QRect, int>(rect, -1);
+ isUpToDate = true;
+ return;
+}
+
+
+
+QRegion QFbScreen::doRedraw()
+{
+ QPoint screenOffset = mGeometry.topLeft();
+
+ QRegion touchedRegion;
+ if (cursor && cursor->isDirty() && cursor->isOnScreen()) {
+ QRect lastCursor = cursor->dirtyRect();
+ repaintRegion += lastCursor;
+ }
+ if (repaintRegion.isEmpty() && (!cursor || !cursor->isDirty())) {
+ return touchedRegion;
+ }
+
+ QVector<QRect> rects = repaintRegion.rects();
+
+ if (!isUpToDate)
+ generateRects();
+
+ if (!compositePainter)
+ compositePainter = new QPainter(mScreenImage);
+ for (int rectIndex = 0; rectIndex < repaintRegion.numRects(); rectIndex++) {
+ QRegion rectRegion = rects[rectIndex];
+
+ for(int i = 0; i < cachedRects.length(); i++) {
+ QRect screenSubRect = cachedRects[i].first;
+ int layer = cachedRects[i].second;
+ QRegion intersect = rectRegion.intersected(screenSubRect);
+
+ if (intersect.isEmpty())
+ continue;
+
+ rectRegion -= intersect;
+
+ // we only expect one rectangle, but defensive coding...
+ foreach (QRect rect, intersect.rects()) {
+ bool firstLayer = true;
+ if (layer == -1) {
+ compositePainter->fillRect(rect, Qt::black);
+ firstLayer = false;
+ layer = windowStack.size() - 1;
+ }
+
+ for (int layerIndex = layer; layerIndex != -1; layerIndex--) {
+ if (!windowStack[layerIndex]->visible())
+ continue;
+ if (windowStack[layerIndex]->widget()->isMinimized())
+ continue;
+ QRect windowRect = windowStack[layerIndex]->geometry().translated(-screenOffset);
+ QRect windowIntersect = rect.translated(-windowRect.left(),
+ -windowRect.top());
+ compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(),
+ windowIntersect);
+ if (firstLayer) {
+ firstLayer = false;
+ }
+ }
+ }
+ }
+ }
+
+ QRect cursorRect;
+ if (cursor && (cursor->isDirty() || repaintRegion.intersects(cursor->lastPainted()))) {
+ cursorRect = cursor->drawCursor(*compositePainter);
+ touchedRegion += cursorRect;
+ }
+ touchedRegion += repaintRegion;
+ repaintRegion = QRegion();
+
+
+
+// qDebug() << "QFbScreen::doRedraw" << windowStack.size() << mScreenImage->size() << touchedRegion;
+
+
+ return touchedRegion;
+}
+
+void QFbScreen::addWindow(QFbWindow *surface)
+{
+ windowStack.prepend(surface);
+ surface->mScreens.append(this);
+ invalidateRectCache();
+ setDirty(surface->geometry());
+}
+
+void QFbScreen::removeWindow(QFbWindow * surface)
+{
+ windowStack.removeOne(surface);
+ surface->mScreens.removeOne(this);
+ invalidateRectCache();
+ setDirty(surface->geometry());
+}
+
+void QFbWindow::raise()
+{
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->raise(this);
+ ++i;
+ }
+}
+
+void QFbScreen::raise(QPlatformWindow * surface)
+{
+ QFbWindow *s = static_cast<QFbWindow *>(surface);
+ int index = windowStack.indexOf(s);
+ if (index <= 0)
+ return;
+ windowStack.move(index, 0);
+ invalidateRectCache();
+ setDirty(s->geometry());
+}
+
+void QFbWindow::lower()
+{
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->lower(this);
+ ++i;
+ }
+}
+
+void QFbScreen::lower(QPlatformWindow * surface)
+{
+ QFbWindow *s = static_cast<QFbWindow *>(surface);
+ int index = windowStack.indexOf(s);
+ if (index == -1 || index == (windowStack.size() - 1))
+ return;
+ windowStack.move(index, windowStack.size() - 1);
+ invalidateRectCache();
+ setDirty(s->geometry());
+}
+
+QWidget * QFbScreen::topLevelAt(const QPoint & p) const
+{
+ for(int i = 0; i < windowStack.size(); i++) {
+ if (windowStack[i]->geometry().contains(p, false) &&
+ windowStack[i]->visible() &&
+ !windowStack[i]->widget()->isMinimized()) {
+ return windowStack[i]->widget();
+ }
+ }
+ return 0;
+}
+
+QFbWindow::QFbWindow(QWidget *window)
+ :QPlatformWindow(window),
+ visibleFlag(false)
+{
+ static QAtomicInt winIdGenerator(1);
+ windowId = winIdGenerator.fetchAndAddRelaxed(1);
+}
+
+
+QFbWindow::~QFbWindow()
+{
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->removeWindow(this);
+ ++i;
+ }
+}
+
+
+QFbWindowSurface::QFbWindowSurface(QFbScreen *screen, QWidget *window)
+ : QWindowSurface(window),
+ mScreen(screen)
+{
+ mImage = QImage(window->size(), mScreen->format());
+
+ platformWindow = static_cast<QFbWindow*>(window->platformWindow());
+ platformWindow->surface = this;
+}
+
+QFbWindowSurface::~QFbWindowSurface()
+{
+}
+
+void QFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+
+
+// qDebug() << "QFbWindowSurface::flush" << region;
+
+
+ platformWindow->repaint(region);
+}
+
+
+void QFbWindow::repaint(const QRegion &region)
+{
+ QRect currentGeometry = geometry();
+
+ QRect dirtyClient = region.boundingRect();
+ QRect dirtyRegion(currentGeometry.left() + dirtyClient.left(),
+ currentGeometry.top() + dirtyClient.top(),
+ dirtyClient.width(),
+ dirtyClient.height());
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ QRect oldGeometryLocal = oldGeometry;
+ oldGeometry = currentGeometry;
+ while (i != end) {
+ // If this is a move, redraw the previous location
+ if (oldGeometryLocal != currentGeometry) {
+ (*i)->setDirty(oldGeometryLocal);
+ }
+ (*i)->setDirty(dirtyRegion);
+ ++i;
+ }
+}
+
+void QFbWindowSurface::resize(const QSize &size)
+{
+ // change the widget's QImage if this is a resize
+ if (mImage.size() != size)
+ mImage = QImage(size, mScreen->format());
+ QWindowSurface::resize(size);
+}
+
+void QFbWindow::setGeometry(const QRect &rect)
+{
+// store previous geometry for screen update
+ oldGeometry = geometry();
+
+
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->invalidateRectCache();
+ ++i;
+ }
+//### QWindowSystemInterface::handleGeometryChange(window(), rect);
+
+ QPlatformWindow::setGeometry(rect);
+}
+
+bool QFbWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ return QWindowSurface::scroll(area, dx, dy);
+}
+
+void QFbWindowSurface::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+void QFbWindowSurface::endPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+void QFbWindow::setVisible(bool visible)
+{
+ visibleFlag = visible;
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->invalidateRectCache();
+ (*i)->setDirty(geometry());
+ ++i;
+ }
+}
+
+Qt::WindowFlags QFbWindow::setWindowFlags(Qt::WindowFlags type)
+{
+ flags = type;
+ QList<QFbScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QFbScreen *>::const_iterator end = mScreens.constEnd();
+ while (i != end) {
+ (*i)->invalidateRectCache();
+ ++i;
+ }
+ return flags;
+}
+
+Qt::WindowFlags QFbWindow::windowFlags() const
+{
+ return flags;
+}
diff --git a/src/plugins/platforms/fb_base/fb_base.h b/src/plugins/platforms/fb_base/fb_base.h
new file mode 100644
index 0000000..c5ae378
--- /dev/null
+++ b/src/plugins/platforms/fb_base/fb_base.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H
+#define QLIGHTHOUSEGRAPHICSSCREEN_H
+
+#include <qrect.h>
+#include <qimage.h>
+#include <qtimer.h>
+#include <qpainter.h>
+#include <QPlatformCursor>
+#include <QPlatformScreen>
+#include <QPlatformWindow>
+#include <QtGui/private/qwindowsurface_p.h>
+
+class QMouseEvent;
+class QSize;
+class QPainter;
+
+class QFbScreen;
+
+class QPlatformSoftwareCursor : public QPlatformCursor
+{
+public:
+ QPlatformSoftwareCursor(QPlatformScreen * scr);
+
+ // output methods
+ QRect dirtyRect();
+ virtual QRect drawCursor(QPainter & painter);
+
+ // input methods
+ virtual void pointerEvent(const QMouseEvent & event);
+ virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);
+
+ virtual void setDirty() { dirty = true; screen->setDirty(QRect()); }
+ virtual bool isDirty() { return dirty; }
+ virtual bool isOnScreen() { return onScreen; }
+ virtual QRect lastPainted() { return prevRect; }
+
+protected:
+ QPlatformCursorImage * graphic;
+
+private:
+ void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
+ void setCursor(Qt::CursorShape shape);
+ void setCursor(const QImage &image, int hotx, int hoty);
+ QRect currentRect; // next place to draw the cursor
+ QRect prevRect; // last place the cursor was drawn
+ QRect getCurrentRect();
+ bool dirty;
+ bool onScreen;
+};
+
+class QFbWindow;
+
+class QFbWindowSurface : public QWindowSurface
+{
+public:
+ QFbWindowSurface(QFbScreen *screen, QWidget *window);
+ ~QFbWindowSurface();
+
+ virtual QPaintDevice *paintDevice() { return &mImage; }
+ virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ virtual bool scroll(const QRegion &area, int dx, int dy);
+
+ virtual void beginPaint(const QRegion &region);
+ virtual void endPaint(const QRegion &region);
+
+
+ const QImage image() { return mImage; }
+ void resize(const QSize &size);
+
+protected:
+ friend class QFbWindow;
+ QFbWindow *platformWindow;
+
+ QFbScreen *mScreen;
+ QImage mImage;
+};
+
+
+class QFbWindow : public QPlatformWindow
+{
+public:
+
+ QFbWindow(QWidget *window);
+ ~QFbWindow();
+
+
+ virtual void setVisible(bool visible);
+ virtual bool visible() { return visibleFlag; }
+
+ virtual void raise();
+ virtual void lower();
+
+ void setGeometry(const QRect &rect);
+
+ virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
+ virtual Qt::WindowFlags windowFlags() const;
+
+ WId winId() const { return windowId; }
+
+ virtual void repaint(const QRegion&);
+
+protected:
+ friend class QFbWindowSurface;
+ friend class QFbScreen;
+ QFbWindowSurface *surface;
+ QList<QFbScreen *> mScreens;
+ QRect oldGeometry;
+ bool visibleFlag;
+ Qt::WindowFlags flags;
+
+ WId windowId;
+};
+
+class QFbScreen : public QPlatformScreen
+{
+ Q_OBJECT
+public:
+ QFbScreen();
+ ~QFbScreen();
+
+ virtual QRect geometry() const { return mGeometry; }
+ virtual int depth() const { return mDepth; }
+ virtual QImage::Format format() const { return mFormat; }
+ virtual QSize physicalSize() const { return mPhysicalSize; }
+
+ virtual void setGeometry(QRect rect);
+ virtual void setDepth(int depth);
+ virtual void setFormat(QImage::Format format);
+ virtual void setPhysicalSize(QSize size);
+
+ virtual void setDirty(const QRect &rect);
+
+ virtual void removeWindow(QFbWindow * surface);
+ virtual void addWindow(QFbWindow * surface);
+ virtual void raise(QPlatformWindow * surface);
+ virtual void lower(QPlatformWindow * surface);
+ virtual QWidget * topLevelAt(const QPoint & p) const;
+
+ QImage * image() const { return mScreenImage; }
+ QPaintDevice * paintDevice() const { return mScreenImage; }
+
+protected:
+ QList<QFbWindow *> windowStack;
+ QRegion repaintRegion;
+ QPlatformSoftwareCursor * cursor;
+ QTimer redrawTimer;
+
+protected slots:
+ virtual QRegion doRedraw();
+
+protected:
+ QRect mGeometry;
+ int mDepth;
+ QImage::Format mFormat;
+ QSize mPhysicalSize;
+ QImage *mScreenImage;
+
+private:
+ QPainter * compositePainter;
+ void generateRects();
+ QList<QPair<QRect, int> > cachedRects;
+
+ void invalidateRectCache() { isUpToDate = false; }
+ friend class QFbWindowSurface;
+ friend class QFbWindow;
+ bool isUpToDate;
+};
+
+#endif // QLIGHTHOUSEGRAPHICSSCREEN_H
diff --git a/src/plugins/platforms/fb_base/fb_base.pri b/src/plugins/platforms/fb_base/fb_base.pri
new file mode 100644
index 0000000..41bd87f
--- /dev/null
+++ b/src/plugins/platforms/fb_base/fb_base.pri
@@ -0,0 +1,2 @@
+SOURCES += ../fb_base/fb_base.cpp
+HEADERS += ../fb_base/fb_base.h
diff --git a/src/plugins/platforms/fb_base/fb_base.pro b/src/plugins/platforms/fb_base/fb_base.pro
new file mode 100644
index 0000000..e08c0c5
--- /dev/null
+++ b/src/plugins/platforms/fb_base/fb_base.pro
@@ -0,0 +1,23 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2009-11-05T13:22:31
+#
+#-------------------------------------------------
+
+#QT -= core gui
+TARGET = fb_base
+#include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems
+
+TEMPLATE = lib
+
+#DEFINES += STATIC_LIBRARY
+CONFIG += staticlib
+
+SOURCES += fb_base.cpp
+
+HEADERS += fb_base.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
+INSTALLS += target
diff --git a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
new file mode 100644
index 0000000..da4698d
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
@@ -0,0 +1,86 @@
+DEFINES += QT_NO_FONTCONFIG
+HEADERS += \
+ $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h \
+ $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
+
+SOURCES += \
+ $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp \
+ $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/basicunix
+
+CONFIG += opentype
+
+contains(QT_CONFIG, freetype) {
+ SOURCES += \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbase.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbbox.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftdebug.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftglyph.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftinit.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftmm.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/fttype1.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsynth.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftbitmap.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/bdf/bdf.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cache/ftcache.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cff/cff.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/cid/type1cid.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/gzip/ftgzip.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pcf/pcf.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pfr/pfr.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psaux/psaux.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/pshinter/pshinter.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/psnames/psmodule.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/raster/raster.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/sfnt/sfnt.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/smooth/smooth.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/truetype/truetype.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type1/type1.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/type42/type42.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/winfonts/winfnt.c \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/lzw/ftlzw.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvalid.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvbase.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgdef.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvjstf.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvcommn.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgpos.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvgsub.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/otvalid/otvmod.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afangles.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afglobal.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/aflatin.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afmodule.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afdummy.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afhints.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/afloader.c\
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/autofit/autofit.c
+
+ symbian {
+ SOURCES += \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src/base/ftsystem.c
+ } else {
+ SOURCES += \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix/ftsystem.c
+ INCLUDEPATH += \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/builds/unix
+ }
+
+ INCLUDEPATH += \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/src \
+ $$QT_SOURCE_TREE/src/3rdparty/freetype/include
+
+ DEFINES += FT2_BUILD_LIBRARY
+ contains(QT_CONFIG, system-zlib) {
+ DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
+ }
+
+ } else:contains(QT_CONFIG, system-freetype) {
+ # pull in the proper freetype2 include directory
+ include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
+ LIBS_PRIVATE += -lfreetype
+ }
+
diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
new file mode 100644
index 0000000..895f8af
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbasicunixfontdatabase.h"
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/QPlatformScreen>
+
+#include <QtCore/QFile>
+#include <QtCore/QLibraryInfo>
+#include <QtCore/QDir>
+
+#undef QT_NO_FREETYPE
+#include <QtGui/private/qfontengine_ft_p.h>
+#include <QtGui/private/qfontengine_p.h>
+
+#include <ft2build.h>
+#include FT_TRUETYPE_TABLES_H
+
+#define SimplifiedChineseCsbBit 18
+#define TraditionalChineseCsbBit 20
+#define JapaneseCsbBit 17
+#define KoreanCsbBit 21
+
+static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = {
+ // Any,
+ { 127, 127 },
+ // Latin,
+ { 0, 127 },
+ // Greek,
+ { 7, 127 },
+ // Cyrillic,
+ { 9, 127 },
+ // Armenian,
+ { 10, 127 },
+ // Hebrew,
+ { 11, 127 },
+ // Arabic,
+ { 13, 127 },
+ // Syriac,
+ { 71, 127 },
+ //Thaana,
+ { 72, 127 },
+ //Devanagari,
+ { 15, 127 },
+ //Bengali,
+ { 16, 127 },
+ //Gurmukhi,
+ { 17, 127 },
+ //Gujarati,
+ { 18, 127 },
+ //Oriya,
+ { 19, 127 },
+ //Tamil,
+ { 20, 127 },
+ //Telugu,
+ { 21, 127 },
+ //Kannada,
+ { 22, 127 },
+ //Malayalam,
+ { 23, 127 },
+ //Sinhala,
+ { 73, 127 },
+ //Thai,
+ { 24, 127 },
+ //Lao,
+ { 25, 127 },
+ //Tibetan,
+ { 70, 127 },
+ //Myanmar,
+ { 74, 127 },
+ // Georgian,
+ { 26, 127 },
+ // Khmer,
+ { 80, 127 },
+ // SimplifiedChinese,
+ { 126, 127 },
+ // TraditionalChinese,
+ { 126, 127 },
+ // Japanese,
+ { 126, 127 },
+ // Korean,
+ { 56, 127 },
+ // Vietnamese,
+ { 0, 127 }, // same as latin1
+ // Other,
+ { 126, 127 },
+ // Ogham,
+ { 78, 127 },
+ // Runic,
+ { 79, 127 },
+ // Nko,
+ { 14, 127 },
+};
+
+static QSupportedWritingSystems determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2])
+{
+ QSupportedWritingSystems writingSystems;
+ bool hasScript = false;
+
+ int i;
+ for(i = 0; i < QFontDatabase::WritingSystemsCount; i++) {
+ int bit = requiredUnicodeBits[i][0];
+ int index = bit/32;
+ int flag = 1 << (bit&31);
+ if (bit != 126 && unicodeRange[index] & flag) {
+ bit = requiredUnicodeBits[i][1];
+ index = bit/32;
+
+ flag = 1 << (bit&31);
+ if (bit == 127 || unicodeRange[index] & flag) {
+ writingSystems.setSupported(QFontDatabase::WritingSystem(i));
+ hasScript = true;
+ // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i);
+ }
+ }
+ }
+ if(codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::SimplifiedChinese);
+ hasScript = true;
+ //qDebug("font %s supports Simplified Chinese", familyName.latin1());
+ }
+ if(codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::TraditionalChinese);
+ hasScript = true;
+ //qDebug("font %s supports Traditional Chinese", familyName.latin1());
+ }
+ if(codePageRange[0] & (1 << JapaneseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Japanese);
+ hasScript = true;
+ //qDebug("font %s supports Japanese", familyName.latin1());
+ }
+ if(codePageRange[0] & (1 << KoreanCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Korean);
+ hasScript = true;
+ //qDebug("font %s supports Korean", familyName.latin1());
+ }
+ if (!hasScript)
+ writingSystems.setSupported(QFontDatabase::Symbol);
+
+ return writingSystems;
+}
+
+static inline bool scriptRequiresOpenType(int script)
+{
+ return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
+ || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
+}
+
+void QBasicUnixFontDatabase::populateFontDatabase()
+{
+ QPlatformFontDatabase::populateFontDatabase();
+ QString fontpath = fontDir();
+
+ if(!QFile::exists(fontpath)) {
+ qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
+ qPrintable(fontpath));
+ }
+
+ QDir dir(fontpath);
+ dir.setNameFilters(QStringList() << QLatin1String("*.ttf")
+ << QLatin1String("*.ttc") << QLatin1String("*.pfa")
+ << QLatin1String("*.pfb"));
+ dir.refresh();
+ for (int i = 0; i < int(dir.count()); ++i) {
+ const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
+// qDebug() << "looking at" << file;
+ addTTFile(QByteArray(), file);
+ }
+}
+
+QFontEngine *QBasicUnixFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *usrPtr)
+{
+ QFontEngineFT *engine;
+ FontFile *fontfile = static_cast<FontFile *> (usrPtr);
+ QFontEngine::FaceId fid;
+ fid.filename = fontfile->fileName.toLocal8Bit();
+ fid.index = fontfile->indexValue;
+ engine = new QFontEngineFT(fontDef);
+
+ bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
+ QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
+ if (!engine->init(fid,antialias,format)) {
+ delete engine;
+ engine = 0;
+ return engine;
+ }
+ if (engine->invalid()) {
+ delete engine;
+ engine = 0;
+ } else if (scriptRequiresOpenType(script)) {
+ HB_Face hbFace = engine->harfbuzzFace();
+ if (!hbFace || !hbFace->supported_scripts[script]) {
+ delete engine;
+ engine = 0;
+ }
+ }
+
+ return engine;
+}
+
+QStringList QBasicUnixFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const
+{
+ Q_UNUSED(family);
+ Q_UNUSED(style);
+ Q_UNUSED(script);
+ return QStringList();
+}
+
+QStringList QBasicUnixFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
+{
+ return addTTFile(fontData,fileName.toLocal8Bit());
+}
+
+void QBasicUnixFontDatabase::releaseHandle(void *handle)
+{
+ FontFile *file = static_cast<FontFile *>(handle);
+ delete file;
+}
+
+QStringList QBasicUnixFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file)
+{
+ extern FT_Library qt_getFreetype();
+ FT_Library library = qt_getFreetype();
+
+ int index = 0;
+ int numFaces = 0;
+ QStringList families;
+ do {
+ FT_Face face;
+ FT_Error error;
+ if (!fontData.isEmpty()) {
+ error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
+ } else {
+ error = FT_New_Face(library, file.constData(), index, &face);
+ }
+ if (error != FT_Err_Ok) {
+ qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
+ break;
+ }
+ numFaces = face->num_faces;
+
+ QFont::Weight weight = QFont::Normal;
+
+ QFont::Style style = QFont::StyleNormal;
+ if (face->style_flags & FT_STYLE_FLAG_ITALIC)
+ style = QFont::StyleItalic;
+
+ if (face->style_flags & FT_STYLE_FLAG_BOLD)
+ weight = QFont::Bold;
+
+ QSupportedWritingSystems writingSystems;
+ // detect symbol fonts
+ for (int i = 0; i < face->num_charmaps; ++i) {
+ FT_CharMap cm = face->charmaps[i];
+ if (cm->encoding == ft_encoding_adobe_custom
+ || cm->encoding == ft_encoding_symbol) {
+ writingSystems.setSupported(QFontDatabase::Symbol);
+ break;
+ }
+ }
+
+ TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+ if (os2) {
+ quint32 unicodeRange[4] = {
+ os2->ulUnicodeRange1, os2->ulUnicodeRange2, os2->ulUnicodeRange3, os2->ulUnicodeRange4
+ };
+ quint32 codePageRange[2] = {
+ os2->ulCodePageRange1, os2->ulCodePageRange2
+ };
+
+ writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
+ }
+
+ QString family = QString::fromAscii(face->family_name);
+ FontFile *fontFile = new FontFile;
+ fontFile->fileName = file;
+ fontFile->indexValue = index;
+
+ QFont::Stretch stretch = QFont::Unstretched;
+
+ registerFont(family,"",weight,style,stretch,true,true,0,writingSystems,fontFile);
+
+ families.append(family);
+
+ FT_Done_Face(face);
+ ++index;
+ } while (index < numFaces);
+ return families;
+}
diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h
new file mode 100644
index 0000000..f04d453
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBASICUNIXFONTDATABASE_H
+#define QBASICUNIXFONTDATABASE_H
+
+#include <QPlatformFontDatabase>
+#include <QtCore/QByteArray>
+#include <QtCore/QString>
+
+struct FontFile
+{
+ QString fileName;
+ int indexValue;
+};
+
+class QBasicUnixFontDatabase : public QPlatformFontDatabase
+{
+public:
+ void populateFontDatabase();
+ QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
+ QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const;
+ QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
+ void releaseHandle(void *handle);
+
+ static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file);
+};
+
+#endif // QBASICUNIXFONTDATABASE_H
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri b/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri
new file mode 100644
index 0000000..19c74ed
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/fontconfig/fontconfig.pri
@@ -0,0 +1,12 @@
+include(../basicunix/basicunix.pri)
+
+HEADERS += \
+ $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
+
+SOURCES += \
+ $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/fontconfig
+LIBS_PRIVATE += -lfontconfig
+
+
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
new file mode 100644
index 0000000..2a3fd5a
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -0,0 +1,601 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfontconfigdatabase.h"
+
+#include <QtCore/QList>
+#include <QtGui/private/qfont_p.h>
+
+#include <QtCore/QElapsedTimer>
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtGui/QPlatformScreen>
+
+#include <QtGui/private/qfontengine_ft_p.h>
+#include <QtGui/private/qfontengine_p.h>
+
+
+
+#include <ft2build.h>
+#include FT_TRUETYPE_TABLES_H
+
+#include <fontconfig/fontconfig.h>
+
+#define SimplifiedChineseCsbBit 18
+#define TraditionalChineseCsbBit 20
+#define JapaneseCsbBit 17
+#define KoreanCsbBit 21
+
+static inline bool requiresOpenType(int writingSystem)
+{
+ return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala)
+ || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko);
+}
+static inline bool scriptRequiresOpenType(int script)
+{
+ return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala)
+ || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko);
+}
+
+static int getFCWeight(int fc_weight)
+{
+ int qtweight = QFont::Black;
+ if (fc_weight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2)
+ qtweight = QFont::Light;
+ else if (fc_weight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2)
+ qtweight = QFont::Normal;
+ else if (fc_weight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2)
+ qtweight = QFont::DemiBold;
+ else if (fc_weight <= (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2)
+ qtweight = QFont::Bold;
+
+ return qtweight;
+}
+
+static const char *specialLanguages[] = {
+ "en", // Common
+ "el", // Greek
+ "ru", // Cyrillic
+ "hy", // Armenian
+ "he", // Hebrew
+ "ar", // Arabic
+ "syr", // Syriac
+ "div", // Thaana
+ "hi", // Devanagari
+ "bn", // Bengali
+ "pa", // Gurmukhi
+ "gu", // Gujarati
+ "or", // Oriya
+ "ta", // Tamil
+ "te", // Telugu
+ "kn", // Kannada
+ "ml", // Malayalam
+ "si", // Sinhala
+ "th", // Thai
+ "lo", // Lao
+ "bo", // Tibetan
+ "my", // Myanmar
+ "ka", // Georgian
+ "ko", // Hangul
+ "", // Ogham
+ "", // Runic
+ "km", // Khmer
+ "" // N'Ko
+};
+enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) };
+
+static const ushort specialChars[] = {
+ 0, // English
+ 0, // Greek
+ 0, // Cyrillic
+ 0, // Armenian
+ 0, // Hebrew
+ 0, // Arabic
+ 0, // Syriac
+ 0, // Thaana
+ 0, // Devanagari
+ 0, // Bengali
+ 0, // Gurmukhi
+ 0, // Gujarati
+ 0, // Oriya
+ 0, // Tamil
+ 0xc15, // Telugu
+ 0xc95, // Kannada
+ 0xd15, // Malayalam
+ 0xd9a, // Sinhala
+ 0, // Thai
+ 0, // Lao
+ 0, // Tibetan
+ 0x1000, // Myanmar
+ 0, // Georgian
+ 0, // Hangul
+ 0x1681, // Ogham
+ 0x16a0, // Runic
+ 0, // Khmer
+ 0x7ca // N'Ko
+};
+enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) };
+
+// this could become a list of all languages used for each writing
+// system, instead of using the single most common language.
+static const char *languageForWritingSystem[] = {
+ 0, // Any
+ "en", // Latin
+ "el", // Greek
+ "ru", // Cyrillic
+ "hy", // Armenian
+ "he", // Hebrew
+ "ar", // Arabic
+ "syr", // Syriac
+ "div", // Thaana
+ "hi", // Devanagari
+ "bn", // Bengali
+ "pa", // Gurmukhi
+ "gu", // Gujarati
+ "or", // Oriya
+ "ta", // Tamil
+ "te", // Telugu
+ "kn", // Kannada
+ "ml", // Malayalam
+ "si", // Sinhala
+ "th", // Thai
+ "lo", // Lao
+ "bo", // Tibetan
+ "my", // Myanmar
+ "ka", // Georgian
+ "km", // Khmer
+ "zh-cn", // SimplifiedChinese
+ "zh-tw", // TraditionalChinese
+ "ja", // Japanese
+ "ko", // Korean
+ "vi", // Vietnamese
+ 0, // Symbol
+ 0, // Ogham
+ 0, // Runic
+ 0 // N'Ko
+};
+enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
+
+// Unfortunately FontConfig doesn't know about some languages. We have to test these through the
+// charset. The lists below contain the systems where we need to do this.
+static const ushort sampleCharForWritingSystem[] = {
+ 0, // Any
+ 0, // Latin
+ 0, // Greek
+ 0, // Cyrillic
+ 0, // Armenian
+ 0, // Hebrew
+ 0, // Arabic
+ 0, // Syriac
+ 0, // Thaana
+ 0, // Devanagari
+ 0, // Bengali
+ 0, // Gurmukhi
+ 0, // Gujarati
+ 0, // Oriya
+ 0, // Tamil
+ 0xc15, // Telugu
+ 0xc95, // Kannada
+ 0xd15, // Malayalam
+ 0xd9a, // Sinhala
+ 0, // Thai
+ 0, // Lao
+ 0, // Tibetan
+ 0x1000, // Myanmar
+ 0, // Georgian
+ 0, // Khmer
+ 0, // SimplifiedChinese
+ 0, // TraditionalChinese
+ 0, // Japanese
+ 0, // Korean
+ 0, // Vietnamese
+ 0, // Symbol
+ 0x1681, // Ogham
+ 0x16a0, // Runic
+ 0x7ca // N'Ko
+};
+enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) };
+
+// Newer FontConfig let's us sort out fonts that contain certain glyphs, but no
+// open type tables for is directly. Do this so we don't pick some strange
+// pseudo unicode font
+static const char *openType[] = {
+ 0, // Any
+ 0, // Latin
+ 0, // Greek
+ 0, // Cyrillic
+ 0, // Armenian
+ 0, // Hebrew
+ 0, // Arabic
+ "syrc", // Syriac
+ "thaa", // Thaana
+ "deva", // Devanagari
+ "beng", // Bengali
+ "guru", // Gurmukhi
+ "gurj", // Gujarati
+ "orya", // Oriya
+ "taml", // Tamil
+ "telu", // Telugu
+ "knda", // Kannada
+ "mlym", // Malayalam
+ "sinh", // Sinhala
+ 0, // Thai
+ 0, // Lao
+ "tibt", // Tibetan
+ "mymr", // Myanmar
+ 0, // Georgian
+ "khmr", // Khmer
+ 0, // SimplifiedChinese
+ 0, // TraditionalChinese
+ 0, // Japanese
+ 0, // Korean
+ 0, // Vietnamese
+ 0, // Symbol
+ 0, // Ogham
+ 0, // Runic
+ "nko " // N'Ko
+};
+
+static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
+{
+ const char *stylehint = 0;
+ switch (style) {
+ case QFont::SansSerif:
+ stylehint = "sans-serif";
+ break;
+ case QFont::Serif:
+ stylehint = "serif";
+ break;
+ case QFont::TypeWriter:
+ stylehint = "monospace";
+ break;
+ default:
+ break;
+ }
+ return stylehint;
+}
+
+void QFontconfigDatabase::populateFontDatabase()
+{
+ FcFontSet *fonts;
+
+ QString familyName;
+ FcChar8 *value = 0;
+ int weight_value;
+ int slant_value;
+ int spacing_value;
+ FcChar8 *file_value;
+ int indexValue;
+ FcChar8 *foundry_value;
+ FcBool scalable;
+ FcBool antialias;
+
+ {
+ FcObjectSet *os = FcObjectSetCreate();
+ FcPattern *pattern = FcPatternCreate();
+ const char *properties [] = {
+ FC_FAMILY, FC_WEIGHT, FC_SLANT,
+ FC_SPACING, FC_FILE, FC_INDEX,
+ FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
+ FC_WIDTH,
+#if FC_VERSION >= 20297
+ FC_CAPABILITY,
+#endif
+ (const char *)0
+ };
+ const char **p = properties;
+ while (*p) {
+ FcObjectSetAdd(os, *p);
+ ++p;
+ }
+ fonts = FcFontList(0, pattern, os);
+ FcObjectSetDestroy(os);
+ FcPatternDestroy(pattern);
+ }
+
+ for (int i = 0; i < fonts->nfont; i++) {
+ if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
+ continue;
+ // capitalize(value);
+ familyName = QString::fromUtf8((const char *)value);
+ slant_value = FC_SLANT_ROMAN;
+ weight_value = FC_WEIGHT_MEDIUM;
+ spacing_value = FC_PROPORTIONAL;
+ file_value = 0;
+ indexValue = 0;
+ scalable = FcTrue;
+
+
+ if (FcPatternGetInteger (fonts->fonts[i], FC_SLANT, 0, &slant_value) != FcResultMatch)
+ slant_value = FC_SLANT_ROMAN;
+ if (FcPatternGetInteger (fonts->fonts[i], FC_WEIGHT, 0, &weight_value) != FcResultMatch)
+ weight_value = FC_WEIGHT_MEDIUM;
+ if (FcPatternGetInteger (fonts->fonts[i], FC_SPACING, 0, &spacing_value) != FcResultMatch)
+ spacing_value = FC_PROPORTIONAL;
+ if (FcPatternGetString (fonts->fonts[i], FC_FILE, 0, &file_value) != FcResultMatch)
+ file_value = 0;
+ if (FcPatternGetInteger (fonts->fonts[i], FC_INDEX, 0, &indexValue) != FcResultMatch)
+ indexValue = 0;
+ if (FcPatternGetBool(fonts->fonts[i], FC_SCALABLE, 0, &scalable) != FcResultMatch)
+ scalable = FcTrue;
+ if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch)
+ foundry_value = 0;
+ if(FcPatternGetBool(fonts->fonts[i],FC_ANTIALIAS,0,&antialias) != FcResultMatch)
+ antialias = true;
+
+ QSupportedWritingSystems writingSystems;
+ FcLangSet *langset = 0;
+ FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset);
+ if (res == FcResultMatch) {
+ for (int i = 1; i < LanguageCount; ++i) {
+ const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[i];
+ if (lang) {
+ FcLangResult langRes = FcLangSetHasLang(langset, lang);
+ if (langRes != FcLangDifferentLang)
+ writingSystems.setSupported(QFontDatabase::WritingSystem(i));
+ }
+ }
+ } else {
+ // we set Other to supported for symbol fonts. It makes no
+ // sense to merge these with other ones, as they are
+ // special in a way.
+ writingSystems.setSupported(QFontDatabase::Other);
+ }
+
+ FcCharSet *cs = 0;
+ res = FcPatternGetCharSet(fonts->fonts[i], FC_CHARSET, 0, &cs);
+ if (res == FcResultMatch) {
+ // some languages are not supported by FontConfig, we rather check the
+ // charset to detect these
+ for (int i = 1; i < SampleCharCount; ++i) {
+ if (!sampleCharForWritingSystem[i])
+ continue;
+ if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i]))
+ writingSystems.setSupported(QFontDatabase::WritingSystem(i));
+ }
+ }
+
+#if FC_VERSION >= 20297
+ for (int j = 1; j < LanguageCount; ++j) {
+ if (writingSystems.supported(QFontDatabase::WritingSystem(j))
+ && requiresOpenType(j) && openType[j]) {
+ FcChar8 *cap;
+ res = FcPatternGetString (fonts->fonts[i], FC_CAPABILITY, 0, &cap);
+ if (res != FcResultMatch || !strstr((const char *)cap, openType[j]))
+ writingSystems.setSupported(QFontDatabase::WritingSystem(j),false);
+ }
+ }
+#endif
+
+ FontFile *fontFile = new FontFile;
+ fontFile->fileName = QLatin1String((const char *)file_value);
+ fontFile->indexValue = indexValue;
+
+ QFont::Style style = (slant_value == FC_SLANT_ITALIC)
+ ? QFont::StyleItalic
+ : ((slant_value == FC_SLANT_OBLIQUE)
+ ? QFont::StyleOblique
+ : QFont::StyleNormal);
+ QFont::Weight weight = QFont::Weight(getFCWeight(weight_value));
+
+ double pixel_size = 0;
+ if (!scalable) {
+ int width = 100;
+ FcPatternGetInteger (fonts->fonts[i], FC_WIDTH, 0, &width);
+ FcPatternGetDouble (fonts->fonts[i], FC_PIXEL_SIZE, 0, &pixel_size);
+ }
+
+ QFont::Stretch stretch = QFont::Unstretched;
+ QPlatformFontDatabase::registerFont(familyName,QLatin1String((const char *)foundry_value),weight,style,stretch,antialias,scalable,pixel_size,writingSystems,fontFile);
+// qDebug() << familyName << (const char *)foundry_value << weight << style << &writingSystems << scalable << true << pixel_size;
+ }
+
+ FcFontSetDestroy (fonts);
+
+ struct FcDefaultFont {
+ const char *qtname;
+ const char *rawname;
+ bool fixed;
+ };
+ const FcDefaultFont defaults[] = {
+ { "Serif", "serif", false },
+ { "Sans Serif", "sans-serif", false },
+ { "Monospace", "monospace", true },
+ { 0, 0, false }
+ };
+ const FcDefaultFont *f = defaults;
+ // aliases only make sense for 'common', not for any of the specials
+ QSupportedWritingSystems ws;
+ ws.setSupported(QFontDatabase::Latin);
+
+
+ while (f->qtname) {
+ registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,ws,0);
+ registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,ws,0);
+ registerFont(f->qtname,QLatin1String(""),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,ws,0);
+ ++f;
+ }
+
+ //Lighthouse has very lazy population of the font db. We want it to be initialized when
+ //QApplication is constructed, so that the population procedure can do something like this to
+ //set the default font
+// const FcDefaultFont *s = defaults;
+// QFont font("Sans Serif");
+// font.setPointSize(9);
+// QApplication::setFont(font);
+}
+
+QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr)
+{
+ if (!usrPtr)
+ return 0;
+ QFontDef fontDef = f;
+
+ QFontEngineFT *engine;
+ FontFile *fontfile = static_cast<FontFile *> (usrPtr);
+ QFontEngine::FaceId fid;
+ fid.filename = fontfile->fileName.toLocal8Bit();
+ fid.index = fontfile->indexValue;
+
+ //try and get the pattern
+ FcPattern *pattern = FcPatternCreate();
+
+ bool antialias = !(fontDef.styleStrategy & QFont::NoAntialias);
+ QFontEngineFT::GlyphFormat format = antialias? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono;
+
+ engine = new QFontEngineFT(fontDef);
+
+ FcValue value;
+ value.type = FcTypeString;
+ QByteArray cs = fontDef.family.toUtf8();
+ value.u.s = (const FcChar8 *)cs.data();
+ FcPatternAdd(pattern,FC_FAMILY,value,true);
+
+
+ value.u.s = (const FcChar8 *)fid.filename.data();
+ FcPatternAdd(pattern,FC_FILE,value,true);
+
+ value.type = FcTypeInteger;
+ value.u.i = fid.index;
+ FcPatternAdd(pattern,FC_INDEX,value,true);
+
+ QFontEngineFT::HintStyle default_hint_style;
+
+ if (FcConfigSubstitute(0,pattern,FcMatchPattern)) {
+
+ //hinting
+ int hint_style = 0;
+ if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch)
+ hint_style = QFontEngineFT::HintFull;
+ switch (hint_style) {
+ case FC_HINT_NONE:
+ default_hint_style = QFontEngineFT::HintNone;
+ break;
+ case FC_HINT_SLIGHT:
+ default_hint_style = QFontEngineFT::HintLight;
+ break;
+ case FC_HINT_MEDIUM:
+ default_hint_style = QFontEngineFT::HintMedium;
+ break;
+ default:
+ default_hint_style = QFontEngineFT::HintFull;
+ break;
+ }
+ }
+
+ engine->setDefaultHintStyle(default_hint_style);
+ if (!engine->init(fid,antialias,format)) {
+ delete engine;
+ engine = 0;
+ return engine;
+ }
+ if (engine->invalid()) {
+ delete engine;
+ engine = 0;
+ } else if (scriptRequiresOpenType(script)) {
+ HB_Face hbFace = engine->harfbuzzFace();
+ if (!hbFace || !hbFace->supported_scripts[script]) {
+ delete engine;
+ engine = 0;
+ }
+ }
+
+ return engine;
+}
+
+QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
+{
+ QStringList fallbackFamilies;
+ FcPattern *pattern = FcPatternCreate();
+ if (!pattern)
+ return fallbackFamilies;
+
+ FcValue value;
+ value.type = FcTypeString;
+ QByteArray cs = family.toUtf8();
+ value.u.s = (const FcChar8 *)cs.data();
+ FcPatternAdd(pattern,FC_FAMILY,value,true);
+
+ int slant_value = FC_SLANT_ROMAN;
+ if (style == QFont::StyleItalic)
+ slant_value = FC_SLANT_ITALIC;
+ else if (style == QFont::StyleOblique)
+ slant_value = FC_SLANT_OBLIQUE;
+ FcPatternAddInteger(pattern, FC_SLANT, slant_value);
+
+ if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') {
+ Q_ASSERT(script < QUnicodeTables::ScriptCount);
+ FcLangSet *ls = FcLangSetCreate();
+ FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]);
+ FcPatternAddLangSet(pattern, FC_LANG, ls);
+ FcLangSetDestroy(ls);
+ }
+
+ const char *stylehint = getFcFamilyForStyleHint(styleHint);
+ if (stylehint) {
+ value.u.s = (const FcChar8 *)stylehint;
+ FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
+ }
+
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcConfigSubstitute(0, pattern, FcMatchFont);
+
+ FcResult result = FcResultMatch;
+ FcFontSet *fontSet = FcFontSort(0,pattern,FcFalse,0,&result);
+
+ if (fontSet && result == FcResultMatch)
+ {
+ for (int i = 0; i < fontSet->nfont; i++) {
+ FcChar8 *value = 0;
+ if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch)
+ continue;
+ // capitalize(value);
+ QString familyName = QString::fromUtf8((const char *)value);
+ if (!fallbackFamilies.contains(familyName,Qt::CaseInsensitive)) {
+ fallbackFamilies << familyName;
+ }
+
+ }
+ }
+// qDebug() << "fallbackFamilies for:" << family << fallbackFamilies;
+
+ return fallbackFamilies;
+}
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
new file mode 100644
index 0000000..ee441f7
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFONTCONFIGDATABASE_H
+#define QFONTCONFIGDATABASE_H
+
+#include <QPlatformFontDatabase>
+#include "qbasicunixfontdatabase.h"
+
+class QFontconfigDatabase : public QBasicUnixFontDatabase
+{
+public:
+ void populateFontDatabase();
+ QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
+ QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
+};
+
+#endif // QFONTCONFIGDATABASE_H
diff --git a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri
new file mode 100644
index 0000000..dbcfbce
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri
@@ -0,0 +1,10 @@
+contains(QT_CONFIG, fontconfig) {
+ include(../fontconfig/fontconfig.pri)
+ DEFINES += Q_FONTCONFIGDATABASE
+} else {
+ include(../basicunix/basicunix.pri)
+}
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix
+HEADERS += \
+ $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h
diff --git a/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h
new file mode 100644
index 0000000..bfe014a
--- /dev/null
+++ b/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGENERICUNIXFONTDATABASE_H
+#define QGENERICUNIXFONTDATABASE_H
+
+#ifdef Q_FONTCONFIGDATABASE
+#include "qfontconfigdatabase.h"
+typedef QFontconfigDatabase QGenericUnixFontDatabase;
+#else
+#include "qbasicunixfontdatabase.h"
+typedef QBasicUnixFontDatabase QGenericUnixFontDatabase;
+#endif //Q_FONTCONFIGDATABASE
+
+#endif // QGENERICUNIXFONTDATABASE_H
diff --git a/src/plugins/platforms/linuxfb/linuxfb.pro b/src/plugins/platforms/linuxfb/linuxfb.pro
new file mode 100644
index 0000000..216b899
--- /dev/null
+++ b/src/plugins/platforms/linuxfb/linuxfb.pro
@@ -0,0 +1,13 @@
+TARGET = qlinuxfbgraphicssystem
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = main.cpp qlinuxfbintegration.cpp
+HEADERS = qlinuxfbintegration.h
+
+include(../fb_base/fb_base.pri)
+include(../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp
new file mode 100644
index 0000000..fb14ef4
--- /dev/null
+++ b/src/plugins/platforms/linuxfb/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPlatformIntegrationPlugin>
+#include "qlinuxfbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QLinuxFbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QLinuxFbIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "LinuxFb";
+ return list;
+}
+
+QPlatformIntegration* QLinuxFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "linuxfb")
+ return new QLinuxFbIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(linuxfb, QLinuxFbIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
new file mode 100644
index 0000000..a088a31
--- /dev/null
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -0,0 +1,875 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlinuxfbintegration.h"
+#include "../fb_base/fb_base.h"
+#include "qgenericunixfontdatabase.h"
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+#include <qimage.h>
+#include <qdebug.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/kd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <limits.h>
+#include <signal.h>
+
+#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD)
+#include <linux/fb.h>
+
+#ifdef __i386__
+#include <asm/mtrr.h>
+#endif
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QLinuxFbIntegrationPrivate
+{
+public:
+ QLinuxFbIntegrationPrivate();
+ ~QLinuxFbIntegrationPrivate();
+
+ void openTty();
+ void closeTty();
+
+ int fd;
+ int startupw;
+ int startuph;
+ int startupd;
+ bool blank;
+
+ bool doGraphicsMode;
+#ifdef QT_QWS_DEPTH_GENERIC
+ bool doGenericColors;
+#endif
+ int ttyfd;
+ long oldKdMode;
+ QString ttyDevice;
+ QString displaySpec;
+};
+
+QLinuxFbIntegrationPrivate::QLinuxFbIntegrationPrivate()
+ : fd(-1), blank(true), doGraphicsMode(true),
+#ifdef QT_QWS_DEPTH_GENERIC
+ doGenericColors(false),
+#endif
+ ttyfd(-1), oldKdMode(KD_TEXT)
+{
+}
+
+QLinuxFbIntegrationPrivate::~QLinuxFbIntegrationPrivate()
+{
+ closeTty();
+}
+
+void QLinuxFbIntegrationPrivate::openTty()
+{
+ const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0};
+
+ if (ttyDevice.isEmpty()) {
+ for (const char * const *dev = devs; *dev; ++dev) {
+ ttyfd = QT_OPEN(*dev, O_RDWR);
+ if (ttyfd != -1)
+ break;
+ }
+ } else {
+ ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR);
+ }
+
+ if (ttyfd == -1)
+ return;
+
+ if (doGraphicsMode) {
+ ioctl(ttyfd, KDGETMODE, &oldKdMode);
+ if (oldKdMode != KD_GRAPHICS) {
+ int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS);
+ if (ret == -1)
+ doGraphicsMode = false;
+ }
+ }
+
+ // No blankin' screen, no blinkin' cursor!, no cursor!
+ const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
+}
+
+void QLinuxFbIntegrationPrivate::closeTty()
+{
+ if (ttyfd == -1)
+ return;
+
+ if (doGraphicsMode)
+ ioctl(ttyfd, KDSETMODE, oldKdMode);
+
+ // Blankin' screen, blinkin' cursor!
+ const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
+
+ QT_CLOSE(ttyfd);
+ ttyfd = -1;
+}
+
+QLinuxFbIntegration::QLinuxFbIntegration()
+ :fontDb(new QGenericUnixFontDatabase())
+{
+ d_ptr = new QLinuxFbIntegrationPrivate();
+
+ // XXX
+ QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY"));
+
+ if (!connect(displaySpec))
+ qFatal("QLinuxFbIntegration: could not initialize screen");
+ initDevice();
+
+ // Create a QImage directly on the screen's framebuffer.
+ // This is the blit target for copying windows to the screen.
+ mPrimaryScreen = new QLinuxFbScreen(data, w, h, lstep,
+ screenFormat);
+ mPrimaryScreen->setPhysicalSize(QSize(physWidth, physHeight));
+ mScreens.append(mPrimaryScreen);
+}
+
+QLinuxFbIntegration::~QLinuxFbIntegration()
+{
+ delete mPrimaryScreen;
+ delete d_ptr;
+}
+
+bool QLinuxFbIntegration::connect(const QString &displaySpec)
+{
+ const QStringList args = displaySpec.split(QLatin1Char(':'));
+
+ if (args.contains(QLatin1String("nographicsmodeswitch")))
+ d_ptr->doGraphicsMode = false;
+
+#ifdef QT_QWS_DEPTH_GENERIC
+ if (args.contains(QLatin1String("genericcolors")))
+ d_ptr->doGenericColors = true;
+#endif
+
+ QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
+ if (args.indexOf(ttyRegExp) != -1)
+ d_ptr->ttyDevice = ttyRegExp.cap(1);
+
+#if 0
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
+ if (args.contains(QLatin1String("littleendian")))
+#endif
+ QScreen::setFrameBufferLittleEndian(true);
+#endif
+#endif
+
+ // Check for explicitly specified device
+ const int len = 8; // "/dev/fbx"
+ int m = displaySpec.indexOf(QLatin1String("/dev/fb"));
+
+ QString dev;
+ if (m > 0)
+ dev = displaySpec.mid(m, len);
+ else
+ dev = QLatin1String("/dev/fb0");
+
+ if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR);
+ if (d_ptr->fd == -1) {
+ if (access(dev.toLatin1().constData(), R_OK) == 0)
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY);
+ if (d_ptr->fd == 1) {
+ qWarning("Error opening framebuffer device %s", qPrintable(dev));
+ return false;
+ }
+ }
+
+ fb_fix_screeninfo finfo;
+ fb_var_screeninfo vinfo;
+ //#######################
+ // Shut up Valgrind
+ memset(&vinfo, 0, sizeof(vinfo));
+ memset(&finfo, 0, sizeof(finfo));
+ //#######################
+
+ /* Get fixed screen information */
+ if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
+ perror("QLinuxFbIntegration::connect");
+ qWarning("Error reading fixed information");
+ return false;
+ }
+
+ if (finfo.type == FB_TYPE_VGA_PLANES) {
+ qWarning("VGA16 video mode not supported");
+ return false;
+ }
+
+ /* Get variable screen information */
+ if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
+ perror("QLinuxFbIntegration::connect");
+ qWarning("Error reading variable information");
+ return false;
+ }
+
+ grayscale = vinfo.grayscale;
+ d = vinfo.bits_per_pixel;
+ if (d == 24) {
+ d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
+ if (d <= 0)
+ d = 24; // reset if color component lengths are not reported
+ } else if (d == 16) {
+ d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
+ if (d <= 0)
+ d = 16;
+ }
+ lstep = finfo.line_length;
+
+ int xoff = vinfo.xoffset;
+ int yoff = vinfo.yoffset;
+ const char* qwssize;
+ if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) {
+ if (d_ptr->fd != -1) {
+ if ((uint)w > vinfo.xres) w = vinfo.xres;
+ if ((uint)h > vinfo.yres) h = vinfo.yres;
+ }
+ dw=w;
+ dh=h;
+ int xxoff, yyoff;
+ if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) {
+ if (xxoff < 0 || xxoff + w > (int)(vinfo.xres))
+ xxoff = vinfo.xres - w;
+ if (yyoff < 0 || yyoff + h > (int)(vinfo.yres))
+ yyoff = vinfo.yres - h;
+ xoff += xxoff;
+ yoff += yyoff;
+ } else {
+ xoff += (vinfo.xres - w)/2;
+ yoff += (vinfo.yres - h)/2;
+ }
+ } else {
+ dw=w=vinfo.xres;
+ dh=h=vinfo.yres;
+ }
+
+ if (w == 0 || h == 0) {
+ qWarning("QLinuxFbIntegration::connect(): Unable to find screen geometry, "
+ "will use 320x240.");
+ dw = w = 320;
+ dh = h = 240;
+ }
+
+ setPixelFormat(vinfo);
+
+ // Handle display physical size spec.
+ QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
+ QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
+ int dimIdxW = displayArgs.indexOf(mmWidthRx);
+ QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
+ int dimIdxH = displayArgs.indexOf(mmHeightRx);
+ if (dimIdxW >= 0) {
+ mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
+ physWidth = mmWidthRx.cap(1).toInt();
+ if (dimIdxH < 0)
+ physHeight = dh*physWidth/dw;
+ }
+ if (dimIdxH >= 0) {
+ mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
+ physHeight = mmHeightRx.cap(1).toInt();
+ if (dimIdxW < 0)
+ physWidth = dw*physHeight/dh;
+ }
+ if (dimIdxW < 0 && dimIdxH < 0) {
+ if (vinfo.width != 0 && vinfo.height != 0
+ && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) {
+ physWidth = vinfo.width;
+ physHeight = vinfo.height;
+ } else {
+ const int dpi = 72;
+ physWidth = qRound(dw * 25.4 / dpi);
+ physHeight = qRound(dh * 25.4 / dpi);
+ }
+ }
+
+ dataoffset = yoff * lstep + xoff * d / 8;
+ //qDebug("Using %dx%dx%d screen",w,h,d);
+
+ /* Figure out the size of the screen in bytes */
+ size = h * lstep;
+
+ mapsize = finfo.smem_len;
+
+ data = (unsigned char *)-1;
+ if (d_ptr->fd != -1)
+ data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, d_ptr->fd, 0);
+
+ if ((long)data == -1) {
+ perror("QLinuxFbIntegration::connect");
+ qWarning("Error: failed to map framebuffer device to memory.");
+ return false;
+ } else {
+ data += dataoffset;
+ }
+
+#if 0
+ canaccel = useOffscreen();
+ if(canaccel)
+ setupOffScreen();
+#endif
+ canaccel = false;
+
+ // Now read in palette
+ if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
+ screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
+ int loopc;
+ fb_cmap startcmap;
+ startcmap.start=0;
+ startcmap.len=screencols;
+ startcmap.red=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ startcmap.green=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ startcmap.blue=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ startcmap.transp=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) {
+ perror("QLinuxFbIntegration::connect");
+ qWarning("Error reading palette from framebuffer, using default palette");
+ createPalette(startcmap, vinfo, finfo);
+ }
+ int bits_used = 0;
+ for(loopc=0;loopc<screencols;loopc++) {
+ screenclut[loopc]=qRgb(startcmap.red[loopc] >> 8,
+ startcmap.green[loopc] >> 8,
+ startcmap.blue[loopc] >> 8);
+ bits_used |= startcmap.red[loopc]
+ | startcmap.green[loopc]
+ | startcmap.blue[loopc];
+ }
+ // WORKAROUND: Some framebuffer drivers only return 8 bit
+ // color values, so we need to not bit shift them..
+ if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) {
+ for(loopc=0;loopc<screencols;loopc++) {
+ screenclut[loopc] = qRgb(startcmap.red[loopc],
+ startcmap.green[loopc],
+ startcmap.blue[loopc]);
+ }
+ qWarning("8 bits cmap returned due to faulty FB driver, colors corrected");
+ }
+ free(startcmap.red);
+ free(startcmap.green);
+ free(startcmap.blue);
+ free(startcmap.transp);
+ } else {
+ screencols=0;
+ }
+
+ return true;
+}
+
+bool QLinuxFbIntegration::initDevice()
+{
+ d_ptr->openTty();
+
+ // Grab current mode so we can reset it
+ fb_var_screeninfo vinfo;
+ fb_fix_screeninfo finfo;
+ //#######################
+ // Shut up Valgrind
+ memset(&vinfo, 0, sizeof(vinfo));
+ memset(&finfo, 0, sizeof(finfo));
+ //#######################
+
+ if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
+ perror("QLinuxFbScreen::initDevice");
+ qFatal("Error reading variable information in card init");
+ return false;
+ }
+
+#ifdef DEBUG_VINFO
+ qDebug("Greyscale %d",vinfo.grayscale);
+ qDebug("Nonstd %d",vinfo.nonstd);
+ qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length,
+ vinfo.red.msb_right);
+ qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length,
+ vinfo.green.msb_right);
+ qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length,
+ vinfo.blue.msb_right);
+ qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length,
+ vinfo.transp.msb_right);
+#endif
+
+ d_ptr->startupw=vinfo.xres;
+ d_ptr->startuph=vinfo.yres;
+ d_ptr->startupd=vinfo.bits_per_pixel;
+ grayscale = vinfo.grayscale;
+
+ if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
+ perror("QLinuxFbScreen::initDevice");
+ qCritical("Error reading fixed information in card init");
+ // It's not an /error/ as such, though definitely a bad sign
+ // so we return true
+ return true;
+ }
+
+#ifdef __i386__
+ // Now init mtrr
+ if(!::getenv("QWS_NOMTRR")) {
+ int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0);
+ // MTRR entry goes away when file is closed - i.e.
+ // hopefully when QWS is killed
+ if(mfd != -1) {
+ mtrr_sentry sentry;
+ sentry.base=(unsigned long int)finfo.smem_start;
+ //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start);
+ // Size needs to be in 4k chunks, but that's not always
+ // what we get thanks to graphics card registers. Write combining
+ // these is Not Good, so we write combine what we can
+ // (which is not much - 4 megs on an 8 meg card, it seems)
+ unsigned int size=finfo.smem_len;
+ size=size >> 22;
+ size=size << 22;
+ sentry.size=size;
+ sentry.type=MTRR_TYPE_WRCOMB;
+ if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) {
+ //printf("Couldn't add mtrr entry for %lx %lx, %s\n",
+ //sentry.base,sentry.size,strerror(errno));
+ }
+ }
+
+ // Should we close mfd here?
+ //QT_CLOSE(mfd);
+ }
+#endif
+ if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
+ {
+ fb_cmap cmap;
+ createPalette(cmap, vinfo, finfo);
+ if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) {
+ perror("QLinuxFbScreen::initDevice");
+ qWarning("Error writing palette to framebuffer");
+ }
+ free(cmap.red);
+ free(cmap.green);
+ free(cmap.blue);
+ free(cmap.transp);
+ }
+
+#if 0
+ if (canaccel) {
+ *entryp=0;
+ *lowest = mapsize;
+ insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start
+ }
+
+ shared->fifocount = 0;
+ shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen)
+ shared->linestep = 0;
+ shared->cliptop = 0xffffffff;
+ shared->clipleft = 0xffffffff;
+ shared->clipright = 0xffffffff;
+ shared->clipbottom = 0xffffffff;
+ shared->rop = 0xffffffff;
+#endif
+
+#ifdef QT_QWS_DEPTH_GENERIC
+ if (pixelFormat() == QImage::Format_Invalid && screencols == 0
+ && d_ptr->doGenericColors)
+ {
+ qt_set_generic_blit(this, vinfo.bits_per_pixel,
+ vinfo.red.length, vinfo.green.length,
+ vinfo.blue.length, vinfo.transp.length,
+ vinfo.red.offset, vinfo.green.offset,
+ vinfo.blue.offset, vinfo.transp.offset);
+ }
+#endif
+
+#if 0
+#ifndef QT_NO_QWS_CURSOR
+ QScreenCursor::initSoftwareCursor();
+#endif
+#endif
+ blank(false);
+
+ return true;
+}
+
+void QLinuxFbIntegration::setPixelFormat(struct fb_var_screeninfo info)
+{
+ const fb_bitfield rgba[4] = { info.red, info.green,
+ info.blue, info.transp };
+
+ QImage::Format format = QImage::Format_Invalid;
+
+ switch (d) {
+ case 32: {
+ const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0},
+ {0, 8, 0}, {24, 8, 0}};
+ const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0},
+ {16, 8, 0}, {24, 8, 0}};
+ if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_ARGB32;
+ } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB32;
+ } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB32;
+ pixeltype = BGRPixel;
+ }
+ break;
+ }
+ case 24: {
+ const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0},
+ {0, 8, 0}, {0, 0, 0}};
+ const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0},
+ {16, 8, 0}, {0, 0, 0}};
+ if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB888;
+ } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB888;
+ pixeltype = BGRPixel;
+ }
+ break;
+ }
+ case 18: {
+ const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0},
+ {0, 6, 0}, {0, 0, 0}};
+ if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0)
+ format = QImage::Format_RGB666;
+ break;
+ }
+ case 16: {
+ const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0},
+ {0, 5, 0}, {0, 0, 0}};
+ const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0},
+ {11, 5, 0}, {0, 0, 0}};
+ if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB16;
+ } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB16;
+ pixeltype = BGRPixel;
+ }
+ break;
+ }
+ case 15: {
+ const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0},
+ {0, 5, 0}, {15, 1, 0}};
+ const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0},
+ {10, 5, 0}, {15, 1, 0}};
+ if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB555;
+ } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) {
+ format = QImage::Format_RGB555;
+ pixeltype = BGRPixel;
+ }
+ break;
+ }
+ case 12: {
+ const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0},
+ {0, 4, 0}, {0, 0, 0}};
+ if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0)
+ format = QImage::Format_RGB444;
+ break;
+ }
+ case 8:
+ break;
+ case 1:
+ format = QImage::Format_Mono; //###: LSB???
+ break;
+ default:
+ break;
+ }
+
+ screenFormat = format;
+}
+
+void QLinuxFbIntegration::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
+{
+ if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
+ screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
+ cmap.start=0;
+ cmap.len=screencols;
+ cmap.red=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ cmap.green=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ cmap.blue=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+ cmap.transp=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*screencols);
+
+ if (screencols==16) {
+ if (finfo.type == FB_TYPE_PACKED_PIXELS) {
+ // We'll setup a grayscale cmap for 4bpp linear
+ int val = 0;
+ for (int idx = 0; idx < 16; ++idx, val += 17) {
+ cmap.red[idx] = (val<<8)|val;
+ cmap.green[idx] = (val<<8)|val;
+ cmap.blue[idx] = (val<<8)|val;
+ screenclut[idx]=qRgb(val, val, val);
+ }
+ } else {
+ // Default 16 colour palette
+ // Green is now trolltech green so certain images look nicer
+ // black d_gray l_gray white red green blue cyan magenta yellow
+ unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 };
+ unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F };
+ unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 };
+
+ for (int idx = 0; idx < 16; ++idx) {
+ cmap.red[idx] = ((reds[idx]) << 8)|reds[idx];
+ cmap.green[idx] = ((greens[idx]) << 8)|greens[idx];
+ cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx];
+ cmap.transp[idx] = 0;
+ screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]);
+ }
+ }
+ } else {
+ if (grayscale) {
+ // Build grayscale palette
+ int i;
+ for(i=0;i<screencols;++i) {
+ int bval = screencols == 256 ? i : (i << 4);
+ ushort val = (bval << 8) | bval;
+ cmap.red[i] = val;
+ cmap.green[i] = val;
+ cmap.blue[i] = val;
+ cmap.transp[i] = 0;
+ screenclut[i] = qRgb(bval,bval,bval);
+ }
+ } else {
+ // 6x6x6 216 color cube
+ int idx = 0;
+ for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
+ for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
+ for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
+ cmap.red[idx] = (ir << 8)|ir;
+ cmap.green[idx] = (ig << 8)|ig;
+ cmap.blue[idx] = (ib << 8)|ib;
+ cmap.transp[idx] = 0;
+ screenclut[idx]=qRgb(ir, ig, ib);
+ ++idx;
+ }
+ }
+ }
+ // Fill in rest with 0
+ for (int loopc=0; loopc<40; ++loopc) {
+ screenclut[idx]=0;
+ ++idx;
+ }
+ screencols=idx;
+ }
+ }
+ } else if(finfo.visual==FB_VISUAL_DIRECTCOLOR) {
+ cmap.start=0;
+ int rbits=0,gbits=0,bbits=0;
+ switch (vinfo.bits_per_pixel) {
+ case 8:
+ rbits=vinfo.red.length;
+ gbits=vinfo.green.length;
+ bbits=vinfo.blue.length;
+ if(rbits==0 && gbits==0 && bbits==0) {
+ // cyber2000 driver bug hack
+ rbits=3;
+ gbits=3;
+ bbits=2;
+ }
+ break;
+ case 15:
+ rbits=5;
+ gbits=5;
+ bbits=5;
+ break;
+ case 16:
+ rbits=5;
+ gbits=6;
+ bbits=5;
+ break;
+ case 18:
+ case 19:
+ rbits=6;
+ gbits=6;
+ bbits=6;
+ break;
+ case 24: case 32:
+ rbits=gbits=bbits=8;
+ break;
+ }
+ screencols=cmap.len=1<<qMax(rbits,qMax(gbits,bbits));
+ cmap.red=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*256);
+ cmap.green=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*256);
+ cmap.blue=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*256);
+ cmap.transp=(unsigned short int *)
+ malloc(sizeof(unsigned short int)*256);
+ for(unsigned int i = 0x0; i < cmap.len; i++) {
+ cmap.red[i] = i*65535/((1<<rbits)-1);
+ cmap.green[i] = i*65535/((1<<gbits)-1);
+ cmap.blue[i] = i*65535/((1<<bbits)-1);
+ cmap.transp[i] = 0;
+ }
+ }
+}
+
+void QLinuxFbIntegration::blank(bool on)
+{
+ if (d_ptr->blank == on)
+ return;
+
+#if defined(QT_QWS_IPAQ)
+ if (on)
+ system("apm -suspend");
+#else
+ if (d_ptr->fd == -1)
+ return;
+// Some old kernel versions don't have this. These defines should go
+// away eventually
+#if defined(FBIOBLANK)
+#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING)
+ ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING);
+#else
+ ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0);
+#endif
+#endif
+#endif
+
+ d_ptr->blank = on;
+}
+
+bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
+QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QWindowSurface *QLinuxFbIntegration::createWindowSurface(QWidget *widget, WId) const
+{
+ QFbWindowSurface * surface =
+ new QFbWindowSurface(mPrimaryScreen, widget);
+ return surface;
+}
+
+QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
+{
+ QFbWindow *w = new QFbWindow(widget);
+ mPrimaryScreen->addWindow(w);
+ return w;
+}
+
+QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const
+{
+ return fontDb;
+}
+
+QLinuxFbScreen::QLinuxFbScreen(uchar * d, int w,
+ int h, int lstep, QImage::Format screenFormat) : compositePainter(0)
+{
+ data = d;
+ mGeometry = QRect(0,0,w,h);
+ bytesPerLine = lstep;
+ mFormat = screenFormat;
+ mDepth = 16;
+ mScreenImage = new QImage(mGeometry.width(), mGeometry.height(),
+ mFormat);
+ mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(),
+ bytesPerLine, mFormat);
+ cursor = new QPlatformSoftwareCursor(this);
+}
+
+void QLinuxFbScreen::setGeometry(QRect rect)
+{
+ mGeometry = rect;
+ delete mFbScreenImage;
+ mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(),
+ bytesPerLine, mFormat);
+ delete compositePainter;
+ compositePainter = 0;
+
+ delete mScreenImage;
+ mScreenImage = new QImage(mGeometry.width(), mGeometry.height(),
+ mFormat);
+}
+
+void QLinuxFbScreen::setFormat(QImage::Format format)
+{
+ mFormat = format;
+ delete mFbScreenImage;
+ mFbScreenImage = new QImage(data, mGeometry.width(), mGeometry.height(),
+ bytesPerLine, mFormat);
+ delete compositePainter;
+ compositePainter = 0;
+
+ delete mScreenImage;
+ mScreenImage = new QImage(mGeometry.width(), mGeometry.height(),
+ mFormat);
+}
+
+QRegion QLinuxFbScreen::doRedraw()
+{
+ QRegion touched;
+ touched = QFbScreen::doRedraw();
+
+ if (!compositePainter) {
+ compositePainter = new QPainter(mFbScreenImage);
+ }
+
+ QVector<QRect> rects = touched.rects();
+ for (int i = 0; i < rects.size(); i++)
+ compositePainter->drawImage(rects[i], *mScreenImage, rects[i]);
+ return touched;
+}
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
new file mode 100644
index 0000000..f361843
--- /dev/null
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_LINUXFB_H
+#define QGRAPHICSSYSTEM_LINUXFB_H
+
+#include <QPlatformIntegration>
+#include "../fb_base/fb_base.h"
+
+QT_BEGIN_NAMESPACE
+
+class QLinuxFbScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ QLinuxFbScreen(uchar * d, int w, int h, int lstep, QImage::Format screenFormat);
+ void setGeometry(QRect rect);
+ void setFormat(QImage::Format format);
+
+public slots:
+ QRegion doRedraw();
+
+private:
+ QImage * mFbScreenImage;
+ uchar * data;
+ int bytesPerLine;
+
+ QPainter *compositePainter;
+};
+
+class QLinuxFbIntegrationPrivate;
+struct fb_cmap;
+struct fb_var_screeninfo;
+struct fb_fix_screeninfo;
+
+class QLinuxFbIntegration : public QPlatformIntegration
+{
+public:
+ QLinuxFbIntegration();
+ ~QLinuxFbIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QLinuxFbScreen *mPrimaryScreen;
+ QList<QPlatformScreen *> mScreens;
+ QLinuxFbIntegrationPrivate *d_ptr;
+
+ enum PixelType { NormalPixel, BGRPixel };
+
+ QRgb screenclut[256];
+ int screencols;
+
+ uchar * data;
+
+ QImage::Format screenFormat;
+ int w;
+ int lstep;
+ int h;
+ int d;
+ PixelType pixeltype;
+ bool grayscale;
+
+ int dw;
+ int dh;
+
+ int size; // Screen size
+ int mapsize; // Total mapped memory
+
+ int displayId;
+
+ int physWidth;
+ int physHeight;
+
+ bool canaccel;
+ int dataoffset;
+ int cacheStart;
+
+ bool connect(const QString &displaySpec);
+ bool initDevice();
+ void setPixelFormat(struct fb_var_screeninfo);
+ void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo);
+ void blank(bool on);
+ QPlatformFontDatabase *fontDb;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp
new file mode 100644
index 0000000..b15f183
--- /dev/null
+++ b/src/plugins/platforms/minimal/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qminimalintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QMinimalIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "Minimal";
+ return list;
+}
+
+QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "minimal")
+ return new QMinimalIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(minimal, QMinimalIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
new file mode 100644
index 0000000..438a88e
--- /dev/null
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -0,0 +1,13 @@
+TARGET = qminimal
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = main.cpp \
+ qminimalintegration.cpp \
+ qminimalwindowsurface.cpp
+HEADERS = qminimalintegration.h \
+ qminimalwindowsurface.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
new file mode 100644
index 0000000..3a545e4
--- /dev/null
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qminimalintegration.h"
+#include "qminimalwindowsurface.h"
+
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtGui/QPlatformWindow>
+
+QMinimalIntegration::QMinimalIntegration()
+{
+ QMinimalScreen *mPrimaryScreen = new QMinimalScreen();
+
+ mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320);
+ mPrimaryScreen->mDepth = 16;
+ mPrimaryScreen->mFormat = QImage::Format_RGB16;
+
+ mScreens.append(mPrimaryScreen);
+}
+
+bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QPlatformWindow(widget);
+}
+
+QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QMinimalWindowSurface(widget);
+}
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
new file mode 100644
index 0000000..5f93443
--- /dev/null
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_MINIMAL_H
+#define QPLATFORMINTEGRATION_MINIMAL_H
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalScreen : public QPlatformScreen
+{
+public:
+ QMinimalScreen()
+ : mDepth(16), mFormat(QImage::Format_RGB16) {}
+
+ QRect geometry() const { return mGeometry; }
+ int depth() const { return mDepth; }
+ QImage::Format format() const { return mFormat; }
+
+public:
+ QRect mGeometry;
+ int mDepth;
+ QImage::Format mFormat;
+ QSize mPhysicalSize;
+};
+
+class QMinimalIntegration : public QPlatformIntegration
+{
+public:
+ QMinimalIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+private:
+ QList<QPlatformScreen *> mScreens;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
new file mode 100644
index 0000000..dd8c9b7
--- /dev/null
+++ b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qminimalwindowsurface.h"
+#include <QtCore/qdebug.h>
+#include <QtGui/private/qapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+{
+ //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this;
+}
+
+QMinimalWindowSurface::~QMinimalWindowSurface()
+{
+}
+
+QPaintDevice *QMinimalWindowSurface::paintDevice()
+{
+ //qDebug() << "QMinimalWindowSurface::paintDevice";
+ return &mImage;
+}
+
+void QMinimalWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ static int c = 0;
+ QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
+ qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData();
+ mImage.save(filename);
+}
+
+void QMinimalWindowSurface::resize(const QSize &size)
+{
+ //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect;
+ QWindowSurface::resize(size);
+ QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+ if (mImage.size() != size)
+ mImage = QImage(size, format);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalwindowsurface.h
new file mode 100644
index 0000000..bfeeaca
--- /dev/null
+++ b/src/plugins/platforms/minimal/qminimalwindowsurface.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_MINIMAL_H
+#define QWINDOWSURFACE_MINIMAL_H
+
+#include <QtGui/private/qwindowsurface_p.h>
+
+#include <QtGui/QPlatformWindow>
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalWindowSurface : public QWindowSurface
+{
+public:
+ QMinimalWindowSurface(QWidget *window);
+ ~QMinimalWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+
+private:
+ QImage mImage;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/openkode/main.cpp b/src/plugins/platforms/openkode/main.cpp
new file mode 100644
index 0000000..ead17a4
--- /dev/null
+++ b/src/plugins/platforms/openkode/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qopenkodeintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QOpenKODEPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QOpenKODEPlugin::keys() const
+{
+ QStringList list;
+ list << "OpenKODE";
+ return list;
+}
+
+QPlatformIntegration * QOpenKODEPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "openkode")
+ return new QOpenKODEIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(openkode, QOpenKODEPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openkode/openkode.pro b/src/plugins/platforms/openkode/openkode.pro
new file mode 100644
index 0000000..c8ae415
--- /dev/null
+++ b/src/plugins/platforms/openkode/openkode.pro
@@ -0,0 +1,42 @@
+TARGET = qopenkodeintegration
+include(../../qpluginbase.pri)
+
+QT += opengl
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = main.cpp \
+ qopenkodeintegration.cpp \
+ qopenkodewindow.cpp \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ qopenkodeeventloopintegration.cpp
+
+HEADERS = qopenkodeintegration.h \
+ qopenkodewindow.h \
+ ../eglconvenience/qeglplatformcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+ qopenkodeeventloopintegration.h \
+ openkodekeytranslator.h
+
+include (../fontdatabases/genericunix/genericunix.pri)
+
+RESOURCES = resources.qrc
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
+
+LIBS += -lKD -lEGL
+!isEmpty(QMAKE_INCDIR_OPENGL_ES2){
+ INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2
+}
+!isEmpty(QMAKE_LIBDIR_OPENGL_ES2){
+ for(p, QMAKE_LIBDIR_OPENGL_ES2) {
+ exists($$p):LIBS += -L$$p
+ }
+}
+!isEmpty(QMAKE_LIBS_OPENGL_ES2){
+ LIBS += $$QMAKE_LIBS_OPENGL_ES2
+} else {
+ LIBS += -lGLESv2
+}
diff --git a/src/plugins/platforms/openkode/openkodekeytranslator.h b/src/plugins/platforms/openkode/openkodekeytranslator.h
new file mode 100644
index 0000000..502bf03
--- /dev/null
+++ b/src/plugins/platforms/openkode/openkodekeytranslator.h
@@ -0,0 +1,244 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OPENKODEKEYTRANSLATOR_H
+#define OPENKODEKEYTRANSLATOR_H
+
+#ifdef KD_ATX_keyboard
+
+#include <KD/ATX_keyboard.h>
+
+QT_BEGIN_NAMESPACE
+
+Qt::Key keyTranslator( int key )
+{
+ switch (key) {
+// KD_KEY_ACCEPT_ATX:
+// KD_KEY_AGAIN_ATX:
+// KD_KEY_ALLCANDIDATES_ATX
+// KD_KEY_ALPHANUMERIC_ATX
+ case KD_KEY_ALT_ATX:
+ return Qt::Key_Alt;
+ case KD_KEY_ALTGRAPH_ATX:
+ return Qt::Key_AltGr;
+// KD_KEY_APPS_ATX
+// KD_KEY_ATTN_ATX
+// KD_KEY_BROWSERBACK_ATX
+// KD_KEY_BROWSERFAVORITES_ATX
+// KD_KEY_BROWSERFORWARD_ATX
+// KD_KEY_BROWSERHOME_ATX
+// KD_KEY_BROWSERREFRESH_ATX
+// KD_KEY_BROWSERSEARCH_ATX
+// KD_KEY_BROWSERSTOP_ATX
+ case KD_KEY_CAPSLOCK_ATX:
+ return Qt::Key_CapsLock;
+ case KD_KEY_CLEAR_ATX:
+ return Qt::Key_Clear;
+ case KD_KEY_CODEINPUT_ATX:
+ return Qt::Key_Codeinput;
+// KD_KEY_COMPOSE_ATX
+ case KD_KEY_CONTROL_ATX:
+ return Qt::Key_Control;
+// KD_KEY_CRSEL_ATX
+// KD_KEY_CONVERT_ATX
+ case KD_KEY_COPY_ATX:
+ return Qt::Key_Copy;
+ case KD_KEY_CUT_ATX:
+ return Qt::Key_Cut;
+ case KD_KEY_DOWN_ATX:
+ return Qt::Key_Down;
+ case KD_KEY_END_ATX:
+ return Qt::Key_End;
+ case KD_KEY_ENTER_ATX:
+ return Qt::Key_Enter;
+// KD_KEY_ERASEEOF_ATX
+// KD_KEY_EXECUTE_ATX
+// KD_KEY_EXSEL_ATX
+ case KD_KEY_F1_ATX:
+ return Qt::Key_F1;
+ case KD_KEY_F2_ATX:
+ return Qt::Key_F2;
+ case KD_KEY_F3_ATX:
+ return Qt::Key_F3;
+ case KD_KEY_F4_ATX:
+ return Qt::Key_F4;
+ case KD_KEY_F5_ATX:
+ return Qt::Key_F5;
+ case KD_KEY_F6_ATX:
+ return Qt::Key_F6;
+ case KD_KEY_F7_ATX:
+ return Qt::Key_F7;
+ case KD_KEY_F8_ATX:
+ return Qt::Key_F8;
+ case KD_KEY_F9_ATX:
+ return Qt::Key_F9;
+ case KD_KEY_F10_ATX:
+ return Qt::Key_F10;
+ case KD_KEY_F11_ATX:
+ return Qt::Key_F11;
+ case KD_KEY_F12_ATX:
+ return Qt::Key_F12;
+ case KD_KEY_F13_ATX:
+ return Qt::Key_F13;
+ case KD_KEY_F14_ATX:
+ return Qt::Key_F14;
+ case KD_KEY_F15_ATX:
+ return Qt::Key_F15;
+ case KD_KEY_F16_ATX:
+ return Qt::Key_F16;
+ case KD_KEY_F17_ATX:
+ return Qt::Key_F17;
+ case KD_KEY_F18_ATX:
+ return Qt::Key_F18;
+ case KD_KEY_F19_ATX:
+ return Qt::Key_F19;
+ case KD_KEY_F20_ATX:
+ return Qt::Key_F20;
+ case KD_KEY_F21_ATX:
+ return Qt::Key_F21;
+ case KD_KEY_F22_ATX:
+ return Qt::Key_F22;
+ case KD_KEY_F23_ATX:
+ return Qt::Key_F23;
+ case KD_KEY_F24_ATX:
+ return Qt::Key_F24;
+// KD_KEY_FINALMODE_ATX
+// KD_KEY_FIND_ATX
+// KD_KEY_FULLWIDTH_ATX
+// KD_KEY_HALFWIDTH_ATX
+ case KD_KEY_HANGULMODE_ATX:
+ return Qt::Key_Hangul;
+// KD_KEY_HANJAMODE_ATX
+ case KD_KEY_HELP_ATX:
+ return Qt::Key_Help;
+ case KD_KEY_HIRAGANA_ATX:
+ return Qt::Key_Hiragana;
+ case KD_KEY_HOME_ATX:
+ return Qt::Key_Home;
+ case KD_KEY_INSERT_ATX:
+ return Qt::Key_Insert;
+// KD_KEY_JAPANESEHIRAGANA_ATX:
+// KD_KEY_JAPANESEKATAKANA_ATX
+// KD_KEY_JAPANESEROMAJI_ATX
+// KD_KEY_JUNJAMODE_ATX
+ case KD_KEY_KANAMODE_ATX:
+ return Qt::Key_Kana_Lock; //?
+ case KD_KEY_KANJIMODE_ATX:
+ return Qt::Key_Kanji;
+// KD_KEY_KATAKANA_ATX
+// KD_KEY_LAUNCHAPPLICATION1_ATX
+// KD_KEY_LAUNCHAPPLICATION2_ATX
+ case KD_KEY_LAUNCHMAIL_ATX:
+ return Qt::Key_MailForward;
+ case KD_KEY_LEFT_ATX:
+ return Qt::Key_Left;
+ case KD_KEY_META_ATX:
+ return Qt::Key_Meta;
+ case KD_KEY_MEDIANEXTTRACK_ATX:
+ return Qt::Key_MediaNext;
+ case KD_KEY_MEDIAPLAYPAUSE_ATX:
+ return Qt::Key_MediaPause;
+ case KD_KEY_MEDIAPREVIOUSTRACK_ATX:
+ return Qt::Key_MediaPrevious;
+ case KD_KEY_MEDIASTOP_ATX:
+ return Qt::Key_MediaStop;
+ case KD_KEY_MODECHANGE_ATX:
+ return Qt::Key_Mode_switch;
+// KD_KEY_NONCONVERT_ATX
+ case KD_KEY_NUMLOCK_ATX:
+ return Qt::Key_NumLock;
+ case KD_KEY_PAGEDOWN_ATX:
+ return Qt::Key_PageDown;
+ case KD_KEY_PAGEUP_ATX:
+ return Qt::Key_PageUp;
+ case KD_KEY_PASTE_ATX:
+ return Qt::Key_Paste;
+ case KD_KEY_PAUSE_ATX:
+ return Qt::Key_Pause;
+ case KD_KEY_PLAY_ATX:
+ return Qt::Key_Play;
+// KD_KEY_PREVIOUSCANDIDATE_ATX
+ case KD_KEY_PRINTSCREEN_ATX:
+ return Qt::Key_Print;
+// case KD_KEY_PROCESS_ATX
+// case KD_KEY_PROPS_ATX
+ case KD_KEY_RIGHT_ATX:
+ return Qt::Key_Right;
+// KD_KEY_ROMANCHARACTERS_ATX
+ case KD_KEY_SCROLL_ATX:
+ return Qt::Key_ScrollLock;
+ case KD_KEY_SELECT_ATX:
+ return Qt::Key_Select;
+// KD_KEY_SELECTMEDIA_ATX
+ case KD_KEY_SHIFT_ATX:
+ return Qt::Key_Shift;
+ case KD_KEY_STOP_ATX:
+ return Qt::Key_Stop;
+ case KD_KEY_UP_ATX:
+ return Qt::Key_Up;
+// KD_KEY_UNDO_ATX
+ case KD_KEY_VOLUMEDOWN_ATX:
+ return Qt::Key_VolumeDown;
+ case KD_KEY_VOLUMEMUTE_ATX:
+ return Qt::Key_VolumeMute;
+ case KD_KEY_VOLUMEUP_ATX:
+ return Qt::Key_VolumeUp;
+ case KD_KEY_WIN_ATX:
+ return Qt::Key_Meta;
+ case KD_KEY_ZOOM_ATX:
+ return Qt::Key_Zoom;
+ case 0x8:
+ return Qt::Key_Backspace;
+ case 0x1b:
+ return Qt::Key_Escape;
+ case 0x9:
+ return Qt::Key_Tab;
+
+ default:
+ break;
+ }
+
+ return Qt::Key_Escape;
+}
+
+QT_END_NAMESPACE
+#endif //KD_ATX_keyboard
+#endif // OPENKODEKEYTRANSLATOR_H
diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp
new file mode 100644
index 0000000..4ca82db
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenkodeeventloopintegration.h"
+
+#include <QDebug>
+
+#include <KD/kd.h>
+#include <KD/ATX_keyboard.h>
+
+QT_BEGIN_NAMESPACE
+
+static const int QT_EVENT_WAKEUP_EVENTLOOP = KD_EVENT_USER + 1;
+
+void kdprocessevent( const KDEvent *event)
+{
+ switch (event->type) {
+ case KD_EVENT_INPUT:
+ qDebug() << "KD_EVENT_INPUT";
+ break;
+ case KD_EVENT_INPUT_POINTER:
+ qDebug() << "KD_EVENT_INPUT_POINTER";
+ break;
+ case KD_EVENT_WINDOW_CLOSE:
+ qDebug() << "KD_EVENT_WINDOW_CLOSE";
+ break;
+ case KD_EVENT_WINDOWPROPERTY_CHANGE:
+ qDebug() << "KD_EVENT_WINDOWPROPERTY_CHANGE";
+ qDebug() << event->data.windowproperty.pname;
+ break;
+ case KD_EVENT_WINDOW_FOCUS:
+ qDebug() << "KD_EVENT_WINDOW_FOCUS";
+ break;
+ case KD_EVENT_WINDOW_REDRAW:
+ qDebug() << "KD_EVENT_WINDOW_REDRAW";
+ break;
+ case KD_EVENT_USER:
+ qDebug() << "KD_EVENT_USER";
+ break;
+ case KD_EVENT_INPUT_KEY_ATX:
+ qDebug() << "KD_EVENT_INPUT_KEY_ATX";
+ break;
+ case QT_EVENT_WAKEUP_EVENTLOOP:
+ QPlatformEventLoopIntegration::processEvents();
+ break;
+ default:
+ break;
+ }
+
+ kdDefaultEvent(event);
+
+}
+
+QOpenKODEEventLoopIntegration::QOpenKODEEventLoopIntegration()
+ : m_quit(false)
+{
+ m_kdThread = kdThreadSelf();
+ kdInstallCallback(&kdprocessevent,QT_EVENT_WAKEUP_EVENTLOOP,this);
+}
+
+void QOpenKODEEventLoopIntegration::startEventLoop()
+{
+
+ while(!m_quit) {
+ qint64 msec = nextTimerEvent();
+ const KDEvent *event = kdWaitEvent(msec);
+ if (event) {
+ kdDefaultEvent(event);
+ while ((event = kdWaitEvent(0)) != 0) {
+ kdDefaultEvent(event);
+ }
+ }
+ QPlatformEventLoopIntegration::processEvents();
+ }
+}
+
+void QOpenKODEEventLoopIntegration::quitEventLoop()
+{
+ m_quit = true;
+}
+
+void QOpenKODEEventLoopIntegration::qtNeedsToProcessEvents()
+{
+ KDEvent *event = kdCreateEvent();
+ event->type = QT_EVENT_WAKEUP_EVENTLOOP;
+ event->userptr = this;
+ kdPostThreadEvent(event,m_kdThread);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h
new file mode 100644
index 0000000..cef3465
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeeventloopintegration.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENKODEEVENTLOOPINTEGRATION_H
+#define QOPENKODEEVENTLOOPINTEGRATION_H
+
+#include <QtGui/QPlatformEventLoopIntegration>
+
+class KDThread;
+class KDEvent;
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QOpenKODEEventLoopIntegration : public QPlatformEventLoopIntegration
+{
+public:
+ QOpenKODEEventLoopIntegration();
+ void startEventLoop();
+ void quitEventLoop();
+ void qtNeedsToProcessEvents();
+
+ void processInputEvent(const KDEvent *event);
+private:
+
+ bool m_quit;
+ KDThread *m_kdThread;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QOPENKODEEVENTLOOPINTEGRATION_H
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
new file mode 100644
index 0000000..35e744be
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenkodeintegration.h"
+#include "qopenkodewindow.h"
+#include "qopenkodeeventloopintegration.h"
+
+#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+#include <QtOpenGL/private/qwindowsurface_gl_p.h>
+
+#include <QtGui/private/qpixmap_raster_p.h>
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qthread.h>
+#include <QtCore/qfile.h>
+
+#include "qgenericunixfontdatabase.h"
+
+#include <KD/kd.h>
+#include <KD/NV_display.h>
+#include <KD/NV_initialize.h>
+
+#include <EGL/egl.h>
+
+#include "GLES2/gl2ext.h"
+
+QT_BEGIN_NAMESPACE
+
+QOpenKODEScreen::QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop)
+ : mIsFullScreen(false)
+{
+ qDebug() << "QOpenKODEScreen::QOpenKODEIntegrationScreen()";
+
+ KDboolean enabled = KD_TRUE;
+ kdSetDisplayPropertybvNV(kdDisplay,
+ KD_DISPLAYPROPERTY_ENABLED_NV,
+ &enabled);
+ KDboolean power = KD_DISPLAY_POWER_ON;
+ kdSetDisplayPropertyivNV(kdDisplay,
+ KD_DISPLAYPROPERTY_POWER_NV,
+ &power);
+
+ kdSetDisplayPropertycvNV(kdDisplay,
+ KD_DISPLAYPROPERTY_DESKTOP_NAME_NV,
+ KD_DEFAULT_DESKTOP_NV);
+
+ KDDisplayModeNV mode;
+ if (kdGetDisplayModeNV(kdDisplay, &mode)) {
+ qErrnoWarning(kdGetError(), "Could not get display mode");
+ return;
+ }
+
+ qDebug() << " - display mode " << mode.width << "x" << mode.height << " refresh " << mode.refresh;
+
+ KDint desktopSize[] = { mode.width, mode.height };
+
+ if (kdSetDesktopPropertyivNV(kdDesktop, KD_DESKTOPPROPERTY_SIZE_NV, desktopSize)) {
+ qErrnoWarning(kdGetError(), "Could not set desktop size");
+ return;
+ }
+
+ // Once we've set up the desktop and display we don't need them anymore
+ kdReleaseDisplayNV(kdDisplay);
+ kdReleaseDesktopNV(kdDesktop);
+
+ mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (mEglDisplay == EGL_NO_DISPLAY) {
+ qErrnoWarning("EGL failed to obtain display");
+ }
+
+ /* Initialize EGL display */
+ EGLBoolean rvbool = eglInitialize(mEglDisplay, 0, 0);
+ if (!rvbool) {
+ qErrnoWarning("EGL failed to initialize display");
+ }
+
+// cursor = new QOpenKODECursor(this);
+
+ mGeometry = QRect(0, 0, mode.width, mode.height);
+ mDepth = 24;
+ mFormat = QImage::Format_RGB32;
+
+
+}
+
+QOpenKODEIntegration::QOpenKODEIntegration()
+ : mEventLoopIntegration(0), mFontDb(new QGenericUnixFontDatabase())
+{
+ if (kdInitializeNV() == KD_ENOTINITIALIZED) {
+ qFatal("Did not manage to initialize openkode");
+ }
+
+ KDDisplaySystemNV *kdDisplaySystem = kdCreateDisplaySystemSnapshotNV(this);
+ KDint32 displayCount = 0;
+ kdGetDisplaySystemPropertyivNV(kdDisplaySystem, KD_DISPLAYPROPERTY_COUNT_NV, 0, &displayCount);
+
+ for (int i = 0; i < displayCount; i++) {
+ KDchar *displayName = 0;
+ KDsize displayNameLength = 0;
+ kdGetDisplaySystemPropertycvNV(kdDisplaySystem,KD_DISPLAYPROPERTY_NAME_NV,i,0,&displayNameLength);
+ if (!displayNameLength)
+ continue;
+ displayName = new KDchar[displayNameLength];
+ kdGetDisplaySystemPropertycvNV(kdDisplaySystem,KD_DISPLAYPROPERTY_NAME_NV,i,displayName,&displayNameLength);
+
+ KDDisplayNV *display = kdGetDisplayNV(displayName,this);
+ if (!display || display == (void*)-1) {
+ qErrnoWarning(kdGetError(), "Could not obtain KDDisplayNV pointer");
+ return;
+ }
+ if (displayNameLength)
+ delete displayName;
+
+ KDchar *desktopName = 0;
+ KDsize desktopNameLength = 0;
+ bool openkodeImpDoesNotFail = false;
+ if (openkodeImpDoesNotFail) {
+ qDebug() << "printing desktopname";
+ kdGetDisplayPropertycvNV(display,KD_DISPLAYPROPERTY_DESKTOP_NAME_NV,desktopName,&desktopNameLength);
+ if (desktopNameLength) {
+ desktopName = new KDchar[desktopNameLength];
+ kdGetDisplayPropertycvNV(display,KD_DISPLAYPROPERTY_DESKTOP_NAME_NV,desktopName,&desktopNameLength);
+ } else {
+ desktopName = KD_DEFAULT_DESKTOP_NV;
+ }
+ } else {
+ desktopName = KD_DEFAULT_DESKTOP_NV;
+ }
+
+ KDDesktopNV *desktop = kdGetDesktopNV(desktopName,this);
+ if (!desktop || desktop == (void*)-1) {
+ qErrnoWarning(kdGetError(), "Could not obtain KDDesktopNV pointer");
+ kdReleaseDisplayNV(display);
+ return;
+ }
+ if (desktopNameLength)
+ delete desktopName;
+
+ QOpenKODEScreen *screen = new QOpenKODEScreen(display,desktop);
+ mScreens.append(screen);
+ }
+}
+
+QOpenKODEIntegration::~QOpenKODEIntegration()
+{
+ delete mEventLoopIntegration;
+ delete mFontDb;
+}
+
+
+bool QOpenKODEIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QGLPixmapData(type);
+}
+
+QPlatformWindow *QOpenKODEIntegration::createPlatformWindow(QWidget *tlw, WId ) const
+{
+ return new QOpenKODEWindow(tlw);
+}
+
+QWindowSurface *QOpenKODEIntegration::createWindowSurface(QWidget *widget, WId) const
+{
+ QWindowSurface *returnSurface = 0;
+ switch (widget->platformWindowFormat().windowApi()) {
+
+ case QPlatformWindowFormat::Raster:
+ case QPlatformWindowFormat::OpenGL:
+ returnSurface = new QGLWindowSurface(widget);
+ break;
+
+ case QPlatformWindowFormat::OpenVG:
+// returnSurface = new QVGWindowSurface(widget);
+// break;
+
+ default:
+ returnSurface = new QGLWindowSurface(widget);
+ break;
+ }
+
+ return returnSurface;
+}
+
+bool QOpenKODEIntegration::hasOpenGL() const
+{
+ return true;
+}
+
+QPlatformEventLoopIntegration *QOpenKODEIntegration::createEventLoopIntegration() const
+{
+ if (!mEventLoopIntegration) {
+ QOpenKODEIntegration *that = const_cast<QOpenKODEIntegration *>(this);
+ that->mEventLoopIntegration = new QOpenKODEEventLoopIntegration;
+ }
+ return mEventLoopIntegration;
+}
+
+QPlatformFontDatabase *QOpenKODEIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h
new file mode 100644
index 0000000..7582e60
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_OPENKODE_H
+#define QGRAPHICSSYSTEM_OPENKODE_H
+
+#include "qopenkodeeventloopintegration.h"
+
+#include <QtCore/qsemaphore.h>
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformFontDatabase>
+
+#include <GLES2/gl2.h>
+#include <EGL/egl.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+struct KDDesktopNV;
+struct KDDisplayNV;
+class QOpenKODECursor;
+
+class QOpenKODEScreen : public QPlatformScreen
+{
+ Q_OBJECT
+public:
+ QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop);
+ ~QOpenKODEScreen() {}
+
+ QRect geometry() const { return mGeometry; }
+ int depth() const { return mDepth; }
+ QImage::Format format() const { return mFormat; }
+
+ EGLDisplay eglDisplay() { return mEglDisplay; }
+
+ bool isFullScreen() const {return mIsFullScreen;}
+ void setFullScreen(bool fullscreen) { mIsFullScreen = fullscreen; }
+private:
+ QRect mGeometry;
+ int mDepth;
+ QImage::Format mFormat;
+ EGLDisplay mEglDisplay;
+ bool mIsFullScreen;
+};
+
+class QOpenKODEIntegration : public QPlatformIntegration
+{
+public:
+ QOpenKODEIntegration();
+ ~QOpenKODEIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ bool hasOpenGL() const;
+
+ QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+ virtual QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ static GLuint blitterProgram();
+
+private:
+ QList<QPlatformScreen *> mScreens;
+ QOpenKODEEventLoopIntegration *mEventLoopIntegration;
+ QPlatformFontDatabase *mFontDb;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp
new file mode 100644
index 0000000..66530a5
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qopenkodewindow.h"
+#include "qopenkodeintegration.h"
+#include "../eglconvenience/qeglplatformcontext.h"
+#include "../eglconvenience/qeglconvenience.h"
+
+#include <KD/kd.h>
+#include <KD/NV_display.h>
+#include <KD/kdplatform.h>
+#ifdef KD_ATX_keyboard
+#include "openkodekeytranslator.h"
+#endif
+
+#include <EGL/egl.h>
+
+#include <QtGui/qwidget.h>
+#include <QtGui/private/qwidget_p.h>
+#include <QtGui/private/qapplication_p.h>
+
+#include <QtCore/qvector.h>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+void kdProcessMouseEvents( const KDEvent *event )
+{
+ QOpenKODEWindow *window = static_cast<QOpenKODEWindow *>(event->userptr);
+ window->processMouseEvents(event);
+}
+
+#ifdef KD_ATX_keyboard
+void kdProcessKeyEvents( const KDEvent *event )
+{
+ QOpenKODEWindow *window = static_cast<QOpenKODEWindow *>(event->userptr);
+ window->processKeyEvents(event);
+}
+#endif //KD_ATX_keyboard
+
+QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw)
+ : QPlatformWindow(tlw), isFullScreen(false)
+{
+ if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) {
+ m_eglApi = EGL_OPENVG_API;
+ } else {
+ m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ m_eglContextAttrs.append(2);
+
+ m_eglApi = EGL_OPENGL_ES_API;
+ }
+ eglBindAPI(m_eglApi);
+
+ m_eglContextAttrs.append(EGL_NONE);
+ m_eglWindowAttrs.append(EGL_NONE);
+
+ QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens();
+ //XXXX: jl figure out how to pick the correct screen.
+// Q_ASSERT(screens.size() > tlw->d_func()->screenNumber);
+// QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(tlw->d_func()->screenNumber));
+ QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0));
+ if (!screen) {
+ qErrnoWarning("Could not make QOpenKODEWindow without a screen");
+ }
+
+ QPlatformWindowFormat format = tlw->platformWindowFormat();
+ format.setRedBufferSize(5);
+ format.setGreenBufferSize(6);
+ format.setBlueBufferSize(5);
+
+ m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),format);
+
+ m_kdWindow = kdCreateWindow(screen->eglDisplay(),
+ m_eglConfig,
+ this);
+ kdInstallCallback(kdProcessMouseEvents,KD_EVENT_INPUT_POINTER,this);
+#ifdef KD_ATX_keyboard
+ kdInstallCallback(kdProcessKeyEvents, KD_EVENT_INPUT_KEY_ATX,this);
+#endif //KD_ATX_keyboard
+
+ if (!m_kdWindow) {
+ qErrnoWarning(kdGetError(), "Error creating native window");
+ return;
+ }
+
+ KDboolean exclusive(false);
+ if (kdSetWindowPropertybv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, &exclusive)) {
+ isFullScreen = true;
+ }
+
+ if (isFullScreen) {
+ tlw->setGeometry(screen->geometry());
+ screen->setFullScreen(isFullScreen);
+ }else {
+ const KDint windowSize[2] = { tlw->width(), tlw->height() };
+ if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) {
+ qErrnoWarning(kdGetError(), "Could not set native window size");
+ }
+ KDboolean visibillity(false);
+ if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) {
+ qErrnoWarning(kdGetError(), "Could not set visibillity to false");
+ }
+
+ const KDint windowPos[2] = { tlw->x(), tlw->y() };
+ if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
+ qErrnoWarning(kdGetError(), "Could not set native window position");
+ return;
+ }
+ }
+
+
+
+
+ if (!isFullScreen || (isFullScreen && !QPlatformGLContext::defaultSharedContext())) {
+ if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) {
+ qErrnoWarning(kdGetError(), "Could not realize native window");
+ return;
+ }
+
+ EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData());
+ m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig,
+ m_eglContextAttrs.data(), surface, m_eglApi);
+ m_platformGlContext->makeDefaultSharedContext();
+ } else {
+ m_platformGlContext = const_cast<QEGLPlatformContext *>(static_cast<const QEGLPlatformContext *>(QPlatformGLContext::defaultSharedContext()));
+ kdDestroyWindow(m_kdWindow);
+ m_kdWindow = 0;
+ }
+}
+
+
+QOpenKODEWindow::~QOpenKODEWindow()
+{
+ if (m_platformGlContext != QPlatformGLContext::defaultSharedContext()) {
+ delete m_platformGlContext;
+ }
+ if (m_kdWindow)
+ kdDestroyWindow(m_kdWindow);
+}
+void QOpenKODEWindow::setGeometry(const QRect &rect)
+{
+ if (isFullScreen) {
+ QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens();
+ QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0));
+ widget()->setGeometry(screen->geometry());
+ return;
+ }
+ bool needToDeleteContext = false;
+ if (!isFullScreen) {
+ const QRect geo = geometry();
+ if (geo.size() != rect.size()) {
+ const KDint windowSize[2] = { rect.width(), rect.height() };
+ if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) {
+ qErrnoWarning(kdGetError(), "Could not set native window size");
+ //return;
+ } else {
+ needToDeleteContext = true;
+ }
+ }
+
+ if (geo.topLeft() != rect.topLeft()) {
+ const KDint windowPos[2] = { rect.x(), rect.y() };
+ if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
+ qErrnoWarning(kdGetError(), "Could not set native window position");
+ //return;
+ } else {
+ needToDeleteContext = true;
+ }
+ }
+ }
+
+ //need to recreate context
+ if (needToDeleteContext) {
+ delete m_platformGlContext;
+
+ QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens();
+ QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0));
+ EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData());
+ m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(),m_eglConfig,
+ m_eglContextAttrs.data(),surface,m_eglApi);
+ }
+}
+
+void QOpenKODEWindow::setVisible(bool visible)
+{
+ if (!m_kdWindow)
+ return;
+ KDboolean visibillity(visible);
+ if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) {
+ qErrnoWarning(kdGetError(), "Could not set visibillity property");
+ }
+}
+
+WId QOpenKODEWindow::winId() const
+{
+ static int i = 0;
+ return i++;
+}
+
+QPlatformGLContext *QOpenKODEWindow::glContext() const
+{
+ return m_platformGlContext;
+}
+
+void QOpenKODEWindow::raise()
+{
+ if (!m_kdWindow)
+ return;
+ KDboolean focus(true);
+ if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_FOCUS, &focus)) {
+ qErrnoWarning(kdGetError(), "Could not set focus");
+ }
+}
+
+void QOpenKODEWindow::lower()
+{
+ if (!m_kdWindow)
+ return;
+ KDboolean focus(false);
+ if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_FOCUS, &focus)) {
+ qErrnoWarning(kdGetError(), "Could not set focus");
+ }
+}
+
+void QOpenKODEWindow::processMouseEvents(const KDEvent *event)
+{
+ int x = event->data.inputpointer.x;
+ int y = event->data.inputpointer.y;
+ Qt::MouseButtons buttons;
+ switch(event->data.inputpointer.select) {
+ case 1:
+ buttons = Qt::LeftButton;
+ break;
+ default:
+ buttons = Qt::NoButton;
+ }
+ QPoint pos(x,y);
+ QWindowSystemInterface::handleMouseEvent(0,event->timestamp,pos,pos,buttons);
+}
+
+void QOpenKODEWindow::processKeyEvents(const KDEvent *event)
+{
+#ifdef KD_ATX_keyboard
+ //KD_KEY_PRESS_ATX 1
+ QEvent::Type keyPressed = QEvent::KeyRelease;
+ if (event->data.keyboardInputKey.flags)
+ keyPressed = QEvent::KeyPress;
+//KD_KEY_LOCATION_LEFT_ATX // dont care for now
+//KD_KEY_LOCATION_RIGHT_ATX
+//KD_KEY_LOCATION_NUMPAD_ATX
+ Qt::KeyboardModifiers mod = Qt::NoModifier;
+ int openkodeMods = event->data.keyboardInputKey.flags;
+ if (openkodeMods & KD_KEY_MODIFIER_SHIFT_ATX)
+ mod |= Qt::ShiftModifier;
+ if (openkodeMods & KD_KEY_MODIFIER_CTRL_ATX)
+ mod |= Qt::ControlModifier;
+ if (openkodeMods & KD_KEY_MODIFIER_ALT_ATX)
+ mod |= Qt::AltModifier;
+ if (openkodeMods & KD_KEY_MODIFIER_META_ATX)
+ mod |= Qt::MetaModifier;
+
+ Qt::Key qtKey;
+ QChar keyText;
+ int key = event->data.keyboardInputKey.keycode;
+ if (key >= 0x20 && key <= 0x0ff){ // 8 bit printable Latin1
+ qtKey = Qt::Key(key);
+ keyText = QChar(event->data.keyboardInputKeyChar.character);
+ if (!(mod & Qt::ShiftModifier))
+ keyText = keyText.toLower();
+ } else {
+ qtKey = keyTranslator(key);
+ }
+ QWindowSystemInterface::handleKeyEvent(0,event->timestamp,keyPressed,qtKey,mod,keyText);
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.h b/src/plugins/platforms/openkode/qopenkodewindow.h
new file mode 100644
index 0000000..83b04b4
--- /dev/null
+++ b/src/plugins/platforms/openkode/qopenkodewindow.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENKODEWINDOW_H
+#define QOPENKODEWINDOW_H
+
+#include <QtGui/QPlatformWindow>
+#include <QtCore/QVector>
+
+#include <KD/kd.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QEGLPlatformContext;
+class QPlatformEventLoopIntegration;
+
+class QOpenKODEWindow : public QPlatformWindow
+{
+public:
+ QOpenKODEWindow(QWidget *tlw);
+ ~QOpenKODEWindow();
+
+ void setGeometry(const QRect &rect);
+ void setVisible(bool visible);
+ WId winId() const;
+
+ QPlatformGLContext *glContext() const;
+
+ void raise();
+ void lower();
+
+ void processKeyEvents( const KDEvent *event );
+ void processMouseEvents( const KDEvent *event );
+
+private:
+ struct KDWindow *m_kdWindow;
+ EGLNativeWindowType m_eglWindow;
+ EGLConfig m_eglConfig;
+ QVector<EGLint> m_eglWindowAttrs;
+ QVector<EGLint> m_eglContextAttrs;
+ EGLenum m_eglApi;
+ QEGLPlatformContext *m_platformGlContext;
+
+ bool isFullScreen;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif //QOPENKODEWINDOW_H
diff --git a/src/plugins/platforms/openkode/resources.qrc b/src/plugins/platforms/openkode/resources.qrc
new file mode 100644
index 0000000..dbb3419
--- /dev/null
+++ b/src/plugins/platforms/openkode/resources.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>shaders/vert.glslv</file>
+ <file>shaders/frag.glslf</file>
+</qresource>
+</RCC>
diff --git a/src/plugins/platforms/openkode/shaders/frag.glslf b/src/plugins/platforms/openkode/shaders/frag.glslf
new file mode 100644
index 0000000..ceac785
--- /dev/null
+++ b/src/plugins/platforms/openkode/shaders/frag.glslf
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform sampler2D tex_samp;
+
+varying vec2 texcoord_var;
+
+void main(void)
+{
+ gl_FragColor = texture2D(tex_samp, texcoord_var);
+}
diff --git a/src/plugins/platforms/openkode/shaders/vert.glslv b/src/plugins/platforms/openkode/shaders/vert.glslv
new file mode 100644
index 0000000..cc40985
--- /dev/null
+++ b/src/plugins/platforms/openkode/shaders/vert.glslv
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform vec2 window; // window size
+
+// Per-vertex attributes]
+attribute vec2 pos_attr;
+attribute vec2 texcoord_attr;
+
+// Output vertex color
+varying vec2 texcoord_var;
+
+void main()
+{
+ gl_Position = vec4( (2.0 * pos_attr / window -1.0) * vec2(1.0, -1.0), 0.0, 1.0);
+ texcoord_var = texcoord_attr;
+}
diff --git a/src/plugins/platforms/openvglite/main.cpp b/src/plugins/platforms/openvglite/main.cpp
new file mode 100644
index 0000000..97321fa
--- /dev/null
+++ b/src/plugins/platforms/openvglite/main.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qgraphicssystemplugin_p.h>
+#include "qgraphicssystem_vglite.h"
+
+QT_BEGIN_NAMESPACE
+
+class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin
+{
+public:
+ QStringList keys() const;
+ QGraphicsSystem *create(const QString&);
+};
+
+QStringList QVGGraphicsSystemPlugin::keys() const
+{
+ QStringList list;
+ list << "OpenVG";
+ return list;
+}
+
+QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system)
+{
+ if (system.toLower() == "openvg")
+ return new QVGLiteGraphicsSystem;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openvglite/openvglite.pro b/src/plugins/platforms/openvglite/openvglite.pro
new file mode 100644
index 0000000..9d7860a
--- /dev/null
+++ b/src/plugins/platforms/openvglite/openvglite.pro
@@ -0,0 +1,12 @@
+TARGET = qvglitegraphicssystem
+include(../../qpluginbase.pri)
+
+QT += openvg
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems
+
+SOURCES = main.cpp qgraphicssystem_vglite.cpp qwindowsurface_vglite.cpp
+HEADERS = qgraphicssystem_vglite.h qwindowsurface_vglite.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
+INSTALLS += target
diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp
new file mode 100644
index 0000000..5f7106e
--- /dev/null
+++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp
@@ -0,0 +1,193 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgraphicssystem_vglite.h"
+#include "qwindowsurface_vglite.h"
+#include <QtOpenVG/private/qpixmapdata_vg_p.h>
+#include <QtGui/private/qegl_p.h>
+#include <QtCore/qdebug.h>
+#ifdef OPENVG_USBHP_INIT
+extern "C" {
+#include <linuxusbhp.h>
+};
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QVGLiteGraphicsSystem::QVGLiteGraphicsSystem()
+ : w(0), h(0), d(0), dw(0), dh(0), physWidth(0), physHeight(0),
+ surface(0), context(0), rootWindow(0),
+ screenFormat(QImage::Format_RGB16), preservedSwap(false)
+{
+#ifdef OPENVG_USBHP_INIT
+ initLibrary();
+#endif
+
+ // The graphics system is also the screen definition.
+ mScreens.append(this);
+
+ QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY"));
+ QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
+
+ // Initialize EGL and create the global EGL context.
+ context = qt_vg_create_context(0);
+ if (!context) {
+ qFatal("QVGLiteGraphicsSystem: could not initialize EGL");
+ return;
+ }
+
+ // Get the root window handle to use. Default to zero.
+ QRegExp winidRx(QLatin1String("winid=?(\\d+)"));
+ int winidIdx = displayArgs.indexOf(winidRx);
+ int handle = 0;
+ if (winidIdx >= 0) {
+ winidRx.exactMatch(displayArgs.at(winidIdx));
+ handle = winidRx.cap(1).toInt();
+ }
+
+ // Create a full-screen window based on the native handle.
+ // If the context is premultiplied, the window should be too.
+ QEglProperties props;
+#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
+ EGLint surfaceType = 0;
+ if (context->configAttrib(EGL_SURFACE_TYPE, &surfaceType) &&
+ (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0)
+ props.setValue(EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE);
+#endif
+ rootWindow = eglCreateWindowSurface
+ (context->display(), context->config(),
+ (EGLNativeWindowType)handle, props.properties());
+ if (rootWindow == EGL_NO_SURFACE) {
+ delete context;
+ context = 0;
+ qFatal("QVGLiteGraphicsSystem: could not create full-screen window");
+ return;
+ }
+
+ // Try to turn on preserved swap behaviour on the root window.
+ // This will allow us to optimize compositing to focus on just
+ // the screen region that has changed. Otherwise we must
+ // re-composite the entire screen every frame.
+#if !defined(QVG_NO_PRESERVED_SWAP)
+ eglGetError(); // Clear error state first.
+ eglSurfaceAttrib(context->display(), rootWindow,
+ EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
+ preservedSwap = (eglGetError() == EGL_SUCCESS);
+#else
+ preservedSwap = false;
+#endif
+
+ // Fetch the root window properties.
+ eglQuerySurface(context->display(), rootWindow, EGL_WIDTH, &w);
+ eglQuerySurface(context->display(), rootWindow, EGL_HEIGHT, &h);
+ screenFormat = qt_vg_config_to_image_format(context);
+ switch (screenFormat) {
+ case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_ARGB32:
+ case QImage::Format_RGB32:
+ default:
+ d = 32;
+ break;
+ case QImage::Format_RGB16:
+ case QImage::Format_ARGB4444_Premultiplied:
+ d = 16;
+ break;
+ }
+ dw = w;
+ dh = h;
+ qDebug("screen size: %dx%dx%d", w, h, d);
+
+ // Handle display physical size spec. From qscreenlinuxfb_qws.cpp.
+ QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
+ int dimIdxW = displayArgs.indexOf(mmWidthRx);
+ QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
+ int dimIdxH = displayArgs.indexOf(mmHeightRx);
+ if (dimIdxW >= 0) {
+ mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
+ physWidth = mmWidthRx.cap(1).toInt();
+ if (dimIdxH < 0)
+ physHeight = dh*physWidth/dw;
+ }
+ if (dimIdxH >= 0) {
+ mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
+ physHeight = mmHeightRx.cap(1).toInt();
+ if (dimIdxW < 0)
+ physWidth = dw*physHeight/dh;
+ }
+ if (dimIdxW < 0 && dimIdxH < 0) {
+ const int dpi = 72;
+ physWidth = qRound(dw * 25.4 / dpi);
+ physHeight = qRound(dh * 25.4 / dpi);
+ }
+}
+
+QVGLiteGraphicsSystem::~QVGLiteGraphicsSystem()
+{
+}
+
+QPixmapData *QVGLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
+{
+#if !defined(QVGLite_NO_SINGLE_CONTEXT) && !defined(QVGLite_NO_PIXMAP_DATA)
+ // Pixmaps can use QVGLitePixmapData; bitmaps must use raster.
+ if (type == QPixmapData::PixmapType)
+ return new QVGPixmapData(type);
+ else
+ return new QRasterPixmapData(type);
+#else
+ return new QRasterPixmapData(type);
+#endif
+}
+
+QWindowSurface *QVGLiteGraphicsSystem::createWindowSurface(QWidget *widget) const
+{
+ if (widget->windowType() == Qt::Desktop)
+ return 0; // Don't create an explicit window surface for the destkop.
+ if (surface) {
+ qWarning() << "QVGLiteGraphicsSystem: only one window surface "
+ "is supported at a time";
+ return 0;
+ }
+ surface = new QVGLiteWindowSurface
+ (const_cast<QVGLiteGraphicsSystem *>(this), widget);
+ return surface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h
new file mode 100644
index 0000000..9d45bf9
--- /dev/null
+++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_VGLITE_H
+#define QGRAPHICSSYSTEM_VGLITE_H
+
+#include <QtGui/private/qgraphicssystem_p.h>
+#include <QtGui/private/qegl_p.h>
+#include <QtGui/qimage.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVGLiteWindowSurface;
+
+class QVGLiteGraphicsSystem : public QGraphicsSystem,
+ public QGraphicsSystemScreen
+{
+public:
+ QVGLiteGraphicsSystem();
+ ~QVGLiteGraphicsSystem();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QWindowSurface *createWindowSurface(QWidget *widget) const;
+ QList<QGraphicsSystemScreen *> screens() const { return mScreens; }
+
+ QRect geometry() const { return QRect(0, 0, w, h); }
+ int depth() const { return d; }
+ QImage::Format format() const { return screenFormat; }
+ QSize physicalSize() const { return QSize(physWidth, physHeight); }
+
+private:
+ friend class QVGLiteWindowSurface;
+
+ int w;
+ int h;
+ int d;
+
+ int dw;
+ int dh;
+
+ int physWidth;
+ int physHeight;
+
+ mutable QVGLiteWindowSurface *surface;
+ QEglContext *context;
+ EGLSurface rootWindow;
+ QImage::Format screenFormat;
+ bool preservedSwap;
+
+ QList<QGraphicsSystemScreen *> mScreens;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp
new file mode 100644
index 0000000..8432ad6
--- /dev/null
+++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowsurface_vglite.h"
+#include "qgraphicssystem_vglite.h"
+#include <QtOpenVG/qvg.h>
+#include <QtOpenVG/private/qvg_p.h>
+#include <QtOpenVG/private/qpaintengine_vg_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QVGLiteWindowSurface::QVGLiteWindowSurface
+ (QVGLiteGraphicsSystem *gs, QWidget *window)
+ : QWindowSurface(window), graphicsSystem(gs),
+ isPaintingActive(false), engine(0)
+{
+}
+
+QVGLiteWindowSurface::~QVGLiteWindowSurface()
+{
+ graphicsSystem->surface = 0;
+ if (engine)
+ qt_vg_destroy_paint_engine(engine);
+}
+
+QPaintDevice *QVGLiteWindowSurface::paintDevice()
+{
+ qt_vg_make_current(graphicsSystem->context, graphicsSystem->rootWindow);
+ isPaintingActive = true;
+ // TODO: clear the parts of the back buffer that are not
+ // covered by the window surface to black.
+ return this;
+}
+
+void QVGLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+ QEglContext *context = graphicsSystem->context;
+ if (context) {
+ if (!isPaintingActive)
+ qt_vg_make_current(context, graphicsSystem->rootWindow);
+ context->swapBuffers();
+ qt_vg_done_current(context);
+ context->setSurface(EGL_NO_SURFACE);
+ isPaintingActive = false;
+ }
+}
+
+void QVGLiteWindowSurface::setGeometry(const QRect &rect)
+{
+ QWindowSurface::setGeometry(rect);
+}
+
+bool QVGLiteWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ return QWindowSurface::scroll(area, dx, dy);
+}
+
+void QVGLiteWindowSurface::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+void QVGLiteWindowSurface::endPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+}
+
+QPaintEngine *QVGLiteWindowSurface::paintEngine() const
+{
+ if (!engine)
+ engine = qt_vg_create_paint_engine();
+ return engine;
+}
+
+// We need to get access to QWidget::metric() from QVGLiteWindowSurface::metric,
+// but it is not a friend of QWidget. To get around this, we create a
+// fake QX11PaintEngine class, which is a friend.
+class QX11PaintEngine
+{
+public:
+ static int metric(const QWidget *widget, QPaintDevice::PaintDeviceMetric met)
+ {
+ return widget->metric(met);
+ }
+};
+
+int QVGLiteWindowSurface::metric(PaintDeviceMetric met) const
+{
+ return QX11PaintEngine::metric(window(), met);
+}
diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h
new file mode 100644
index 0000000..6d66c42
--- /dev/null
+++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_VGLITE_H
+#define QWINDOWSURFACE_VGLITE_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 <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qegl_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVGLiteGraphicsSystem;
+class QVGPaintEngine;
+
+class Q_OPENVG_EXPORT QVGLiteWindowSurface : public QWindowSurface, public QPaintDevice
+{
+public:
+ QVGLiteWindowSurface(QVGLiteGraphicsSystem *gs, QWidget *window);
+ ~QVGLiteWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void setGeometry(const QRect &rect);
+ bool scroll(const QRegion &area, int dx, int dy);
+
+ void beginPaint(const QRegion &region);
+ void endPaint(const QRegion &region);
+
+ QPaintEngine *paintEngine() const;
+
+protected:
+ int metric(PaintDeviceMetric metric) const;
+
+private:
+ QVGLiteGraphicsSystem *graphicsSystem;
+ bool isPaintingActive;
+ mutable QVGPaintEngine *engine;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSURFACE_VGLITE_H
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
new file mode 100644
index 0000000..57015e7
--- /dev/null
+++ b/src/plugins/platforms/platforms.pro
@@ -0,0 +1,8 @@
+TEMPLATE = subdirs
+
+SUBDIRS += minimal
+
+contains(QT_CONFIG, wayland) {
+ SUBDIRS += wayland
+}
+
diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp
new file mode 100644
index 0000000..5c3b72b
--- /dev/null
+++ b/src/plugins/platforms/qvfb/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPlatformIntegrationPlugin>
+#include "qvfbintegration.h"
+#include <qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVFbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QVFbIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "QVFb";
+ return list;
+}
+
+QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "qvfb")
+ return new QVFbIntegration(paramList);
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(qvfb, QVFbIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro
new file mode 100644
index 0000000..d2b332a
--- /dev/null
+++ b/src/plugins/platforms/qvfb/qvfb.pro
@@ -0,0 +1,13 @@
+TARGET = qvfbintegration
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+
+SOURCES = main.cpp qvfbintegration.cpp qvfbwindowsurface.cpp
+HEADERS = qvfbintegration.h qvfbwindowsurface.h
+
+include(../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp
new file mode 100644
index 0000000..ddde800
--- /dev/null
+++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp
@@ -0,0 +1,448 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
+#include <qvfbhdr.h>
+#include <qsocketnotifier.h>
+
+#include "qvfbintegration.h"
+#include "qvfbwindowsurface.h"
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtCore/qdebug.h>
+#include <QMouseEvent>
+
+#include <qsocketnotifier.h>
+#include <QApplication>
+#include <QWindowSystemInterface>
+
+#include "qgenericunixfontdatabase.h"
+
+QT_BEGIN_NAMESPACE
+
+
+class QVFbScreenKeyboardHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QVFbScreenKeyboardHandler(int displayId);
+ ~QVFbScreenKeyboardHandler();
+
+private slots:
+ void readKeyboardData();
+
+private:
+ int kbdFD;
+ int kbdIdx;
+ int kbdBufferLen;
+ unsigned char *kbdBuffer;
+ QSocketNotifier *keyNotifier;
+};
+
+QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler(int displayId)
+{
+ const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId);
+
+
+ kbdFD = -1;
+ kbdIdx = 0;
+ kbdBufferLen = sizeof(QVFbKeyData) * 5;
+ kbdBuffer = new unsigned char [kbdBufferLen];
+
+ kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY);
+
+ if (kbdFD == -1) {
+ perror("QVFbScreenKeyboardHandler");
+ qWarning("QVFbScreenKeyboardHandler: Unable to open device %s",
+ qPrintable(keyboardDev));
+ return;
+ }
+
+ // Clear pending input
+ char buf[2];
+ while (QT_READ(kbdFD, buf, 1) > 0) { }
+
+ keyNotifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
+ connect(keyNotifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
+
+}
+
+QVFbScreenKeyboardHandler::~QVFbScreenKeyboardHandler()
+{
+ if (kbdFD >= 0)
+ QT_CLOSE(kbdFD);
+ delete [] kbdBuffer;
+}
+
+
+void QVFbScreenKeyboardHandler::readKeyboardData()
+{
+ int n;
+ do {
+ n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
+ if (n > 0)
+ kbdIdx += n;
+ } while (n > 0);
+
+ int idx = 0;
+ while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) {
+ QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx);
+ if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) {
+ // magic exit key
+ qWarning("Instructed to quit by Virtual Keyboard");
+ qApp->quit();
+ }
+
+ //QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat);
+
+ QEvent::Type type = kd->press ? QEvent::KeyPress : QEvent::KeyRelease;
+
+ QString text;
+ if (kd->unicode && kd->unicode != 0xffff)
+ text += QChar(kd->unicode);
+
+// qDebug() << "readKeyboardData" << type << hex << kd->keycode << kd->modifiers << text;
+
+ QWindowSystemInterface::handleKeyEvent(0, type, kd->keycode, kd->modifiers, text, kd->repeat, int(text.length()));
+ idx += sizeof(QVFbKeyData);
+ }
+
+ int surplus = kbdIdx - idx;
+ for (int i = 0; i < surplus; i++)
+ kbdBuffer[i] = kbdBuffer[idx+i];
+ kbdIdx = surplus;
+}
+
+
+
+
+class QVFbScreenMouseHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QVFbScreenMouseHandler(int displayId);
+ ~QVFbScreenMouseHandler();
+
+private slots:
+ void readMouseData();
+
+private:
+ int mouseFD;
+ int mouseIdx;
+ enum {mouseBufSize = 128};
+ uchar mouseBuf[mouseBufSize];
+ QSocketNotifier *mouseNotifier;
+
+ int oldButtonState;
+};
+
+QVFbScreenMouseHandler::QVFbScreenMouseHandler(int displayId)
+{
+ QString mouseDev = QT_VFB_MOUSE_PIPE(displayId);
+
+ mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
+
+ if (mouseFD == -1) {
+ perror("QVFbMouseHandler::QVFbMouseHandler");
+ qWarning("QVFbMouseHander: Unable to open device %s",
+ qPrintable(mouseDev));
+ return;
+ }
+
+ // Clear pending input
+ char buf[2];
+ while (QT_READ(mouseFD, buf, 1) > 0) { }
+
+ mouseIdx = 0;
+ oldButtonState = 0;
+ mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
+ connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
+}
+
+
+QVFbScreenMouseHandler::~QVFbScreenMouseHandler()
+{
+ if (mouseFD >= 0)
+ QT_CLOSE(mouseFD);
+}
+
+void QVFbScreenMouseHandler::readMouseData()
+{
+ int n;
+ do {
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
+ if (n > 0)
+ mouseIdx += n;
+ } while (n > 0);
+
+ int idx = 0;
+ static const int packetsize = sizeof(QPoint) + 2*sizeof(int);
+ while (mouseIdx-idx >= packetsize) {
+ uchar *mb = mouseBuf+idx;
+ QPoint mousePos = *reinterpret_cast<QPoint *>(mb);
+ mb += sizeof(QPoint);
+ int bstate = *reinterpret_cast<int *>(mb);
+ mb += sizeof(int);
+ //int wheel = *reinterpret_cast<int *>(mb);
+
+ int button = bstate ^ oldButtonState;
+ QEvent::Type type = QEvent::MouseMove;
+
+ if (button) {
+ type = (button & bstate) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
+ }
+ QWindowSystemInterface::handleMouseEvent(0, mousePos, mousePos, Qt::MouseButtons(bstate));
+
+// qDebug() << "readMouseData" << mousePos << button << bstate << oldButtonState << type;
+
+ oldButtonState = bstate;
+
+ idx += packetsize;
+ }
+
+ int surplus = mouseIdx - idx;
+ for (int i = 0; i < surplus; i++)
+ mouseBuf[i] = mouseBuf[idx+i];
+ mouseIdx = surplus;
+
+}
+
+
+class QVFbScreenPrivate
+{
+public:
+ QVFbScreenPrivate(int id)
+ : shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0)
+ {
+ displayId = id;
+ connect(displayId);
+ }
+
+ ~QVFbScreenPrivate() { disconnect(); }
+ void setDirty(const QRect &r);
+
+ bool connect(int displayId);
+ void disconnect();
+
+ QImage *screenImage() { return &img; }
+ QSize screenSize() { return img.size(); }
+
+ int depth() const { return img.depth(); }
+ QImage::Format format() const { return img.format(); }
+
+private:
+ unsigned char *shmrgn;
+ QVFbHeader *hdr;
+ uchar *data;
+ QVFbScreenMouseHandler *mouseHandler;
+ QVFbScreenKeyboardHandler *keyboardHandler;
+ int displayId;
+
+ QImage img;
+};
+
+
+void QVFbScreenPrivate::setDirty(const QRect &r)
+{
+ hdr->dirty = true;
+ hdr->update = hdr->update.united(r);
+}
+
+
+bool QVFbScreenPrivate::connect(int displayId)
+{
+ qDebug() << "QVFbScreenPrivate::connect" << displayId;
+ key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b');
+
+ if (key == -1)
+ return false;
+
+
+ int shmId = shmget(key, 0, 0);
+ if (shmId != -1)
+ shmrgn = (unsigned char *)shmat(shmId, 0, 0);
+ else
+ return false;
+
+ if ((long)shmrgn == -1 || shmrgn == 0) {
+ qDebug("No shmrgn %ld", (long)shmrgn);
+ return false;
+ }
+
+ hdr = (QVFbHeader *)shmrgn;
+ data = shmrgn + hdr->dataoffset;
+
+ int w = hdr->width;
+ int h = hdr->height;
+ int d = hdr->depth;
+ int lstep = hdr->linestep;
+
+ QImage::Format format = QImage::Format_Invalid;
+ if (d == 32)
+ format = QImage::Format_ARGB32_Premultiplied;
+ else if (d == 16)
+ format = QImage::Format_RGB16;
+
+
+ if (format == QImage::Format_Invalid) {
+ img = QImage();
+ return false;
+ }
+
+ img = QImage(data, w, h, lstep, format);
+
+ qDebug("connected %dx%d %d bpp", w, h, d);
+
+
+ mouseHandler = new QVFbScreenMouseHandler(displayId);
+ keyboardHandler = new QVFbScreenKeyboardHandler(displayId);
+ return true;
+}
+
+void QVFbScreenPrivate::disconnect()
+{
+ if ((long)shmrgn != -1 && shmrgn) {
+ shmdt((char*)shmrgn);
+ shmrgn = 0;
+ }
+ delete mouseHandler;
+ mouseHandler = 0;
+ delete keyboardHandler;
+ keyboardHandler = 0;
+}
+
+
+QVFbScreen::QVFbScreen(int id)
+{
+ d_ptr = new QVFbScreenPrivate(id);
+}
+
+
+QVFbScreen::~QVFbScreen()
+{
+ delete d_ptr;
+}
+
+void QVFbScreen::setDirty(const QRect &rect)
+{
+ d_ptr->setDirty(rect);
+}
+
+
+
+QRect QVFbScreen::geometry() const {
+ return QRect(QPoint(), d_ptr->screenSize());
+}
+
+
+int QVFbScreen::depth() const
+{
+ return d_ptr->depth();
+}
+
+QImage::Format QVFbScreen::format() const
+{
+ return d_ptr->format();
+}
+
+QSize QVFbScreen::physicalSize() const {
+ return (d_ptr->screenSize()*254)/720;
+}
+
+#if 0
+int QVFbScreen::linestep() const {
+ return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0;
+}
+
+uchar *QVFbScreen::base() const {
+ return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0;
+}
+#endif
+
+QImage *QVFbScreen::screenImage()
+{
+ return d_ptr->screenImage();
+}
+
+QVFbIntegration::QVFbIntegration(const QStringList &paramList)
+ : mFontDb(new QGenericUnixFontDatabase())
+{
+ int displayId = 0;
+ if (paramList.length() > 0)
+ displayId = paramList.at(0).toInt();
+
+ mPrimaryScreen = new QVFbScreen(displayId);
+
+ mScreens.append(mPrimaryScreen);
+}
+
+QPixmapData *QVFbIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QWindowSurface *QVFbIntegration::createWindowSurface(QWidget *widget, WId) const
+{
+ return new QVFbWindowSurface(mPrimaryScreen, widget);
+}
+
+
+QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) const
+{
+ return new QVFbWindow(mPrimaryScreen, widget);
+}
+
+QPlatformFontDatabase *QVFbIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QT_END_NAMESPACE
+
+#include "qvfbintegration.moc"
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h
new file mode 100644
index 0000000..33e31a5
--- /dev/null
+++ b/src/plugins/platforms/qvfb/qvfbintegration.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_QVFB_H
+#define QGRAPHICSSYSTEM_QVFB_H
+
+#include <QPlatformScreen>
+#include <QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+
+class QVFbScreenPrivate;
+
+class QVFbScreen : public QPlatformScreen
+{
+public:
+ QVFbScreen(int id);
+ ~QVFbScreen();
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+ QSize physicalSize() const;
+
+ QImage *screenImage();
+
+ void setDirty(const QRect &rect);
+
+public:
+
+ QVFbScreenPrivate *d_ptr;
+};
+
+class QVFbIntegrationPrivate;
+
+
+class QVFbIntegration : public QPlatformIntegration
+{
+public:
+ QVFbIntegration(const QStringList &paramList);
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QVFbScreen *mPrimaryScreen;
+ QList<QPlatformScreen *> mScreens;
+ QPlatformFontDatabase *mFontDb;
+};
+
+
+
+QT_END_NAMESPACE
+
+
+#endif
diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp
new file mode 100644
index 0000000..85918eb
--- /dev/null
+++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qvfbwindowsurface.h"
+#include "qvfbintegration.h"
+#include <QtCore/qdebug.h>
+#include <QtGui/qpainter.h>
+#include <private/qapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QVFbWindowSurface::QVFbWindowSurface(//QVFbIntegration *graphicsSystem,
+ QVFbScreen *screen, QWidget *window)
+ : QWindowSurface(window),
+ mScreen(screen)
+{
+}
+
+QVFbWindowSurface::~QVFbWindowSurface()
+{
+}
+
+QPaintDevice *QVFbWindowSurface::paintDevice()
+{
+ return mScreen->screenImage();
+}
+
+void QVFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+
+// QRect rect = geometry();
+// QPoint topLeft = rect.topLeft();
+
+ mScreen->setDirty(region.boundingRect());
+}
+
+void QVFbWindowSurface::resize(const QSize&)
+{
+
+// any size you like as long as it's full-screen...
+
+ QRect rect(mScreen->availableGeometry());
+ QWindowSurface::resize(rect.size());
+}
+
+
+QVFbWindow::QVFbWindow(QVFbScreen *screen, QWidget *window)
+ : QPlatformWindow(window),
+ mScreen(screen)
+{
+}
+
+
+void QVFbWindow::setGeometry(const QRect &)
+{
+
+// any size you like as long as it's full-screen...
+
+ QRect rect(mScreen->availableGeometry());
+ QWindowSystemInterface::handleGeometryChange(this->widget(), rect);
+
+ QPlatformWindow::setGeometry(rect);
+}
+
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.h b/src/plugins/platforms/qvfb/qvfbwindowsurface.h
new file mode 100644
index 0000000..9f828d3
--- /dev/null
+++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_QVFB_H
+#define QWINDOWSURFACE_QVFB_H
+
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QPlatformWindow>
+
+QT_BEGIN_NAMESPACE
+
+class QVFbIntegration;
+class QVFbScreen;
+
+class QVFbWindowSurface : public QWindowSurface
+{
+public:
+ QVFbWindowSurface(QVFbScreen *screen, QWidget *window);
+ ~QVFbWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+
+private:
+ QVFbScreen *mScreen;
+};
+
+class QVFbWindow : public QPlatformWindow
+{
+public:
+ QVFbWindow(QVFbScreen *screen, QWidget *window);
+ void setGeometry(const QRect &rect);
+
+private:
+ QVFbScreen *mScreen;
+};
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/uikit/README b/src/plugins/platforms/uikit/README
new file mode 100644
index 0000000..b2984fc
--- /dev/null
+++ b/src/plugins/platforms/uikit/README
@@ -0,0 +1,45 @@
+This is a proof-of-concept implemenation of a UIKit based
+QPA plugin. Note that this is completely unsupported, and it is probable
+that many parts of QtCore and other Qt Modules don't work properly.
+
+1) Build Qt
+
+The example Xcode project in the examples subdirectory requires that you do shadow
+builds of Qt in qt-lighthouse-ios-simulator and qt-lighthouse-ios-device directories
+parallel to the sources. To build for simulator make sure that both the Simulator
+configuration *and* the simulator specific target are active. To build for device
+make sure that both the Device configuration *and* the device specific target are
+active.
+
+The setup is configured to use the iOS 4.2 SDKs, you might want to edit the mkspecs
+to fit your need.
+
+After configuring and building Qt you need to also build src/plugins/platforms/uikit.
+
+Simulator:
+----------
+configure -qpa -xplatform qws/macx-iphonesimulator-g++ -arch i386 -developer-build -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations
+
+Device:
+-------
+configure -qpa -xplatform qws/macx-iphonedevice-g++ -arch armv7 -developer-build -release -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations
+
+2) XCode setup:
+- there are examples in the examples subdirectory of the platform plugin
+- to create something fresh do something like:
+ - Xcode: Create a "View-based Appplication"
+ - remove the nibs and view controller and app controller files
+ - remove the reference to "Main nib file" from plist file
+ - create a main.mm like in the examples
+ - add the qmlapplicationviewer sources to your project (including the moc_*.h)
+ (best to link, not copy), the code for this is from the Qt Creator
+ mobile Qt Quick application template
+ - Add the Qt .a libraries, uikit platform plugin and libz (v1.2.3) to Frameworks
+ - add "$(SRCROOT)/../../../../qt-lighthouse-ios-device/include" (or -simulator)
+ to the include search paths.
+ - add "$(SRCROOT)/../qmltest" to the include search path if you didn't copy but
+ linked to the qmlapplicationviewer
+ - for device set the architecture to armv7 only
+
+3) Done: Build and Run.
+
diff --git a/src/plugins/platforms/uikit/examples/qmltest/main.mm b/src/plugins/platforms/uikit/examples/qmltest/main.mm
new file mode 100644
index 0000000..6fd5629
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/main.mm
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// main.m
+// qmltest
+//
+// Created by Eike Troll on 18.02.11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#include "qmlapplicationviewer/qmlapplicationviewer.h"
+
+#include <QtGui/QApplication>
+#include <QtCore/QtPlugin>
+
+Q_IMPORT_PLUGIN(UIKit)
+
+int main(int argc, char *argv[]) {
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ setenv("QT_QPA_PLATFORM","uikit",1);
+
+ QApplication app(argc, argv);
+ QmlApplicationViewer viewer;
+ viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
+ viewer.setMainQmlFile(QString::fromUtf8([[resourcePath stringByAppendingPathComponent:@"qml/main.qml"] UTF8String]));
+ viewer.showMaximized();
+ int retVal = app.exec();
+ [pool release];
+ return retVal;
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml b/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml
new file mode 100644
index 0000000..889a6d0
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * 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.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+** OWNER OR 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."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ id: box
+ width: 350; height: 250
+
+ Rectangle {
+ id: redSquare
+ width: 80; height: 80
+ anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
+ color: "red"
+
+ Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onEntered: info.text = 'Entered'
+ onExited: info.text = 'Exited (pressed=' + pressed + ')'
+
+ onPressed: {
+ info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left')
+ + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')'
+ var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y)
+ posInfo.text = + mouse.x + ',' + mouse.y + ' in square'
+ + ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
+ }
+
+ onReleased: {
+ info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
+ posInfo.text = ''
+ }
+
+ onPressAndHold: info.text = 'Press and hold'
+ onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
+ onDoubleClicked: info.text = 'Double clicked'
+ }
+ }
+
+ Rectangle {
+ id: blueSquare
+ width: 80; height: 80
+ x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors
+ color: "blue"
+
+ Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: blueSquare
+ drag.axis: Drag.XandYAxis
+ drag.minimumX: 0
+ drag.maximumX: box.width - parent.width
+ drag.minimumY: 0
+ drag.maximumY: box.height - parent.width
+ }
+ }
+
+ Text {
+ id: info
+ anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+
+ onTextChanged: console.log(text)
+ }
+
+ Text {
+ id: posInfo
+ anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+ }
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp
new file mode 100644
index 0000000..a2b40ec
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+** Meta object code from reading C++ file 'qmlapplicationviewer.h'
+**
+** Created: Fri Feb 18 17:53:42 2011
+** by: The Qt Meta Object Compiler version 62 (Qt 4.7.2)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "qmlapplicationviewer.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'qmlapplicationviewer.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 62
+#error "This file was generated using the moc from 4.7.2. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_QmlApplicationViewer[] = {
+
+ // content:
+ 5, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_QmlApplicationViewer[] = {
+ "QmlApplicationViewer\0"
+};
+
+const QMetaObject QmlApplicationViewer::staticMetaObject = {
+ { &QDeclarativeView::staticMetaObject, qt_meta_stringdata_QmlApplicationViewer,
+ qt_meta_data_QmlApplicationViewer, 0 }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &QmlApplicationViewer::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *QmlApplicationViewer::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *QmlApplicationViewer::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_QmlApplicationViewer))
+ return static_cast<void*>(const_cast< QmlApplicationViewer*>(this));
+ return QDeclarativeView::qt_metacast(_clname);
+}
+
+int QmlApplicationViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QDeclarativeView::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp
new file mode 100644
index 0000000..72f8c52
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// checksum 0x17fa version 0x3000a
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qmlapplicationviewer.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
+
+#if defined(QMLJSDEBUGGER)
+#include <qt_private/qdeclarativedebughelper_p.h>
+#endif
+
+#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
+#include <jsdebuggeragent.h>
+#endif
+#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
+#include <qdeclarativeviewobserver.h>
+#endif
+
+#if defined(QMLJSDEBUGGER)
+
+// Enable debugging before any QDeclarativeEngine is created
+struct QmlJsDebuggingEnabler
+{
+ QmlJsDebuggingEnabler()
+ {
+ QDeclarativeDebugHelper::enableDebugging();
+ }
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+static QmlJsDebuggingEnabler enableDebuggingHelper;
+
+#endif // QMLJSDEBUGGER
+
+class QmlApplicationViewerPrivate
+{
+ QString mainQmlFile;
+ friend class QmlApplicationViewer;
+ static QString adjustPath(const QString &path);
+};
+
+QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
+{
+#ifdef Q_OS_UNIX
+#ifdef Q_OS_MAC
+ if (!QDir::isAbsolutePath(path))
+ return QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/") + path;
+#else
+ const QString pathInShareDir = QCoreApplication::applicationDirPath()
+ + QLatin1String("/../share/")
+ + QFileInfo(QCoreApplication::applicationFilePath()).fileName()
+ + QLatin1Char('/') + path;
+ if (QFileInfo(pathInShareDir).exists())
+ return pathInShareDir;
+#endif
+#endif
+ return path;
+}
+
+QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) :
+ QDeclarativeView(parent),
+ m_d(new QmlApplicationViewerPrivate)
+{
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QDeclarativeView::SizeRootObjectToView);
+#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
+ new QmlJSDebugger::JSDebuggerAgent(engine());
+#endif
+#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
+ new QmlJSDebugger::QDeclarativeViewObserver(this, parent);
+#endif
+}
+
+QmlApplicationViewer::~QmlApplicationViewer()
+{
+ delete m_d;
+}
+
+void QmlApplicationViewer::setMainQmlFile(const QString &file)
+{
+ m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
+ setSource(QUrl::fromLocalFile(m_d->mainQmlFile));
+}
+
+void QmlApplicationViewer::addImportPath(const QString &path)
+{
+ engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
+}
+
+void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
+{
+//#if defined(Q_OS_SYMBIAN)
+// // If the version of Qt on the device is < 4.7.2, that attribute won't work
+// if (orientation != ScreenOrientationAuto) {
+// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
+// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
+// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
+// return;
+// }
+// }
+//#endif // Q_OS_SYMBIAN
+//
+// Qt::WidgetAttribute attribute;
+// switch (orientation) {
+//#if QT_VERSION < 0x040702
+// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
+// case ScreenOrientationLockPortrait:
+// attribute = static_cast<Qt::WidgetAttribute>(128);
+// break;
+// case ScreenOrientationLockLandscape:
+// attribute = static_cast<Qt::WidgetAttribute>(129);
+// break;
+// default:
+// case ScreenOrientationAuto:
+// attribute = static_cast<Qt::WidgetAttribute>(130);
+// break;
+//#else // QT_VERSION < 0x040702
+// case ScreenOrientationLockPortrait:
+// attribute = Qt::WA_LockPortraitOrientation;
+// break;
+// case ScreenOrientationLockLandscape:
+// attribute = Qt::WA_LockLandscapeOrientation;
+// break;
+// default:
+// case ScreenOrientationAuto:
+// attribute = Qt::WA_AutoOrientation;
+// break;
+//#endif // QT_VERSION < 0x040702
+// };
+// setAttribute(attribute, true);
+}
+
+void QmlApplicationViewer::showExpanded()
+{
+#ifdef Q_OS_SYMBIAN
+ showFullScreen();
+#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ showMaximized();
+#else
+ show();
+#endif
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h
new file mode 100644
index 0000000..01b2af0
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// checksum 0x5a59 version 0x3000a
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QMLAPPLICATIONVIEWER_H
+#define QMLAPPLICATIONVIEWER_H
+
+#include <QtDeclarative/QDeclarativeView>
+
+class QmlApplicationViewer : public QDeclarativeView
+{
+ Q_OBJECT
+
+public:
+ enum ScreenOrientation {
+ ScreenOrientationLockPortrait,
+ ScreenOrientationLockLandscape,
+ ScreenOrientationAuto
+ };
+
+ explicit QmlApplicationViewer(QWidget *parent = 0);
+ virtual ~QmlApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+ void setOrientation(ScreenOrientation orientation);
+ void showExpanded();
+
+private:
+ class QmlApplicationViewerPrivate *m_d;
+};
+
+#endif // QMLAPPLICATIONVIEWER_H
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist
new file mode 100644
index 0000000..1566585
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+</dict>
+</plist>
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj
new file mode 100755
index 0000000..fc4f1df
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj
@@ -0,0 +1,463 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
+ D3CAA7C813264AAD008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; };
+ D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; };
+ D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; };
+ D3CAA7EC13264F52008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; };
+ D3CAA7ED13264F52008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; };
+ D3CAA7EE13264F52008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; };
+ D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
+ D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
+ D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; };
+ D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; };
+ D3CAA81B13265056008BB877 /* libQtCore_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81613265056008BB877 /* libQtCore_debug.a */; };
+ D3CAA81C13265056008BB877 /* libQtDeclarative_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */; };
+ D3CAA81D13265056008BB877 /* libQtGui_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81813265056008BB877 /* libQtGui_debug.a */; };
+ D3CAA81E13265056008BB877 /* libQtScript_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81913265056008BB877 /* libQtScript_debug.a */; };
+ D3CAA81F13265056008BB877 /* libQtSql_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81A13265056008BB877 /* libQtSql_debug.a */; };
+ D3CAA8211326507D008BB877 /* libquikit_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA8201326507D008BB877 /* libquikit_debug.a */; };
+ D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA82713265220008BB877 /* libQtNetwork_debug.a */; };
+ D3CAA88A132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; };
+ D3CAA88B132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; };
+ D3CAA89113265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; };
+ D3CAA89213265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; };
+ D3D817B2132A2CFD00CDE422 /* libQtCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AA132A2CFD00CDE422 /* libQtCore.a */; };
+ D3D817B3132A2CFD00CDE422 /* libQtDeclarative.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */; };
+ D3D817B4132A2CFD00CDE422 /* libQtGui.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AC132A2CFD00CDE422 /* libQtGui.a */; };
+ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */; };
+ D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AE132A2CFD00CDE422 /* libQtScript.a */; };
+ D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AF132A2CFD00CDE422 /* libQtSql.a */; };
+ D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B0132A2CFD00CDE422 /* libQtXml.a */; };
+ D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */; };
+ D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817BA132A2D0E00CDE422 /* libquikit.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 1D6058910D05DD3D006BFB54 /* qmltest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = qmltest.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 32CA4F630368D1EE00C91783 /* qmltest_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = qmltest_Prefix.pch; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* qmltest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "qmltest-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
+ D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
+ D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = "<group>"; };
+ D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = "<group>"; };
+ D3CAA7E513264EA6008BB877 /* qmlapplicationviewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qmlapplicationviewer.h; path = qmlapplicationviewer/qmlapplicationviewer.h; sourceTree = "<group>"; };
+ D3CAA7F613264F52008BB877 /* qmltest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = qmltest.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.3.dylib; path = usr/lib/libz.1.2.3.dylib; sourceTree = SDKROOT; };
+ D3CAA81613265056008BB877 /* libQtCore_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtCore_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtDeclarative_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81813265056008BB877 /* libQtGui_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtGui_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtGui_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81913265056008BB877 /* libQtScript_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtScript_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81A13265056008BB877 /* libQtSql_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtSql_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA8201326507D008BB877 /* libquikit_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms/libquikit_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA82713265220008BB877 /* libQtNetwork_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtNetwork_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA836132652E5008BB877 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fonts; path = ../../../../../../lib/fonts; sourceTree = SOURCE_ROOT; };
+ D3CAA88E13265310008BB877 /* qml */ = {isa = PBXFileReference; lastKnownFileType = folder; path = qml; sourceTree = SOURCE_ROOT; };
+ D3D817AA132A2CFD00CDE422 /* libQtCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtCore.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtDeclarative.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AC132A2CFD00CDE422 /* libQtGui.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtGui.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtGui.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtNetwork.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AE132A2CFD00CDE422 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtScript.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AF132A2CFD00CDE422 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtSql.a"; sourceTree = SOURCE_ROOT; };
+ D3D817B0132A2CFD00CDE422 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXml.a"; sourceTree = SOURCE_ROOT; };
+ D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXmlPatterns.a"; sourceTree = SOURCE_ROOT; };
+ D3D817BA132A2D0E00CDE422 /* libquikit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit.a; path = "../../../../../../../qt-lighthouse-ios-device/plugins/platforms/libquikit.a"; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
+ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
+ D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */,
+ D3CAA81B13265056008BB877 /* libQtCore_debug.a in Frameworks */,
+ D3CAA81C13265056008BB877 /* libQtDeclarative_debug.a in Frameworks */,
+ D3CAA81D13265056008BB877 /* libQtGui_debug.a in Frameworks */,
+ D3CAA81E13265056008BB877 /* libQtScript_debug.a in Frameworks */,
+ D3CAA81F13265056008BB877 /* libQtSql_debug.a in Frameworks */,
+ D3CAA8211326507D008BB877 /* libquikit_debug.a in Frameworks */,
+ D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7EF13264F52008BB877 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */,
+ D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */,
+ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */,
+ D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */,
+ D3D817B2132A2CFD00CDE422 /* libQtCore.a in Frameworks */,
+ D3D817B3132A2CFD00CDE422 /* libQtDeclarative.a in Frameworks */,
+ D3D817B4132A2CFD00CDE422 /* libQtGui.a in Frameworks */,
+ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */,
+ D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */,
+ D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */,
+ D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */,
+ D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */,
+ D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 19C28FACFE9D520D11CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 1D6058910D05DD3D006BFB54 /* qmltest.app */,
+ D3CAA7F613264F52008BB877 /* qmltest.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
+ isa = PBXGroup;
+ children = (
+ 29B97315FDCFA39411CA2CEA /* Other Sources */,
+ 29B97317FDCFA39411CA2CEA /* Resources */,
+ D3CAA7E213264E8C008BB877 /* QMLApplicationViewer */,
+ 29B97323FDCFA39411CA2CEA /* Frameworks */,
+ 19C28FACFE9D520D11CA2CBB /* Products */,
+ );
+ name = CustomTemplate;
+ sourceTree = "<group>";
+ };
+ 29B97315FDCFA39411CA2CEA /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 32CA4F630368D1EE00C91783 /* qmltest_Prefix.pch */,
+ D3CAA7C713264AAD008BB877 /* main.mm */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+ 29B97317FDCFA39411CA2CEA /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA88E13265310008BB877 /* qml */,
+ D3CAA836132652E5008BB877 /* fonts */,
+ 8D1107310486CEB800E47090 /* qmltest-Info.plist */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA81513265035008BB877 /* Simulator */,
+ D3CAA8141326500A008BB877 /* Device */,
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
+ 1D30AB110D05D00D00671497 /* Foundation.framework */,
+ 288765A40DF7441C002DB57D /* CoreGraphics.framework */,
+ D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ D3CAA7E213264E8C008BB877 /* QMLApplicationViewer */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */,
+ D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */,
+ D3CAA7E513264EA6008BB877 /* qmlapplicationviewer.h */,
+ );
+ name = QMLApplicationViewer;
+ sourceTree = "<group>";
+ };
+ D3CAA8141326500A008BB877 /* Device */ = {
+ isa = PBXGroup;
+ children = (
+ D3D817BA132A2D0E00CDE422 /* libquikit.a */,
+ D3D817AA132A2CFD00CDE422 /* libQtCore.a */,
+ D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */,
+ D3D817AC132A2CFD00CDE422 /* libQtGui.a */,
+ D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */,
+ D3D817AE132A2CFD00CDE422 /* libQtScript.a */,
+ D3D817AF132A2CFD00CDE422 /* libQtSql.a */,
+ D3D817B0132A2CFD00CDE422 /* libQtXml.a */,
+ D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */,
+ );
+ name = Device;
+ sourceTree = "<group>";
+ };
+ D3CAA81513265035008BB877 /* Simulator */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA8201326507D008BB877 /* libquikit_debug.a */,
+ D3CAA81613265056008BB877 /* libQtCore_debug.a */,
+ D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */,
+ D3CAA81813265056008BB877 /* libQtGui_debug.a */,
+ D3CAA82713265220008BB877 /* libQtNetwork_debug.a */,
+ D3CAA81913265056008BB877 /* libQtScript_debug.a */,
+ D3CAA81A13265056008BB877 /* libQtSql_debug.a */,
+ );
+ name = Simulator;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 1D6058900D05DD3D006BFB54 /* qmltest simulator */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "qmltest simulator" */;
+ buildPhases = (
+ 1D60588D0D05DD3D006BFB54 /* Resources */,
+ 1D60588E0D05DD3D006BFB54 /* Sources */,
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "qmltest simulator";
+ productName = qmltest;
+ productReference = 1D6058910D05DD3D006BFB54 /* qmltest.app */;
+ productType = "com.apple.product-type.application";
+ };
+ D3CAA7E813264F52008BB877 /* qmltest device */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = D3CAA7F313264F52008BB877 /* Build configuration list for PBXNativeTarget "qmltest device" */;
+ buildPhases = (
+ D3CAA7E913264F52008BB877 /* Resources */,
+ D3CAA7EB13264F52008BB877 /* Sources */,
+ D3CAA7EF13264F52008BB877 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "qmltest device";
+ productName = qmltest;
+ productReference = D3CAA7F613264F52008BB877 /* qmltest.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 29B97313FDCFA39411CA2CEA /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "qmltest" */;
+ compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
+ hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
+ mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 1D6058900D05DD3D006BFB54 /* qmltest simulator */,
+ D3CAA7E813264F52008BB877 /* qmltest device */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 1D60588D0D05DD3D006BFB54 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA88A132652E5008BB877 /* fonts in Resources */,
+ D3CAA89113265310008BB877 /* qml in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7E913264F52008BB877 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA88B132652E5008BB877 /* fonts in Resources */,
+ D3CAA89213265310008BB877 /* qml in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 1D60588E0D05DD3D006BFB54 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7C813264AAD008BB877 /* main.mm in Sources */,
+ D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */,
+ D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7EB13264F52008BB877 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7EC13264F52008BB877 /* main.mm in Sources */,
+ D3CAA7ED13264F52008BB877 /* moc_qmlapplicationviewer.cpp in Sources */,
+ D3CAA7EE13264F52008BB877 /* qmlapplicationviewer.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1D6058940D05DD3E006BFB54 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ };
+ name = Debug;
+ };
+ 1D6058950D05DD3E006BFB54 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ C01FCF4F08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ C01FCF5008A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ PREBINDING = NO;
+ SDKROOT = iphoneos;
+ };
+ name = Release;
+ };
+ D3CAA7F413264F52008BB877 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ };
+ name = Debug;
+ };
+ D3CAA7F513264F52008BB877 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "qmltest simulator" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1D6058940D05DD3E006BFB54 /* Debug */,
+ 1D6058950D05DD3E006BFB54 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C01FCF4E08A954540054247B /* Build configuration list for PBXProject "qmltest" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4F08A954540054247B /* Debug */,
+ C01FCF5008A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ D3CAA7F313264F52008BB877 /* Build configuration list for PBXNativeTarget "qmltest device" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D3CAA7F413264F52008BB877 /* Debug */,
+ D3CAA7F513264F52008BB877 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch b/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch
new file mode 100644
index 0000000..c06715c
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch
@@ -0,0 +1,8 @@
+//
+// Prefix header for all source files of the 'qmltest' target in the 'qmltest' project
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <UIKit/UIKit.h>
+#endif
diff --git a/src/plugins/platforms/uikit/main.mm b/src/plugins/platforms/uikit/main.mm
new file mode 100644
index 0000000..1ef69fa
--- /dev/null
+++ b/src/plugins/platforms/uikit/main.mm
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "quikitintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QUIKitIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "UIKit";
+ return list;
+}
+
+QPlatformIntegration * QUIKitIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "uikit")
+ return new QUIKitIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(UIKit, QUIKitIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikiteventloop.h b/src/plugins/platforms/uikit/quikiteventloop.h
new file mode 100644
index 0000000..cf5c682
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikiteventloop.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUIKITEVENTLOOP_H
+#define QUIKITEVENTLOOP_H
+
+#include <QtGui/QPlatformEventLoopIntegration>
+
+@class EventLoopHelper;
+@class NSTimer;
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitEventLoop : public QPlatformEventLoopIntegration
+{
+public:
+ QUIKitEventLoop();
+ ~QUIKitEventLoop();
+
+ void startEventLoop();
+ void quitEventLoop();
+ void qtNeedsToProcessEvents();
+
+ EventLoopHelper *mHelper;
+ NSTimer *mTimer;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm
new file mode 100644
index 0000000..70757b1
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikiteventloop.mm
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quikiteventloop.h"
+#include "quikitwindow.h"
+#include "quikitwindowsurface.h"
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QApplication>
+#include <QtGui/QWidget>
+#include <QtDebug>
+
+@interface QUIKitAppDelegate : NSObject <UIApplicationDelegate> {
+}
+@end
+
+@interface EventLoopHelper : NSObject {
+ QUIKitEventLoop *mIntegration;
+}
+
+- (id)initWithEventLoopIntegration:(QUIKitEventLoop *)integration;
+
+- (void)processEvents;
+- (void)processEventsAndSchedule;
+
+@end
+
+@implementation QUIKitAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ Q_UNUSED(launchOptions)
+ foreach (QWidget *widget, qApp->topLevelWidgets()) {
+ QRect geom = widget->geometry();
+ CGRect bar = application.statusBarFrame;
+ if (geom.y() <= bar.size.height) {
+ geom.setY(bar.size.height);
+ widget->setGeometry(geom);
+ }
+ QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow());
+ platformWindow->ensureNativeWindow();
+ QUIKitWindowSurface *surface = static_cast<QUIKitWindowSurface*>(widget->windowSurface());
+ UIView *view = surface->nativeView();
+ [platformWindow->nativeWindow() addSubview:view];
+ [platformWindow->nativeWindow() makeKeyAndVisible];
+ }
+ return YES;
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ Q_UNUSED(application)
+ // TODO this isn't called for some reason
+ qDebug() << "quit";
+ qApp->quit();
+}
+
+@end
+
+@implementation EventLoopHelper
+
+- (id)initWithEventLoopIntegration:(QUIKitEventLoop *)integration
+{
+ if ((self = [self init])) {
+ mIntegration = integration;
+ }
+ return self;
+}
+
+- (void)processEvents
+{
+ QPlatformEventLoopIntegration::processEvents();
+}
+
+- (void)processEventsAndSchedule
+{
+ QPlatformEventLoopIntegration::processEvents();
+ qint64 nextTime = mIntegration->nextTimerEvent();
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSDate *nextDate = [[NSDate date] dateByAddingTimeInterval:((double)nextTime/1000)];
+ [mIntegration->mTimer setFireDate:nextDate];
+ [pool release];
+}
+
+@end
+
+QT_BEGIN_NAMESPACE
+
+QUIKitEventLoop::QUIKitEventLoop()
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ mHelper = [[EventLoopHelper alloc] initWithEventLoopIntegration:this];
+ mTimer = [[NSTimer timerWithTimeInterval:0.030 target:mHelper selector:@selector(processEventsAndSchedule) userInfo:nil repeats:YES] retain];
+ [pool release];
+}
+
+QUIKitEventLoop::~QUIKitEventLoop()
+{
+ [mTimer release];
+ [mHelper release];
+}
+
+void QUIKitEventLoop::startEventLoop()
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ [[NSRunLoop currentRunLoop] addTimer:[mTimer autorelease] forMode:NSDefaultRunLoopMode];
+ UIApplicationMain(qApp->argc(), qApp->argv(), nil, @"QUIKitAppDelegate");
+ [pool release];
+}
+
+void QUIKitEventLoop::quitEventLoop()
+{
+
+}
+
+void QUIKitEventLoop::qtNeedsToProcessEvents()
+{
+ [mHelper performSelectorOnMainThread:@selector(processEvents) withObject:nil waitUntilDone:NO];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitintegration.h b/src/plugins/platforms/uikit/quikitintegration.h
new file mode 100644
index 0000000..a986e92
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitintegration.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_UIKIT_H
+#define QPLATFORMINTEGRATION_UIKIT_H
+
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitIntegration : public QPlatformIntegration
+{
+public:
+ QUIKitIntegration();
+ ~QUIKitIntegration();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+ QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+private:
+ QList<QPlatformScreen *> mScreens;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm
new file mode 100644
index 0000000..d4b4192
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitintegration.mm
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quikitintegration.h"
+#include "quikitwindow.h"
+#include "quikitwindowsurface.h"
+#include "quikitscreen.h"
+#include "quikiteventloop.h"
+
+#include <QtGui/QApplication>
+
+#include <private/qpixmap_raster_p.h>
+
+#include <UIKit/UIKit.h>
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitIntegration::QUIKitIntegration()
+{
+ mScreens << new QUIKitScreen(0);
+}
+
+QUIKitIntegration::~QUIKitIntegration()
+{
+}
+
+QPixmapData *QUIKitIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QUIKitIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QUIKitWindow(widget);
+}
+
+QList<QPlatformScreen *> QUIKitIntegration::screens() const
+{
+ return mScreens;
+}
+
+QWindowSurface *QUIKitIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QUIKitWindowSurface(widget);
+}
+
+QPlatformEventLoopIntegration *QUIKitIntegration::createEventLoopIntegration() const
+{
+ return new QUIKitEventLoop();
+}
+
+QPlatformFontDatabase * QUIKitIntegration::fontDatabase() const
+{
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ setenv("QT_QPA_FONTDIR",[[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"fonts"] UTF8String],1);
+ }
+ return QPlatformIntegration::fontDatabase();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitscreen.h b/src/plugins/platforms/uikit/quikitscreen.h
new file mode 100644
index 0000000..15c7d69
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitscreen.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUIKITSCREEN_H
+#define QUIKITSCREEN_H
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitScreen : public QPlatformScreen
+{
+public:
+ QUIKitScreen(int screenIndex);
+ ~QUIKitScreen();
+
+ QRect geometry() const { return m_geometry; }
+ int depth() const { return m_depth; }
+ QImage::Format format() const { return m_format; }
+ QSize physicalSize() const { return m_physicalSize; }
+
+ UIScreen *uiScreen() const;
+
+private:
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QSize m_physicalSize;
+ int m_index;
+};
+
+QT_END_NAMESPACE
+
+
+#endif
diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm
new file mode 100644
index 0000000..ec94e3a
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitscreen.mm
@@ -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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quikitscreen.h"
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitScreen::QUIKitScreen(int screenIndex)
+ : QPlatformScreen(),
+ m_index(screenIndex)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex];
+ UIScreenMode *mode = [screen currentMode];
+ CGSize size = [mode size];
+ m_geometry = QRect(0, 0, size.width, size.height);
+ CGRect bounds = [screen bounds]; // in 'points', 1p == 1/160in
+
+// qreal xDpi = size.width * 160. / bounds.size.width;
+// qreal yDpi = size.height * 160. / bounds.size.height;
+// qDebug() << xDpi << yDpi;
+
+ m_format = QImage::Format_ARGB32;
+
+ m_depth = 24;
+
+ const qreal inch = 25.4;
+ m_physicalSize = QSize(qRound(bounds.size.width * inch / 160.), qRound(bounds.size.height * inch / 160.));
+ [pool release];
+}
+
+QUIKitScreen::~QUIKitScreen()
+{
+}
+
+UIScreen *QUIKitScreen::uiScreen() const
+{
+ return [[UIScreen screens] objectAtIndex:m_index];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h
new file mode 100644
index 0000000..d5a6690
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindow.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUIKITWINDOW_H
+#define QUIKITWINDOW_H
+
+#include <QPlatformWindow>
+#include <UIKit/UIKit.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitScreen;
+
+class QUIKitWindow : public QPlatformWindow
+{
+public:
+ explicit QUIKitWindow(QWidget *tlw);
+ ~QUIKitWindow();
+
+ UIWindow *nativeWindow() const { return mWindow; }
+ void setGeometry(const QRect &rect);
+
+ UIWindow *ensureNativeWindow();
+
+private:
+ QUIKitScreen *mScreen;
+ UIWindow *mWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif // QUIKITWINDOW_H
diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm
new file mode 100644
index 0000000..ebdee06
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindow.mm
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quikitwindow.h"
+
+#include "quikitscreen.h"
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitWindow::QUIKitWindow(QWidget *tlw) :
+ QPlatformWindow(tlw),
+ mWindow(nil)
+{
+ mScreen = static_cast<QUIKitScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+ CGRect screenBounds = [mScreen->uiScreen() bounds];
+ QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height);
+ setGeometry(geom);
+ // TODO ensure the native window if the application is already running
+}
+
+QUIKitWindow::~QUIKitWindow()
+{
+ [mWindow release];
+}
+
+void QUIKitWindow::setGeometry(const QRect &rect)
+{
+ if (mWindow) {
+ mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
+ [mWindow setNeedsDisplay];
+ }
+ QPlatformWindow::setGeometry(rect);
+}
+
+UIWindow *QUIKitWindow::ensureNativeWindow()
+{
+ if (!mWindow) {
+ CGRect screenBounds = [mScreen->uiScreen() bounds];
+ QRect geom = geometry();
+ CGRect frame = CGRectMake(geom.x(), geom.y(), geom.width(), geom.height());
+ mWindow = [[UIWindow alloc] initWithFrame:frame];
+ mWindow.screen = mScreen->uiScreen();
+ mWindow.frame = frame; // for some reason setting the screen resets frame.origin
+ [mWindow setNeedsDisplay];
+ }
+ return mWindow;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.h b/src/plugins/platforms/uikit/quikitwindowsurface.h
new file mode 100644
index 0000000..50d02b4
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindowsurface.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUIKITWINDOWSURFACE_H
+#define QUIKITWINDOWSURFACE_H
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QImage>
+#include <QtGui/QWindowSystemInterface>
+
+#include <UIKit/UIKit.h>
+
+@interface QImageView : UIView
+{
+ CGImageRef m_cgImage;
+ QWidget *m_widget;
+}
+
+- (void)setImage:(QImage *)image;
+- (void)setWidget:(QWidget *)widget;
+
+//- (QList<struct QWindowSystemInterface::TouchPoint>)touchPointsForTouches:(NSSet *)touches;
+- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons;
+@end
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitWindowSurface : public QWindowSurface
+{
+public:
+ QUIKitWindowSurface(QWidget *window);
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize (const QSize &size);
+
+ QImageView *nativeView() const { return mView; }
+private:
+ QImage *mImage;
+ QImageView *mView;
+};
+
+QT_END_NAMESPACE
+
+#endif // QUIKITWINDOWSURFACE_H
diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.mm b/src/plugins/platforms/uikit/quikitwindowsurface.mm
new file mode 100644
index 0000000..1274fca
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindowsurface.mm
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "quikitwindowsurface.h"
+#include "quikitwindow.h"
+
+#include <QtDebug>
+
+@implementation QImageView
+
+- (void)dealloc
+{
+ CGImageRelease(m_cgImage);
+ [super dealloc];
+}
+
+- (void)setImage:(QImage *)image
+{
+ CGImageRelease(m_cgImage);
+
+ const uchar *imageData = image->bits();
+ int bitDepth = image->depth();
+ int colorBufferSize = 8;
+ int bytesPrLine = image->bytesPerLine();
+ int width = image->width();
+ int height = image->height();
+
+ CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
+
+ CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData(
+ NULL,
+ imageData,
+ image->byteCount(),
+ NULL);
+
+ m_cgImage = CGImageCreate(width,
+ height,
+ colorBufferSize,
+ bitDepth,
+ bytesPrLine,
+ cgColourSpaceRef,
+ kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
+ cgDataProviderRef,
+ NULL,
+ false,
+ kCGRenderingIntentDefault);
+
+ CGDataProviderRelease(cgDataProviderRef);
+ CGColorSpaceRelease(cgColourSpaceRef);
+}
+
+- (void)setWidget:(QWidget *)widget
+{
+ m_widget = widget;
+}
+
+- (void)drawRect:(CGRect)rect
+{
+
+ if (!m_cgImage)
+ return;
+
+ CGContextRef cgContext = UIGraphicsGetCurrentContext();
+ CGContextSaveGState( cgContext );
+
+ int dy = rect.origin.y + CGRectGetMaxY(rect);
+ CGContextTranslateCTM(cgContext, 0, dy);
+ CGContextScaleCTM(cgContext, 1, -1);
+ CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, rect);
+ CGContextDrawImage(cgContext,rect,subImage);
+ CGImageRelease(subImage);
+
+ CGContextRestoreGState(cgContext);
+}
+
+//- (QList<struct QWindowSystemInterface::TouchPoint>)touchPointsForTouches:(NSSet *)touches
+//{
+// NSEnumerator *enumerator = [touches objectEnumerator];
+// id touch;
+// int count = 0;
+// QList<struct QWindowSystemInterface::TouchPoint> result;
+// while ((touch = [enumerator nextObject])) {
+// CGPoint locationInView = [touch locationInView:self];
+// CGRect bounds = [self bounds];
+// struct QWindowSystemInterface::TouchPoint p;
+// p.id = count;
+// p.isPrimary = true;
+// p.normalPosition = QPointF(locationInView.x / bounds.size.width,
+// locationInView.y / bounds.size.height);
+// p.area = QRectF(locationInView.x, locationInView.y, 1, 1);
+// p.pressure = 1.;
+// switch ([touch phase]) {
+// case UITouchPhaseBegan:
+// p.state = Qt::TouchPointPressed;
+// break;
+// case UITouchPhaseMoved:
+// p.state = Qt::TouchPointMoved;
+// break;
+// case UITouchPhaseStationary:
+// p.state = Qt::TouchPointStationary;
+// break;
+// case UITouchPhaseEnded:
+// case UITouchPhaseCancelled:
+// p.state = Qt::TouchPointReleased;
+// break;
+// }
+// result << p;
+// qDebug() << p.id << ":" << p.normalPosition << p.area << p.state;
+// ++count;
+// }
+// qDebug() << result.size();
+// return result;
+//}
+
+- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons
+{
+ UITouch *touch = [touches anyObject];
+ CGPoint locationInView = [touch locationInView:self];
+ QPoint p(locationInView.x, locationInView.y);
+ // TODO handle global touch point? for status bar?
+ QWindowSystemInterface::handleMouseEvent(m_widget, (ulong)(event.timestamp*1000),
+ p, p, buttons);
+}
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchBegin, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton];
+}
+
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchUpdate, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton];
+}
+
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchEnd, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton];
+}
+
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchEnd, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton];
+}
+
+@end
+
+QT_BEGIN_NAMESPACE
+
+QUIKitWindowSurface::QUIKitWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+{
+ QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(window->platformWindow());
+ Q_ASSERT(platformWindow);
+ const QRect geo = window->geometry();
+ mView = [[QImageView alloc] initWithFrame:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())];
+ [mView setMultipleTouchEnabled:YES];
+ [mView setWidget:window];
+ mImage = new QImage(window->size(),QImage::Format_ARGB32_Premultiplied);
+ [mView setImage:mImage];
+ if (platformWindow->nativeWindow()) {
+ [platformWindow->nativeWindow() addSubview:mView];
+ [mView setNeedsDisplay];
+ }
+}
+
+QPaintDevice *QUIKitWindowSurface::paintDevice()
+{
+ return mImage;
+}
+
+void QUIKitWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+
+ QRect geo = region.boundingRect();
+ [mView setNeedsDisplayInRect:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())];
+}
+
+void QUIKitWindowSurface::resize (const QSize &size)
+{
+ QWindowSurface::resize(size);
+
+ delete mImage;
+ mImage = new QImage(size,QImage::Format_ARGB32_Premultiplied);
+ [mView setImage:mImage];
+ const QRect geo = geometry();
+ [mView setFrame:CGRectMake(geo.x(), geo.y(), size.width(), size.height())];
+ [mView setNeedsDisplay];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro
new file mode 100644
index 0000000..b73c334
--- /dev/null
+++ b/src/plugins/platforms/uikit/uikit.pro
@@ -0,0 +1,23 @@
+TARGET = quikit
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+OBJECTIVE_SOURCES = main.mm \
+ quikitintegration.mm \
+ quikitwindow.mm \
+ quikitscreen.mm \
+ quikiteventloop.mm \
+ quikitwindowsurface.mm
+
+OBJECTIVE_HEADERS = quikitintegration.h \
+ quikitwindow.h \
+ quikitscreen.h \
+ quikiteventloop.h \
+ quikitwindowsurface.h
+
+#add libz for freetype.
+LIBS += -lz
+
+#include(../fontdatabases/basicunix/basicunix.pri)
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp
new file mode 100644
index 0000000..890b8f8
--- /dev/null
+++ b/src/plugins/platforms/vnc/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncintegration.h"
+#include <qstringlist.h>
+#include <QtGui/QPlatformIntegrationPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QVNCIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList &);
+};
+
+QStringList QVNCIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "VNC";
+ return list;
+}
+
+QPlatformIntegration* QVNCIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "vnc")
+ return new QVNCIntegration(paramList);
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(vnc, QVNCIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp
new file mode 100644
index 0000000..dbcdef3
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnccursor.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPainter>
+#include <QTcpSocket>
+#include <arpa/inet.h>
+#include <QBitmap>
+#include <QApplication>
+
+#include <QDebug>
+
+#include "qvnccursor.h"
+#include "qvncserver.h"
+#include "qvncintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+QVNCCursor::QVNCCursor(QVNCServer * srvr, QVNCScreen *scr )
+ :QPlatformSoftwareCursor(scr), useVncCursor(false), server(srvr)
+{
+}
+
+void QVNCCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+{
+ QPlatformSoftwareCursor::changeCursor(widgetCursor, widget);
+ if (useVncCursor) {
+ server->setDirtyCursor();
+ } else {
+ setDirty();
+ }
+}
+
+void QVNCCursor::setCursorMode(bool vnc)
+{
+ if (vnc) {
+ setDirty();
+ server->setDirtyCursor();
+ } else {
+ server->setDirtyCursor();
+ }
+ useVncCursor = vnc;
+}
+
+QRect QVNCCursor::drawCursor(QPainter & painter)
+{
+ if (useVncCursor)
+ return QRect();
+
+ return QPlatformSoftwareCursor::drawCursor(painter);
+}
+
+void QVNCCursor::clearClientCursor()
+{
+ QTcpSocket *socket = server->clientSocket();
+ if (!socket) {
+ return;
+ }
+ // FramebufferUpdate header
+ {
+ const quint16 tmp[6] = { htons(0),
+ htons(1),
+ htons(0), htons(0),
+ htons(0),
+ htons(0) };
+ socket->write((char*)tmp, sizeof(tmp));
+
+ const quint32 encoding = htonl(-239);
+ socket->write((char*)(&encoding), sizeof(encoding));
+ }
+}
+
+void QVNCCursor::sendClientCursor()
+{
+ if (useVncCursor == false) {
+ clearClientCursor();
+ return;
+ }
+ QImage *image = graphic->image();
+ if (image->isNull())
+ return;
+ QTcpSocket *socket = server->clientSocket();
+ if (!socket) {
+ return;
+ }
+ // FramebufferUpdate header
+ {
+ const quint16 tmp[6] = { htons(0),
+ htons(1),
+ htons(graphic->hotspot().x()), htons(graphic->hotspot().y()),
+ htons(image->width()),
+ htons(image->height()) };
+ socket->write((char*)tmp, sizeof(tmp));
+
+ const quint32 encoding = htonl(-239);
+ socket->write((char*)(&encoding), sizeof(encoding));
+ }
+
+ // write pixels
+ //Q_ASSERT(cursor->hasAlphaChannel());
+ const QImage img = image->convertToFormat(QImage::Format_RGB32);
+ const int n = server->clientBytesPerPixel() * img.width();
+ char *buffer = new char[n];
+ for (int i = 0; i < img.height(); ++i) {
+ server->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
+ socket->write(buffer, n);
+ }
+ delete[] buffer;
+
+ // write mask
+ const QImage bitmap = image->createAlphaMask().convertToFormat(QImage::Format_Mono);
+ Q_ASSERT(bitmap.depth() == 1);
+ Q_ASSERT(bitmap.size() == img.size());
+ const int width = (bitmap.width() + 7) / 8;
+ for (int i = 0; i < bitmap.height(); ++i)
+ socket->write((const char*)bitmap.scanLine(i), width);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h
new file mode 100644
index 0000000..8eb26e0
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnccursor.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QVNCCURSOR_H
+#define QVNCCURSOR_H
+
+#include "../fb_base/fb_base.h"
+#include <QList>
+#include <QImage>
+#include <QMouseEvent>
+
+QT_BEGIN_NAMESPACE
+
+class QVNCScreen;
+class QVNCServer;
+
+class QVNCCursor : public QPlatformSoftwareCursor {
+public:
+ QVNCCursor(QVNCServer *, QVNCScreen *);
+
+ // input methods
+ void setCursorMode(bool vnc);
+ void changeCursor(QCursor * widgetCursor, QWidget * widget);
+
+ // output methods
+ QRect drawCursor(QPainter &);
+
+ // VNC client communication
+ void sendClientCursor();
+ void clearClientCursor();
+private:
+ bool useVncCursor; // VNC or local
+
+ QVNCServer * server; // VNC server to get events from
+};
+
+QT_END_NAMESPACE
+
+#endif // QVNCCURSOR_H
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
new file mode 100644
index 0000000..b99ff3f
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncintegration.h"
+#include "../fb_base/fb_base.h"
+#include <private/qapplication_p.h>
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtCore/qdebug.h>
+
+#include <qvncserver.h>
+#include <QtGui/QPainter>
+
+#include <QtCore/QTimer>
+#include "qgenericunixfontdatabase.h"
+
+QVNCScreen::QVNCScreen(QRect screenSize, int screenId)
+ : QFbScreen::QFbScreen()
+{
+ setGeometry(screenSize);
+ setDepth(32);
+ setFormat(QImage::Format_RGB32);
+ setPhysicalSize((geometry().size()*254)/720);
+
+
+ d_ptr = new QVNCScreenPrivate(this, screenId);
+
+ cursor = new QVNCCursor(d_ptr->vncServer, this);
+ d_ptr->vncServer->setCursor(static_cast<QVNCCursor *>(cursor));
+}
+
+QVNCDirtyMap *QVNCScreen::dirtyMap()
+{
+ return d_ptr->dirty;
+}
+
+QRegion QVNCScreen::doRedraw()
+{
+ QRegion touched;
+ touched = QFbScreen::doRedraw();
+
+ QVector<QRect> rects = touched.rects();
+ for (int i = 0; i < rects.size(); i++)
+ d_ptr->setDirty(rects[i]);
+ return touched;
+}
+
+static inline int defaultWidth() { return 800; }
+static inline int defaultHeight() { return 600; }
+static inline int defaultDisplay() { return 0; }
+
+static void usage()
+{
+ qWarning() << "VNC Platform Integration options:";
+ qWarning() << " size=<Width>x<Height> - set the display width and height";
+ qWarning() << " defaults to" << defaultWidth() << "x" << defaultHeight();
+ qWarning() << " display=<ID> - set the VNC display port to ID + 5900";
+ qWarning() << " defaults to" << defaultDisplay();
+ qWarning() << " offset=<X>x<Y> - set the current screens offset";
+ qWarning() << " vnc - start configuration of a new screen";
+ qWarning() << " size and offset are inherited from the previous screen if not set";
+ qWarning() << " display id is incremented from the previous screen if not set";
+ qWarning() << " virtual - manage the set of screens as a virtual desktop";
+}
+
+QVNCIntegration::QVNCIntegration(const QStringList& paramList)
+ : virtualDesktop(false), fontDb(new QGenericUnixFontDatabase())
+{
+ int sizeX = defaultWidth();
+ int sizeY = defaultHeight();
+ int offsetX = 0;
+ int offsetY = 0;
+ int display = defaultDisplay();
+ bool showUsage = false;
+
+ foreach(QString confString, paramList) {
+ if (confString.startsWith(QLatin1String("size="))) {
+ QString val = confString.section(QLatin1Char('='), 1, 1);
+ sizeX = val.section(QLatin1Char('x'), 0, 0).toInt();
+ sizeY = val.section(QLatin1Char('x'), 1, 1).toInt();
+ }
+ else if (confString.startsWith(QLatin1String("display="))) {
+ display = confString.section(QLatin1Char('='), 1, 1).toInt();
+ }
+ else if (confString.startsWith(QLatin1String("offset="))) {
+ QString val = confString.section(QLatin1Char('='), 1, 1);
+ offsetX = val.section(QLatin1Char('x'), 0, 0).toInt();
+ offsetY = val.section(QLatin1Char('x'), 1, 1).toInt();
+ }
+ else if (confString == QLatin1String("vnc")) {
+ QRect screenRect(offsetX, offsetY, sizeX, sizeY);
+ QVNCScreen *screen = new QVNCScreen(screenRect, display);
+ mScreens.append(screen);
+ screen->setObjectName(QString("screen %1").arg(display));
+ screen->setDirty(screenRect);
+ ++display;
+ }
+ else if (confString == QLatin1String("virtual")) {
+ virtualDesktop = true;
+ }
+ else {
+ qWarning() << "Unknown VNC option:" << confString;
+ showUsage = true;
+ }
+ }
+
+ if (showUsage)
+ usage();
+
+ QRect screenRect(offsetX, offsetY, sizeX, sizeY);
+ QVNCScreen *screen = new QVNCScreen(screenRect, display);
+ mScreens.append(screen);
+ mPrimaryScreen = qobject_cast<QVNCScreen *>(mScreens.first());
+ screen->setObjectName(QString("screen %1").arg(display));
+ screen->setDirty(screenRect);
+}
+
+bool QVNCIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
+QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QWindowSurface *QVNCIntegration::createWindowSurface(QWidget *widget, WId) const
+{
+ QFbWindowSurface * surface;
+ surface = new QFbWindowSurface(mPrimaryScreen, widget);
+ return surface;
+}
+
+
+QPlatformWindow *QVNCIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
+{
+ QFbWindow *w = new QFbWindow(widget);
+ if (virtualDesktop) {
+ QList<QPlatformScreen *>::const_iterator i = mScreens.constBegin();
+ QList<QPlatformScreen *>::const_iterator end = mScreens.constEnd();
+ QFbScreen *screen;
+ while (i != end) {
+ screen = static_cast<QFbScreen *>(*i);
+ screen->addWindow(w);
+ ++i;
+ }
+ }
+ else
+ mPrimaryScreen->addWindow(w);
+ return w;
+}
+
+QPixmap QVNCIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+// qDebug() << "QVNCIntegration::grabWindow" << window << x << y << width << height;
+
+ if (window == 0) { //desktop
+ QImage *desktopImage = mPrimaryScreen->image();
+ if (x==0 && y == 0 && width < 0 && height < 0) {
+ return QPixmap::fromImage(*desktopImage);
+ }
+ if (width < 0)
+ width = desktopImage->width() - x;
+ if (height < 0)
+ height = desktopImage->height() - y;
+ int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp
+ QImage img(desktopImage->scanLine(y) + bytesPerPixel*x, width, height, desktopImage->bytesPerLine(), desktopImage->format());
+ return QPixmap::fromImage(img);
+ }
+ QWidget *win = QWidget::find(window);
+ if (win) {
+ QRect r = win->geometry();
+ if (width < 0)
+ width = r.width() - x;
+ if (height < 0)
+ height = r.height() - y;
+ QImage *desktopImage = mPrimaryScreen->image();
+ int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp
+
+ QImage img(desktopImage->scanLine(r.top() + y) + bytesPerPixel*(r.left()+x), width, height, desktopImage->bytesPerLine(), desktopImage->format());
+ return QPixmap::fromImage(img);
+ }
+ return QPixmap();
+}
+
+
+void QVNCIntegration::moveToScreen(QWidget *window, int screen)
+{
+ if (virtualDesktop) { // all windows exist on all screens in virtual desktop mode
+ return;
+ }
+ if (screen < 0 || screen > mScreens.size())
+ return;
+ QVNCScreen * newScreen = qobject_cast<QVNCScreen *>(mScreens.at(screen));
+ for(int i = 0; i < mScreens.size(); i++) {
+ QVNCScreen *oldScreen = qobject_cast<QVNCScreen *>(mScreens.at(i));
+ if (oldScreen->windowStack.contains(static_cast<QFbWindow *>(window->platformWindow()))) {
+ oldScreen->removeWindow(static_cast<QFbWindow *>(window->platformWindow()));
+ break;
+ }
+ }
+ window->platformWindow()->setGeometry(window->geometry()); // this should be unified elsewhere
+ newScreen->addWindow(static_cast<QFbWindow *>(window->platformWindow()));
+}
+
+QPlatformFontDatabase *QVNCIntegration::fontDatabase() const
+{
+ return fontDb;
+}
diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h
new file mode 100644
index 0000000..ef16dfa
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncintegration.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_VNC_H
+#define QGRAPHICSSYSTEM_VNC_H
+
+#include "qvnccursor.h"
+#include "../fb_base/fb_base.h"
+#include <QPlatformIntegration>
+#include "qgenericunixfontdatabase.h"
+
+QT_BEGIN_NAMESPACE
+
+class QVNCServer;
+class QVNCDirtyMap;
+
+class QVNCScreenPrivate;
+
+class QVNCScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ QVNCScreen(QRect screenSize, int screenId);
+
+ int linestep() const { return image() ? image()->bytesPerLine() : 0; }
+ uchar *base() const { return image() ? image()->bits() : 0; }
+ QVNCDirtyMap *dirtyMap();
+
+public:
+ QVNCScreenPrivate *d_ptr;
+
+private:
+ QVNCServer *server;
+ QRegion doRedraw();
+ friend class QVNCIntegration;
+};
+
+class QVNCIntegrationPrivate;
+
+
+class QVNCIntegration : public QPlatformIntegration
+{
+public:
+ QVNCIntegration(const QStringList& paramList);
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ bool isVirtualDesktop() { return virtualDesktop; }
+ void moveToScreen(QWidget *window, int screen);
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QVNCScreen *mPrimaryScreen;
+ QList<QPlatformScreen *> mScreens;
+ bool virtualDesktop;
+ QPlatformFontDatabase *fontDb;
+};
+
+
+
+QT_END_NAMESPACE
+
+#endif //QGRAPHICSSYSTEM_VNC_H
+
diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp
new file mode 100644
index 0000000..be2de7c
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncserver.cpp
@@ -0,0 +1,1935 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncserver.h"
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qregexp.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/qpolygon.h>
+#include <QtGui/qpainter.h>
+
+#include <QtGui/qevent.h>
+#include <QWindowSystemInterface>
+
+#include <qplatformdefs.h>
+
+#include <qdebug.h>
+
+#include <stdlib.h>
+
+
+#define QT_QWS_VNC_DEBUG
+#define QT_NO_QWS_CURSOR //###
+
+
+QT_BEGIN_NAMESPACE
+
+
+
+//copied from qscreen_qws.h
+#ifndef QT_QWS_DEPTH16_RGB
+#define QT_QWS_DEPTH16_RGB 565
+#endif
+static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
+static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
+static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
+static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
+static const int qt_green_shift = qt_bbits-(8-qt_gbits);
+static const int qt_neg_blue_shift = 8-qt_bbits;
+static const int qt_blue_mask = (1<<qt_bbits)-1;
+static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
+static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
+
+static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
+static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
+static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
+
+
+inline QRgb qt_conv16ToRgb(ushort c)
+{
+ const int r=(c & qt_red_mask);
+ const int g=(c & qt_green_mask);
+ const int b=(c & qt_blue_mask);
+ const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
+ const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
+ const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
+
+ return qRgb(tr,tg,tb);
+}
+
+
+
+//===========================================================================
+
+static const struct {
+ int keysym;
+ int keycode;
+} keyMap[] = {
+ { 0xff08, Qt::Key_Backspace },
+ { 0xff09, Qt::Key_Tab },
+ { 0xff0d, Qt::Key_Return },
+ { 0xff1b, Qt::Key_Escape },
+ { 0xff63, Qt::Key_Insert },
+ { 0xffff, Qt::Key_Delete },
+ { 0xff50, Qt::Key_Home },
+ { 0xff57, Qt::Key_End },
+ { 0xff55, Qt::Key_PageUp },
+ { 0xff56, Qt::Key_PageDown },
+ { 0xff51, Qt::Key_Left },
+ { 0xff52, Qt::Key_Up },
+ { 0xff53, Qt::Key_Right },
+ { 0xff54, Qt::Key_Down },
+ { 0xffbe, Qt::Key_F1 },
+ { 0xffbf, Qt::Key_F2 },
+ { 0xffc0, Qt::Key_F3 },
+ { 0xffc1, Qt::Key_F4 },
+ { 0xffc2, Qt::Key_F5 },
+ { 0xffc3, Qt::Key_F6 },
+ { 0xffc4, Qt::Key_F7 },
+ { 0xffc5, Qt::Key_F8 },
+ { 0xffc6, Qt::Key_F9 },
+ { 0xffc7, Qt::Key_F10 },
+ { 0xffc8, Qt::Key_F11 },
+ { 0xffc9, Qt::Key_F12 },
+ { 0xffe1, Qt::Key_Shift },
+ { 0xffe2, Qt::Key_Shift },
+ { 0xffe3, Qt::Key_Control },
+ { 0xffe4, Qt::Key_Control },
+ { 0xffe7, Qt::Key_Meta },
+ { 0xffe8, Qt::Key_Meta },
+ { 0xffe9, Qt::Key_Alt },
+ { 0xffea, Qt::Key_Alt },
+ { 0, 0 }
+};
+
+void QRfbRect::read(QTcpSocket *s)
+{
+ quint16 buf[4];
+ s->read((char*)buf, 8);
+ x = ntohs(buf[0]);
+ y = ntohs(buf[1]);
+ w = ntohs(buf[2]);
+ h = ntohs(buf[3]);
+}
+
+void QRfbRect::write(QTcpSocket *s) const
+{
+ quint16 buf[4];
+ buf[0] = htons(x);
+ buf[1] = htons(y);
+ buf[2] = htons(w);
+ buf[3] = htons(h);
+ s->write((char*)buf, 8);
+}
+
+void QRfbPixelFormat::read(QTcpSocket *s)
+{
+ char buf[16];
+ s->read(buf, 16);
+ bitsPerPixel = buf[0];
+ depth = buf[1];
+ bigEndian = buf[2];
+ trueColor = buf[3];
+
+ quint16 a = ntohs(*(quint16 *)(buf + 4));
+ redBits = 0;
+ while (a) { a >>= 1; redBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 6));
+ greenBits = 0;
+ while (a) { a >>= 1; greenBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 8));
+ blueBits = 0;
+ while (a) { a >>= 1; blueBits++; }
+
+ redShift = buf[10];
+ greenShift = buf[11];
+ blueShift = buf[12];
+}
+
+void QRfbPixelFormat::write(QTcpSocket *s)
+{
+ char buf[16];
+ buf[0] = bitsPerPixel;
+ buf[1] = depth;
+ buf[2] = bigEndian;
+ buf[3] = trueColor;
+
+ quint16 a = 0;
+ for (int i = 0; i < redBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 4) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < greenBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 6) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < blueBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 8) = htons(a);
+
+ buf[10] = redShift;
+ buf[11] = greenShift;
+ buf[12] = blueShift;
+ s->write(buf, 16);
+}
+
+
+void QRfbServerInit::setName(const char *n)
+{
+ delete[] name;
+ name = new char [strlen(n) + 1];
+ strcpy(name, n);
+}
+
+void QRfbServerInit::read(QTcpSocket *s)
+{
+ s->read((char *)&width, 2);
+ width = ntohs(width);
+ s->read((char *)&height, 2);
+ height = ntohs(height);
+ format.read(s);
+
+ quint32 len;
+ s->read((char *)&len, 4);
+ len = ntohl(len);
+
+ name = new char [len + 1];
+ s->read(name, len);
+ name[len] = '\0';
+}
+
+void QRfbServerInit::write(QTcpSocket *s)
+{
+ quint16 t = htons(width);
+ s->write((char *)&t, 2);
+ t = htons(height);
+ s->write((char *)&t, 2);
+ format.write(s);
+ quint32 len = strlen(name);
+ len = htonl(len);
+ s->write((char *)&len, 4);
+ s->write(name, strlen(name));
+}
+
+bool QRfbSetEncodings::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 3)
+ return false;
+
+ char tmp;
+ s->read(&tmp, 1); // padding
+ s->read((char *)&count, 2);
+ count = ntohs(count);
+
+ return true;
+}
+
+bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 9)
+ return false;
+
+ s->read(&incremental, 1);
+ rect.read(s);
+
+ return true;
+}
+
+bool QRfbKeyEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ s->read(&down, 1);
+ quint16 tmp;
+ s->read((char *)&tmp, 2); // padding
+
+ quint32 key;
+ s->read((char *)&key, 4);
+ key = ntohl(key);
+
+ unicode = 0;
+ keycode = 0;
+ int i = 0;
+ while (keyMap[i].keysym && !keycode) {
+ if (keyMap[i].keysym == (int)key)
+ keycode = keyMap[i].keycode;
+ i++;
+ }
+ if (!keycode) {
+ if (key <= 0xff) {
+ unicode = key;
+ if (key >= 'a' && key <= 'z')
+ keycode = Qt::Key_A + key - 'a';
+ else if (key >= ' ' && key <= '~')
+ keycode = Qt::Key_Space + key - ' ';
+ }
+ }
+
+ return true;
+}
+
+bool QRfbPointerEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 5)
+ return false;
+
+ char buttonMask;
+ s->read(&buttonMask, 1);
+
+ buttons = Qt::NoButton;
+ wheelDirection = WheelNone;
+ if (buttonMask & 1)
+ buttons |= Qt::LeftButton;
+ if (buttonMask & 2)
+ buttons |= Qt::MidButton;
+ if (buttonMask & 4)
+ buttons |= Qt::RightButton;
+ if (buttonMask & 8)
+ wheelDirection = WheelUp;
+ if (buttonMask & 16)
+ wheelDirection = WheelDown;
+ if (buttonMask & 32)
+ wheelDirection = WheelLeft;
+ if (buttonMask & 64)
+ wheelDirection = WheelRight;
+
+ quint16 tmp;
+ s->read((char *)&tmp, 2);
+ x = ntohs(tmp);
+ s->read((char *)&tmp, 2);
+ y = ntohs(tmp);
+
+ return true;
+}
+
+bool QRfbClientCutText::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ char tmp[3];
+ s->read(tmp, 3); // padding
+ s->read((char *)&length, 4);
+ length = ntohl(length);
+
+ return true;
+}
+
+//===========================================================================
+
+QVNCServer::QVNCServer(QVNCScreen *screen)
+ : qvnc_screen(screen), cursor(0)
+{
+ init(5900);
+}
+
+QVNCServer::QVNCServer(QVNCScreen *screen, int id)
+ : qvnc_screen(screen), cursor(0)
+{
+ init(5900 + id);
+}
+
+void QVNCServer::init(uint port)
+{
+ qDebug() << "QVNCServer::init" << port;
+
+ handleMsg = false;
+ client = 0;
+ encodingsPending = 0;
+ cutTextPending = 0;
+ keymod = 0;
+ state = Unconnected;
+ dirtyCursor = false;
+
+ refreshRate = 25;
+ timer = new QTimer(this);
+ timer->setSingleShot(true);
+ connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
+
+ serverSocket = new QTcpServer(this);
+ if (!serverSocket->listen(QHostAddress::Any, port))
+ qDebug() << "QVNCServer could not connect:" << serverSocket->errorString();
+ else
+ qDebug("QVNCServer created on port %d", port);
+
+ connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
+
+#ifndef QT_NO_QWS_CURSOR
+ qvnc_cursor = 0;
+#endif
+ encoder = 0;
+}
+
+QVNCServer::~QVNCServer()
+{
+ delete encoder;
+ encoder = 0;
+ delete client;
+ client = 0;
+#ifndef QT_NO_QWS_CURSOR
+ delete qvnc_cursor;
+ qvnc_cursor = 0;
+#endif
+}
+
+void QVNCServer::setDirty()
+{
+ if (state == Connected && !timer->isActive() &&
+ ((dirtyMap()->numDirty > 0) || dirtyCursor)) {
+ timer->start();
+ }
+}
+
+void QVNCServer::newConnection()
+{
+ if (client)
+ delete client;
+
+ client = serverSocket->nextPendingConnection();
+ connect(client,SIGNAL(readyRead()),this,SLOT(readClient()));
+ connect(client,SIGNAL(disconnected()),this,SLOT(discardClient()));
+ handleMsg = false;
+ encodingsPending = 0;
+ cutTextPending = 0;
+ supportHextile = false;
+ wantUpdate = false;
+
+ timer->start(1000 / refreshRate);
+ dirtyMap()->reset();
+
+ // send protocol version
+ const char *proto = "RFB 003.003\n";
+ client->write(proto, 12);
+ state = Protocol;
+
+// if (!qvnc_screen->screen())
+// QWSServer::instance()->enablePainting(true);
+}
+
+void QVNCServer::readClient()
+{
+ switch (state) {
+ case Protocol:
+ if (client->bytesAvailable() >= 12) {
+ char proto[13];
+ client->read(proto, 12);
+ proto[12] = '\0';
+ qDebug("Client protocol version %s", proto);
+ // No authentication
+ quint32 auth = htonl(1);
+ client->write((char *) &auth, sizeof(auth));
+ state = Init;
+ }
+ break;
+
+ case Init:
+ if (client->bytesAvailable() >= 1) {
+ quint8 shared;
+ client->read((char *) &shared, 1);
+
+ // Server Init msg
+ QRfbServerInit sim;
+ QRfbPixelFormat &format = sim.format;
+ switch (qvnc_screen->depth()) {
+ case 32:
+ format.bitsPerPixel = 32;
+ format.depth = 32;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 24:
+ format.bitsPerPixel = 24;
+ format.depth = 24;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 18:
+ format.bitsPerPixel = 24;
+ format.depth = 18;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 6;
+ format.greenBits = 6;
+ format.blueBits = 6;
+ format.redShift = 12;
+ format.greenShift = 6;
+ format.blueShift = 0;
+ break;
+
+ case 16:
+ format.bitsPerPixel = 16;
+ format.depth = 16;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 6;
+ format.blueBits = 5;
+ format.redShift = 11;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 15:
+ format.bitsPerPixel = 16;
+ format.depth = 15;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 5;
+ format.blueBits = 5;
+ format.redShift = 10;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 12:
+ format.bitsPerPixel = 16;
+ format.depth = 12;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 4;
+ format.greenBits = 4;
+ format.blueBits = 4;
+ format.redShift = 8;
+ format.greenShift = 4;
+ format.blueShift = 0;
+ break;
+
+ case 8:
+ case 4:
+ format.bitsPerPixel = 8;
+ format.depth = 8;
+ format.bigEndian = 0;
+ format.trueColor = false;
+ format.redBits = 0;
+ format.greenBits = 0;
+ format.blueBits = 0;
+ format.redShift = 0;
+ format.greenShift = 0;
+ format.blueShift = 0;
+ break;
+
+ default:
+ qDebug("QVNC cannot drive depth %d", qvnc_screen->depth());
+ discardClient();
+ return;
+ }
+ sim.width = qvnc_screen->geometry().width();
+ sim.height = qvnc_screen->geometry().height();
+ sim.setName("Qt for Embedded Linux VNC Server");
+ sim.write(client);
+ state = Connected;
+ }
+ break;
+
+ case Connected:
+ do {
+ if (!handleMsg) {
+ client->read((char *)&msgType, 1);
+ handleMsg = true;
+ }
+ if (handleMsg) {
+ switch (msgType ) {
+ case SetPixelFormat:
+ setPixelFormat();
+ break;
+ case FixColourMapEntries:
+ qDebug("Not supported: FixColourMapEntries");
+ handleMsg = false;
+ break;
+ case SetEncodings:
+ setEncodings();
+ break;
+ case FramebufferUpdateRequest:
+ frameBufferUpdateRequest();
+ break;
+ case KeyEvent:
+ keyEvent();
+ break;
+ case PointerEvent:
+ pointerEvent();
+ break;
+ case ClientCutText:
+ clientCutText();
+ break;
+ default:
+ qDebug("Unknown message type: %d", (int)msgType);
+ handleMsg = false;
+ }
+ }
+ } while (!handleMsg && client->bytesAvailable());
+ break;
+ default:
+ break;
+ }
+}
+
+#if 0//Q_BYTE_ORDER == Q_BIG_ENDIAN
+bool QVNCScreen::swapBytes() const
+{
+ if (depth() != 16)
+ return false;
+
+ if (screen())
+ return screen()->frameBufferLittleEndian();
+ return frameBufferLittleEndian();
+}
+#endif
+
+void QVNCServer::setPixelFormat()
+{
+ if (client->bytesAvailable() >= 19) {
+ char buf[3];
+ client->read(buf, 3); // just padding
+ pixelFormat.read(client);
+#ifdef QT_QWS_VNC_DEBUG
+ qDebug("Want format: %d %d %d %d %d %d %d %d %d %d",
+ int(pixelFormat.bitsPerPixel),
+ int(pixelFormat.depth),
+ int(pixelFormat.bigEndian),
+ int(pixelFormat.trueColor),
+ int(pixelFormat.redBits),
+ int(pixelFormat.greenBits),
+ int(pixelFormat.blueBits),
+ int(pixelFormat.redShift),
+ int(pixelFormat.greenShift),
+ int(pixelFormat.blueShift));
+#endif
+ if (!pixelFormat.trueColor) {
+ qDebug("Can only handle true color clients");
+ discardClient();
+ }
+ handleMsg = false;
+ sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian;
+ needConversion = pixelConversionNeeded();
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ swapBytes = qvnc_screen->swapBytes();
+#endif
+ }
+}
+
+void QVNCServer::setEncodings()
+{
+ QRfbSetEncodings enc;
+
+ if (!encodingsPending && enc.read(client)) {
+ encodingsPending = enc.count;
+ if (!encodingsPending)
+ handleMsg = false;
+ }
+
+ if (encoder) {
+ delete encoder;
+ encoder = 0;
+ }
+
+ enum Encodings {
+ Raw = 0,
+ CopyRect = 1,
+ RRE = 2,
+ CoRRE = 4,
+ Hextile = 5,
+ ZRLE = 16,
+ Cursor = -239,
+ DesktopSize = -223
+ };
+
+ supportCursor = false;
+
+ if (encodingsPending && (unsigned)client->bytesAvailable() >=
+ encodingsPending * sizeof(quint32)) {
+ for (int i = 0; i < encodingsPending; ++i) {
+ qint32 enc;
+ client->read((char *)&enc, sizeof(qint32));
+ enc = ntohl(enc);
+#ifdef QT_QWS_VNC_DEBUG
+ qDebug("QVNCServer::setEncodings: %d", enc);
+#endif
+ switch (enc) {
+ case Raw:
+ if (!encoder) {
+ encoder = new QRfbRawEncoder(this);
+#ifdef QT_QWS_VNC_DEBUG
+ qDebug("QVNCServer::setEncodings: using raw");
+#endif
+ }
+ break;
+ case CopyRect:
+ supportCopyRect = true;
+ break;
+ case RRE:
+ supportRRE = true;
+ break;
+ case CoRRE:
+ supportCoRRE = true;
+ break;
+ case Hextile:
+ supportHextile = true;
+ if (encoder)
+ break;
+ switch (qvnc_screen->depth()) {
+#ifdef QT_QWS_DEPTH_8
+ case 8:
+ encoder = new QRfbHextileEncoder<quint8>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_12
+ case 12:
+ encoder = new QRfbHextileEncoder<qrgb444>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_15
+ case 15:
+ encoder = new QRfbHextileEncoder<qrgb555>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_16
+ case 16:
+ encoder = new QRfbHextileEncoder<quint16>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_18
+ case 18:
+ encoder = new QRfbHextileEncoder<qrgb666>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_24
+ case 24:
+ encoder = new QRfbHextileEncoder<qrgb888>(this);
+ break;
+#endif
+#ifdef QT_QWS_DEPTH_32
+ case 32:
+ encoder = new QRfbHextileEncoder<quint32>(this);
+ break;
+#endif
+ default:
+ break;
+ }
+#ifdef QT_QWS_VNC_DEBUG
+ qDebug("QVNCServer::setEncodings: using hextile");
+#endif
+ break;
+ case ZRLE:
+ supportZRLE = true;
+ break;
+ case Cursor:
+ supportCursor = true;
+#ifndef QT_NO_QWS_CURSOR
+ if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) {
+ delete qvnc_cursor;
+ qvnc_cursor = new QVNCClientCursor(this);
+ }
+#endif
+ break;
+ case DesktopSize:
+ supportDesktopSize = true;
+ break;
+ default:
+ break;
+ }
+ }
+ handleMsg = false;
+ encodingsPending = 0;
+ }
+
+ if (!encoder) {
+ encoder = new QRfbRawEncoder(this);
+#ifdef QT_QWS_VNC_DEBUG
+ qDebug("QVNCServer::setEncodings: fallback using raw");
+#endif
+ }
+
+ if (cursor)
+ cursor->setCursorMode(supportCursor);
+}
+
+void QVNCServer::frameBufferUpdateRequest()
+{
+ QRfbFrameBufferUpdateRequest ev;
+
+ if (ev.read(client)) {
+ if (!ev.incremental) {
+ QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
+////### r.translate(qvnc_screen->offset());
+ qvnc_screen->d_ptr->setDirty(r, true);
+ }
+ wantUpdate = true;
+ checkUpdate();
+ handleMsg = false;
+ }
+}
+
+static bool buttonChange(Qt::MouseButtons before, Qt::MouseButtons after, Qt::MouseButton *button, bool *isPress)
+{
+ if (before == after)
+ return false;
+ for (int b = Qt::LeftButton; b <= Qt::MidButton; b<<=1) {
+ if ((before & b) != (after & b)) {
+ *button = static_cast<Qt::MouseButton>(b);
+ *isPress = (after & b);
+ return true;
+ }
+ }
+ return false;
+}
+
+void QVNCServer::pointerEvent()
+{
+ QPoint screenOffset = this->screen()->geometry().topLeft();
+
+ QRfbPointerEvent ev;
+ if (ev.read(client)) {
+ QPoint eventPoint(ev.x, ev.y);
+ eventPoint += screenOffset; // local to global translation
+
+ if (ev.wheelDirection == ev.WheelNone) {
+ QEvent::Type type = QEvent::MouseMove;
+ Qt::MouseButton button = Qt::NoButton;
+ bool isPress;
+ if (buttonChange(buttons, ev.buttons, &button, &isPress))
+ type = isPress ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
+ QWindowSystemInterface::handleMouseEvent(0, eventPoint, eventPoint, ev.buttons);
+ } else {
+ // No buttons or motion reported at the same time as wheel events
+ Qt::Orientation orientation;
+ if (ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelRight)
+ orientation = Qt::Horizontal;
+ else
+ orientation = Qt::Vertical;
+ int delta = 120 * ((ev.wheelDirection == ev.WheelLeft || ev.wheelDirection == ev.WheelUp) ? 1 : -1);
+ QWindowSystemInterface::handleWheelEvent(0, eventPoint, eventPoint, delta, orientation);
+ }
+ handleMsg = false;
+ }
+}
+
+void QVNCServer::keyEvent()
+{
+ QRfbKeyEvent ev;
+
+ if (ev.read(client)) {
+ if (ev.keycode == Qt::Key_Shift)
+ keymod = ev.down ? keymod | Qt::ShiftModifier :
+ keymod & ~Qt::ShiftModifier;
+ else if (ev.keycode == Qt::Key_Control)
+ keymod = ev.down ? keymod | Qt::ControlModifier :
+ keymod & ~Qt::ControlModifier;
+ else if (ev.keycode == Qt::Key_Alt)
+ keymod = ev.down ? keymod | Qt::AltModifier :
+ keymod & ~Qt::AltModifier;
+ if (ev.unicode || ev.keycode) {
+// qDebug() << "keyEvent" << hex << ev.unicode << ev.keycode << keymod << ev.down;
+ QEvent::Type type = ev.down ? QEvent::KeyPress : QEvent::KeyRelease;
+ QString str;
+ if (ev.unicode && ev.unicode != 0xffff)
+ str = QString(ev.unicode);
+ QWindowSystemInterface::handleKeyEvent(0, type, ev.keycode, keymod, str);
+ }
+ handleMsg = false;
+ }
+}
+
+void QVNCServer::clientCutText()
+{
+ QRfbClientCutText ev;
+
+ if (cutTextPending == 0 && ev.read(client)) {
+ cutTextPending = ev.length;
+ if (!cutTextPending)
+ handleMsg = false;
+ }
+
+ if (cutTextPending && client->bytesAvailable() >= cutTextPending) {
+ char *text = new char [cutTextPending+1];
+ client->read(text, cutTextPending);
+ delete [] text;
+ cutTextPending = 0;
+ handleMsg = false;
+ }
+}
+
+// stride in bytes
+template <class SRC>
+bool QRfbSingleColorHextile<SRC>::read(const uchar *data,
+ int width, int height, int stride)
+{
+ const int depth = encoder->server->screen()->depth();
+ if (width % (depth / 8)) // hw: should rather fallback to simple loop
+ return false;
+
+ static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt();
+ if (alwaysFalse)
+ return false;
+
+ switch (depth) {
+ case 4: {
+ const quint8 *data8 = reinterpret_cast<const quint8*>(data);
+ if ((data8[0] & 0xf) != (data8[0] >> 4))
+ return false;
+ width /= 2;
+ } // fallthrough
+ case 8: {
+ const quint8 *data8 = reinterpret_cast<const quint8*>(data);
+ if (data8[0] != data8[1])
+ return false;
+ width /= 2;
+ } // fallthrough
+ case 12:
+ case 15:
+ case 16: {
+ const quint16 *data16 = reinterpret_cast<const quint16*>(data);
+ if (data16[0] != data16[1])
+ return false;
+ width /= 2;
+ } // fallthrough
+ case 18:
+ case 24:
+ case 32: {
+ const quint32 *data32 = reinterpret_cast<const quint32*>(data);
+ const quint32 first = data32[0];
+ const int linestep = (stride / sizeof(quint32)) - width;
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ if (*(data32++) != first)
+ return false;
+ }
+ data32 += linestep;
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+
+ SRC color = reinterpret_cast<const SRC*>(data)[0];
+ encoder->newBg |= (color != encoder->bg);
+ encoder->bg = color;
+ return true;
+}
+
+template <class SRC>
+void QRfbSingleColorHextile<SRC>::write(QTcpSocket *socket) const
+{
+ if (true || encoder->newBg) {
+ const int bpp = encoder->server->clientBytesPerPixel();
+ const int padding = 3;
+ QVarLengthArray<char> buffer(padding + 1 + bpp);
+ buffer[padding] = 2; // BackgroundSpecified
+ encoder->server->convertPixels(buffer.data() + padding + 1,
+ reinterpret_cast<char*>(&encoder->bg),
+ 1);
+ socket->write(buffer.data() + padding, bpp + 1);
+// encoder->newBg = false;
+ } else {
+ char subenc = 0;
+ socket->write(&subenc, 1);
+ }
+}
+
+template <class SRC>
+bool QRfbDualColorHextile<SRC>::read(const uchar *data,
+ int width, int height, int stride)
+{
+ const SRC *ptr = reinterpret_cast<const SRC*>(data);
+ const int linestep = (stride / sizeof(SRC)) - width;
+
+ SRC c1;
+ SRC c2 = 0;
+ int n1 = 0;
+ int n2 = 0;
+ int x = 0;
+ int y = 0;
+
+ c1 = *ptr;
+
+ // find second color
+ while (y < height) {
+ while (x < width) {
+ if (*ptr == c1) {
+ ++n1;
+ } else {
+ c2 = *ptr;
+ goto found_second_color;
+ }
+ ++ptr;
+ ++x;
+ }
+ x = 0;
+ ptr += linestep;
+ ++y;
+ }
+
+found_second_color:
+ // finish counting
+ while (y < height) {
+ while (x < width) {
+ if (*ptr == c1) {
+ ++n1;
+ } else if (*ptr == c2) {
+ ++n2;
+ } else {
+ return false;
+ }
+ ++ptr;
+ ++x;
+ }
+ x = 0;
+ ptr += linestep;
+ ++y;
+ }
+
+ if (n2 > n1) {
+ const quint32 tmpC = c1;
+ c1 = c2;
+ c2 = tmpC;
+ }
+
+ encoder->newBg |= (c1 != encoder->bg);
+ encoder->newFg |= (c2 != encoder->fg);
+
+ encoder->bg = c1;
+ encoder->fg = c2;
+
+ // create map
+ bool inRect = false;
+ numRects = 0;
+ ptr = reinterpret_cast<const SRC*>(data);
+ for (y = 0; y < height; ++y) {
+ for (x = 0; x < width; ++x) {
+ if (inRect && *ptr == encoder->bg) {
+ // rect finished
+ setWidth(x - lastx());
+ next();
+ inRect = false;
+ } else if (!inRect && *ptr == encoder->fg) {
+ // rect start
+ setX(x);
+ setY(y);
+ setHeight(1);
+ inRect = true;
+ }
+ ++ptr;
+ }
+ if (inRect) {
+ // finish rect
+ setWidth(width - lastx());
+ next();
+ inRect = false;
+ }
+ ptr += linestep;
+ }
+
+ return true;
+}
+
+template <class SRC>
+void QRfbDualColorHextile<SRC>::write(QTcpSocket *socket) const
+{
+ const int bpp = encoder->server->clientBytesPerPixel();
+ const int padding = 3;
+ QVarLengthArray<char> buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects));
+ char &subenc = buffer[padding];
+ int n = padding + sizeof(subenc);
+
+ subenc = 0x8; // AnySubrects
+
+ if (encoder->newBg) {
+ subenc |= 0x2; // Background
+ encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1);
+ n += bpp;
+// encoder->newBg = false;
+ }
+
+ if (encoder->newFg) {
+ subenc |= 0x4; // Foreground
+ encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1);
+ n += bpp;
+// encoder->newFg = false;
+ }
+ buffer[n] = numRects;
+ n += sizeof(numRects);
+
+ socket->write(buffer.data() + padding, n - padding);
+ socket->write((char*)rects, numRects * sizeof(Rect));
+}
+
+template <class SRC>
+void QRfbDualColorHextile<SRC>::next()
+{
+ for (int r = numRects - 1; r >= 0; --r) {
+ if (recty(r) == lasty())
+ continue;
+ if (recty(r) < lasty() - 1) // only search previous scanline
+ break;
+ if (rectx(r) == lastx() && width(r) == width(numRects)) {
+ ++rects[r].wh;
+ return;
+ }
+ }
+ ++numRects;
+}
+
+template <class SRC>
+inline void QRfbMultiColorHextile<SRC>::setColor(SRC color)
+{
+ encoder->server->convertPixels(reinterpret_cast<char*>(rect(numRects)),
+ (const char*)&color, 1);
+}
+
+template <class SRC>
+inline bool QRfbMultiColorHextile<SRC>::beginRect()
+{
+ if ((rects.size() + bpp + 2) > maxRectsSize)
+ return false;
+ rects.resize(rects.size() + bpp + 2);
+ return true;
+}
+
+template <class SRC>
+inline void QRfbMultiColorHextile<SRC>::endRect()
+{
+ setHeight(numRects, 1);
+ ++numRects;
+}
+
+template <class SRC>
+bool QRfbMultiColorHextile<SRC>::read(const uchar *data,
+ int width, int height, int stride)
+{
+ const SRC *ptr = reinterpret_cast<const SRC*>(data);
+ const int linestep = (stride / sizeof(SRC)) - width;
+
+ bpp = encoder->server->clientBytesPerPixel();
+
+ if (encoder->newBg)
+ encoder->bg = ptr[0];
+
+ const SRC bg = encoder->bg;
+ SRC color = bg;
+ bool inRect = false;
+
+ numRects = 0;
+ rects.clear();
+
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ if (inRect && *ptr != color) { // end rect
+ setWidth(numRects, x - rectx(numRects));
+ endRect();
+ inRect = false;
+ }
+
+ if (!inRect && *ptr != bg) { // begin rect
+ if (!beginRect())
+ return false;
+ inRect = true;
+ color = *ptr;
+ setColor(color);
+ setX(numRects, x);
+ setY(numRects, y);
+ }
+ ++ptr;
+ }
+ if (inRect) { // end rect
+ setWidth(numRects, width - rectx(numRects));
+ endRect();
+ inRect = false;
+ }
+ ptr += linestep;
+ }
+
+ return true;
+}
+
+template <class SRC>
+void QRfbMultiColorHextile<SRC>::write(QTcpSocket *socket) const
+{
+ const int padding = 3;
+ QVarLengthArray<quint8> buffer(bpp + padding + sizeof(quint8) + sizeof(numRects));
+
+ quint8 &subenc = buffer[padding];
+ int n = padding + sizeof(quint8);
+
+ subenc = 8 | 16; // AnySubrects | SubrectsColoured
+
+ if (encoder->newBg) {
+ subenc |= 0x2; // Background
+ encoder->server->convertPixels(reinterpret_cast<char*>(buffer.data() + n),
+ reinterpret_cast<const char*>(&encoder->bg),
+ 1);
+ n += bpp;
+// encoder->newBg = false;
+ }
+
+ buffer[n] = numRects;
+ n += sizeof(numRects);
+
+ socket->write(reinterpret_cast<const char*>(buffer.data() + padding),
+ n - padding);
+ socket->write(reinterpret_cast<const char*>(rects.constData()),
+ rects.size());
+}
+
+bool QVNCServer::pixelConversionNeeded() const
+{
+ if (!sameEndian)
+ return true;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (qvnc_screen->swapBytes())
+ return true;
+#endif
+
+ const int screendepth = qvnc_screen->depth();
+ if (screendepth != pixelFormat.bitsPerPixel)
+ return true;
+
+ switch (screendepth) {
+ case 32:
+ case 24:
+ return false;
+ case 18:
+ return (pixelFormat.redBits == 6
+ && pixelFormat.greenBits == 6
+ && pixelFormat.blueBits == 6);
+ case 16:
+ return (pixelFormat.redBits == 5
+ && pixelFormat.greenBits == 6
+ && pixelFormat.blueBits == 5);
+ case 15:
+ return (pixelFormat.redBits == 5
+ && pixelFormat.greenBits == 5
+ && pixelFormat.blueBits == 5);
+ case 12:
+ return (pixelFormat.redBits == 4
+ && pixelFormat.greenBits == 4
+ && pixelFormat.blueBits == 4);
+ }
+ return true;
+}
+
+// count: number of pixels
+void QVNCServer::convertPixels(char *dst, const char *src, int count) const
+{
+ const int screendepth = qvnc_screen->depth();
+ const bool isBgr = false; //### qvnc_screen->pixelType() == QScreen::BGRPixel;
+
+ // cutoffs
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (!swapBytes)
+#endif
+ if (sameEndian) {
+ if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs
+
+ switch (screendepth) {
+ case 32:
+ memcpy(dst, src, count * sizeof(quint32));
+ return;
+ case 16:
+ if (pixelFormat.redBits == 5
+ && pixelFormat.greenBits == 6
+ && pixelFormat.blueBits == 5)
+ {
+ memcpy(dst, src, count * sizeof(quint16));
+ return;
+ }
+ }
+ } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) {
+#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned
+ const quint32 *src32 = reinterpret_cast<const quint32*>(src);
+ quint32 *dst32 = reinterpret_cast<quint32*>(dst);
+ int count32 = count * sizeof(quint16) / sizeof(quint32);
+ while (count32--) {
+ const quint32 s = *src32++;
+ quint32 result1;
+ quint32 result2;
+
+ // red
+ result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8;
+ result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8;
+
+ // green
+ result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11;
+ result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5;
+
+ // blue
+ result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13;
+ result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3;
+
+ *dst32++ = result2;
+ *dst32++ = result1;
+ }
+ if (count & 0x1) {
+ const quint16 *src16 = reinterpret_cast<const quint16*>(src);
+ *dst32 = qt_conv16ToRgb(src16[count - 1]);
+ }
+ return;
+#endif
+ }
+ }
+
+ const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8;
+
+// nibble = 0;
+
+ for (int i = 0; i < count; ++i) {
+ int r, g, b;
+
+ switch (screendepth) {
+#if 0
+ case 4: {
+ if (!nibble) {
+ r = ((*src) & 0x0f) << 4;
+ } else {
+ r = (*src) & 0xf0;
+ src++;
+ }
+ nibble = !nibble;
+ g = b = r;
+ break;
+ }
+#endif
+#if 0
+ case 8: {
+ QRgb rgb = qvnc_screen->clut()[int(*src)];
+ r = qRed(rgb);
+ g = qGreen(rgb);
+ b = qBlue(rgb);
+ src++;
+ break;
+ }
+#endif
+#ifdef QT_QWS_DEPTH_12
+ case 12: {
+ quint32 p = quint32(*reinterpret_cast<const qrgb444*>(src));
+ r = qRed(p);
+ g = qGreen(p);
+ b = qBlue(p);
+ src += sizeof(qrgb444);
+ break;
+ }
+#endif
+#ifdef QT_QWS_DEPTH_15
+ case 15: {
+ quint32 p = quint32(*reinterpret_cast<const qrgb555*>(src));
+ r = qRed(p);
+ g = qGreen(p);
+ b = qBlue(p);
+ src += sizeof(qrgb555);
+ break;
+ }
+#endif
+ case 16: {
+ quint16 p = *reinterpret_cast<const quint16*>(src);
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (swapBytes)
+ p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
+#endif
+ r = (p >> 11) & 0x1f;
+ g = (p >> 5) & 0x3f;
+ b = p & 0x1f;
+ r <<= 3;
+ g <<= 2;
+ b <<= 3;
+ src += sizeof(quint16);
+ break;
+ }
+#ifdef QT_QWS_DEPTH_18
+ case 18: {
+ quint32 p = quint32(*reinterpret_cast<const qrgb666*>(src));
+ r = qRed(p);
+ g = qGreen(p);
+ b = qBlue(p);
+ src += sizeof(qrgb666);
+ break;
+ }
+#endif
+#ifdef QT_QWS_DEPTH_24
+ case 24: {
+ quint32 p = quint32(*reinterpret_cast<const qrgb888*>(src));
+ r = qRed(p);
+ g = qGreen(p);
+ b = qBlue(p);
+ src += sizeof(qrgb888);
+ break;
+ }
+#endif
+ case 32: {
+ quint32 p = *reinterpret_cast<const quint32*>(src);
+ r = (p >> 16) & 0xff;
+ g = (p >> 8) & 0xff;
+ b = p & 0xff;
+ src += sizeof(quint32);
+ break;
+ }
+ default: {
+ r = g = b = 0;
+ qDebug("QVNCServer: don't support %dbpp display", screendepth);
+ return;
+ }
+ }
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (swapBytes ^ isBgr)
+#else
+ if (isBgr)
+#endif
+ qSwap(r, b);
+
+ r >>= (8 - pixelFormat.redBits);
+ g >>= (8 - pixelFormat.greenBits);
+ b >>= (8 - pixelFormat.blueBits);
+
+ int pixel = (r << pixelFormat.redShift) |
+ (g << pixelFormat.greenShift) |
+ (b << pixelFormat.blueShift);
+
+ if (sameEndian || pixelFormat.bitsPerPixel == 8) {
+ memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead?
+ dst += bytesPerPixel;
+ continue;
+ }
+
+
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ switch (pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel);
+ }
+ } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
+ switch (pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0xff000000) >> 8) |
+ ((pixel & 0x00ff0000) << 8));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qDebug("Cannot handle %d bpp client",
+ pixelFormat.bitsPerPixel);
+ break;
+ }
+ }
+ memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead?
+ dst += bytesPerPixel;
+ }
+}
+
+#ifndef QT_NO_QWS_CURSOR
+static void blendCursor(QImage &image, const QRect &imageRect)
+{
+ const QRect cursorRect = qt_screencursor->boundingRect();
+ const QRect intersection = (cursorRect & imageRect);
+ const QRect destRect = intersection.translated(-imageRect.topLeft());
+ const QRect srcRect = intersection.translated(-cursorRect.topLeft());
+
+ QPainter painter(&image);
+ painter.drawImage(destRect, qt_screencursor->image(), srcRect);
+ painter.end();
+}
+#endif // QT_NO_QWS_CURSOR
+
+QVNCDirtyMap::QVNCDirtyMap(QVNCScreen *s)
+ : bytesPerPixel(0), numDirty(0), screen(s)
+{
+ bytesPerPixel = (screen->depth() + 7) / 8;
+ QSize screenSize = screen->geometry().size();
+ bufferWidth = screenSize.width();
+ bufferHeight = screenSize.height();
+ bufferStride = bufferWidth * bytesPerPixel;
+ buffer = new uchar[bufferHeight * bufferStride];
+
+ mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ numTiles = mapWidth * mapHeight;
+ map = new uchar[numTiles];
+}
+
+QVNCDirtyMap::~QVNCDirtyMap()
+{
+ delete[] map;
+ delete[] buffer;
+}
+
+void QVNCDirtyMap::reset()
+{
+ memset(map, 1, numTiles);
+ memset(buffer, 0, bufferHeight * bufferStride);
+ numDirty = numTiles;
+}
+
+inline bool QVNCDirtyMap::dirty(int x, int y) const
+{
+ return map[y * mapWidth + x];
+}
+
+inline void QVNCDirtyMap::setClean(int x, int y)
+{
+ map[y * mapWidth + x] = 0;
+ --numDirty;
+}
+
+template <class T>
+void QVNCDirtyMapOptimized<T>::setDirty(int tileX, int tileY, bool force)
+{
+ static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt();
+ if (alwaysForce)
+ force = true;
+
+ bool changed = false;
+
+ if (!force) {
+ const int lstep = screen->linestep();
+ const int startX = tileX * MAP_TILE_SIZE;
+ const int startY = tileY * MAP_TILE_SIZE;
+ const uchar *scrn = screen->base()
+ + startY * lstep + startX * bytesPerPixel;
+ uchar *old = buffer + startY * bufferStride + startX * sizeof(T);
+
+ const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ?
+ bufferHeight - startY : MAP_TILE_SIZE);
+ const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ?
+ bufferWidth - startX : MAP_TILE_SIZE);
+ const bool doInlines = (tileWidth == MAP_TILE_SIZE);
+
+ int y = tileHeight;
+
+ if (doInlines) { // hw: memcmp/memcpy is inlined when using constants
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ } else {
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * tileWidth)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * tileWidth);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ }
+ }
+
+ const int mapIndex = tileY * mapWidth + tileX;
+ if ((force || changed) && !map[mapIndex]) {
+ map[mapIndex] = 1;
+ ++numDirty;
+ }
+}
+
+template <class SRC>
+QRfbHextileEncoder<SRC>::QRfbHextileEncoder(QVNCServer *s)
+ : QRfbEncoder(s),
+ singleColorHextile(this), dualColorHextile(this), multiColorHextile(this)
+{
+}
+
+/*
+ \internal
+ Send dirty rects using hextile encoding.
+*/
+template <class SRC>
+void QRfbHextileEncoder<SRC>::write()
+{
+// QWSDisplay::grab(true);
+
+ QVNCDirtyMap *map = server->dirtyMap();
+ QTcpSocket *socket = server->clientSocket();
+
+ const quint32 encoding = htonl(5); // hextile encoding
+ const int bytesPerPixel = server->clientBytesPerPixel();
+
+ {
+ const char tmp[2] = { 0, 0 }; // msg type, padding
+ socket->write(tmp, sizeof(tmp));
+ }
+ {
+ const quint16 count = htons(map->numDirty);
+ socket->write((char *)&count, sizeof(count));
+ }
+
+ if (map->numDirty <= 0) {
+// QWSDisplay::ungrab();
+ return;
+ }
+
+ newBg = true;
+ newFg = true;
+
+ const QImage screenImage = server->screenImage();
+ QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE);
+
+ QSize screenSize = server->screen()->geometry().size();
+
+ for (int y = 0; y < map->mapHeight; ++y) {
+ if (rect.y + MAP_TILE_SIZE > screenSize.height())
+ rect.h = screenSize.height() - rect.y;
+ rect.w = MAP_TILE_SIZE;
+ for (int x = 0; x < map->mapWidth; ++x) {
+ if (!map->dirty(x, y))
+ continue;
+ map->setClean(x, y);
+
+ rect.x = x * MAP_TILE_SIZE;
+ if (rect.x + MAP_TILE_SIZE > screenSize.width()) //###deviceWidth ???
+ rect.w = screenSize.width() - rect.x;
+ rect.write(socket);
+
+ socket->write((char *)&encoding, sizeof(encoding));
+
+ const uchar *screendata = screenImage.scanLine(rect.y)
+ + rect.x * screenImage.depth() / 8;
+ int linestep = screenImage.bytesPerLine();
+
+#ifndef QT_NO_QWS_CURSOR
+ // hardware cursors must be blended with the screen memory
+ const bool doBlendCursor = qt_screencursor
+ && !server->hasClientCursor()
+ && qt_screencursor->isAccelerated();
+ QImage tileImage;
+ if (doBlendCursor) {
+ const QRect tileRect(rect.x, rect.y, rect.w, rect.h);
+ const QRect cursorRect = qt_screencursor->boundingRect()
+ .translated(-server->screen()->offset());
+ if (tileRect.intersects(cursorRect)) {
+ tileImage = screenImage.copy(tileRect);
+ blendCursor(tileImage,
+ tileRect.translated(server->screen()->offset()));
+ screendata = tileImage.bits();
+ linestep = tileImage.bytesPerLine();
+ }
+ }
+#endif // QT_NO_QWS_CURSOR
+
+ if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) {
+ singleColorHextile.write(socket);
+ } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) {
+ dualColorHextile.write(socket);
+ } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) {
+ multiColorHextile.write(socket);
+ } else if (server->doPixelConversion()) {
+ const int bufferSize = rect.w * rect.h * bytesPerPixel + 1;
+ const int padding = sizeof(quint32) - sizeof(char);
+ buffer.resize(bufferSize + padding);
+
+ buffer[padding] = 1; // Raw subencoding
+
+ // convert pixels
+ char *b = buffer.data() + padding + 1;
+ const int bstep = rect.w * bytesPerPixel;
+ for (int i = 0; i < rect.h; ++i) {
+ server->convertPixels(b, (const char*)screendata, rect.w);
+ screendata += linestep;
+ b += bstep;
+ }
+ socket->write(buffer.constData() + padding, bufferSize);
+ } else {
+ quint8 subenc = 1; // Raw subencoding
+ socket->write((char *)&subenc, 1);
+
+ // send pixels
+ for (int i = 0; i < rect.h; ++i) {
+ socket->write((const char*)screendata,
+ rect.w * bytesPerPixel);
+ screendata += linestep;
+ }
+ }
+ }
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ break;
+ rect.y += MAP_TILE_SIZE;
+ }
+ socket->flush();
+ Q_ASSERT(map->numDirty == 0);
+
+// QWSDisplay::ungrab();
+}
+
+void QRfbRawEncoder::write()
+{
+// QWSDisplay::grab(false);
+
+ QVNCDirtyMap *map = server->dirtyMap();
+ QTcpSocket *socket = server->clientSocket();
+
+ const int bytesPerPixel = server->clientBytesPerPixel();
+ QSize screenSize = server->screen()->geometry().size();
+
+ // create a region from the dirty rects and send the region's merged rects.
+ QRegion rgn;
+ if (map) {
+ for (int y = 0; y < map->mapHeight; ++y) {
+ for (int x = 0; x < map->mapWidth; ++x) {
+ if (!map->dirty(x, y))
+ continue;
+ rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
+ MAP_TILE_SIZE, MAP_TILE_SIZE);
+ map->setClean(x, y);
+ }
+ }
+
+ rgn &= QRect(0, 0, screenSize.width(),
+ screenSize.height());
+ }
+ const QVector<QRect> rects = rgn.rects();
+
+ {
+ const char tmp[2] = { 0, 0 }; // msg type, padding
+ socket->write(tmp, sizeof(tmp));
+ }
+
+ {
+ const quint16 count = htons(rects.size());
+ socket->write((char *)&count, sizeof(count));
+ }
+
+ if (rects.size() <= 0) {
+// QWSDisplay::ungrab();
+ return;
+ }
+
+ const QImage *screenImage = server->screenImage();
+
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect tileRect = rects.at(i);
+ const QRfbRect rect(tileRect.x(), tileRect.y(),
+ tileRect.width(), tileRect.height());
+ rect.write(socket);
+
+ const quint32 encoding = htonl(0); // raw encoding
+ socket->write((char *)&encoding, sizeof(encoding));
+
+ int linestep = screenImage->bytesPerLine();
+ const uchar *screendata = screenImage->scanLine(rect.y)
+ + rect.x * screenImage->depth() / 8;
+
+#ifndef QT_NO_QWS_CURSOR
+ // hardware cursors must be blended with the screen memory
+ const bool doBlendCursor = qt_screencursor
+ && !server->hasClientCursor()
+ && qt_screencursor->isAccelerated();
+ QImage tileImage;
+ if (doBlendCursor) {
+ const QRect cursorRect = qt_screencursor->boundingRect()
+ .translated(-server->screen()->offset());
+ if (tileRect.intersects(cursorRect)) {
+ tileImage = screenImage->copy(tileRect);
+ blendCursor(tileImage,
+ tileRect.translated(server->screen()->offset()));
+ screendata = tileImage.bits();
+ linestep = tileImage.bytesPerLine();
+ }
+ }
+#endif // QT_NO_QWS_CURSOR
+
+ if (server->doPixelConversion()) {
+ const int bufferSize = rect.w * rect.h * bytesPerPixel;
+ if (bufferSize > buffer.size())
+ buffer.resize(bufferSize);
+
+ // convert pixels
+ char *b = buffer.data();
+ const int bstep = rect.w * bytesPerPixel;
+ for (int i = 0; i < rect.h; ++i) {
+ server->convertPixels(b, (const char*)screendata, rect.w);
+ screendata += linestep;
+ b += bstep;
+ }
+ socket->write(buffer.constData(), bufferSize);
+ } else {
+ for (int i = 0; i < rect.h; ++i) {
+ socket->write((const char*)screendata, rect.w * bytesPerPixel);
+ screendata += linestep;
+ }
+ }
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ break;
+ }
+ socket->flush();
+
+// QWSDisplay::ungrab();
+}
+
+inline QImage *QVNCServer::screenImage() const
+{
+ return qvnc_screen->image();
+}
+
+void QVNCServer::checkUpdate()
+{
+ if (!wantUpdate)
+ return;
+
+ if (dirtyCursor) {
+#ifndef QT_NO_QWS_CURSOR
+ Q_ASSERT(qvnc_cursor);
+ qvnc_cursor->write();
+#endif
+ cursor->sendClientCursor();
+ dirtyCursor = false;
+ wantUpdate = false;
+ return;
+ }
+
+ if (dirtyMap()->numDirty > 0) {
+ if (encoder)
+ encoder->write();
+ wantUpdate = false;
+ }
+}
+
+void QVNCServer::discardClient()
+{
+ timer->stop();
+ state = Unconnected;
+ delete encoder;
+ encoder = 0;
+#ifndef QT_NO_QWS_CURSOR
+ delete qvnc_cursor;
+ qvnc_cursor = 0;
+#endif
+// if (!qvnc_screen->screen())
+// QWSServer::instance()->enablePainting(false);
+}
+
+
+
+QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent, int screenId)
+ : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25),
+ vncServer(0), q_ptr(parent)
+{
+#if 0//ndef QT_NO_QWS_SIGNALHANDLER
+ QWSSignalHandler::instance()->addObject(this);
+#endif
+
+ vncServer = new QVNCServer(q_ptr, screenId);
+ vncServer->setRefreshRate(refreshRate);
+
+
+ Q_ASSERT(q_ptr->depth() == 32);
+
+ dirty = new QVNCDirtyMapOptimized<quint32>(q_ptr);
+}
+
+QVNCScreenPrivate::~QVNCScreenPrivate()
+{
+}
+
+
+void QVNCScreenPrivate::setDirty(const QRect& rect, bool force)
+{
+ if (rect.isEmpty())
+ return;
+
+// if (q_ptr->screen())
+// q_ptr->screen()->setDirty(rect);
+
+ if (!vncServer || !vncServer->isConnected()) {
+// qDebug() << "QVNCScreenPrivate::setDirty() - Not connected";
+ return;
+ }
+ const QRect r = rect; // .translated(-q_ptr->offset());
+ const int x1 = r.x() / MAP_TILE_SIZE;
+ int y = r.y() / MAP_TILE_SIZE;
+ for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++)
+ for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++)
+ dirty->setDirty(x, y, force);
+
+ vncServer->setDirty();
+}
+
+
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h
new file mode 100644
index 0000000..3b514a5
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncserver.h
@@ -0,0 +1,533 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCREENVNC_P_H
+#define QSCREENVNC_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 QLibrary class. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qvncintegration.h"
+#include "qvnccursor.h"
+#define QT_NO_QWS_CURSOR
+
+#ifndef QT_NO_QWS_VNC
+
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qsharedmemory.h>
+#include <QtNetwork/qtcpsocket.h>
+#include <QtNetwork/qtcpserver.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVNCServer;
+
+#ifndef QT_NO_QWS_CURSOR
+class QVNCCursor : public QProxyScreenCursor
+{
+public:
+ QVNCCursor(QVNCScreen *s);
+ ~QVNCCursor();
+
+ void hide();
+ void show();
+ void set(const QImage &image, int hotx, int hoty);
+ void move(int x, int y);
+
+private:
+ void setDirty(const QRect &r) const;
+ QVNCScreen *screen;
+};
+
+class QVNCClientCursor : public QProxyScreenCursor
+{
+public:
+ QVNCClientCursor(QVNCServer *s);
+ ~QVNCClientCursor();
+
+ void set(const QImage &image, int hotx, int hoty);
+ void write() const;
+
+private:
+ QVNCServer *server;
+};
+#endif // QT_NO_QWS_CURSOR
+
+#define MAP_TILE_SIZE 16
+#define MAP_WIDTH 1280 / MAP_TILE_SIZE
+#define MAP_HEIGHT 1024 / MAP_TILE_SIZE
+
+class QVNCDirtyMap
+{
+public:
+ QVNCDirtyMap(QVNCScreen *screen);
+ virtual ~QVNCDirtyMap();
+
+ void reset();
+ bool dirty(int x, int y) const;
+ virtual void setDirty(int x, int y, bool force = false) = 0;
+ void setClean(int x, int y);
+
+ int bytesPerPixel;
+
+ int numDirty;
+ int mapWidth;
+ int mapHeight;
+
+protected:
+ uchar *map;
+ QVNCScreen *screen;
+ uchar *buffer;
+ int bufferWidth;
+ int bufferHeight;
+ int bufferStride;
+ int numTiles;
+};
+
+template <class T>
+class QVNCDirtyMapOptimized : public QVNCDirtyMap
+{
+public:
+ QVNCDirtyMapOptimized(QVNCScreen *screen) : QVNCDirtyMap(screen) {}
+ ~QVNCDirtyMapOptimized() {}
+
+ void setDirty(int x, int y, bool force = false);
+};
+
+class QRfbRect
+{
+public:
+ QRfbRect() {}
+ QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) {
+ x = _x; y = _y; w = _w; h = _h;
+ }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s) const;
+
+ quint16 x;
+ quint16 y;
+ quint16 w;
+ quint16 h;
+};
+
+class QRfbPixelFormat
+{
+public:
+ static int size() { return 16; }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ int bitsPerPixel;
+ int depth;
+ bool bigEndian;
+ bool trueColor;
+ int redBits;
+ int greenBits;
+ int blueBits;
+ int redShift;
+ int greenShift;
+ int blueShift;
+};
+
+class QRfbServerInit
+{
+public:
+ QRfbServerInit() { name = 0; }
+ ~QRfbServerInit() { delete[] name; }
+
+ int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); }
+ void setName(const char *n);
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ quint16 width;
+ quint16 height;
+ QRfbPixelFormat format;
+ char *name;
+};
+
+class QRfbSetEncodings
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint16 count;
+};
+
+class QRfbFrameBufferUpdateRequest
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char incremental;
+ QRfbRect rect;
+};
+
+class QRfbKeyEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char down;
+ int keycode;
+ int unicode;
+};
+
+class QRfbPointerEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ Qt::MouseButtons buttons;
+ enum { WheelNone,
+ WheelUp,
+ WheelDown,
+ WheelLeft,
+ WheelRight
+ } wheelDirection;
+ quint16 x;
+ quint16 y;
+};
+
+class QRfbClientCutText
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint32 length;
+};
+
+class QVNCScreenPrivate : public QObject
+{
+public:
+ QVNCScreenPrivate(QVNCScreen *parent, int screenId);
+ ~QVNCScreenPrivate();
+
+ void setDirty(const QRect &rect, bool force = false);
+ void configure();
+
+ qreal dpiX;
+ qreal dpiY;
+ bool doOnScreenSurface;
+ QVNCDirtyMap *dirty;
+ int refreshRate;
+ QVNCServer *vncServer;
+
+#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
+ QSharedMemory shm;
+#endif
+
+ QVNCScreen *q_ptr;
+};
+
+class QRfbEncoder
+{
+public:
+ QRfbEncoder(QVNCServer *s) : server(s) {}
+ virtual ~QRfbEncoder() {}
+
+ virtual void write() = 0;
+
+protected:
+ QVNCServer *server;
+};
+
+class QRfbRawEncoder : public QRfbEncoder
+{
+public:
+ QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {}
+
+ void write();
+
+private:
+ QByteArray buffer;
+};
+
+template <class SRC> class QRfbHextileEncoder;
+
+template <class SRC>
+class QRfbSingleColorHextile
+{
+public:
+ QRfbSingleColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbDualColorHextile
+{
+public:
+ QRfbDualColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ struct Rect {
+ quint8 xy;
+ quint8 wh;
+ } Q_PACKED rects[8 * 16];
+
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+
+private:
+ inline int lastx() const { return rectx(numRects); }
+ inline int lasty() const { return recty(numRects); }
+ inline int rectx(int r) const { return rects[r].xy >> 4; }
+ inline int recty(int r) const { return rects[r].xy & 0x0f; }
+ inline int width(int r) const { return (rects[r].wh >> 4) + 1; }
+ inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; }
+
+ inline void setX(int r, int x) {
+ rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ rects[r].xy = (rects[r].xy & 0xf0) | y;
+ }
+ inline void setWidth(int r, int width) {
+ rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
+ }
+
+ inline void setWidth(int width) { setWidth(numRects, width); }
+ inline void setHeight(int height) { setHeight(numRects, height); }
+ inline void setX(int x) { setX(numRects, x); }
+ inline void setY(int y) { setY(numRects, y); }
+ void next();
+};
+
+template <class SRC>
+class QRfbMultiColorHextile
+{
+public:
+ QRfbMultiColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ inline quint8* rect(int r) {
+ return rects.data() + r * (bpp + 2);
+ }
+ inline const quint8* rect(int r) const {
+ return rects.constData() + r * (bpp + 2);
+ }
+ inline void setX(int r, int x) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (x << 4) | (*ptr & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (*ptr & 0xf0) | y;
+ }
+ void setColor(SRC color);
+ inline int rectx(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr >> 4;
+ }
+ inline int recty(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr & 0x0f;
+ }
+ inline void setWidth(int r, int width) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = (*ptr & 0xf0) | (height - 1);
+ }
+
+ bool beginRect();
+ void endRect();
+
+ static const int maxRectsSize = 16 * 16;
+ QVarLengthArray<quint8, maxRectsSize> rects;
+
+ quint8 bpp;
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbHextileEncoder : public QRfbEncoder
+{
+public:
+ QRfbHextileEncoder(QVNCServer *s);
+ void write();
+
+private:
+ enum SubEncoding {
+ Raw = 1,
+ BackgroundSpecified = 2,
+ ForegroundSpecified = 4,
+ AnySubrects = 8,
+ SubrectsColoured = 16
+ };
+
+ QByteArray buffer;
+ QRfbSingleColorHextile<SRC> singleColorHextile;
+ QRfbDualColorHextile<SRC> dualColorHextile;
+ QRfbMultiColorHextile<SRC> multiColorHextile;
+
+ SRC bg;
+ SRC fg;
+ bool newBg;
+ bool newFg;
+
+ friend class QRfbSingleColorHextile<SRC>;
+ friend class QRfbDualColorHextile<SRC>;
+ friend class QRfbMultiColorHextile<SRC>;
+};
+
+class QVNCServer : public QObject
+{
+ Q_OBJECT
+public:
+ QVNCServer(QVNCScreen *screen);
+ QVNCServer(QVNCScreen *screen, int id);
+ ~QVNCServer();
+
+ void setDirty();
+ void setDirtyCursor() { dirtyCursor = true; setDirty(); }
+ inline bool isConnected() const { return state == Connected; }
+ inline void setRefreshRate(int rate) { refreshRate = rate; }
+
+ enum ClientMsg { SetPixelFormat = 0,
+ FixColourMapEntries = 1,
+ SetEncodings = 2,
+ FramebufferUpdateRequest = 3,
+ KeyEvent = 4,
+ PointerEvent = 5,
+ ClientCutText = 6 };
+
+ enum ServerMsg { FramebufferUpdate = 0,
+ SetColourMapEntries = 1 };
+
+ void convertPixels(char *dst, const char *src, int count) const;
+
+ inline int clientBytesPerPixel() const {
+ return pixelFormat.bitsPerPixel / 8;
+ }
+
+ inline QVNCScreen* screen() const { return qvnc_screen; }
+ inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->dirtyMap(); }
+ inline QTcpSocket* clientSocket() const { return client; }
+ QImage *screenImage() const;
+ inline bool doPixelConversion() const { return needConversion; }
+#ifndef QT_NO_QWS_CURSOR
+ inline bool hasClientCursor() const { return qvnc_cursor != 0; }
+#endif
+
+ void setCursor(QVNCCursor * c) { cursor = c; }
+private:
+ void setPixelFormat();
+ void setEncodings();
+ void frameBufferUpdateRequest();
+ void pointerEvent();
+ void keyEvent();
+ void clientCutText();
+ bool pixelConversionNeeded() const;
+
+private slots:
+ void newConnection();
+ void readClient();
+ void checkUpdate();
+ void discardClient();
+
+private:
+ void init(uint port);
+ enum ClientState { Unconnected, Protocol, Init, Connected };
+ QTimer *timer;
+ QTcpServer *serverSocket;
+ QTcpSocket *client;
+ ClientState state;
+ quint8 msgType;
+ bool handleMsg;
+ QRfbPixelFormat pixelFormat;
+ Qt::KeyboardModifiers keymod;
+ Qt::MouseButtons buttons;
+ int encodingsPending;
+ int cutTextPending;
+ uint supportCopyRect : 1;
+ uint supportRRE : 1;
+ uint supportCoRRE : 1;
+ uint supportHextile : 1;
+ uint supportZRLE : 1;
+ uint supportCursor : 1;
+ uint supportDesktopSize : 1;
+ bool wantUpdate;
+ bool sameEndian;
+ bool needConversion;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ bool swapBytes;
+#endif
+ bool dirtyCursor;
+ int refreshRate;
+ QVNCScreen *qvnc_screen;
+#ifndef QT_NO_QWS_CURSOR
+ QVNCClientCursor *qvnc_cursor;
+#endif
+
+ QRfbEncoder *encoder;
+ QVNCCursor *cursor;
+};
+
+
+QT_END_NAMESPACE
+#endif // QT_NO_QWS_VNC
+#endif // QSCREENVNC_P_H
diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro
new file mode 100644
index 0000000..07f8d88
--- /dev/null
+++ b/src/plugins/platforms/vnc/vnc.pro
@@ -0,0 +1,22 @@
+TARGET = qvncgraphicssystem
+include(../../qpluginbase.pri)
+
+QT += network
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = main.cpp qvncintegration.cpp
+HEADERS = qvncintegration.h
+
+HEADERS += qvncserver.h
+SOURCES += qvncserver.cpp
+
+HEADERS += qvnccursor.h
+SOURCES += qvnccursor.cpp
+
+include(../fb_base/fb_base.pri)
+include(../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+
+INSTALLS += target
diff --git a/src/plugins/platforms/wayland/main.cpp b/src/plugins/platforms/wayland/main.cpp
new file mode 100644
index 0000000..6dc1c2b
--- /dev/null
+++ b/src/plugins/platforms/wayland/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qwaylandintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QWaylandIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "Wayland";
+ list << "WaylandGL";
+ return list;
+}
+
+QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "wayland")
+ return new QWaylandIntegration;
+ if (system.toLower() == "waylandgl")
+ return new QWaylandIntegration(true);
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(wayland, QWaylandIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h
new file mode 100644
index 0000000..643e89c
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandbuffer.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the config.tests 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 QWAYLANDBUFFER_H
+#define QWAYLANDBUFFER_H
+
+#include <QtCore/QSize>
+
+#include <wayland-client-protocol.h>
+
+class QWaylandBuffer {
+public:
+ QWaylandBuffer() { }
+ virtual ~QWaylandBuffer() { }
+ wl_buffer *buffer() {return mBuffer;}
+ virtual QSize size() const = 0;
+
+protected:
+ struct wl_buffer *mBuffer;
+};
+
+#endif // QWAYLANDBUFFER_H
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
new file mode 100644
index 0000000..614686f
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandcursor.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandinputdevice.h"
+#include "qwaylandshmsurface.h"
+#include "qwaylandscreen.h"
+
+#include <QtGui/QImageReader>
+
+#define DATADIR "/usr/share"
+
+static const struct pointer_image {
+ const char *filename;
+ int hotspot_x, hotspot_y;
+} pointer_images[] = {
+ /* FIXME: Half of these are wrong... */
+ /* Qt::ArrowCursor */
+ { DATADIR "/wayland/left_ptr.png", 10, 5 },
+ /* Qt::UpArrowCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::CrossCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::WaitCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::IBeamCursor */
+ { DATADIR "/wayland/xterm.png", 15, 15 },
+ /* Qt::SizeVerCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::SizeHorCursor */
+ { DATADIR "/wayland/bottom_left_corner.png", 6, 30 },
+ /* Qt::SizeBDiagCursor */
+ { DATADIR "/wayland/bottom_right_corner.png", 28, 28 },
+ /* Qt::SizeFDiagCursor */
+ { DATADIR "/wayland/bottom_side.png", 16, 20 },
+ /* Qt::SizeAllCursor */
+ { DATADIR "/wayland/left_side.png", 10, 20 },
+ /* Qt::BlankCursor */
+ { DATADIR "/wayland/right_side.png", 30, 19 },
+ /* Qt::SplitVCursor */
+ { DATADIR "/wayland/sb_v_double_arrow.png", 15, 15 },
+ /* Qt::SplitHCursor */
+ { DATADIR "/wayland/sb_h_double_arrow.png", 15, 15 },
+ /* Qt::PointingHandCursor */
+ { DATADIR "/wayland/hand2.png", 14, 8 },
+ /* Qt::ForbiddenCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::WhatsThisCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::BusyCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::OpenHandCursor */
+ { DATADIR "/wayland/hand1.png", 18, 11 },
+ /* Qt::ClosedHandCursor */
+ { DATADIR "/wayland/grabbing.png", 20, 17 },
+ /* Qt::DragCopyCursor */
+ { DATADIR "/wayland/dnd-copy.png", 13, 13 },
+ /* Qt::DragMoveCursor */
+ { DATADIR "/wayland/dnd-move.png", 13, 13 },
+ /* Qt::DragLinkCursor */
+ { DATADIR "/wayland/dnd-link.png", 13, 13 },
+};
+
+QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
+ : QPlatformCursor(screen)
+ , mBuffer(0)
+ , mDisplay(screen->display())
+{
+}
+
+void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget)
+{
+ const struct pointer_image *p;
+
+ if (widget == NULL)
+ return;
+
+ p = NULL;
+
+ switch (cursor->shape()) {
+ case Qt::ArrowCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::UpArrowCursor:
+ case Qt::CrossCursor:
+ case Qt::WaitCursor:
+ break;
+ case Qt::IBeamCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::SizeVerCursor: /* 5 */
+ case Qt::SizeHorCursor:
+ case Qt::SizeBDiagCursor:
+ case Qt::SizeFDiagCursor:
+ case Qt::SizeAllCursor:
+ case Qt::BlankCursor: /* 10 */
+ break;
+ case Qt::SplitVCursor:
+ case Qt::SplitHCursor:
+ case Qt::PointingHandCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::ForbiddenCursor:
+ case Qt::WhatsThisCursor: /* 15 */
+ case Qt::BusyCursor:
+ break;
+ case Qt::OpenHandCursor:
+ case Qt::ClosedHandCursor:
+ case Qt::DragCopyCursor:
+ case Qt::DragMoveCursor: /* 20 */
+ case Qt::DragLinkCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+
+ default:
+ case Qt::BitmapCursor:
+ break;
+ }
+
+ if (!p) {
+ p = &pointer_images[0];
+ qWarning("unhandled cursor %d", cursor->shape());
+ }
+
+ QImageReader reader(p->filename);
+
+ if (!reader.canRead())
+ return;
+
+ if (mBuffer == NULL || mBuffer->size() != reader.size()) {
+ if (mBuffer)
+ delete mBuffer;
+
+ mBuffer = new QWaylandShmBuffer(mDisplay, reader.size(),
+ QImage::Format_ARGB32);
+ }
+
+ reader.read(mBuffer->image());
+
+ mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y);
+}
+
+void QWaylandDisplay::setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y)
+{
+ /* Qt doesn't tell us which input device we should set the cursor
+ * for, so set it for all devices. */
+ for (int i = 0; i < mInputDevices.count(); i++) {
+ QWaylandInputDevice *inputDevice = mInputDevices.at(i);
+ inputDevice->attach(buffer, x, y);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h
new file mode 100644
index 0000000..254cb94
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandcursor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDCURSOR_H
+#define QWAYLANDCURSOR_H
+
+#include <QtGui/QPlatformCursor>
+
+class QWaylandShmBuffer;
+class QWaylandDisplay;
+class QWaylandScreen;
+
+class QWaylandCursor : QPlatformCursor {
+public:
+ QWaylandCursor(QWaylandScreen *screen);
+
+ void changeCursor(QCursor *cursor, QWidget *widget);
+ QWaylandShmBuffer *mBuffer;
+ QWaylandDisplay *mDisplay;
+};
+
+#endif // QWAYLANDCURSOR_H
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
new file mode 100644
index 0000000..27f4334
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylanddisplay.h"
+
+#include "qwaylandwindow.h"
+#include "qwaylandscreen.h"
+#include "qwaylandcursor.h"
+#include "qwaylandinputdevice.h"
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+struct wl_surface *QWaylandDisplay::createSurface()
+{
+ return wl_compositor_create_surface(mCompositor);
+}
+
+struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd,
+ int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual)
+{
+ return wl_shm_create_buffer(mShm, fd, width, height, stride, visual);
+}
+
+struct wl_visual *QWaylandDisplay::rgbVisual()
+{
+ return wl_display_get_rgb_visual(mDisplay);
+}
+
+struct wl_visual *QWaylandDisplay::argbVisual()
+{
+ return wl_display_get_argb_visual(mDisplay);
+}
+
+struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
+{
+ return wl_display_get_premultiplied_argb_visual(mDisplay);
+}
+
+struct wl_egl_display *QWaylandDisplay::nativeDisplay()
+{
+ return mNativeEglDisplay;
+}
+
+void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell,
+ uint32_t time, uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width, int32_t height)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(shell);
+ Q_UNUSED(time);
+ Q_UNUSED(edges);
+ QWaylandWindow *ww = (QWaylandWindow *) wl_surface_get_user_data(surface);
+
+ ww->configure(time, edges, 0, 0, width, height);
+}
+
+const struct wl_shell_listener QWaylandDisplay::shellListener = {
+ QWaylandDisplay::shellHandleConfigure,
+};
+
+void QWaylandDisplay::outputHandleGeometry(void *data,
+ struct wl_output *output,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ QWaylandDisplay *waylandDisplay = (QWaylandDisplay *) data;
+
+ QRect outputRect = QRect(x, y, width, height);
+ waylandDisplay->createNewScreen(output, outputRect);
+}
+
+const struct wl_output_listener QWaylandDisplay::outputListener = {
+ QWaylandDisplay::outputHandleGeometry
+};
+
+void QWaylandDisplay::displayHandleGlobal(struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version, void *data)
+{
+ Q_UNUSED(version);
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+
+ if (strcmp(interface, "compositor") == 0) {
+ qwd->mCompositor = wl_compositor_create(display, id);
+ } else if (strcmp(interface, "shm") == 0) {
+ qwd->mShm = wl_shm_create(display, id);
+ } else if (strcmp(interface, "shell") == 0) {
+ qwd->mShell = wl_shell_create(display, id);
+ wl_shell_add_listener(qwd->mShell, &shellListener, qwd);
+ } else if (strcmp(interface, "output") == 0) {
+ struct wl_output *output = wl_output_create(display, id);
+ wl_output_add_listener(output, &outputListener, qwd);
+ } else if (strcmp(interface, "input_device") == 0) {
+ QWaylandInputDevice *inputDevice =
+ new QWaylandInputDevice(display, id);
+ qwd->mInputDevices.append(inputDevice);
+ }
+}
+
+void QWaylandDisplay::iterate()
+{
+ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE | WL_DISPLAY_WRITABLE);
+}
+
+void QWaylandDisplay::readEvents(void)
+{
+ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE);
+}
+
+int
+QWaylandDisplay::sourceUpdate(uint32_t mask, void *data)
+{
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+
+ /* FIXME: We get a callback here when we ask wl_display for the
+ * fd, but at that point we don't have the socket notifier as we
+ * need the fd to create that. We'll probably need to split that
+ * API into get_fd and set_update_func functions. */
+ if (qwd->mWriteNotifier == NULL)
+ return 0;
+
+ qwd->mWriteNotifier->setEnabled(mask & WL_DISPLAY_WRITABLE);
+
+ return 0;
+}
+
+void QWaylandDisplay::flushRequests(void)
+{
+ wl_display_iterate(mDisplay, WL_DISPLAY_WRITABLE);
+}
+
+QWaylandDisplay::QWaylandDisplay(void)
+ : mWriteNotifier(0)
+{
+#ifdef QT_WAYLAND_GL_SUPPORT
+ EGLint major, minor;
+#endif
+ mDisplay = wl_display_connect(NULL);
+ if (mDisplay == NULL) {
+ fprintf(stderr, "failed to create display: %m\n");
+ return;
+ }
+
+ wl_display_add_global_listener(mDisplay,
+ QWaylandDisplay::displayHandleGlobal, this);
+
+#ifdef QT_WAYLAND_GL_SUPPORT
+ mNativeEglDisplay = wl_egl_display_create(mDisplay);
+#else
+ mNativeEglDisplay = 0;
+#endif
+
+ readEvents();
+
+#ifdef QT_WAYLAND_GL_SUPPORT
+ mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
+ if (mEglDisplay == NULL) {
+ qWarning("EGL not available");
+ } else {
+ if (!eglInitialize(mEglDisplay, &major, &minor)) {
+ qWarning("failed to initialize EGL display");
+ return;
+ }
+ }
+#else
+ mEglDisplay = 0;
+#endif
+
+ int fd = wl_display_get_fd(mDisplay, sourceUpdate, this);
+ mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
+ connect(mReadNotifier,
+ SIGNAL(activated(int)), this, SLOT(readEvents()));
+
+ mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this);
+ connect(mWriteNotifier,
+ SIGNAL(activated(int)), this, SLOT(flushRequests()));
+ mWriteNotifier->setEnabled(false);
+}
+
+QWaylandDisplay::~QWaylandDisplay(void)
+{
+ close(mFd);
+#ifdef QT_WAYLAND_GL_SUPPORT
+ eglTerminate(mEglDisplay);
+#endif
+ wl_display_destroy(mDisplay);
+}
+
+void QWaylandDisplay::createNewScreen(struct wl_output *output, QRect geometry)
+{
+ QWaylandScreen *waylandScreen = new QWaylandScreen(this,output,geometry);
+ mScreens.append(waylandScreen);
+}
+
+void QWaylandDisplay::syncCallback(wl_display_sync_func_t func, void *data)
+{
+ wl_display_sync_callback(mDisplay, func, data);
+}
+
+void QWaylandDisplay::frameCallback(wl_display_frame_func_t func, void *data)
+{
+ wl_display_frame_callback(mDisplay, func, data);
+}
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
new file mode 100644
index 0000000..d994ffe
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDDISPLAY_H
+#define QWAYLANDDISPLAY_H
+
+#include <QtCore/QObject>
+#include <QtCore/QRect>
+#include <QtCore/QDataStream>
+#include <QtCore/QTextStream>
+#include <QtCore/QMetaType>
+#include <QtGui>
+
+#include "qwaylandinclude.h"
+
+class QWaylandInputDevice;
+class QSocketNotifier;
+class QWaylandBuffer;
+class QPlatformScreen;
+class QWaylandScreen;
+
+class QWaylandDisplay : public QObject {
+ Q_OBJECT
+
+public:
+ QWaylandDisplay(void);
+ ~QWaylandDisplay(void);
+
+ void createNewScreen(struct wl_output *output, QRect geometry);
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+ struct wl_surface *createSurface();
+ struct wl_buffer *createShmBuffer(int fd, int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual);
+ struct wl_visual *rgbVisual();
+ struct wl_visual *argbVisual();
+ struct wl_visual *argbPremultipliedVisual();
+ struct wl_egl_display *nativeDisplay();
+ EGLDisplay eglDisplay() { return mEglDisplay; }
+
+ void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
+
+ void syncCallback(wl_display_sync_func_t func, void *data);
+ void frameCallback(wl_display_frame_func_t func, void *data);
+
+ void iterate();
+
+public slots:
+ void readEvents(void);
+ void flushRequests(void);
+
+private:
+ struct wl_display *mDisplay;
+ struct wl_compositor *mCompositor;
+ struct wl_shm *mShm;
+ struct wl_shell *mShell;
+ char *mDeviceName;
+ int mFd;
+ QList<QPlatformScreen *> mScreens;
+ QList<QWaylandInputDevice *> mInputDevices;
+ QSocketNotifier *mReadNotifier;
+ QSocketNotifier *mWriteNotifier;
+ EGLDisplay mEglDisplay;
+ struct wl_egl_display *mNativeEglDisplay;
+
+ static void displayHandleGlobal(struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version, void *data);
+
+ static void outputHandleGeometry(void *data,
+ struct wl_output *output,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height);
+
+ static void shellHandleConfigure(void *data, struct wl_shell *shell,
+ uint32_t time, uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width, int32_t height);
+
+ static int sourceUpdate(uint32_t mask, void *data);
+
+ static const struct wl_output_listener outputListener;
+ static const struct wl_shell_listener shellListener;
+};
+
+#endif // QWAYLANDDISPLAY_H
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
new file mode 100644
index 0000000..a8bc352
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
@@ -0,0 +1,183 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylanddrmsurface.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylandscreen.h"
+
+#include <QtOpenGL/QGLFramebufferObject>
+#include <QtOpenGL/QGLContext>
+
+#include <QtOpenGL/private/qglengineshadermanager_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+
+static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
+{
+ const GLenum target = GL_TEXTURE_2D;
+ QRectF src = br.isEmpty()
+ ? QRectF(QPointF(), texSize)
+ : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
+
+ if (target == GL_TEXTURE_2D) {
+ qreal width = texSize.width();
+ qreal height = texSize.height();
+
+ src.setLeft(src.left() / width);
+ src.setRight(src.right() / width);
+ src.setTop(src.top() / height);
+ src.setBottom(src.bottom() / height);
+ }
+
+ const GLfloat tx1 = src.left();
+ const GLfloat tx2 = src.right();
+ const GLfloat ty1 = src.top();
+ const GLfloat ty2 = src.bottom();
+
+ GLfloat texCoordArray[4*2] = {
+ tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
+ };
+
+ GLfloat vertexArray[4*2];
+ vertexArray[0] = rect.left(); vertexArray[1] = rect.top();
+ vertexArray[2] = rect.right(); vertexArray[3] = rect.top();
+ vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom();
+ vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom();
+
+ glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
+ glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
+
+ glBindTexture(target, tex_id);
+
+ glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
+ glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
+ glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
+
+ glBindTexture(target, 0);
+}
+
+static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
+{
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_BLEND);
+ glViewport(0, 0, viewport.width(), viewport.height());
+
+ QGLShaderProgram *blitProgram =
+ QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
+ blitProgram->bind();
+ blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
+
+ // The shader manager's blit program does not multiply the
+ // vertices by the pmv matrix, so we need to do the effect
+ // of the orthographic projection here ourselves.
+ QRectF r;
+ qreal w = viewport.width();
+ qreal h = viewport.height();
+ r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
+ if (targetRect.right() == (viewport.width() - 1))
+ r.setRight(1.0f);
+ else
+ r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
+ r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
+ if (targetRect.bottom() == (viewport.height() - 1))
+ r.setTop(1.0f);
+ else
+ r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
+
+ drawTexture(r, texture, texSize, sourceRect);
+}
+
+QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mPaintDevice(0)
+{
+
+}
+
+QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface()
+{
+ delete mPaintDevice;
+}
+
+QPaintDevice *QWaylandDrmWindowSurface::paintDevice()
+{
+ return mPaintDevice;
+}
+
+void QWaylandDrmWindowSurface::beginPaint(const QRegion &)
+{
+ window()->platformWindow()->glContext()->makeCurrent();
+ glClearColor(0,0,0,0xff);
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
+void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(offset);
+ Q_UNUSED(region);
+ QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
+
+ if (mPaintDevice->isBound())
+ mPaintDevice->release();
+
+ QRect rect(0,0,size().width(),size().height());
+ QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
+ blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
+ ww->glContext()->swapBuffers();
+}
+
+void QWaylandDrmWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+ window()->platformWindow()->glContext()->makeCurrent();
+ delete mPaintDevice;
+ mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil,GL_TEXTURE_2D,GL_RGBA);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
new file mode 100644
index 0000000..78418ee
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 config.tests 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 QWAYLANDDRMSURFACE_H
+#define QWAYLANDDRMSURFACE_H
+
+#include "qwaylanddisplay.h"
+
+#include <QtGui/private/qwindowsurface_p.h>
+
+class QGLFramebufferObject;
+
+class QWaylandDrmWindowSurface : public QWindowSurface
+{
+public:
+ QWaylandDrmWindowSurface(QWidget *window);
+ ~QWaylandDrmWindowSurface();
+
+ void beginPaint(const QRegion &);
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+
+ void resize(const QSize &size);
+
+private:
+
+ QWaylandDisplay *mDisplay;
+ QGLFramebufferObject *mPaintDevice;
+};
+
+#endif // QWAYLANDDRMSURFACE_H
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/qwaylandeglwindow.cpp
new file mode 100644
index 0000000..ed54bb9
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandeglwindow.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the config.tests 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 "qwaylandeglwindow.h"
+
+#include "qwaylandscreen.h"
+#include "qwaylandglcontext.h"
+#include "qwaylandinclude.h"
+
+QWaylandEglWindow::QWaylandEglWindow(QWidget *window)
+ : QWaylandWindow(window)
+ , mGLContext(0)
+ , mWaylandEglWindow(0)
+{
+ //super creates a new surface
+ newSurfaceCreated();
+}
+
+QWaylandEglWindow::~QWaylandEglWindow()
+{
+ if (mGLContext)
+ delete mGLContext;
+}
+
+QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
+{
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandEglWindow::setGeometry(const QRect &rect)
+{
+ QWaylandWindow::setGeometry(rect);
+ if (mWaylandEglWindow) {
+ wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0);
+ }
+}
+
+void QWaylandEglWindow::setParent(const QPlatformWindow *parent)
+{
+ const QWaylandWindow *wParent = static_cast<const QWaylandWindow *>(parent);
+
+ mParentWindow = wParent;
+}
+
+QPlatformGLContext * QWaylandEglWindow::glContext() const
+{
+ if (!mGLContext) {
+ QWaylandEglWindow *that = const_cast<QWaylandEglWindow *>(this);
+ that->mGLContext = new QWaylandGLContext(that->mDisplay,widget()->platformWindowFormat());
+
+ EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
+ EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ that->mGLContext->setEglSurface(surface);
+ }
+
+ return mGLContext;
+}
+
+void QWaylandEglWindow::newSurfaceCreated()
+{
+ if (mWaylandEglWindow) {
+ wl_egl_window_destroy(mWaylandEglWindow);
+ }
+ wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual();
+ QSize size = geometry().size();
+ if (!size.isValid())
+ size = QSize(0,0);
+
+ mWaylandEglWindow = wl_egl_window_create(mDisplay->nativeDisplay(),mSurface,size.width(),size.height(),visual);
+ if (mGLContext) {
+ EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
+ EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ mGLContext->setEglSurface(surface);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.h b/src/plugins/platforms/wayland/qwaylandeglwindow.h
new file mode 100644
index 0000000..4b3bb5b
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandeglwindow.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 config.tests 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 QWAYLANDEGLWINDOW_H
+#define QWAYLANDEGLWINDOW_H
+
+#include "qwaylandwindow.h"
+
+class QWaylandGLContext;
+
+class QWaylandEglWindow : public QWaylandWindow
+{
+public:
+ QWaylandEglWindow(QWidget *window);
+ ~QWaylandEglWindow();
+ WindowType windowType() const;
+ void setGeometry(const QRect &rect);
+ void setParent(const QPlatformWindow *parent);
+ QPlatformGLContext *glContext() const;
+protected:
+ void newSurfaceCreated();
+private:
+ QWaylandGLContext *mGLContext;
+ struct wl_egl_window *mWaylandEglWindow;
+ EGLConfig mConfig;
+
+ const QWaylandWindow *mParentWindow;
+};
+
+#endif // QWAYLANDEGLWINDOW_H
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
new file mode 100644
index 0000000..3720567
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandglcontext.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylanddrmsurface.h"
+
+#include "../eglconvenience/qeglconvenience.h"
+
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformWindowFormat>
+
+Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex)
+
+QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format)
+ : QPlatformGLContext()
+ , mDisplay(wd)
+ , mSurface(EGL_NO_SURFACE)
+ , mConfig(q_configFromQPlatformWindowFormat(mDisplay->eglDisplay(),format,true))
+ , mFormat(qt_qPlatformWindowFormatFromConfig(mDisplay->eglDisplay(),mConfig))
+{
+ QPlatformGLContext *sharePlatformContext = 0;
+ if (format.useDefaultSharedContext()) {
+ if (!QPlatformGLContext::defaultSharedContext()) {
+ if (qt_defaultSharedContextMutex()->tryLock()){
+ createDefaultSharedContex(wd);
+ qt_defaultSharedContextMutex()->unlock();
+ } else {
+ qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created
+ qt_defaultSharedContextMutex()->unlock();
+ }
+ }
+ sharePlatformContext = QPlatformGLContext::defaultSharedContext();
+ } else {
+ sharePlatformContext = format.sharedGLContext();
+ }
+ mFormat.setSharedContext(sharePlatformContext);
+ EGLContext shareEGLContext = EGL_NO_CONTEXT;
+ if (sharePlatformContext)
+ shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ mContext = eglCreateContext(mDisplay->eglDisplay(), mConfig,
+ shareEGLContext, eglContextAttrs.constData());
+}
+
+QWaylandGLContext::QWaylandGLContext()
+ : QPlatformGLContext()
+ , mDisplay(0)
+ , mContext(EGL_NO_CONTEXT)
+ , mSurface(EGL_NO_SURFACE)
+ , mConfig(0)
+{ }
+
+QWaylandGLContext::~QWaylandGLContext()
+{
+ eglDestroyContext(mDisplay->eglDisplay(),mContext);
+}
+
+void QWaylandGLContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ if (mSurface == EGL_NO_SURFACE) {
+ qWarning("makeCurrent with EGL_NO_SURFACE");
+ }
+ eglMakeCurrent(mDisplay->eglDisplay(), mSurface, mSurface, mContext);
+}
+
+void QWaylandGLContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void QWaylandGLContext::swapBuffers()
+{
+ eglSwapBuffers(mDisplay->eglDisplay(),mSurface);
+}
+
+void *QWaylandGLContext::getProcAddress(const QString &string)
+{
+ return (void *) eglGetProcAddress(string.toLatin1().data());
+}
+
+void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display)
+{
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ QWaylandGLContext *defaultSharedContext = new QWaylandGLContext;
+ defaultSharedContext->mDisplay = display;
+ defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(),mConfig,
+ EGL_NO_CONTEXT, eglContextAttrs.constData());
+ QPlatformGLContext::setDefaultSharedContext(defaultSharedContext);
+}
+
+void QWaylandGLContext::setEglSurface(EGLSurface surface)
+{
+ doneCurrent();
+ mSurface = surface;
+}
+
+EGLConfig QWaylandGLContext::eglConfig() const
+{
+ return mConfig;
+}
+
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.h b/src/plugins/platforms/wayland/qwaylandglcontext.h
new file mode 100644
index 0000000..dd319fd
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDGLCONTEXT_H
+#define QWAYLANDGLCONTEXT_H
+
+#include "qwaylanddisplay.h"
+
+#include <QtGui/QPlatformGLContext>
+
+class QWaylandWindow;
+class QWaylandDrmWindowSurface;
+
+#include "qwaylandinclude.h"
+
+class QWaylandGLContext : public QPlatformGLContext {
+public:
+ QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format);
+ ~QWaylandGLContext();
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString&);
+
+ QPlatformWindowFormat platformWindowFormat() const { return mFormat; }
+
+ void setEglSurface(EGLSurface surface);
+ EGLConfig eglConfig() const;
+private:
+ QWaylandDisplay *mDisplay;
+
+ EGLContext mContext;
+ EGLSurface mSurface;
+ EGLConfig mConfig;
+ QPlatformWindowFormat mFormat;
+
+ void createDefaultSharedContex(QWaylandDisplay *display);
+ QWaylandGLContext();
+
+};
+
+
+#endif // QWAYLANDGLCONTEXT_H
diff --git a/src/plugins/platforms/wayland/qwaylandinclude.h b/src/plugins/platforms/wayland/qwaylandinclude.h
new file mode 100644
index 0000000..0135251
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinclude.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 config.tests 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 QWAYLANDINCLUDE_H
+#define QWAYLANDINCLUDE_H
+
+#include <wayland-client.h>
+
+#ifdef QT_WAYLAND_GL_SUPPORT
+#include <wayland-egl.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+
+#else
+typedef void* EGLDisplay;
+typedef void* EGLConfig;
+#endif
+
+#endif // QWAYLANDINCLUDE_H
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
new file mode 100644
index 0000000..47f9c91
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandinputdevice.h"
+
+#include "qwaylandintegration.h"
+#include "qwaylandwindow.h"
+#include "qwaylandbuffer.h"
+
+#include <QWindowSystemInterface>
+
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtGui/QPlatformWindow>
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifndef QT_NO_WAYLAND_XKB
+#include <X11/extensions/XKBcommon.h>
+#include <X11/keysym.h>
+#endif
+
+QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
+ uint32_t id)
+ : mDisplay(display)
+ , mInputDevice(wl_input_device_create(display, id))
+ , mPointerFocus(NULL)
+ , mKeyboardFocus(NULL)
+ , mButtons(0)
+{
+ wl_input_device_add_listener(mInputDevice,
+ &inputDeviceListener,
+ this);
+ wl_input_device_set_user_data(mInputDevice, this);
+
+#ifndef QT_NO_WAYLAND_XKB
+ struct xkb_rule_names names;
+ names.rules = "evdev";
+ names.model = "pc105";
+ names.layout = "us";
+ names.variant = "";
+ names.options = "";
+
+ mXkb = xkb_compile_keymap_from_rules(&names);
+#endif
+}
+
+void QWaylandInputDevice::inputHandleMotion(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t surface_x, int32_t surface_y)
+{
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mPointerFocus;
+
+ inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
+ inputDevice->mGlobalPos = QPoint(x, y);
+ inputDevice->mTime = time;
+ QWindowSystemInterface::handleMouseEvent(window->widget(),
+ time,
+ inputDevice->mSurfacePos,
+ inputDevice->mGlobalPos,
+ inputDevice->mButtons);
+}
+
+void QWaylandInputDevice::inputHandleButton(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t button, uint32_t state)
+{
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mPointerFocus;
+ Qt::MouseButton qt_button;
+
+ switch (button) {
+ case 272:
+ qt_button = Qt::LeftButton;
+ break;
+ case 273:
+ qt_button = Qt::RightButton;
+ break;
+ case 274:
+ qt_button = Qt::MiddleButton;
+ break;
+ default:
+ return;
+ }
+
+ if (state)
+ inputDevice->mButtons |= qt_button;
+ else
+ inputDevice->mButtons &= ~qt_button;
+
+ inputDevice->mTime = time;
+ QWindowSystemInterface::handleMouseEvent(window->widget(),
+ time,
+ inputDevice->mSurfacePos,
+ inputDevice->mGlobalPos,
+ inputDevice->mButtons);
+}
+
+#ifndef QT_NO_WAYLAND_XKB
+static Qt::KeyboardModifiers translateModifiers(int s)
+{
+ const uchar qt_alt_mask = XKB_COMMON_MOD1_MASK;
+ const uchar qt_meta_mask = XKB_COMMON_MOD4_MASK;
+
+ Qt::KeyboardModifiers ret = 0;
+ if (s & XKB_COMMON_SHIFT_MASK)
+ ret |= Qt::ShiftModifier;
+ if (s & XKB_COMMON_CONTROL_MASK)
+ ret |= Qt::ControlModifier;
+ if (s & qt_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & qt_meta_mask)
+ ret |= Qt::MetaModifier;
+
+ return ret;
+}
+
+static uint32_t translateKey(uint32_t sym, char *string, size_t size)
+{
+ Q_UNUSED(size);
+ string[0] = '\0';
+
+ switch (sym) {
+ case XK_Escape: return Qt::Key_Escape;
+ case XK_Tab: return Qt::Key_Tab;
+ case XK_ISO_Left_Tab: return Qt::Key_Backtab;
+ case XK_BackSpace: return Qt::Key_Backspace;
+ case XK_Return: return Qt::Key_Return;
+ case XK_Insert: return Qt::Key_Insert;
+ case XK_Delete: return Qt::Key_Delete;
+ case XK_Clear: return Qt::Key_Delete;
+ case XK_Pause: return Qt::Key_Pause;
+ case XK_Print: return Qt::Key_Print;
+
+ case XK_Home: return Qt::Key_Home;
+ case XK_End: return Qt::Key_End;
+ case XK_Left: return Qt::Key_Left;
+ case XK_Up: return Qt::Key_Up;
+ case XK_Right: return Qt::Key_Right;
+ case XK_Down: return Qt::Key_Down;
+ case XK_Prior: return Qt::Key_PageUp;
+ case XK_Next: return Qt::Key_PageDown;
+
+ case XK_Shift_L: return Qt::Key_Shift;
+ case XK_Shift_R: return Qt::Key_Shift;
+ case XK_Shift_Lock: return Qt::Key_Shift;
+ case XK_Control_L: return Qt::Key_Control;
+ case XK_Control_R: return Qt::Key_Control;
+ case XK_Meta_L: return Qt::Key_Meta;
+ case XK_Meta_R: return Qt::Key_Meta;
+ case XK_Alt_L: return Qt::Key_Alt;
+ case XK_Alt_R: return Qt::Key_Alt;
+ case XK_Caps_Lock: return Qt::Key_CapsLock;
+ case XK_Num_Lock: return Qt::Key_NumLock;
+ case XK_Scroll_Lock: return Qt::Key_ScrollLock;
+ case XK_Super_L: return Qt::Key_Super_L;
+ case XK_Super_R: return Qt::Key_Super_R;
+ case XK_Menu: return Qt::Key_Menu;
+
+ default:
+ string[0] = sym;
+ string[1] = '\0';
+ return toupper(sym);
+ }
+}
+#endif
+
+void QWaylandInputDevice::inputHandleKey(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t key, uint32_t state)
+{
+#ifndef QT_NO_WAYLAND_XKB
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mKeyboardFocus;
+ uint32_t code, sym, level;
+ Qt::KeyboardModifiers modifiers;
+ QEvent::Type type;
+ char s[2];
+
+ code = key + inputDevice->mXkb->min_key_code;
+
+ level = 0;
+ if (inputDevice->mModifiers & Qt::ShiftModifier &&
+ XkbKeyGroupWidth(inputDevice->mXkb, code, 0) > 1)
+ level = 1;
+
+ sym = XkbKeySymEntry(inputDevice->mXkb, code, level, 0);
+
+ modifiers = translateModifiers(inputDevice->mXkb->map->modmap[code]);
+
+ if (state) {
+ inputDevice->mModifiers |= modifiers;
+ type = QEvent::KeyPress;
+ } else {
+ inputDevice->mModifiers &= ~modifiers;
+ type = QEvent::KeyRelease;
+ }
+
+ sym = translateKey(sym, s, sizeof s);
+
+ qWarning("keycode %d, sym %d, string %d, modifiers 0x%x",
+ code, sym, s[0], (int) inputDevice->mModifiers);
+
+ if (window) {
+ QWindowSystemInterface::handleKeyEvent(window->widget(),
+ time, type, sym,
+ inputDevice->mModifiers,
+ QString::fromLatin1(s));
+ }
+#endif
+}
+
+void QWaylandInputDevice::inputHandlePointerFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, struct wl_surface *surface,
+ int32_t x, int32_t y, int32_t sx, int32_t sy)
+{
+ Q_UNUSED(input_device);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(sx);
+ Q_UNUSED(sy);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window;
+
+ if (inputDevice->mPointerFocus) {
+ window = inputDevice->mPointerFocus;
+ QWindowSystemInterface::handleLeaveEvent(window->widget());
+ inputDevice->mPointerFocus = NULL;
+ }
+
+ if (surface) {
+ window = (QWaylandWindow *) wl_surface_get_user_data(surface);
+ QWindowSystemInterface::handleEnterEvent(window->widget());
+ inputDevice->mPointerFocus = window;
+ }
+
+ inputDevice->mTime = time;
+}
+
+void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ struct wl_surface *surface,
+ struct wl_array *keys)
+{
+#ifndef QT_NO_WAYLAND_XKB
+ Q_UNUSED(input_device);
+ Q_UNUSED(time);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window;
+ uint32_t *k, *end;
+ uint32_t code;
+
+ end = (uint32_t *) ((char *) keys->data + keys->size);
+ inputDevice->mModifiers = 0;
+ for (k = (uint32_t *) keys->data; k < end; k++) {
+ code = *k + inputDevice->mXkb->min_key_code;
+ inputDevice->mModifiers |=
+ translateModifiers(inputDevice->mXkb->map->modmap[code]);
+ }
+
+ if (surface) {
+ window = (QWaylandWindow *) wl_surface_get_user_data(surface);
+ inputDevice->mKeyboardFocus = window;
+ QWindowSystemInterface::handleWindowActivated(window->widget());
+ } else {
+ inputDevice->mKeyboardFocus = NULL;
+ QWindowSystemInterface::handleWindowActivated(0);
+ }
+#endif
+}
+
+const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = {
+ QWaylandInputDevice::inputHandleMotion,
+ QWaylandInputDevice::inputHandleButton,
+ QWaylandInputDevice::inputHandleKey,
+ QWaylandInputDevice::inputHandlePointerFocus,
+ QWaylandInputDevice::inputHandleKeyboardFocus,
+};
+
+void QWaylandInputDevice::attach(QWaylandBuffer *buffer, int x, int y)
+{
+ wl_input_device_attach(mInputDevice, mTime, buffer->buffer(), x, y);
+}
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h
new file mode 100644
index 0000000..2328db8
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDINPUTDEVICE_H
+#define QWAYLANDINPUTDEVICE_H
+
+#include "qwaylandwindow.h"
+
+#include <QSocketNotifier>
+#include <QObject>
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+#include <wayland-client.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+
+class QWaylandInputDevice {
+public:
+ QWaylandInputDevice(struct wl_display *display, uint32_t id);
+ void attach(QWaylandBuffer *buffer, int x, int y);
+
+private:
+ struct wl_display *mDisplay;
+ struct wl_input_device *mInputDevice;
+ QWaylandWindow *mPointerFocus;
+ QWaylandWindow *mKeyboardFocus;
+ static const struct wl_input_device_listener inputDeviceListener;
+ Qt::MouseButtons mButtons;
+ QPoint mSurfacePos;
+ QPoint mGlobalPos;
+ struct xkb_desc *mXkb;
+ Qt::KeyboardModifiers mModifiers;
+ uint32_t mTime;
+
+ static void inputHandleMotion(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t sx, int32_t sy);
+ static void inputHandleButton(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t button, uint32_t state);
+ static void inputHandleKey(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t key, uint32_t state);
+ static void inputHandlePointerFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, struct wl_surface *surface,
+ int32_t x, int32_t y, int32_t sx, int32_t sy);
+ static void inputHandleKeyboardFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ struct wl_surface *surface,
+ struct wl_array *keys);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
new file mode 100644
index 0000000..267a037
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 config.tests 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 "qwaylandintegration.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandshmsurface.h"
+#include "qwaylanddrmsurface.h"
+#include "qwaylandshmwindow.h"
+#include "qwaylandeglwindow.h"
+
+#include "qgenericunixfontdatabase.h"
+
+#include <QtGui/QWindowSystemInterface>
+#include <QtGui/QPlatformCursor>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <QtGui/private/qpixmap_raster_p.h>
+#ifdef QT_WAYLAND_GL_SUPPORT
+#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+#endif
+
+QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
+ : mFontDb(new QGenericUnixFontDatabase())
+ , mDisplay(new QWaylandDisplay())
+ , mUseOpenGL(useOpenGL)
+{
+}
+
+QList<QPlatformScreen *>
+QWaylandIntegration::screens() const
+{
+ return mDisplay->screens();
+}
+
+bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+#ifdef QT_WAYLAND_GL_SUPPORT
+ if (mUseOpenGL)
+ return new QGLPixmapData(type);
+#endif
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ if (useOpenGL)
+ return new QWaylandEglWindow(widget);
+
+ return new QWaylandShmWindow(widget);
+}
+
+QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ Q_UNUSED(winId);
+ bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ if (useOpenGL)
+ return new QWaylandDrmWindowSurface(widget);
+
+ return new QWaylandShmWindowSurface(widget);
+}
+
+QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
new file mode 100644
index 0000000..067b6e4
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_WAYLAND_H
+#define QPLATFORMINTEGRATION_WAYLAND_H
+
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandBuffer;
+class QWaylandDisplay;
+
+class QWaylandIntegration : public QPlatformIntegration
+{
+public:
+ QWaylandIntegration(bool useOpenGL = false);
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QPlatformFontDatabase *mFontDb;
+ QWaylandDisplay *mDisplay;
+ bool mUseOpenGL;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
new file mode 100644
index 0000000..35e2532
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandscreen.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandcursor.h"
+
+QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry)
+ : QPlatformScreen()
+ , mWaylandDisplay(waylandDisplay)
+ , mOutput(output)
+ , mGeometry(geometry)
+ , mDepth(32)
+ , mFormat(QImage::Format_ARGB32_Premultiplied)
+ , mWaylandCursor(new QWaylandCursor(this))
+{
+}
+
+QWaylandScreen::~QWaylandScreen()
+{
+ delete mWaylandCursor;
+}
+
+QWaylandDisplay * QWaylandScreen::display() const
+{
+ return mWaylandDisplay;
+}
+
+QRect QWaylandScreen::geometry() const
+{
+ return mGeometry;
+}
+
+int QWaylandScreen::depth() const
+{
+ return mDepth;
+}
+
+QImage::Format QWaylandScreen::format() const
+{
+ return mFormat;
+}
+
+QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget)
+{
+ QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget);
+ return static_cast<QWaylandScreen *>(platformScreen);
+}
+
+wl_visual * QWaylandScreen::visual() const
+{
+ struct wl_visual *visual;
+
+ switch (format()) {
+ case QImage::Format_ARGB32:
+ visual = mWaylandDisplay->argbVisual();
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ visual = mWaylandDisplay->argbPremultipliedVisual();
+ break;
+ default:
+ qDebug("unsupported buffer format %d requested\n", format());
+ visual = mWaylandDisplay->argbVisual();
+ break;
+ }
+ return visual;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h
new file mode 100644
index 0000000..7784646
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandscreen.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSCREEN_H
+#define QWAYLANDSCREEN_H
+
+#include <QtGui/QPlatformScreen>
+
+class QWaylandDisplay;
+class QWaylandCursor;
+struct wl_visual;
+
+class QWaylandScreen : public QPlatformScreen
+{
+public:
+ QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry);
+ ~QWaylandScreen();
+
+ QWaylandDisplay *display() const;
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+
+ wl_visual *visual() const;
+
+ static QWaylandScreen *waylandScreenFromWidget(QWidget *widget);
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct wl_output *mOutput;
+ QRect mGeometry;
+ int mDepth;
+ QImage::Format mFormat;
+ QSize mPhysicalSize;
+ QWaylandCursor *mWaylandCursor;
+};
+
+#endif // QWAYLANDSCREEN_H
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
new file mode 100644
index 0000000..54da9a1
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwaylandshmsurface.h"
+
+#include <QtCore/qdebug.h>
+#include <QtGui/private/qapplication_p.h>
+
+#include "qwaylanddisplay.h"
+#include "qwaylandshmwindow.h"
+#include "qwaylandscreen.h"
+
+#include <wayland-client.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format)
+{
+ int stride = size.width() * 4;
+ int alloc = stride * size.height();
+ char filename[] = "/tmp/wayland-shm-XXXXXX";
+ int fd = mkstemp(filename);
+ if (fd < 0)
+ qWarning("open %s failed: %s", filename, strerror(errno));
+ if (ftruncate(fd, alloc) < 0) {
+ qWarning("ftruncate failed: %s", strerror(errno));
+ close(fd);
+ return;
+ }
+ uchar *data = (uchar *)
+ mmap(NULL, alloc, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ unlink(filename);
+
+ if (data == (uchar *) MAP_FAILED) {
+ qWarning("mmap /dev/zero failed: %s", strerror(errno));
+ close(fd);
+ return;
+ }
+
+ mImage = QImage(data, size.width(), size.height(), stride, format);
+ mBuffer = display->createShmBuffer(fd, size.width(), size.height(),
+ stride, display->argbVisual());
+ close(fd);
+}
+
+QWaylandShmBuffer::~QWaylandShmBuffer(void)
+{
+ munmap((void *) mImage.constBits(), mImage.byteCount());
+ wl_buffer_destroy(mBuffer);
+}
+
+QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+ , mBuffer(0)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mWaitingForFrameSync(false)
+{
+}
+
+QWaylandShmWindowSurface::~QWaylandShmWindowSurface()
+{
+}
+
+QPaintDevice *QWaylandShmWindowSurface::paintDevice()
+{
+ return mBuffer->image();
+}
+
+void QWaylandShmWindowSurface::beginPaint(const QRegion &)
+{
+ while (mWaitingForFrameSync) {
+ mDisplay->iterate();
+ }
+}
+
+void QWaylandShmWindowSurface::frameCallback(void *data, uint32_t time)
+{
+ QWaylandShmWindowSurface *self = static_cast<QWaylandShmWindowSurface*>(data);
+ self->mWaitingForFrameSync = false;
+}
+
+void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); i++) {
+ waylandWindow->damage(rects.at(i));
+ }
+ mWaitingForFrameSync = true;
+ mDisplay->frameCallback(QWaylandShmWindowSurface::frameCallback, this);
+}
+
+void QWaylandShmWindowSurface::resize(const QSize &size)
+{
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
+
+ QWindowSurface::resize(size);
+ QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format();
+
+ if (mBuffer != NULL && mBuffer->size() == size)
+ return;
+
+ if (mBuffer != NULL)
+ delete mBuffer;
+
+ mBuffer = new QWaylandShmBuffer(mDisplay, size, format);
+
+ waylandWindow->attach(mBuffer);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h
new file mode 100644
index 0000000..02b324a
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_WAYLAND_H
+#define QWINDOWSURFACE_WAYLAND_H
+
+#include "qwaylandbuffer.h"
+#include <QtGui/private/qwindowsurface_p.h>
+
+#include <QtGui/QPlatformWindow>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandDisplay;
+
+class QWaylandShmBuffer : public QWaylandBuffer {
+public:
+ QWaylandShmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format);
+ ~QWaylandShmBuffer();
+ QSize size() const { return mImage.size(); }
+ QImage *image() { return &mImage; }
+private:
+ QImage mImage;
+};
+
+class QWaylandShmWindowSurface : public QWindowSurface
+{
+public:
+ QWaylandShmWindowSurface(QWidget *window);
+ ~QWaylandShmWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+ void beginPaint(const QRegion &);
+
+private:
+ static void frameCallback(void *data, uint32_t time);\
+
+ QWaylandShmBuffer *mBuffer;
+ QWaylandDisplay *mDisplay;
+ bool mWaitingForFrameSync;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
new file mode 100644
index 0000000..cafd2d0
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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 config.tests 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 "qwaylandshmwindow.h"
+
+#include "qwaylandbuffer.h"
+
+QWaylandShmWindow::QWaylandShmWindow(QWidget *widget)
+ : QWaylandWindow(widget)
+ , mBuffer(0)
+{
+ newSurfaceCreated();
+}
+
+QWaylandShmWindow::~QWaylandShmWindow()
+{
+
+}
+
+QWaylandWindow::WindowType QWaylandShmWindow::windowType() const
+{
+ return QWaylandWindow::Shm;
+}
+
+QPlatformGLContext * QWaylandShmWindow::glContext() const
+{
+ qWarning("Trying to retrieve a glContext from a Raster window surface!");
+ return 0;
+}
+
+void QWaylandShmWindow::attach(QWaylandBuffer *buffer)
+{
+ mBuffer = buffer;
+ if (mSurface) {
+ wl_surface_attach(mSurface, buffer->buffer(),0,0);
+ }
+}
+
+
+void QWaylandShmWindow::damage(const QRect &rect)
+{
+ wl_surface_damage(mSurface,
+ rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+void QWaylandShmWindow::newSurfaceCreated()
+{
+ if (mBuffer) {
+ wl_surface_attach(mSurface,mBuffer->buffer(),0,0);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h
new file mode 100644
index 0000000..14a29d2
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 config.tests 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 QWAYLANDSHMWINDOW_H
+#define QWAYLANDSHMWINDOW_H
+
+#include "qwaylandwindow.h"
+
+class QWaylandShmWindow : public QWaylandWindow
+{
+public:
+ QWaylandShmWindow(QWidget *widget);
+ ~QWaylandShmWindow();
+
+ WindowType windowType() const;
+ QPlatformGLContext *glContext() const;
+ void attach(QWaylandBuffer *buffer);
+ void damage(const QRect &rect);
+protected:
+ void newSurfaceCreated();
+private:
+ QWaylandBuffer *mBuffer;
+};
+
+#endif // QWAYLANDSHMWINDOW_H
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
new file mode 100644
index 0000000..a912a83
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** 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 config.tests 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 "qwaylandwindow.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandscreen.h"
+
+#include <QtGui/QWidget>
+#include <QtGui/QWindowSystemInterface>
+
+#include <QDebug>
+
+QWaylandWindow::QWaylandWindow(QWidget *window)
+ : QPlatformWindow(window)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+{
+ static WId id = 1;
+ mWindowId = id++;
+
+ mSurface = mDisplay->createSurface();
+}
+
+QWaylandWindow::~QWaylandWindow()
+{
+}
+
+WId QWaylandWindow::winId() const
+{
+ return mWindowId;
+}
+
+void QWaylandWindow::setParent(const QPlatformWindow *parent)
+{
+ Q_UNUSED(parent);
+ qWarning("Trying to add a raster window as a sub-window");
+}
+
+void QWaylandWindow::setVisible(bool visible)
+{
+ if (!mSurface) {
+ mSurface = mDisplay->createSurface();
+ newSurfaceCreated();
+ }
+
+ if (visible) {
+ wl_surface_set_user_data(mSurface, this);
+ wl_surface_map_toplevel(mSurface);
+ } else {
+ wl_surface_destroy(mSurface);
+ mSurface = NULL;
+ }
+}
+
+void QWaylandWindow::configure(uint32_t time, uint32_t edges,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ Q_UNUSED(time);
+ Q_UNUSED(edges);
+ QRect geometry = QRect(x, y, width, height);
+
+ setGeometry(geometry);
+
+ QWindowSystemInterface::handleGeometryChange(widget(), geometry);
+}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
new file mode 100644
index 0000000..3b51ee7
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandwindow.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 config.tests 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 QWAYLANDWINDOW_H
+#define QWAYLANDWINDOW_H
+
+#include <QtGui/QPlatformWindow>
+
+#include <stdint.h>
+#include "qwaylanddisplay.h"
+
+class QWaylandDisplay;
+class QWaylandBuffer;
+struct wl_egl_window;
+
+class QWaylandWindow : public QPlatformWindow
+{
+public:
+ enum WindowType {
+ Shm,
+ Egl
+ };
+
+ QWaylandWindow(QWidget *window);
+ ~QWaylandWindow();
+
+ virtual WindowType windowType() const = 0;
+ WId winId() const;
+ void setVisible(bool visible);
+ void setParent(const QPlatformWindow *parent);
+
+ void configure(uint32_t time, uint32_t edges,
+ int32_t x, int32_t y, int32_t width, int32_t height);
+
+protected:
+ struct wl_surface *mSurface;
+ virtual void newSurfaceCreated() = 0;
+ QWaylandDisplay *mDisplay;
+ WId mWindowId;
+
+
+};
+
+
+#endif // QWAYLANDWINDOW_H
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
new file mode 100644
index 0000000..face860
--- /dev/null
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -0,0 +1,58 @@
+TARGET = qwayland
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+DEFINES += Q_PLATFORM_WAYLAND
+DEFINES += $$QMAKE_DEFINES_WAYLAND
+
+SOURCES = main.cpp \
+ qwaylandintegration.cpp \
+ qwaylandshmsurface.cpp \
+ qwaylandinputdevice.cpp \
+ qwaylandcursor.cpp \
+ qwaylanddisplay.cpp \
+ qwaylandwindow.cpp \
+ qwaylandscreen.cpp \
+ qwaylandshmwindow.cpp
+
+HEADERS = qwaylandintegration.h \
+ qwaylandcursor.h \
+ qwaylanddisplay.h \
+ qwaylandwindow.h \
+ qwaylandscreen.h \
+ qwaylandshmsurface.h \
+ qwaylanddrmsurface.h \
+ qwaylandbuffer.h \
+ qwaylandinclude.h \
+ qwaylandeglwindow.h \
+ qwaylandshmwindow.h
+
+INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
+LIBS += $$QMAKE_LIBS_WAYLAND
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
+
+contains(QT_CONFIG, opengles2) {
+ QT += opengl
+ LIBS += -lwayland-egl -lEGL
+
+ SOURCES += qwaylanddrmsurface.cpp \
+ qwaylandglcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ qwaylandeglwindow.cpp
+
+ HEADERS += qwaylandglcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+
+ DEFINES += QT_WAYLAND_GL_SUPPORT
+}
+
+unix:isEmpty(QMAKE_INCDIR_WAYLAND) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += libdrm
+}
+
+include (../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README
new file mode 100644
index 0000000..e88596b
--- /dev/null
+++ b/src/plugins/platforms/xcb/README
@@ -0,0 +1,2 @@
+Required packages:
+libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev
diff --git a/src/plugins/platforms/xcb/main.cpp b/src/plugins/platforms/xcb/main.cpp
new file mode 100644
index 0000000..89bc66e
--- /dev/null
+++ b/src/plugins/platforms/xcb/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qxcbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QXcbIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "xcb";
+ return list;
+}
+
+QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "xcb")
+ return new QXcbIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(xcb, QXcbIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp
new file mode 100644
index 0000000..0079f91
--- /dev/null
+++ b/src/plugins/platforms/xcb/qdri2context.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdri2context.h"
+
+#include "qxcbwindow.h"
+#include "qxcbconnection.h"
+
+#include <QtCore/QDebug>
+#include <QtGui/QWidget>
+
+#include <xcb/dri2.h>
+#include <xcb/xfixes.h>
+
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+class QDri2ContextPrivate
+{
+public:
+ QDri2ContextPrivate(QXcbWindow *window)
+ : qXcbWindow(window)
+ , windowFormat(window->widget()->platformWindowFormat())
+ , image(0)
+ {
+ }
+
+ xcb_window_t xcbWindow() { return qXcbWindow->window(); }
+ xcb_connection_t *xcbConnection() { return qXcbWindow->xcb_connection(); }
+
+ QXcbWindow *qXcbWindow;
+ QPlatformWindowFormat windowFormat;
+
+ EGLContext eglContext;
+
+ EGLImageKHR image;
+
+ GLuint fbo;
+ GLuint rbo;
+ GLuint depth;
+
+ QSize size;
+};
+
+QDri2Context::QDri2Context(QXcbWindow *window)
+ : d_ptr(new QDri2ContextPrivate(window))
+{
+ Q_D(QDri2Context);
+
+ static const EGLint contextAttribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ EGLContext shareContext = EGL_NO_CONTEXT;
+ if (window->widget()->platformWindowFormat().sharedGLContext()) {
+ QDri2Context *context = static_cast<QDri2Context *>(window->widget()->platformWindowFormat().sharedGLContext());
+ shareContext = context->d_func()->eglContext;
+ }
+ d->eglContext = eglCreateContext(EGL_DISPLAY_FROM_XCB(d->qXcbWindow), NULL,
+ shareContext, contextAttribs);
+
+ if (d->eglContext == EGL_NO_CONTEXT) {
+ qDebug() << "No eglContext!" << eglGetError();
+ }
+
+ EGLBoolean makeCurrentSuccess = eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
+ if (!makeCurrentSuccess) {
+ qDebug() << "eglMakeCurrent failed!" << eglGetError();
+ }
+
+ xcb_dri2_create_drawable (d->xcbConnection(), d->xcbWindow());
+
+ glGenFramebuffers(1,&d->fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+ glActiveTexture(GL_TEXTURE0);
+
+ glGenRenderbuffers(1, &d->rbo);
+ glBindRenderbuffer(GL_RENDERBUFFER, d->rbo);
+
+ glGenRenderbuffers(1,&d->depth);
+ glBindRenderbuffer(GL_RENDERBUFFER, d->depth);
+
+ resize(d->qXcbWindow->widget()->geometry().size());
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, d->rbo);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERER,d->depth);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERER,d->depth);
+
+ //restore the old current context
+ const QPlatformGLContext *currentContext = QPlatformGLContext::currentContext();
+ if (currentContext)
+ const_cast<QPlatformGLContext*>(currentContext)->makeCurrent();
+}
+
+QDri2Context::~QDri2Context()
+{
+ //cleanup
+}
+
+void QDri2Context::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ Q_D(QDri2Context);
+
+ eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+
+}
+
+void QDri2Context::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ Q_D(QDri2Context);
+ eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
+}
+
+void QDri2Context::swapBuffers()
+{
+ Q_D(QDri2Context);
+ xcb_rectangle_t rectangle;
+ rectangle.x = 0;
+ rectangle.y = 0;
+ rectangle.width = d->qXcbWindow->widget()->geometry().width();
+ rectangle.height = d->qXcbWindow->widget()->geometry().height();
+
+ xcb_xfixes_region_t xfixesRegion = xcb_generate_id(d->xcbConnection());
+ xcb_xfixes_create_region(d->xcbConnection(), xfixesRegion,
+ 1, &rectangle);
+
+ xcb_dri2_copy_region_cookie_t cookie = xcb_dri2_copy_region_unchecked(d->xcbConnection(),
+ d->qXcbWindow->window(),
+ xfixesRegion,
+ XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT,
+ XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT);
+
+ xcb_dri2_copy_region_reply_t *reply = xcb_dri2_copy_region_reply(d->xcbConnection(),cookie,NULL);
+
+ //cleanup
+ delete reply;
+ xcb_xfixes_destroy_region(d->xcbConnection(), xfixesRegion);
+
+}
+
+void * QDri2Context::getProcAddress(const QString &procName)
+{
+ return (void *)eglGetProcAddress(qPrintable(procName));
+}
+
+void QDri2Context::resize(const QSize &size)
+{
+ Q_D(QDri2Context);
+ d->size= size;
+
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+
+ xcb_dri2_dri2_buffer_t *backBfr = backBuffer();
+
+ if (d->image) {
+ qDebug() << "destroing image";
+ eglDestroyImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),d->image);
+ }
+
+ EGLint imgAttribs[] = {
+ EGL_WIDTH, d->size.width(),
+ EGL_HEIGHT, d->size.height(),
+ EGL_DRM_BUFFER_STRIDE_MESA, backBfr->pitch /4,
+ EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+ EGL_NONE
+ };
+
+ d->image = eglCreateImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),
+ EGL_NO_CONTEXT,
+ EGL_DRM_BUFFER_MESA,
+ (EGLClientBuffer) backBfr->name,
+ imgAttribs);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, d->rbo);
+ glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
+ d->image);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, d->depth);
+ glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8_OES,d->size.width(), d->size.height());
+
+}
+
+QPlatformWindowFormat QDri2Context::platformWindowFormat() const
+{
+ Q_D(const QDri2Context);
+ return d->windowFormat;
+}
+
+xcb_dri2_dri2_buffer_t * QDri2Context::backBuffer()
+{
+ Q_D(QDri2Context);
+
+ unsigned int backBufferAttachment = XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT;
+ xcb_dri2_get_buffers_cookie_t cookie = xcb_dri2_get_buffers_unchecked (d->xcbConnection(),
+ d->xcbWindow(),
+ 1, 1, &backBufferAttachment);
+
+ xcb_dri2_get_buffers_reply_t *reply = xcb_dri2_get_buffers_reply (d->xcbConnection(), cookie, NULL);
+ if (!reply) {
+ qDebug() << "failed to get buffers reply";
+ return 0;
+ }
+
+ xcb_dri2_dri2_buffer_t *buffers = xcb_dri2_get_buffers_buffers (reply);
+ if (!buffers) {
+ qDebug() << "failed to get buffers";
+ return 0;
+ }
+
+ Q_ASSERT(reply->count == 1);
+
+ delete reply;
+
+ return buffers;
+}
+
+void * QDri2Context::eglContext() const
+{
+ Q_D(QDri2Context);
+ return d->eglContext;
+}
diff --git a/src/plugins/platforms/xcb/qdri2context.h b/src/plugins/platforms/xcb/qdri2context.h
new file mode 100644
index 0000000..42dd6bd
--- /dev/null
+++ b/src/plugins/platforms/xcb/qdri2context.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDRI2CONTEXT_H
+#define QDRI2CONTEXT_H
+
+#include <QtGui/QPlatformGLContext>
+
+class QXcbWindow;
+class QDri2ContextPrivate;
+
+struct xcb_dri2_dri2_buffer_t;
+
+class QDri2Context : public QPlatformGLContext
+{
+ Q_DECLARE_PRIVATE(QDri2Context);
+public:
+ QDri2Context(QXcbWindow *window);
+ ~QDri2Context();
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString& procName);
+
+ void resize(const QSize &size);
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ void *eglContext() const;
+
+protected:
+ xcb_dri2_dri2_buffer_t *backBuffer();
+ QScopedPointer<QDri2ContextPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QDri2Context)
+};
+
+#endif // QDRI2CONTEXT_H
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
new file mode 100644
index 0000000..e94b6a6
--- /dev/null
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -0,0 +1,360 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QLibrary>
+#include <QGLFormat>
+
+#include "qxcbwindow.h"
+#include "qxcbscreen.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+
+#include "qglxintegration.h"
+
+#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
+#include <dlfcn.h>
+#endif
+
+QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive);
+
+QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format)
+{
+ QVector<int> spec(48);
+ int i = 0;
+
+ spec[i++] = GLX_LEVEL;
+ spec[i++] = 0;
+ spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT;
+
+ if (format.rgba()) {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
+ spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
+ spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
+ spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
+ if (format.alpha()) {
+ spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
+ }
+
+ spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+
+ if (format.alpha()) {
+ spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ }
+
+ } else {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
+ spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
+ }
+
+ spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
+ spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
+
+ if (format.depth()) {
+ spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
+ }
+
+ if (format.stencil()) {
+ spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
+ }
+ if (format.sampleBuffers()) {
+ spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
+ spec[i++] = 1;
+ spec[i++] = GLX_SAMPLES_ARB;
+ spec[i++] = format.samples() == -1 ? 4 : format.samples();
+ }
+
+ spec[i++] = None;
+ return spec;
+}
+
+GLXFBConfig QGLXContext::findConfig(const QXcbScreen *screen, const QPlatformWindowFormat &format)
+{
+ bool reduced = true;
+ GLXFBConfig chosenConfig = 0;
+ QPlatformWindowFormat reducedFormat = format;
+ while (!chosenConfig && reduced) {
+ QVector<int> spec = buildSpec(reducedFormat);
+ int confcount = 0;
+ GLXFBConfig *configs;
+ configs = glXChooseFBConfig(DISPLAY_FROM_XCB(screen), screen->screenNumber(), spec.constData(), &confcount);
+ if (confcount)
+ {
+ for (int i = 0; i < confcount; i++) {
+ chosenConfig = configs[i];
+ // Make sure we try to get an ARGB visual if the format asked for an alpha:
+ if (reducedFormat.alpha()) {
+ int alphaSize;
+ glXGetFBConfigAttrib(DISPLAY_FROM_XCB(screen), configs[i], GLX_ALPHA_SIZE, &alphaSize);
+ if (alphaSize > 0)
+ break;
+ } else {
+ break; // Just choose the first in the list if there's no alpha requested
+ }
+ }
+
+ XFree(configs);
+ }
+ reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced);
+ }
+
+ if (!chosenConfig)
+ qWarning("Warning no context created");
+
+ return chosenConfig;
+}
+
+XVisualInfo *QGLXContext::findVisualInfo(const QXcbScreen *screen, const QPlatformWindowFormat &format)
+{
+ GLXFBConfig config = QGLXContext::findConfig(screen,format);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config);
+ return visualInfo;
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
+{
+ QPlatformWindowFormat format;
+ int redSize = 0;
+ int greenSize = 0;
+ int blueSize = 0;
+ int alphaSize = 0;
+ int depthSize = 0;
+ int stencilSize = 0;
+ int sampleBuffers = 0;
+ int sampleCount = 0;
+ int level = 0;
+ int rgba = 0;
+ int stereo = 0;
+ int accumSizeA = 0;
+ int accumSizeR = 0;
+ int accumSizeG = 0;
+ int accumSizeB = 0;
+
+ XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
+ glXGetConfig(display,vi,GLX_RGBA,&rgba);
+ XFree(vi);
+ glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
+ glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
+ glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize);
+ glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize);
+ glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
+ glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
+ glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
+ glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSampleBuffers(sampleBuffers);
+ if (format.sampleBuffers()) {
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
+ format.setSamples(sampleCount);
+ }
+
+ format.setDirectRendering(glXIsDirect(display, ctx));
+ format.setRgba(rgba);
+ format.setStereo(stereo);
+ format.setAccumBufferSize(accumSizeB);
+
+ return format;
+}
+
+QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
+{
+ QPlatformWindowFormat retFormat = format;
+ *reduced = true;
+
+ if (retFormat.sampleBuffers()) {
+ retFormat.setSampleBuffers(false);
+ } else if (retFormat.stereo()) {
+ retFormat.setStereo(false);
+ } else if (retFormat.accum()) {
+ retFormat.setAccum(false);
+ }else if (retFormat.stencil()) {
+ retFormat.setStencil(false);
+ }else if (retFormat.alpha()) {
+ retFormat.setAlpha(false);
+ }else if (retFormat.depth()) {
+ retFormat.setDepth(false);
+ }else if (retFormat.doubleBuffer()) {
+ retFormat.setDoubleBuffer(false);
+ }else{
+ *reduced = false;
+ }
+ return retFormat;
+}
+
+QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format)
+ : QPlatformGLContext()
+ , m_screen(screen)
+ , m_drawable((Drawable)window)
+ , m_context(0)
+{
+
+ const QPlatformGLContext *sharePlatformContext;
+ if (format.useDefaultSharedContext()) {
+ if (!QPlatformGLContext::defaultSharedContext()) {
+ if (m_defaultSharedContextMutex.tryLock()){
+ createDefaultSharedContex(screen);
+ m_defaultSharedContextMutex.unlock();
+ } else {
+ m_defaultSharedContextMutex.lock(); //wait to the the shared context is created
+ m_defaultSharedContextMutex.unlock();
+ }
+ }
+ sharePlatformContext = QPlatformGLContext::defaultSharedContext();
+ } else {
+ sharePlatformContext = format.sharedGLContext();
+ }
+ GLXContext shareGlxContext = 0;
+ if (sharePlatformContext)
+ shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
+
+ GLXFBConfig config = findConfig(screen,format);
+ m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
+ m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
+}
+
+QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext context)
+ : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
+{
+
+}
+
+QGLXContext::~QGLXContext()
+{
+ if (m_context)
+ glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
+}
+
+void QGLXContext::createDefaultSharedContex(QXcbScreen *screen)
+{
+ int x = 0;
+ int y = 0;
+ int w = 3;
+ int h = 3;
+
+ QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat();
+ GLXContext context;
+ GLXFBConfig config = findConfig(screen,format);
+ if (config) {
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config);
+ Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(screen), screen->root(), visualInfo->visual, AllocNone);
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ Window sharedWindow = XCreateWindow(DISPLAY_FROM_XCB(screen), screen->root(), x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE);
+ QPlatformGLContext *sharedContext = new QGLXContext(screen, sharedWindow, context);
+ QPlatformGLContext::setDefaultSharedContext(sharedContext);
+ } else {
+ qWarning("Warning no shared context created");
+ }
+}
+
+void QGLXContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context);
+}
+
+void QGLXContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
+}
+
+void QGLXContext::swapBuffers()
+{
+ glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
+}
+
+void* QGLXContext::getProcAddress(const QString& procName)
+{
+ typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
+ static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
+ static bool resolved = false;
+
+ if (resolved && !glXGetProcAddressARB)
+ return 0;
+ if (!glXGetProcAddressARB) {
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(DISPLAY_FROM_XCB(m_screen), GLX_EXTENSIONS)).split(' ');
+ if (glxExt.contains("GLX_ARB_get_proc_address")) {
+#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
+ void *handle = dlopen(NULL, RTLD_LAZY);
+ if (handle) {
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB");
+ dlclose(handle);
+ }
+ if (!glXGetProcAddressARB)
+#endif
+ {
+ extern const QString qt_gl_library_name();
+// QLibrary lib(qt_gl_library_name());
+ QLibrary lib(QLatin1String("GL"));
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ }
+ }
+ resolved = true;
+ }
+ if (!glXGetProcAddressARB)
+ return 0;
+ return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFormat() const
+{
+ return m_windowFormat;
+}
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
new file mode 100644
index 0000000..f2e20c4
--- /dev/null
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLXINTEGRATION_H
+#define QGLXINTEGRATION_H
+
+#include "qxcbwindow.h"
+
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <QtCore/QMutex>
+
+#include <GL/glx.h>
+
+class QGLXContext : public QPlatformGLContext
+{
+public:
+ QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format);
+ ~QGLXContext();
+
+ virtual void makeCurrent();
+ virtual void doneCurrent();
+ virtual void swapBuffers();
+ virtual void* getProcAddress(const QString& procName);
+
+ GLXContext glxContext() const { return m_context; }
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ static XVisualInfo *findVisualInfo(const QXcbScreen *xd, const QPlatformWindowFormat &format);
+
+private:
+ static GLXFBConfig findConfig(const QXcbScreen *xd,const QPlatformWindowFormat &format);
+ static QVector<int> buildSpec(const QPlatformWindowFormat &format);
+ static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
+ static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced);
+
+ QXcbScreen *m_screen;
+ Drawable m_drawable;
+ GLXContext m_context;
+ QPlatformWindowFormat m_windowFormat;
+
+ QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context);
+ static QMutex m_defaultSharedContextMutex;
+ static void createDefaultSharedContex(QXcbScreen *xd);
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
new file mode 100644
index 0000000..191699b
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -0,0 +1,557 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbconnection.h"
+#include "qxcbkeyboard.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+
+#include <QtAlgorithms>
+#include <QSocketNotifier>
+#include <QtGui/private/qapplication_p.h>
+
+#include <QtCore/QDebug>
+
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef XCB_USE_XLIB
+#include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
+#endif
+
+#ifdef XCB_USE_EGL //dont pull in eglext prototypes
+#include <EGL/egl.h>
+#endif
+
+#ifdef XCB_USE_DRI2
+#include <xcb/dri2.h>
+#include <xcb/xfixes.h>
+extern "C" {
+#include <xf86drm.h>
+}
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#endif
+
+QXcbConnection::QXcbConnection(const char *displayName)
+ : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
+#ifdef XCB_USE_DRI2
+ , m_dri2_major(0)
+ , m_dri2_minor(0)
+ , m_dri2_support_probed(false)
+ , m_has_support_for_dri2(false)
+#endif
+{
+ int primaryScreen = 0;
+
+#ifdef XCB_USE_XLIB
+ Display *dpy = XOpenDisplay(m_displayName.constData());
+ primaryScreen = DefaultScreen(dpy);
+ m_connection = XGetXCBConnection(dpy);
+ XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
+ m_xlib_display = dpy;
+#ifdef XCB_USE_EGL
+ EGLDisplay eglDisplay = eglGetDisplay(dpy);
+ m_egl_display = eglDisplay;
+ EGLint major, minor;
+ eglBindAPI(EGL_OPENGL_ES_API);
+ m_has_egl = eglInitialize(eglDisplay,&major,&minor);
+#endif //XCB_USE_EGL
+#else
+ m_connection = xcb_connect(m_displayName.constData(), &primaryScreen);
+
+#endif //XCB_USE_XLIB
+ m_setup = xcb_get_setup(xcb_connection());
+
+ xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup);
+
+ int screenNumber = 0;
+ while (it.rem) {
+ m_screens << new QXcbScreen(this, it.data, screenNumber++);
+ xcb_screen_next(&it);
+ }
+
+ QSocketNotifier *socket = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
+ connect(socket, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+
+ m_keyboard = new QXcbKeyboard(this);
+
+ initializeAllAtoms();
+
+#ifdef XCB_USE_DRI2
+ initializeDri2();
+#endif
+}
+
+QXcbConnection::~QXcbConnection()
+{
+ qDeleteAll(m_screens);
+
+#ifdef XCB_USE_XLIB
+ XCloseDisplay((Display *)m_xlib_display);
+#else
+ xcb_disconnect(xcb_connection());
+#endif
+
+ delete m_keyboard;
+}
+
+QXcbWindow *platformWindowFromId(xcb_window_t id)
+{
+ QWidget *widget = QWidget::find(id);
+ if (widget)
+ return static_cast<QXcbWindow *>(widget->platformWindow());
+ return 0;
+}
+
+#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \
+{ \
+ event_t *e = (event_t *)event; \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) \
+ platformWindow->handler(e); \
+} \
+break;
+
+#define HANDLE_KEYBOARD_EVENT(event_t, handler) \
+{ \
+ event_t *e = (event_t *)event; \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \
+ m_keyboard->handler(platformWindow->widget(), e); \
+} \
+break;
+
+//#define XCB_EVENT_DEBUG
+
+void printXcbEvent(const char *message, xcb_generic_event_t *event)
+{
+#ifdef XCB_EVENT_DEBUG
+#define PRINT_XCB_EVENT(event) \
+ case event: \
+ printf("%s: %d - %s\n", message, event, #event); \
+ break;
+
+ switch (event->response_type & ~0x80) {
+ PRINT_XCB_EVENT(XCB_KEY_PRESS);
+ PRINT_XCB_EVENT(XCB_KEY_RELEASE);
+ PRINT_XCB_EVENT(XCB_BUTTON_PRESS);
+ PRINT_XCB_EVENT(XCB_BUTTON_RELEASE);
+ PRINT_XCB_EVENT(XCB_MOTION_NOTIFY);
+ PRINT_XCB_EVENT(XCB_ENTER_NOTIFY);
+ PRINT_XCB_EVENT(XCB_LEAVE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_FOCUS_IN);
+ PRINT_XCB_EVENT(XCB_FOCUS_OUT);
+ PRINT_XCB_EVENT(XCB_KEYMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_EXPOSE);
+ PRINT_XCB_EVENT(XCB_GRAPHICS_EXPOSURE);
+ PRINT_XCB_EVENT(XCB_VISIBILITY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CREATE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_DESTROY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_UNMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_MAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_MAP_REQUEST);
+ PRINT_XCB_EVENT(XCB_REPARENT_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CONFIGURE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CONFIGURE_REQUEST);
+ PRINT_XCB_EVENT(XCB_GRAVITY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_RESIZE_REQUEST);
+ PRINT_XCB_EVENT(XCB_CIRCULATE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CIRCULATE_REQUEST);
+ PRINT_XCB_EVENT(XCB_PROPERTY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_SELECTION_CLEAR);
+ PRINT_XCB_EVENT(XCB_SELECTION_REQUEST);
+ PRINT_XCB_EVENT(XCB_SELECTION_NOTIFY);
+ PRINT_XCB_EVENT(XCB_COLORMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CLIENT_MESSAGE);
+ PRINT_XCB_EVENT(XCB_MAPPING_NOTIFY);
+ default:
+ printf("%s: %d - %s\n", message, event->response_type, "unknown");
+ }
+#else
+ Q_UNUSED(message);
+ Q_UNUSED(event);
+#endif
+}
+
+void QXcbConnection::eventDispatcher()
+{
+ while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) {
+ bool handled = true;
+ switch (event->response_type & ~0x80) {
+ case XCB_EXPOSE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
+ case XCB_BUTTON_PRESS:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
+ case XCB_BUTTON_RELEASE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
+ case XCB_MOTION_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
+ case XCB_CONFIGURE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
+ case XCB_CLIENT_MESSAGE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent);
+ case XCB_ENTER_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
+ case XCB_LEAVE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
+ case XCB_FOCUS_IN:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent);
+ case XCB_FOCUS_OUT:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent);
+ case XCB_KEY_PRESS:
+ HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent);
+ case XCB_KEY_RELEASE:
+ HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
+ case XCB_MAPPING_NOTIFY:
+ m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
+ break;
+ default:
+ handled = false;
+ return;
+ }
+ if (handled)
+ printXcbEvent("Handled XCB event", event);
+ else
+ printXcbEvent("Unhandled XCB event", event);
+ }
+}
+
+static const char * xcb_atomnames = {
+ // window-manager <-> client protocols
+ "WM_PROTOCOLS\0"
+ "WM_DELETE_WINDOW\0"
+ "WM_TAKE_FOCUS\0"
+ "_NET_WM_PING\0"
+ "_NET_WM_CONTEXT_HELP\0"
+ "_NET_WM_SYNC_REQUEST\0"
+ "_NET_WM_SYNC_REQUEST_COUNTER\0"
+
+ // ICCCM window state
+ "WM_STATE\0"
+ "WM_CHANGE_STATE\0"
+
+ // Session management
+ "WM_CLIENT_LEADER\0"
+ "WM_WINDOW_ROLE\0"
+ "SM_CLIENT_ID\0"
+
+ // Clipboard
+ "CLIPBOARD\0"
+ "INCR\0"
+ "TARGETS\0"
+ "MULTIPLE\0"
+ "TIMESTAMP\0"
+ "SAVE_TARGETS\0"
+ "CLIP_TEMPORARY\0"
+ "_QT_SELECTION\0"
+ "_QT_CLIPBOARD_SENTINEL\0"
+ "_QT_SELECTION_SENTINEL\0"
+ "CLIPBOARD_MANAGER\0"
+
+ "RESOURCE_MANAGER\0"
+
+ "_XSETROOT_ID\0"
+
+ "_QT_SCROLL_DONE\0"
+ "_QT_INPUT_ENCODING\0"
+
+ "_MOTIF_WM_HINTS\0"
+
+ "DTWM_IS_RUNNING\0"
+ "ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
+ "_SGI_DESKS_MANAGER\0"
+
+ // EWMH (aka NETWM)
+ "_NET_SUPPORTED\0"
+ "_NET_VIRTUAL_ROOTS\0"
+ "_NET_WORKAREA\0"
+
+ "_NET_MOVERESIZE_WINDOW\0"
+ "_NET_WM_MOVERESIZE\0"
+
+ "_NET_WM_NAME\0"
+ "_NET_WM_ICON_NAME\0"
+ "_NET_WM_ICON\0"
+
+ "_NET_WM_PID\0"
+
+ "_NET_WM_WINDOW_OPACITY\0"
+
+ "_NET_WM_STATE\0"
+ "_NET_WM_STATE_ABOVE\0"
+ "_NET_WM_STATE_BELOW\0"
+ "_NET_WM_STATE_FULLSCREEN\0"
+ "_NET_WM_STATE_MAXIMIZED_HORZ\0"
+ "_NET_WM_STATE_MAXIMIZED_VERT\0"
+ "_NET_WM_STATE_MODAL\0"
+ "_NET_WM_STATE_STAYS_ON_TOP\0"
+ "_NET_WM_STATE_DEMANDS_ATTENTION\0"
+
+ "_NET_WM_USER_TIME\0"
+ "_NET_WM_USER_TIME_WINDOW\0"
+ "_NET_WM_FULL_PLACEMENT\0"
+
+ "_NET_WM_WINDOW_TYPE\0"
+ "_NET_WM_WINDOW_TYPE_DESKTOP\0"
+ "_NET_WM_WINDOW_TYPE_DOCK\0"
+ "_NET_WM_WINDOW_TYPE_TOOLBAR\0"
+ "_NET_WM_WINDOW_TYPE_MENU\0"
+ "_NET_WM_WINDOW_TYPE_UTILITY\0"
+ "_NET_WM_WINDOW_TYPE_SPLASH\0"
+ "_NET_WM_WINDOW_TYPE_DIALOG\0"
+ "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU\0"
+ "_NET_WM_WINDOW_TYPE_POPUP_MENU\0"
+ "_NET_WM_WINDOW_TYPE_TOOLTIP\0"
+ "_NET_WM_WINDOW_TYPE_NOTIFICATION\0"
+ "_NET_WM_WINDOW_TYPE_COMBO\0"
+ "_NET_WM_WINDOW_TYPE_DND\0"
+ "_NET_WM_WINDOW_TYPE_NORMAL\0"
+ "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE\0"
+
+ "_KDE_NET_WM_FRAME_STRUT\0"
+
+ "_NET_STARTUP_INFO\0"
+ "_NET_STARTUP_INFO_BEGIN\0"
+
+ "_NET_SUPPORTING_WM_CHECK\0"
+
+ "_NET_WM_CM_S0\0"
+
+ "_NET_SYSTEM_TRAY_VISUAL\0"
+
+ "_NET_ACTIVE_WINDOW\0"
+
+ // Property formats
+ "COMPOUND_TEXT\0"
+ "TEXT\0"
+ "UTF8_STRING\0"
+
+ // xdnd
+ "XdndEnter\0"
+ "XdndPosition\0"
+ "XdndStatus\0"
+ "XdndLeave\0"
+ "XdndDrop\0"
+ "XdndFinished\0"
+ "XdndTypeList\0"
+ "XdndActionList\0"
+
+ "XdndSelection\0"
+
+ "XdndAware\0"
+ "XdndProxy\0"
+
+ "XdndActionCopy\0"
+ "XdndActionLink\0"
+ "XdndActionMove\0"
+ "XdndActionPrivate\0"
+
+ // Motif DND
+ "_MOTIF_DRAG_AND_DROP_MESSAGE\0"
+ "_MOTIF_DRAG_INITIATOR_INFO\0"
+ "_MOTIF_DRAG_RECEIVER_INFO\0"
+ "_MOTIF_DRAG_WINDOW\0"
+ "_MOTIF_DRAG_TARGETS\0"
+
+ "XmTRANSFER_SUCCESS\0"
+ "XmTRANSFER_FAILURE\0"
+
+ // Xkb
+ "_XKB_RULES_NAMES\0"
+
+ // XEMBED
+ "_XEMBED\0"
+ "_XEMBED_INFO\0"
+
+ // Wacom old. (before version 0.10)
+ "Wacom Stylus\0"
+ "Wacom Cursor\0"
+ "Wacom Eraser\0"
+
+ // Tablet
+ "STYLUS\0"
+ "ERASER\0"
+};
+
+xcb_atom_t QXcbConnection::atom(QXcbAtom::Atom atom)
+{
+ return m_allAtoms[atom];
+}
+
+void QXcbConnection::initializeAllAtoms() {
+ const char *names[QXcbAtom::NAtoms];
+ const char *ptr = xcb_atomnames;
+
+ int i = 0;
+ while (*ptr) {
+ names[i++] = ptr;
+ while (*ptr)
+ ++ptr;
+ ++ptr;
+ }
+
+ Q_ASSERT(i == QXcbAtom::NPredefinedAtoms);
+
+ QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
+ settings_atom_name += m_displayName;
+ names[i++] = settings_atom_name;
+
+ xcb_intern_atom_cookie_t cookies[QXcbAtom::NAtoms];
+
+ Q_ASSERT(i == QXcbAtom::NAtoms);
+ for (i = 0; i < QXcbAtom::NAtoms; ++i)
+ cookies[i] = xcb_intern_atom(xcb_connection(), false, strlen(names[i]), names[i]);
+
+ for (i = 0; i < QXcbAtom::NAtoms; ++i)
+ m_allAtoms[i] = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0)->atom;
+}
+
+#if defined(XCB_USE_EGL)
+bool QXcbConnection::hasEgl() const
+{
+ return m_has_egl;
+}
+#endif // defined(XCB_USE_EGL)
+
+#ifdef XCB_USE_DRI2
+void QXcbConnection::initializeDri2()
+{
+ xcb_dri2_connect_cookie_t connect_cookie = xcb_dri2_connect_unchecked (m_connection,
+ m_screens[0]->root(),
+ XCB_DRI2_DRIVER_TYPE_DRI);
+
+ xcb_dri2_connect_reply_t *connect = xcb_dri2_connect_reply (m_connection,
+ connect_cookie, NULL);
+
+ if (! connect || connect->driver_name_length + connect->device_name_length == 0) {
+ qDebug() << "Failed to connect to dri2";
+ return;
+ }
+
+ m_dri2_device_name = QByteArray(xcb_dri2_connect_device_name (connect),
+ xcb_dri2_connect_device_name_length (connect));
+ delete connect;
+
+ int fd = open(m_dri2_device_name.constData(), O_RDWR);
+ if (fd < 0) {
+ qDebug() << "InitializeDri2: Could'nt open device << dri2DeviceName";
+ m_dri2_device_name = QByteArray();
+ return;
+ }
+
+ drm_magic_t magic;
+ if (drmGetMagic(fd, &magic)) {
+ qDebug() << "Failed to get drmMagic";
+ return;
+ }
+
+ xcb_dri2_authenticate_cookie_t authenticate_cookie = xcb_dri2_authenticate_unchecked(m_connection,
+ m_screens[0]->root(), magic);
+ xcb_dri2_authenticate_reply_t *authenticate = xcb_dri2_authenticate_reply(m_connection,
+ authenticate_cookie, NULL);
+ if (authenticate == NULL || !authenticate->authenticated) {
+ fprintf(stderr, "DRI2: failed to authenticate\n");
+ free(authenticate);
+ return;
+ }
+
+ delete authenticate;
+
+ EGLDisplay display = eglGetDRMDisplayMESA(fd);
+ if (!display) {
+ fprintf(stderr, "failed to create display\n");
+ return;
+ }
+
+ m_egl_display = display;
+ EGLint major,minor;
+ if (!eglInitialize(display, &major, &minor)) {
+ fprintf(stderr, "failed to initialize display\n");
+ return;
+ }
+}
+
+bool QXcbConnection::hasSupportForDri2() const
+{
+ if (!m_dri2_support_probed) {
+ xcb_generic_error_t *error = 0;
+
+ xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
+ xcb_prefetch_extension_data (m_connection, &xcb_dri2_id);
+
+ xcb_xfixes_query_version_cookie_t xfixes_query_cookie = xcb_xfixes_query_version(m_connection,
+ XCB_XFIXES_MAJOR_VERSION,
+ XCB_XFIXES_MINOR_VERSION);
+
+ xcb_dri2_query_version_cookie_t dri2_query_cookie = xcb_dri2_query_version (m_connection,
+ XCB_DRI2_MAJOR_VERSION,
+ XCB_DRI2_MINOR_VERSION);
+
+ xcb_xfixes_query_version_reply_t *xfixes_query = xcb_xfixes_query_version_reply (m_connection,
+ xfixes_query_cookie, &error);
+ if (!xfixes_query || error || xfixes_query->major_version < 2) {
+ delete error;
+ delete xfixes_query;
+ return false;
+ }
+ delete xfixes_query;
+
+ xcb_dri2_query_version_reply_t *dri2_query = xcb_dri2_query_version_reply (m_connection,
+ dri2_query_cookie, &error);
+ if (!dri2_query || error) {
+ delete error;
+ delete dri2_query;
+ return false;
+ }
+
+ QXcbConnection *that = const_cast<QXcbConnection *>(this);
+ that->m_dri2_major = dri2_query->major_version;
+ that->m_dri2_minor = dri2_query->minor_version;
+
+ that->m_has_support_for_dri2 = true;
+ that->m_dri2_support_probed = true;
+ }
+ return m_has_support_for_dri2;
+}
+#endif //XCB_USE_DRI2
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
new file mode 100644
index 0000000..e00fbb1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBCONNECTION_H
+#define QXCBCONNECTION_H
+
+#include <xcb/xcb.h>
+
+#include <QList>
+#include <QObject>
+
+class QXcbScreen;
+
+namespace QXcbAtom {
+ enum Atom {
+ // window-manager <-> client protocols
+ WM_PROTOCOLS,
+ WM_DELETE_WINDOW,
+ WM_TAKE_FOCUS,
+ _NET_WM_PING,
+ _NET_WM_CONTEXT_HELP,
+ _NET_WM_SYNC_REQUEST,
+ _NET_WM_SYNC_REQUEST_COUNTER,
+
+ // ICCCM window state
+ WM_STATE,
+ WM_CHANGE_STATE,
+
+ // Session management
+ WM_CLIENT_LEADER,
+ WM_WINDOW_ROLE,
+ SM_CLIENT_ID,
+
+ // Clipboard
+ CLIPBOARD,
+ INCR,
+ TARGETS,
+ MULTIPLE,
+ TIMESTAMP,
+ SAVE_TARGETS,
+ CLIP_TEMPORARY,
+ _QT_SELECTION,
+ _QT_CLIPBOARD_SENTINEL,
+ _QT_SELECTION_SENTINEL,
+ CLIPBOARD_MANAGER,
+
+ RESOURCE_MANAGER,
+
+ _XSETROOT_ID,
+
+ _QT_SCROLL_DONE,
+ _QT_INPUT_ENCODING,
+
+ _MOTIF_WM_HINTS,
+
+ DTWM_IS_RUNNING,
+ ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
+ _SGI_DESKS_MANAGER,
+
+ // EWMH (aka NETWM)
+ _NET_SUPPORTED,
+ _NET_VIRTUAL_ROOTS,
+ _NET_WORKAREA,
+
+ _NET_MOVERESIZE_WINDOW,
+ _NET_WM_MOVERESIZE,
+
+ _NET_WM_NAME,
+ _NET_WM_ICON_NAME,
+ _NET_WM_ICON,
+
+ _NET_WM_PID,
+
+ _NET_WM_WINDOW_OPACITY,
+
+ _NET_WM_STATE,
+ _NET_WM_STATE_ABOVE,
+ _NET_WM_STATE_BELOW,
+ _NET_WM_STATE_FULLSCREEN,
+ _NET_WM_STATE_MAXIMIZED_HORZ,
+ _NET_WM_STATE_MAXIMIZED_VERT,
+ _NET_WM_STATE_MODAL,
+ _NET_WM_STATE_STAYS_ON_TOP,
+ _NET_WM_STATE_DEMANDS_ATTENTION,
+
+ _NET_WM_USER_TIME,
+ _NET_WM_USER_TIME_WINDOW,
+ _NET_WM_FULL_PLACEMENT,
+
+ _NET_WM_WINDOW_TYPE,
+ _NET_WM_WINDOW_TYPE_DESKTOP,
+ _NET_WM_WINDOW_TYPE_DOCK,
+ _NET_WM_WINDOW_TYPE_TOOLBAR,
+ _NET_WM_WINDOW_TYPE_MENU,
+ _NET_WM_WINDOW_TYPE_UTILITY,
+ _NET_WM_WINDOW_TYPE_SPLASH,
+ _NET_WM_WINDOW_TYPE_DIALOG,
+ _NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+ _NET_WM_WINDOW_TYPE_POPUP_MENU,
+ _NET_WM_WINDOW_TYPE_TOOLTIP,
+ _NET_WM_WINDOW_TYPE_NOTIFICATION,
+ _NET_WM_WINDOW_TYPE_COMBO,
+ _NET_WM_WINDOW_TYPE_DND,
+ _NET_WM_WINDOW_TYPE_NORMAL,
+ _KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
+
+ _KDE_NET_WM_FRAME_STRUT,
+
+ _NET_STARTUP_INFO,
+ _NET_STARTUP_INFO_BEGIN,
+
+ _NET_SUPPORTING_WM_CHECK,
+
+ _NET_WM_CM_S0,
+
+ _NET_SYSTEM_TRAY_VISUAL,
+
+ _NET_ACTIVE_WINDOW,
+
+ // Property formats
+ COMPOUND_TEXT,
+ TEXT,
+ UTF8_STRING,
+
+ // Xdnd
+ XdndEnter,
+ XdndPosition,
+ XdndStatus,
+ XdndLeave,
+ XdndDrop,
+ XdndFinished,
+ XdndTypelist,
+ XdndActionList,
+
+ XdndSelection,
+
+ XdndAware,
+ XdndProxy,
+
+ XdndActionCopy,
+ XdndActionLink,
+ XdndActionMove,
+ XdndActionPrivate,
+
+ // Motif DND
+ _MOTIF_DRAG_AND_DROP_MESSAGE,
+ _MOTIF_DRAG_INITIATOR_INFO,
+ _MOTIF_DRAG_RECEIVER_INFO,
+ _MOTIF_DRAG_WINDOW,
+ _MOTIF_DRAG_TARGETS,
+
+ XmTRANSFER_SUCCESS,
+ XmTRANSFER_FAILURE,
+
+ // Xkb
+ _XKB_RULES_NAMES,
+
+ // XEMBED
+ _XEMBED,
+ _XEMBED_INFO,
+
+ XWacomStylus,
+ XWacomCursor,
+ XWacomEraser,
+
+ XTabletStylus,
+ XTabletEraser,
+
+ NPredefinedAtoms,
+
+ _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
+ NAtoms
+ };
+}
+
+class QXcbKeyboard;
+
+class QXcbConnection : public QObject
+{
+ Q_OBJECT
+public:
+ QXcbConnection(const char *displayName = 0);
+ ~QXcbConnection();
+
+ QList<QXcbScreen *> screens() const { return m_screens; }
+ int primaryScreen() const { return m_primaryScreen; }
+
+ xcb_atom_t atom(QXcbAtom::Atom atom);
+
+ const char *displayName() const { return m_displayName.constData(); }
+
+ xcb_connection_t *xcb_connection() const { return m_connection; }
+
+ QXcbKeyboard *keyboard() const { return m_keyboard; }
+
+#ifdef XCB_USE_XLIB
+ void *xlib_display() const { return m_xlib_display; }
+#endif
+
+#ifdef XCB_USE_DRI2
+ bool hasSupportForDri2() const;
+ QByteArray dri2DeviceName() const { return m_dri2_device_name; }
+#endif
+#ifdef XCB_USE_EGL
+ bool hasEgl() const;
+#endif
+#if defined(XCB_USE_EGL) || defined(XCB_USE_DRI2)
+ void *egl_display() const { return m_egl_display; }
+#endif
+
+private slots:
+ void eventDispatcher();
+
+private:
+ void initializeAllAtoms();
+#ifdef XCB_USE_DRI2
+ void initializeDri2();
+#endif
+
+ xcb_connection_t *m_connection;
+ const xcb_setup_t *m_setup;
+
+ QList<QXcbScreen *> m_screens;
+ int m_primaryScreen;
+
+ xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
+
+ QByteArray m_displayName;
+
+ QXcbKeyboard *m_keyboard;
+
+#if defined(XCB_USE_XLIB)
+ void *m_xlib_display;
+#endif
+
+#ifdef XCB_USE_DRI2
+ uint32_t m_dri2_major;
+ uint32_t m_dri2_minor;
+ bool m_dri2_support_probed;
+ bool m_has_support_for_dri2;
+ QByteArray m_dri2_device_name;
+#endif
+#if defined(XCB_USE_EGL) || defined(XCB_USE_DRI2)
+ void *m_egl_display;
+ bool m_has_egl;
+#endif
+};
+
+#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
+
+#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
+#define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display()))
+#endif //endifXCB_USE_DRI2
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
new file mode 100644
index 0000000..63c26a1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbintegration.h"
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+#include "qxcbwindowsurface.h"
+#include "qxcbnativeinterface.h"
+
+#include <xcb/xcb.h>
+
+#include <private/qpixmap_raster_p.h>
+
+#include "qgenericunixfontdatabase.h"
+
+#include <stdio.h>
+
+#ifdef XCB_USE_EGL
+#include <EGL/egl.h>
+#endif
+
+QXcbIntegration::QXcbIntegration()
+ : m_connection(new QXcbConnection)
+{
+ foreach (QXcbScreen *screen, m_connection->screens())
+ m_screens << screen;
+
+ m_fontDatabase = new QGenericUnixFontDatabase();
+ m_nativeInterface = new QXcbNativeInterface;
+}
+
+QXcbIntegration::~QXcbIntegration()
+{
+ delete m_connection;
+}
+
+QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QXcbWindow(widget);
+}
+
+QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QXcbWindowSurface(widget);
+}
+
+QList<QPlatformScreen *> QXcbIntegration::screens() const
+{
+ return m_screens;
+}
+
+void QXcbIntegration::moveToScreen(QWidget *window, int screen)
+{
+ Q_UNUSED(window);
+ Q_UNUSED(screen);
+}
+
+bool QXcbIntegration::isVirtualDesktop()
+{
+ return false;
+}
+
+QPlatformFontDatabase *QXcbIntegration::fontDatabase() const
+{
+ return m_fontDatabase;
+}
+
+QPixmap QXcbIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ Q_UNUSED(window);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ return QPixmap();
+}
+
+
+bool QXcbIntegration::hasOpenGL() const
+{
+#if defined(XCB_USE_GLX)
+ return true;
+#elif defined(XCB_USE_EGL)
+ return m_connection->hasEgl();
+#elif defined(XCB_USE_DRI2)
+ if (m_connection->hasSupportForDri2()) {
+ return true;
+ }
+#endif
+ return false;
+}
+
+QPlatformNativeInterface * QXcbIntegration::nativeInterface() const
+{
+ return m_nativeInterface;
+}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
new file mode 100644
index 0000000..6c9634e
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbintegration.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBINTEGRATION_H
+#define QXCBINTEGRATION_H
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_NAMESPACE
+
+class QXcbConnection;
+
+class QXcbIntegration : public QPlatformIntegration
+{
+public:
+ QXcbIntegration();
+ ~QXcbIntegration();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+ void moveToScreen(QWidget *window, int screen);
+ bool isVirtualDesktop();
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+ bool hasOpenGL() const;
+
+ QPlatformNativeInterface *nativeInterface()const;
+
+private:
+ QList<QPlatformScreen *> m_screens;
+ QXcbConnection *m_connection;
+
+ QPlatformFontDatabase *m_fontDatabase;
+ QPlatformNativeInterface *m_nativeInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
new file mode 100644
index 0000000..ec9a009
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -0,0 +1,967 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbkeyboard.h"
+
+#include <xcb/xcb_keysyms.h>
+
+#include <X11/keysym.h>
+
+#include <QtGui/QWindowSystemInterface>
+#include <QtCore/QTextCodec>
+
+#include <stdio.h>
+
+#ifndef XK_ISO_Left_Tab
+#define XK_ISO_Left_Tab 0xFE20
+#endif
+
+#ifndef XK_dead_hook
+#define XK_dead_hook 0xFE61
+#endif
+
+#ifndef XK_dead_horn
+#define XK_dead_horn 0xFE62
+#endif
+
+#ifndef XK_Codeinput
+#define XK_Codeinput 0xFF37
+#endif
+
+#ifndef XK_Kanji_Bangou
+#define XK_Kanji_Bangou 0xFF37 /* same as codeinput */
+#endif
+
+// Fix old X libraries
+#ifndef XK_KP_Home
+#define XK_KP_Home 0xFF95
+#endif
+#ifndef XK_KP_Left
+#define XK_KP_Left 0xFF96
+#endif
+#ifndef XK_KP_Up
+#define XK_KP_Up 0xFF97
+#endif
+#ifndef XK_KP_Right
+#define XK_KP_Right 0xFF98
+#endif
+#ifndef XK_KP_Down
+#define XK_KP_Down 0xFF99
+#endif
+#ifndef XK_KP_Prior
+#define XK_KP_Prior 0xFF9A
+#endif
+#ifndef XK_KP_Next
+#define XK_KP_Next 0xFF9B
+#endif
+#ifndef XK_KP_End
+#define XK_KP_End 0xFF9C
+#endif
+#ifndef XK_KP_Insert
+#define XK_KP_Insert 0xFF9E
+#endif
+#ifndef XK_KP_Delete
+#define XK_KP_Delete 0xFF9F
+#endif
+
+// the next lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special
+// multimedia keys. They are included here as not every system has them.
+#define XF86XK_MonBrightnessUp 0x1008FF02
+#define XF86XK_MonBrightnessDown 0x1008FF03
+#define XF86XK_KbdLightOnOff 0x1008FF04
+#define XF86XK_KbdBrightnessUp 0x1008FF05
+#define XF86XK_KbdBrightnessDown 0x1008FF06
+#define XF86XK_Standby 0x1008FF10
+#define XF86XK_AudioLowerVolume 0x1008FF11
+#define XF86XK_AudioMute 0x1008FF12
+#define XF86XK_AudioRaiseVolume 0x1008FF13
+#define XF86XK_AudioPlay 0x1008FF14
+#define XF86XK_AudioStop 0x1008FF15
+#define XF86XK_AudioPrev 0x1008FF16
+#define XF86XK_AudioNext 0x1008FF17
+#define XF86XK_HomePage 0x1008FF18
+#define XF86XK_Mail 0x1008FF19
+#define XF86XK_Start 0x1008FF1A
+#define XF86XK_Search 0x1008FF1B
+#define XF86XK_AudioRecord 0x1008FF1C
+#define XF86XK_Calculator 0x1008FF1D
+#define XF86XK_Memo 0x1008FF1E
+#define XF86XK_ToDoList 0x1008FF1F
+#define XF86XK_Calendar 0x1008FF20
+#define XF86XK_PowerDown 0x1008FF21
+#define XF86XK_ContrastAdjust 0x1008FF22
+#define XF86XK_Back 0x1008FF26
+#define XF86XK_Forward 0x1008FF27
+#define XF86XK_Stop 0x1008FF28
+#define XF86XK_Refresh 0x1008FF29
+#define XF86XK_PowerOff 0x1008FF2A
+#define XF86XK_WakeUp 0x1008FF2B
+#define XF86XK_Eject 0x1008FF2C
+#define XF86XK_ScreenSaver 0x1008FF2D
+#define XF86XK_WWW 0x1008FF2E
+#define XF86XK_Sleep 0x1008FF2F
+#define XF86XK_Favorites 0x1008FF30
+#define XF86XK_AudioPause 0x1008FF31
+#define XF86XK_AudioMedia 0x1008FF32
+#define XF86XK_MyComputer 0x1008FF33
+#define XF86XK_LightBulb 0x1008FF35
+#define XF86XK_Shop 0x1008FF36
+#define XF86XK_History 0x1008FF37
+#define XF86XK_OpenURL 0x1008FF38
+#define XF86XK_AddFavorite 0x1008FF39
+#define XF86XK_HotLinks 0x1008FF3A
+#define XF86XK_BrightnessAdjust 0x1008FF3B
+#define XF86XK_Finance 0x1008FF3C
+#define XF86XK_Community 0x1008FF3D
+#define XF86XK_AudioRewind 0x1008FF3E
+#define XF86XK_BackForward 0x1008FF3F
+#define XF86XK_Launch0 0x1008FF40
+#define XF86XK_Launch1 0x1008FF41
+#define XF86XK_Launch2 0x1008FF42
+#define XF86XK_Launch3 0x1008FF43
+#define XF86XK_Launch4 0x1008FF44
+#define XF86XK_Launch5 0x1008FF45
+#define XF86XK_Launch6 0x1008FF46
+#define XF86XK_Launch7 0x1008FF47
+#define XF86XK_Launch8 0x1008FF48
+#define XF86XK_Launch9 0x1008FF49
+#define XF86XK_LaunchA 0x1008FF4A
+#define XF86XK_LaunchB 0x1008FF4B
+#define XF86XK_LaunchC 0x1008FF4C
+#define XF86XK_LaunchD 0x1008FF4D
+#define XF86XK_LaunchE 0x1008FF4E
+#define XF86XK_LaunchF 0x1008FF4F
+#define XF86XK_ApplicationLeft 0x1008FF50
+#define XF86XK_ApplicationRight 0x1008FF51
+#define XF86XK_Book 0x1008FF52
+#define XF86XK_CD 0x1008FF53
+#define XF86XK_Calculater 0x1008FF54
+#define XF86XK_Clear 0x1008FF55
+#define XF86XK_ClearGrab 0x1008FE21
+#define XF86XK_Close 0x1008FF56
+#define XF86XK_Copy 0x1008FF57
+#define XF86XK_Cut 0x1008FF58
+#define XF86XK_Display 0x1008FF59
+#define XF86XK_DOS 0x1008FF5A
+#define XF86XK_Documents 0x1008FF5B
+#define XF86XK_Excel 0x1008FF5C
+#define XF86XK_Explorer 0x1008FF5D
+#define XF86XK_Game 0x1008FF5E
+#define XF86XK_Go 0x1008FF5F
+#define XF86XK_iTouch 0x1008FF60
+#define XF86XK_LogOff 0x1008FF61
+#define XF86XK_Market 0x1008FF62
+#define XF86XK_Meeting 0x1008FF63
+#define XF86XK_MenuKB 0x1008FF65
+#define XF86XK_MenuPB 0x1008FF66
+#define XF86XK_MySites 0x1008FF67
+#define XF86XK_News 0x1008FF69
+#define XF86XK_OfficeHome 0x1008FF6A
+#define XF86XK_Option 0x1008FF6C
+#define XF86XK_Paste 0x1008FF6D
+#define XF86XK_Phone 0x1008FF6E
+#define XF86XK_Reply 0x1008FF72
+#define XF86XK_Reload 0x1008FF73
+#define XF86XK_RotateWindows 0x1008FF74
+#define XF86XK_RotationPB 0x1008FF75
+#define XF86XK_RotationKB 0x1008FF76
+#define XF86XK_Save 0x1008FF77
+#define XF86XK_Send 0x1008FF7B
+#define XF86XK_Spell 0x1008FF7C
+#define XF86XK_SplitScreen 0x1008FF7D
+#define XF86XK_Support 0x1008FF7E
+#define XF86XK_TaskPane 0x1008FF7F
+#define XF86XK_Terminal 0x1008FF80
+#define XF86XK_Tools 0x1008FF81
+#define XF86XK_Travel 0x1008FF82
+#define XF86XK_Video 0x1008FF87
+#define XF86XK_Word 0x1008FF89
+#define XF86XK_Xfer 0x1008FF8A
+#define XF86XK_ZoomIn 0x1008FF8B
+#define XF86XK_ZoomOut 0x1008FF8C
+#define XF86XK_Away 0x1008FF8D
+#define XF86XK_Messenger 0x1008FF8E
+#define XF86XK_WebCam 0x1008FF8F
+#define XF86XK_MailForward 0x1008FF90
+#define XF86XK_Pictures 0x1008FF91
+#define XF86XK_Music 0x1008FF92
+#define XF86XK_Battery 0x1008FF93
+#define XF86XK_Bluetooth 0x1008FF94
+#define XF86XK_WLAN 0x1008FF95
+#define XF86XK_UWB 0x1008FF96
+#define XF86XK_AudioForward 0x1008FF97
+#define XF86XK_AudioRepeat 0x1008FF98
+#define XF86XK_AudioRandomPlay 0x1008FF99
+#define XF86XK_Subtitle 0x1008FF9A
+#define XF86XK_AudioCycleTrack 0x1008FF9B
+#define XF86XK_Time 0x1008FF9F
+#define XF86XK_Select 0x1008FFA0
+#define XF86XK_View 0x1008FFA1
+#define XF86XK_TopMenu 0x1008FFA2
+#define XF86XK_Suspend 0x1008FFA7
+#define XF86XK_Hibernate 0x1008FFA8
+
+
+// end of XF86keysyms.h
+
+// Special keys used by Qtopia, mapped into the X11 private keypad range.
+#define QTOPIAXK_Select 0x11000601
+#define QTOPIAXK_Yes 0x11000602
+#define QTOPIAXK_No 0x11000603
+#define QTOPIAXK_Cancel 0x11000604
+#define QTOPIAXK_Printer 0x11000605
+#define QTOPIAXK_Execute 0x11000606
+#define QTOPIAXK_Sleep 0x11000607
+#define QTOPIAXK_Play 0x11000608
+#define QTOPIAXK_Zoom 0x11000609
+#define QTOPIAXK_Context1 0x1100060A
+#define QTOPIAXK_Context2 0x1100060B
+#define QTOPIAXK_Context3 0x1100060C
+#define QTOPIAXK_Context4 0x1100060D
+#define QTOPIAXK_Call 0x1100060E
+#define QTOPIAXK_Hangup 0x1100060F
+#define QTOPIAXK_Flip 0x11000610
+
+// keyboard mapping table
+static const unsigned int KeyTbl[] = {
+
+ // misc keys
+
+ XK_Escape, Qt::Key_Escape,
+ XK_Tab, Qt::Key_Tab,
+ XK_ISO_Left_Tab, Qt::Key_Backtab,
+ XK_BackSpace, Qt::Key_Backspace,
+ XK_Return, Qt::Key_Return,
+ XK_Insert, Qt::Key_Insert,
+ XK_Delete, Qt::Key_Delete,
+ XK_Clear, Qt::Key_Delete,
+ XK_Pause, Qt::Key_Pause,
+ XK_Print, Qt::Key_Print,
+ 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq
+ 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq
+
+ // cursor movement
+
+ XK_Home, Qt::Key_Home,
+ XK_End, Qt::Key_End,
+ XK_Left, Qt::Key_Left,
+ XK_Up, Qt::Key_Up,
+ XK_Right, Qt::Key_Right,
+ XK_Down, Qt::Key_Down,
+ XK_Prior, Qt::Key_PageUp,
+ XK_Next, Qt::Key_PageDown,
+
+ // modifiers
+
+ XK_Shift_L, Qt::Key_Shift,
+ XK_Shift_R, Qt::Key_Shift,
+ XK_Shift_Lock, Qt::Key_Shift,
+ XK_Control_L, Qt::Key_Control,
+ XK_Control_R, Qt::Key_Control,
+ XK_Meta_L, Qt::Key_Meta,
+ XK_Meta_R, Qt::Key_Meta,
+ XK_Alt_L, Qt::Key_Alt,
+ XK_Alt_R, Qt::Key_Alt,
+ XK_Caps_Lock, Qt::Key_CapsLock,
+ XK_Num_Lock, Qt::Key_NumLock,
+ XK_Scroll_Lock, Qt::Key_ScrollLock,
+ XK_Super_L, Qt::Key_Super_L,
+ XK_Super_R, Qt::Key_Super_R,
+ XK_Menu, Qt::Key_Menu,
+ XK_Hyper_L, Qt::Key_Hyper_L,
+ XK_Hyper_R, Qt::Key_Hyper_R,
+ XK_Help, Qt::Key_Help,
+ 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab
+ 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11)
+ 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12)
+
+ // numeric and function keypad keys
+
+ XK_KP_Space, Qt::Key_Space,
+ XK_KP_Tab, Qt::Key_Tab,
+ XK_KP_Enter, Qt::Key_Enter,
+ //XK_KP_F1, Qt::Key_F1,
+ //XK_KP_F2, Qt::Key_F2,
+ //XK_KP_F3, Qt::Key_F3,
+ //XK_KP_F4, Qt::Key_F4,
+ XK_KP_Home, Qt::Key_Home,
+ XK_KP_Left, Qt::Key_Left,
+ XK_KP_Up, Qt::Key_Up,
+ XK_KP_Right, Qt::Key_Right,
+ XK_KP_Down, Qt::Key_Down,
+ XK_KP_Prior, Qt::Key_PageUp,
+ XK_KP_Next, Qt::Key_PageDown,
+ XK_KP_End, Qt::Key_End,
+ XK_KP_Begin, Qt::Key_Clear,
+ XK_KP_Insert, Qt::Key_Insert,
+ XK_KP_Delete, Qt::Key_Delete,
+ XK_KP_Equal, Qt::Key_Equal,
+ XK_KP_Multiply, Qt::Key_Asterisk,
+ XK_KP_Add, Qt::Key_Plus,
+ XK_KP_Separator, Qt::Key_Comma,
+ XK_KP_Subtract, Qt::Key_Minus,
+ XK_KP_Decimal, Qt::Key_Period,
+ XK_KP_Divide, Qt::Key_Slash,
+
+ // International input method support keys
+
+ // International & multi-key character composition
+ XK_ISO_Level3_Shift, Qt::Key_AltGr,
+ XK_Multi_key, Qt::Key_Multi_key,
+ XK_Codeinput, Qt::Key_Codeinput,
+ XK_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_MultipleCandidate, Qt::Key_MultipleCandidate,
+ XK_PreviousCandidate, Qt::Key_PreviousCandidate,
+
+ // Misc Functions
+ XK_Mode_switch, Qt::Key_Mode_switch,
+ XK_script_switch, Qt::Key_Mode_switch,
+
+ // Japanese keyboard support
+ XK_Kanji, Qt::Key_Kanji,
+ XK_Muhenkan, Qt::Key_Muhenkan,
+ //XK_Henkan_Mode, Qt::Key_Henkan_Mode,
+ XK_Henkan_Mode, Qt::Key_Henkan,
+ XK_Henkan, Qt::Key_Henkan,
+ XK_Romaji, Qt::Key_Romaji,
+ XK_Hiragana, Qt::Key_Hiragana,
+ XK_Katakana, Qt::Key_Katakana,
+ XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana,
+ XK_Zenkaku, Qt::Key_Zenkaku,
+ XK_Hankaku, Qt::Key_Hankaku,
+ XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku,
+ XK_Touroku, Qt::Key_Touroku,
+ XK_Massyo, Qt::Key_Massyo,
+ XK_Kana_Lock, Qt::Key_Kana_Lock,
+ XK_Kana_Shift, Qt::Key_Kana_Shift,
+ XK_Eisu_Shift, Qt::Key_Eisu_Shift,
+ XK_Eisu_toggle, Qt::Key_Eisu_toggle,
+ //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou,
+ //XK_Zen_Koho, Qt::Key_Zen_Koho,
+ //XK_Mae_Koho, Qt::Key_Mae_Koho,
+ XK_Kanji_Bangou, Qt::Key_Codeinput,
+ XK_Zen_Koho, Qt::Key_MultipleCandidate,
+ XK_Mae_Koho, Qt::Key_PreviousCandidate,
+
+#ifdef XK_KOREAN
+ // Korean keyboard support
+ XK_Hangul, Qt::Key_Hangul,
+ XK_Hangul_Start, Qt::Key_Hangul_Start,
+ XK_Hangul_End, Qt::Key_Hangul_End,
+ XK_Hangul_Hanja, Qt::Key_Hangul_Hanja,
+ XK_Hangul_Jamo, Qt::Key_Hangul_Jamo,
+ XK_Hangul_Romaja, Qt::Key_Hangul_Romaja,
+ //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput,
+ XK_Hangul_Codeinput, Qt::Key_Codeinput,
+ XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja,
+ XK_Hangul_Banja, Qt::Key_Hangul_Banja,
+ XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja,
+ XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja,
+ //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate,
+ //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate,
+ //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate,
+ XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate,
+ XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate,
+ XK_Hangul_Special, Qt::Key_Hangul_Special,
+ //XK_Hangul_switch, Qt::Key_Hangul_switch,
+ XK_Hangul_switch, Qt::Key_Mode_switch,
+#endif // XK_KOREAN
+
+ // dead keys
+ XK_dead_grave, Qt::Key_Dead_Grave,
+ XK_dead_acute, Qt::Key_Dead_Acute,
+ XK_dead_circumflex, Qt::Key_Dead_Circumflex,
+ XK_dead_tilde, Qt::Key_Dead_Tilde,
+ XK_dead_macron, Qt::Key_Dead_Macron,
+ XK_dead_breve, Qt::Key_Dead_Breve,
+ XK_dead_abovedot, Qt::Key_Dead_Abovedot,
+ XK_dead_diaeresis, Qt::Key_Dead_Diaeresis,
+ XK_dead_abovering, Qt::Key_Dead_Abovering,
+ XK_dead_doubleacute, Qt::Key_Dead_Doubleacute,
+ XK_dead_caron, Qt::Key_Dead_Caron,
+ XK_dead_cedilla, Qt::Key_Dead_Cedilla,
+ XK_dead_ogonek, Qt::Key_Dead_Ogonek,
+ XK_dead_iota, Qt::Key_Dead_Iota,
+ XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
+ XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
+ XK_dead_belowdot, Qt::Key_Dead_Belowdot,
+ XK_dead_hook, Qt::Key_Dead_Hook,
+ XK_dead_horn, Qt::Key_Dead_Horn,
+
+ // Special keys from X.org - This include multimedia keys,
+ // wireless/bluetooth/uwb keys, special launcher keys, etc.
+ XF86XK_Back, Qt::Key_Back,
+ XF86XK_Forward, Qt::Key_Forward,
+ XF86XK_Stop, Qt::Key_Stop,
+ XF86XK_Refresh, Qt::Key_Refresh,
+ XF86XK_Favorites, Qt::Key_Favorites,
+ XF86XK_AudioMedia, Qt::Key_LaunchMedia,
+ XF86XK_OpenURL, Qt::Key_OpenUrl,
+ XF86XK_HomePage, Qt::Key_HomePage,
+ XF86XK_Search, Qt::Key_Search,
+ XF86XK_AudioLowerVolume, Qt::Key_VolumeDown,
+ XF86XK_AudioMute, Qt::Key_VolumeMute,
+ XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp,
+ XF86XK_AudioPlay, Qt::Key_MediaPlay,
+ XF86XK_AudioStop, Qt::Key_MediaStop,
+ XF86XK_AudioPrev, Qt::Key_MediaPrevious,
+ XF86XK_AudioNext, Qt::Key_MediaNext,
+ XF86XK_AudioRecord, Qt::Key_MediaRecord,
+ XF86XK_Mail, Qt::Key_LaunchMail,
+ XF86XK_MyComputer, Qt::Key_Launch0, // ### Qt 5: remap properly
+ XF86XK_Calculator, Qt::Key_Launch1,
+ XF86XK_Memo, Qt::Key_Memo,
+ XF86XK_ToDoList, Qt::Key_ToDoList,
+ XF86XK_Calendar, Qt::Key_Calendar,
+ XF86XK_PowerDown, Qt::Key_PowerDown,
+ XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust,
+ XF86XK_Standby, Qt::Key_Standby,
+ XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp,
+ XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown,
+ XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff,
+ XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp,
+ XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown,
+ XF86XK_PowerOff, Qt::Key_PowerOff,
+ XF86XK_WakeUp, Qt::Key_WakeUp,
+ XF86XK_Eject, Qt::Key_Eject,
+ XF86XK_ScreenSaver, Qt::Key_ScreenSaver,
+ XF86XK_WWW, Qt::Key_WWW,
+ XF86XK_Sleep, Qt::Key_Sleep,
+ XF86XK_LightBulb, Qt::Key_LightBulb,
+ XF86XK_Shop, Qt::Key_Shop,
+ XF86XK_History, Qt::Key_History,
+ XF86XK_AddFavorite, Qt::Key_AddFavorite,
+ XF86XK_HotLinks, Qt::Key_HotLinks,
+ XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust,
+ XF86XK_Finance, Qt::Key_Finance,
+ XF86XK_Community, Qt::Key_Community,
+ XF86XK_AudioRewind, Qt::Key_AudioRewind,
+ XF86XK_BackForward, Qt::Key_BackForward,
+ XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft,
+ XF86XK_ApplicationRight, Qt::Key_ApplicationRight,
+ XF86XK_Book, Qt::Key_Book,
+ XF86XK_CD, Qt::Key_CD,
+ XF86XK_Calculater, Qt::Key_Calculator,
+ XF86XK_Clear, Qt::Key_Clear,
+ XF86XK_ClearGrab, Qt::Key_ClearGrab,
+ XF86XK_Close, Qt::Key_Close,
+ XF86XK_Copy, Qt::Key_Copy,
+ XF86XK_Cut, Qt::Key_Cut,
+ XF86XK_Display, Qt::Key_Display,
+ XF86XK_DOS, Qt::Key_DOS,
+ XF86XK_Documents, Qt::Key_Documents,
+ XF86XK_Excel, Qt::Key_Excel,
+ XF86XK_Explorer, Qt::Key_Explorer,
+ XF86XK_Game, Qt::Key_Game,
+ XF86XK_Go, Qt::Key_Go,
+ XF86XK_iTouch, Qt::Key_iTouch,
+ XF86XK_LogOff, Qt::Key_LogOff,
+ XF86XK_Market, Qt::Key_Market,
+ XF86XK_Meeting, Qt::Key_Meeting,
+ XF86XK_MenuKB, Qt::Key_MenuKB,
+ XF86XK_MenuPB, Qt::Key_MenuPB,
+ XF86XK_MySites, Qt::Key_MySites,
+ XF86XK_News, Qt::Key_News,
+ XF86XK_OfficeHome, Qt::Key_OfficeHome,
+ XF86XK_Option, Qt::Key_Option,
+ XF86XK_Paste, Qt::Key_Paste,
+ XF86XK_Phone, Qt::Key_Phone,
+ XF86XK_Reply, Qt::Key_Reply,
+ XF86XK_Reload, Qt::Key_Reload,
+ XF86XK_RotateWindows, Qt::Key_RotateWindows,
+ XF86XK_RotationPB, Qt::Key_RotationPB,
+ XF86XK_RotationKB, Qt::Key_RotationKB,
+ XF86XK_Save, Qt::Key_Save,
+ XF86XK_Send, Qt::Key_Send,
+ XF86XK_Spell, Qt::Key_Spell,
+ XF86XK_SplitScreen, Qt::Key_SplitScreen,
+ XF86XK_Support, Qt::Key_Support,
+ XF86XK_TaskPane, Qt::Key_TaskPane,
+ XF86XK_Terminal, Qt::Key_Terminal,
+ XF86XK_Tools, Qt::Key_Tools,
+ XF86XK_Travel, Qt::Key_Travel,
+ XF86XK_Video, Qt::Key_Video,
+ XF86XK_Word, Qt::Key_Word,
+ XF86XK_Xfer, Qt::Key_Xfer,
+ XF86XK_ZoomIn, Qt::Key_ZoomIn,
+ XF86XK_ZoomOut, Qt::Key_ZoomOut,
+ XF86XK_Away, Qt::Key_Away,
+ XF86XK_Messenger, Qt::Key_Messenger,
+ XF86XK_WebCam, Qt::Key_WebCam,
+ XF86XK_MailForward, Qt::Key_MailForward,
+ XF86XK_Pictures, Qt::Key_Pictures,
+ XF86XK_Music, Qt::Key_Music,
+ XF86XK_Battery, Qt::Key_Battery,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_WLAN, Qt::Key_WLAN,
+ XF86XK_UWB, Qt::Key_UWB,
+ XF86XK_AudioForward, Qt::Key_AudioForward,
+ XF86XK_AudioRepeat, Qt::Key_AudioRepeat,
+ XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay,
+ XF86XK_Subtitle, Qt::Key_Subtitle,
+ XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack,
+ XF86XK_Time, Qt::Key_Time,
+ XF86XK_Select, Qt::Key_Select,
+ XF86XK_View, Qt::Key_View,
+ XF86XK_TopMenu, Qt::Key_TopMenu,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_Suspend, Qt::Key_Suspend,
+ XF86XK_Hibernate, Qt::Key_Hibernate,
+ XF86XK_Launch0, Qt::Key_Launch2, // ### Qt 5: remap properly
+ XF86XK_Launch1, Qt::Key_Launch3,
+ XF86XK_Launch2, Qt::Key_Launch4,
+ XF86XK_Launch3, Qt::Key_Launch5,
+ XF86XK_Launch4, Qt::Key_Launch6,
+ XF86XK_Launch5, Qt::Key_Launch7,
+ XF86XK_Launch6, Qt::Key_Launch8,
+ XF86XK_Launch7, Qt::Key_Launch9,
+ XF86XK_Launch8, Qt::Key_LaunchA,
+ XF86XK_Launch9, Qt::Key_LaunchB,
+ XF86XK_LaunchA, Qt::Key_LaunchC,
+ XF86XK_LaunchB, Qt::Key_LaunchD,
+ XF86XK_LaunchC, Qt::Key_LaunchE,
+ XF86XK_LaunchD, Qt::Key_LaunchF,
+ XF86XK_LaunchE, Qt::Key_LaunchG,
+ XF86XK_LaunchF, Qt::Key_LaunchH,
+
+ // Qtopia keys
+ QTOPIAXK_Select, Qt::Key_Select,
+ QTOPIAXK_Yes, Qt::Key_Yes,
+ QTOPIAXK_No, Qt::Key_No,
+ QTOPIAXK_Cancel, Qt::Key_Cancel,
+ QTOPIAXK_Printer, Qt::Key_Printer,
+ QTOPIAXK_Execute, Qt::Key_Execute,
+ QTOPIAXK_Sleep, Qt::Key_Sleep,
+ QTOPIAXK_Play, Qt::Key_Play,
+ QTOPIAXK_Zoom, Qt::Key_Zoom,
+ QTOPIAXK_Context1, Qt::Key_Context1,
+ QTOPIAXK_Context2, Qt::Key_Context2,
+ QTOPIAXK_Context3, Qt::Key_Context3,
+ QTOPIAXK_Context4, Qt::Key_Context4,
+ QTOPIAXK_Call, Qt::Key_Call,
+ QTOPIAXK_Hangup, Qt::Key_Hangup,
+ QTOPIAXK_Flip, Qt::Key_Flip,
+
+ 0, 0
+};
+
+static const unsigned short katakanaKeysymsToUnicode[] = {
+ 0x0000, 0x3002, 0x300C, 0x300D, 0x3001, 0x30FB, 0x30F2, 0x30A1,
+ 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3,
+ 0x30FC, 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD,
+ 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD,
+ 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC,
+ 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE,
+ 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9,
+ 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F3, 0x309B, 0x309C
+};
+
+static const unsigned short cyrillicKeysymsToUnicode[] = {
+ 0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f,
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a
+};
+
+static const unsigned short greekKeysymsToUnicode[] = {
+ 0x0000, 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c,
+ 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015,
+ 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc,
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
+ 0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
+ 0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
+ 0x03c8, 0x03c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short technicalKeysymsToUnicode[] = {
+ 0x0000, 0x23B7, 0x250C, 0x2500, 0x2320, 0x2321, 0x2502, 0x23A1,
+ 0x23A3, 0x23A4, 0x23A6, 0x239B, 0x239D, 0x239E, 0x23A0, 0x23A8,
+ 0x23AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222B,
+ 0x2234, 0x221D, 0x221E, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000,
+ 0x223C, 0x2243, 0x0000, 0x0000, 0x0000, 0x21D4, 0x21D2, 0x2261,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221A, 0x0000,
+ 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222A, 0x2227, 0x2228,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2202,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193, 0x0000
+};
+
+static const unsigned short specialKeysymsToUnicode[] = {
+ 0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x0000, 0x0000,
+ 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA,
+ 0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C,
+ 0x2502, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short publishingKeysymsToUnicode[] = {
+ 0x0000, 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009,
+ 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025,
+ 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a,
+ 0x2105, 0x0000, 0x0000, 0x2012, 0x2329, 0x0000, 0x232a, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000,
+ 0x0000, 0x2122, 0x2613, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25af,
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033,
+ 0x0000, 0x271d, 0x0000, 0x25ac, 0x25c0, 0x25b6, 0x25cf, 0x25ae,
+ 0x25e6, 0x25ab, 0x25ad, 0x25b3, 0x25bd, 0x2606, 0x2022, 0x25aa,
+ 0x25b2, 0x25bc, 0x261c, 0x261e, 0x2663, 0x2666, 0x2665, 0x0000,
+ 0x2720, 0x2020, 0x2021, 0x2713, 0x2717, 0x266f, 0x266d, 0x2642,
+ 0x2640, 0x260e, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e, 0x0000
+};
+
+static const unsigned short aplKeysymsToUnicode[] = {
+ 0x0000, 0x0000, 0x0000, 0x003c, 0x0000, 0x0000, 0x003e, 0x0000,
+ 0x2228, 0x2227, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x00af, 0x0000, 0x22a5, 0x2229, 0x230a, 0x0000, 0x005f, 0x0000,
+ 0x0000, 0x0000, 0x2218, 0x0000, 0x2395, 0x0000, 0x22a4, 0x25cb,
+ 0x0000, 0x0000, 0x0000, 0x2308, 0x0000, 0x0000, 0x222a, 0x0000,
+ 0x2283, 0x0000, 0x2282, 0x0000, 0x22a2, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x22a3, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short koreanKeysymsToUnicode[] = {
+ 0x0000, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137,
+ 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f,
+ 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147,
+ 0x3148, 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f,
+ 0x3150, 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157,
+ 0x3158, 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f,
+ 0x3160, 0x3161, 0x3162, 0x3163, 0x11a8, 0x11a9, 0x11aa, 0x11ab,
+ 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3,
+ 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb,
+ 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x316d,
+ 0x3171, 0x3178, 0x317f, 0x3181, 0x3184, 0x3186, 0x318d, 0x318e,
+ 0x11eb, 0x11f0, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9
+};
+
+static QChar keysymToUnicode(unsigned char byte3, unsigned char byte4)
+{
+ switch (byte3) {
+ case 0x04:
+ // katakana
+ if (byte4 > 0xa0 && byte4 < 0xe0)
+ return QChar(katakanaKeysymsToUnicode[byte4 - 0xa0]);
+ else if (byte4 == 0x7e)
+ return QChar(0x203e); // Overline
+ break;
+ case 0x06:
+ // russian, use lookup table
+ if (byte4 > 0xa0)
+ return QChar(cyrillicKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x07:
+ // greek
+ if (byte4 > 0xa0)
+ return QChar(greekKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x08:
+ // technical
+ if (byte4 > 0xa0)
+ return QChar(technicalKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x09:
+ // special
+ if (byte4 >= 0xe0)
+ return QChar(specialKeysymsToUnicode[byte4 - 0xe0]);
+ break;
+ case 0x0a:
+ // publishing
+ if (byte4 > 0xa0)
+ return QChar(publishingKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0b:
+ // APL
+ if (byte4 > 0xa0)
+ return QChar(aplKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0e:
+ // Korean
+ if (byte4 > 0xa0)
+ return QChar(koreanKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ default:
+ break;
+ }
+ return QChar(0x0);
+}
+
+Qt::KeyboardModifiers QXcbKeyboard::translateModifiers(int s)
+{
+ Qt::KeyboardModifiers ret = 0;
+ if (s & XCB_MOD_MASK_SHIFT)
+ ret |= Qt::ShiftModifier;
+ if (s & XCB_MOD_MASK_CONTROL)
+ ret |= Qt::ControlModifier;
+ if (s & m_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & m_meta_mask)
+ ret |= Qt::MetaModifier;
+ return ret;
+}
+
+int QXcbKeyboard::translateKeySym(uint key) const
+{
+ int code = -1;
+ int i = 0; // any other keys
+ while (KeyTbl[i]) {
+ if (key == KeyTbl[i]) {
+ code = (int)KeyTbl[i+1];
+ break;
+ }
+ i += 2;
+ }
+ if (m_meta_mask) {
+ // translate Super/Hyper keys to Meta if we're using them as the MetaModifier
+ if (m_meta_mask == m_super_mask && (code == Qt::Key_Super_L || code == Qt::Key_Super_R)) {
+ code = Qt::Key_Meta;
+ } else if (m_meta_mask == m_hyper_mask && (code == Qt::Key_Hyper_L || code == Qt::Key_Hyper_R)) {
+ code = Qt::Key_Meta;
+ }
+ }
+ return code;
+}
+
+QString QXcbKeyboard::translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count)
+{
+ // all keysyms smaller than 0xff00 are actally keys that can be mapped to unicode chars
+
+ QTextCodec *mapper = QTextCodec::codecForLocale();
+ QChar converted;
+
+ if (/*count == 0 &&*/ keysym < 0xff00) {
+ unsigned char byte3 = (unsigned char)(keysym >> 8);
+ int mib = -1;
+ switch(byte3) {
+ case 0: // Latin 1
+ case 1: // Latin 2
+ case 2: //latin 3
+ case 3: // latin4
+ mib = byte3 + 4; break;
+ case 5: // arabic
+ mib = 82; break;
+ case 12: // Hebrew
+ mib = 85; break;
+ case 13: // Thai
+ mib = 2259; break;
+ case 4: // kana
+ case 6: // cyrillic
+ case 7: // greek
+ case 8: // technical, no mapping here at the moment
+ case 9: // Special
+ case 10: // Publishing
+ case 11: // APL
+ case 14: // Korean, no mapping
+ mib = -1; // manual conversion
+ mapper= 0;
+#if !defined(QT_NO_XIM)
+ converted = keysymToUnicode(byte3, keysym & 0xff);
+#endif
+ case 0x20:
+ // currency symbols
+ if (keysym >= 0x20a0 && keysym <= 0x20ac) {
+ mib = -1; // manual conversion
+ mapper = 0;
+ converted = (uint)keysym;
+ }
+ break;
+ default:
+ break;
+ }
+ if (mib != -1) {
+ mapper = QTextCodec::codecForMib(mib);
+ if (chars.isEmpty())
+ chars.resize(1);
+ chars[0] = (unsigned char) (keysym & 0xff); // get only the fourth bit for conversion later
+ count = 1;
+ }
+ } else if (keysym >= 0x1000000 && keysym <= 0x100ffff) {
+ converted = (ushort) (keysym - 0x1000000);
+ mapper = 0;
+ }
+ if (count < (int)chars.size()-1)
+ chars[count] = '\0';
+
+ QString text;
+ if (!mapper && converted.unicode() != 0x0) {
+ text = converted;
+ } else if (!chars.isEmpty()) {
+ // convert chars (8bit) to text (unicode).
+ if (mapper)
+ text = mapper->toUnicode(chars.data(), count, 0);
+ if (text.isEmpty()) {
+ // no mapper, or codec couldn't convert to unicode (this
+ // can happen when running in the C locale or with no LANG
+ // set). try converting from latin-1
+ text = QString::fromLatin1(chars);
+ }
+ }
+
+ modifiers = translateModifiers(xmodifiers);
+
+ // Commentary in X11/keysymdef says that X codes match ASCII, so it
+ // is safe to use the locale functions to process X codes in ISO8859-1.
+ //
+ // This is mainly for compatibility - applications should not use the
+ // Qt keycodes between 128 and 255, but should rather use the
+ // QKeyEvent::text().
+ //
+ if (keysym < 128 || (keysym < 256 && (!mapper || mapper->mibEnum()==4))) {
+ // upper-case key, if known
+ code = isprint((int)keysym) ? toupper((int)keysym) : 0;
+ } else if (keysym >= XK_F1 && keysym <= XK_F35) {
+ // function keys
+ code = Qt::Key_F1 + ((int)keysym - XK_F1);
+ } else if (keysym >= XK_KP_Space && keysym <= XK_KP_9) {
+ if (keysym >= XK_KP_0) {
+ // numeric keypad keys
+ code = Qt::Key_0 + ((int)keysym - XK_KP_0);
+ } else {
+ code = translateKeySym(keysym);
+ }
+ modifiers |= Qt::KeypadModifier;
+ } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f && text.unicode()->unicode() != 0x7f && !(keysym >= XK_dead_grave && keysym <= XK_dead_horn)) {
+ code = text.unicode()->toUpper().unicode();
+ } else {
+ // any other keys
+ code = translateKeySym(keysym);
+
+ if (code == Qt::Key_Tab && (modifiers & Qt::ShiftModifier)) {
+ // map shift+tab to shift+backtab, QShortcutMap knows about it
+ // and will handle it.
+ code = Qt::Key_Backtab;
+ text = QString();
+ }
+ }
+
+ return text;
+}
+
+QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
+ : QXcbObject(connection)
+ , m_alt_mask(0)
+ , m_super_mask(0)
+ , m_hyper_mask(0)
+ , m_meta_mask(0)
+{
+ m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
+}
+
+QXcbKeyboard::~QXcbKeyboard()
+{
+ xcb_key_symbols_free(m_key_symbols);
+}
+
+// #define XCB_KEYBOARD_DEBUG
+
+void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
+{
+ int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
+
+ const int altGrOffset = 4;
+ if (state & 128)
+ col += altGrOffset;
+
+#ifdef XCB_KEYBOARD_DEBUG
+ printf("key code: %d, state: %d, syms: ", code, state);
+ for (int i = 0; i <= 5; ++i) {
+ printf("%d ", xcb_key_symbols_get_keysym(m_key_symbols, code, i));
+ }
+ printf("\n");
+#endif
+
+ xcb_keysym_t sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col);
+ if (sym == XCB_NO_SYMBOL)
+ sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col ^ 0x1);
+
+ if (state & XCB_MOD_MASK_LOCK && sym <= 0x7f && isprint(sym)) {
+ if (isupper(sym))
+ sym = tolower(sym);
+ else
+ sym = toupper(sym);
+ }
+
+ QByteArray chars;
+
+ Qt::KeyboardModifiers modifiers;
+ int qtcode = 0;
+ int count = 0;
+
+ QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
+
+ QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count));
+}
+
+void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event)
+{
+ handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time);
+}
+
+void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event)
+{
+ handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time);
+}
+
+void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event)
+{
+ xcb_refresh_keyboard_mapping(m_key_symbols, const_cast<xcb_mapping_notify_event_t *>(event));
+}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
new file mode 100644
index 0000000..ddade79
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.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 plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBKEYBOARD_H
+#define QXCBKEYBOARD_H
+
+#include "qxcbobject.h"
+
+#include "xcb/xcb_keysyms.h"
+
+#include <QEvent>
+
+class QXcbKeyboard : public QXcbObject
+{
+public:
+ QXcbKeyboard(QXcbConnection *connection);
+ ~QXcbKeyboard();
+
+ void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event);
+ void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event);
+
+ void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event);
+
+ Qt::KeyboardModifiers translateModifiers(int s);
+
+private:
+ void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
+
+ int translateKeySym(uint key) const;
+ QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count);
+
+ uint m_alt_mask;
+ uint m_super_mask;
+ uint m_hyper_mask;
+ uint m_meta_mask;
+ uint m_mode_switch_mask;
+ uint m_num_lock_mask;
+
+ xcb_key_symbols_t *m_key_symbols;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
new file mode 100644
index 0000000..b2ca1be
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbnativeinterface.h"
+
+#include "qxcbscreen.h"
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtCore/QMap>
+
+#include <QtCore/QDebug>
+
+#if defined(XCB_USE_EGL)
+#include "../eglconvenience/qeglplatformcontext.h"
+#elif defined (XCB_USE_DRI2)
+#include "qdri2context.h"
+#endif
+
+class QXcbResourceMap : public QMap<QByteArray, QXcbNativeInterface::ResourceType>
+{
+public:
+ QXcbResourceMap()
+ :QMap<QByteArray, QXcbNativeInterface::ResourceType>()
+ {
+ insert("display",QXcbNativeInterface::Display);
+ insert("egldisplay",QXcbNativeInterface::EglDisplay);
+ insert("connection",QXcbNativeInterface::Connection);
+ insert("screen",QXcbNativeInterface::Screen);
+ insert("graphicsdevice",QXcbNativeInterface::GraphicsDevice);
+ insert("eglcontext",QXcbNativeInterface::EglContext);
+ }
+};
+
+Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
+
+void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch(resource) {
+ case Display:
+ result = displayForWidget(widget);
+ break;
+ case EglDisplay:
+ result = eglDisplayForWidget(widget);
+ break;
+ case Connection:
+ result = connectionForWidget(widget);
+ break;
+ case Screen:
+ result = qPlatformScreenForWidget(widget);
+ break;
+ case GraphicsDevice:
+ result = graphicsDeviceForWidget(widget);
+ break;
+ case EglContext:
+ result = eglContextForWidget(widget);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+}
+
+QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+{
+ QXcbScreen *screen;
+ if (widget) {
+ screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ }else {
+ screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ }
+ return screen;
+}
+
+void *QXcbNativeInterface::displayForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_XLIB)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->connection()->xlib_display();
+#else
+ Q_UNUSED(widget);
+ return 0;
+#endif
+}
+
+void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->connection()->egl_display();
+#else
+ Q_UNUSED(widget)
+ return 0;
+#endif
+}
+
+void *QXcbNativeInterface::connectionForWidget(QWidget *widget)
+{
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->xcb_connection();
+}
+
+void *QXcbNativeInterface::screenForWidget(QWidget *widget)
+{
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->screen();
+}
+
+void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_DRI2)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QByteArray deviceName = screen->connection()->dri2DeviceName();
+ return deviceName.data();
+#else
+ Q_UNUSED(widget);
+ return 0;
+#endif
+
+}
+
+void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
+{
+ Q_ASSERT(widget);
+ if (!widget->platformWindow()) {
+ qDebug() << "QPlatformWindow does not exist for widget" << widget
+ << "cannot return EGLContext";
+ return 0;
+ }
+ QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ if (!platformContext) {
+ qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ << "cannot return EGLContext";
+ return 0;
+ }
+#if defined(XCB_USE_EGL)
+ QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(platformContext);
+ return eglPlatformContext->eglContext();
+#elif defined (XCB_USE_DRI2)
+ QDri2Context *dri2Context = static_cast<QDri2Context *>(platformContext);
+ return dri2Context->eglContext();
+#else
+ return 0;
+#endif
+}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
new file mode 100644
index 0000000..f60905c
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBNATIVEINTERFACE_H
+#define QXCBNATIVEINTERFACE_H
+
+#include <QtGui/QPlatformNativeInterface>
+
+class QWidget;
+class QXcbScreen;
+
+class QXcbNativeInterface : public QPlatformNativeInterface
+{
+public:
+ enum ResourceType {
+ Display,
+ EglDisplay,
+ Connection,
+ Screen,
+ GraphicsDevice,
+ EglContext
+ };
+
+ void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
+
+ void *displayForWidget(QWidget *widget);
+ void *eglDisplayForWidget(QWidget *widget);
+ void *connectionForWidget(QWidget *widget);
+ void *screenForWidget(QWidget *widget);
+ void *graphicsDeviceForWidget(QWidget *widget);
+ void *eglContextForWidget(QWidget *widget);
+
+private:
+ static QXcbScreen *qPlatformScreenForWidget(QWidget *widget);
+};
+
+#endif // QXCBNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/xcb/qxcbobject.h b/src/plugins/platforms/xcb/qxcbobject.h
new file mode 100644
index 0000000..69494b0
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbobject.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBOBJECT_H
+#define QXCBOBJECT_H
+
+#include "qxcbconnection.h"
+
+class QXcbObject
+{
+public:
+ QXcbObject(QXcbConnection *connection = 0) : m_connection(connection) {}
+
+ void setConnection(QXcbConnection *connection) { m_connection = connection; }
+ QXcbConnection *connection() const { return m_connection; }
+
+ xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_connection->atom(atom); }
+ xcb_connection_t *xcb_connection() const { return m_connection->xcb_connection(); }
+
+private:
+ QXcbConnection *m_connection;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
new file mode 100644
index 0000000..fffeb2e
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbscreen.h"
+
+#include <stdio.h>
+
+QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number)
+ : QXcbObject(connection)
+ , m_screen(screen)
+ , m_number(number)
+{
+ printf ("\n");
+ printf ("Information of screen %d:\n", screen->root);
+ printf (" width.........: %d\n", screen->width_in_pixels);
+ printf (" height........: %d\n", screen->height_in_pixels);
+ printf (" depth.........: %d\n", screen->root_depth);
+ printf (" white pixel...: %x\n", screen->white_pixel);
+ printf (" black pixel...: %x\n", screen->black_pixel);
+ printf ("\n");
+
+ const quint32 mask = XCB_CW_EVENT_MASK;
+ const quint32 values[] = {
+ // XCB_CW_EVENT_MASK
+ XCB_EVENT_MASK_KEYMAP_STATE
+ | XCB_EVENT_MASK_ENTER_WINDOW
+ | XCB_EVENT_MASK_LEAVE_WINDOW
+ | XCB_EVENT_MASK_PROPERTY_CHANGE
+ };
+
+ xcb_change_window_attributes(xcb_connection(), screen->root, mask, values);
+}
+
+QXcbScreen::~QXcbScreen()
+{
+}
+
+QRect QXcbScreen::geometry() const
+{
+ return QRect(0, 0, m_screen->width_in_pixels, m_screen->height_in_pixels);
+}
+
+int QXcbScreen::depth() const
+{
+ return m_screen->root_depth;
+}
+
+QImage::Format QXcbScreen::format() const
+{
+ return QImage::Format_RGB32;
+}
+
+QSize QXcbScreen::physicalSize() const
+{
+ return QSize(m_screen->width_in_millimeters, m_screen->height_in_millimeters);
+}
+
+int QXcbScreen::screenNumber() const
+{
+ return m_number;
+}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
new file mode 100644
index 0000000..6f69fc7
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBSCREEN_H
+#define QXCBSCREEN_H
+
+#include <QtGui/QPlatformScreen>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbConnection;
+
+class QXcbScreen : public QXcbObject, public QPlatformScreen
+{
+public:
+ QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number);
+ ~QXcbScreen();
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+ QSize physicalSize() const;
+
+ int screenNumber() const;
+
+ xcb_screen_t *screen() const { return m_screen; }
+ xcb_window_t root() const { return m_screen->root; }
+
+private:
+ xcb_screen_t *m_screen;
+ int m_number;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
new file mode 100644
index 0000000..cbf50f7
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -0,0 +1,588 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbwindow.h"
+
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#ifdef XCB_USE_DRI2
+#include "qdri2context.h"
+#endif
+
+#include <xcb/xcb_icccm.h>
+
+#include <private/qapplication_p.h>
+#include <private/qwindowsurface_p.h>
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <stdio.h>
+
+#ifdef XCB_USE_XLIB
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif
+
+#if defined(XCB_USE_GLX)
+#include "qglxintegration.h"
+#elif defined(XCB_USE_EGL)
+#include "../eglconvenience/qeglplatformcontext.h"
+#include "../eglconvenience/qeglconvenience.h"
+#include "../eglconvenience/qxlibeglintegration.h"
+#endif
+
+// Returns true if we should set WM_TRANSIENT_FOR on \a w
+static inline bool isTransient(const QWidget *w)
+{
+ return ((w->windowType() == Qt::Dialog
+ || w->windowType() == Qt::Sheet
+ || w->windowType() == Qt::Tool
+ || w->windowType() == Qt::SplashScreen
+ || w->windowType() == Qt::ToolTip
+ || w->windowType() == Qt::Drawer
+ || w->windowType() == Qt::Popup)
+ && !w->testAttribute(Qt::WA_X11BypassTransientForHint));
+}
+
+QXcbWindow::QXcbWindow(QWidget *tlw)
+ : QPlatformWindow(tlw)
+ , m_context(0)
+{
+ m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+
+ setConnection(m_screen->connection());
+
+ const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK;
+ const quint32 values[] = {
+ // XCB_CW_BACK_PIXMAP
+ XCB_NONE,
+ // XCB_CW_EVENT_MASK
+ XCB_EVENT_MASK_EXPOSURE
+ | XCB_EVENT_MASK_STRUCTURE_NOTIFY
+ | XCB_EVENT_MASK_KEY_PRESS
+ | XCB_EVENT_MASK_KEY_RELEASE
+ | XCB_EVENT_MASK_BUTTON_PRESS
+ | XCB_EVENT_MASK_BUTTON_RELEASE
+ | XCB_EVENT_MASK_BUTTON_MOTION
+ | XCB_EVENT_MASK_ENTER_WINDOW
+ | XCB_EVENT_MASK_LEAVE_WINDOW
+ | XCB_EVENT_MASK_PROPERTY_CHANGE
+ | XCB_EVENT_MASK_FOCUS_CHANGE
+ };
+
+#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
+ if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ && QApplicationPrivate::platformIntegration()->hasOpenGL() ) {
+#if defined(XCB_USE_GLX)
+ XVisualInfo *visualInfo = QGLXContext::findVisualInfo(m_screen, tlw->platformWindowFormat());
+#elif defined(XCB_USE_EGL)
+ EGLDisplay eglDisplay = eglGetDisplay(DISPLAY_FROM_XCB(this));
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true);
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this),eglConfig);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
+#endif //XCB_USE_GLX
+ if (visualInfo) {
+ Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ printf("created GL window: %d\n", m_window);
+ } else {
+ qFatal("no window!");
+ }
+ } else
+#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
+ {
+ m_window = xcb_generate_id(xcb_connection());
+
+ xcb_create_window(xcb_connection(),
+ XCB_COPY_FROM_PARENT, // depth -- same as root
+ m_window, // window id
+ m_screen->root(), // parent window id
+ tlw->x(),
+ tlw->y(),
+ tlw->width(),
+ tlw->height(),
+ 0, // border width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
+ m_screen->screen()->root_visual, // visual
+ 0, // value mask
+ 0); // value list
+
+ printf("created regular window: %d\n", m_window);
+ }
+
+ xcb_change_window_attributes(xcb_connection(), m_window, mask, values);
+
+ xcb_atom_t properties[4];
+ int propertyCount = 0;
+ properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW);
+ properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
+ properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
+
+ if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint)
+ properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP);
+
+ xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::WM_PROTOCOLS),
+ 4,
+ 32,
+ propertyCount,
+ properties);
+
+ if (isTransient(tlw) && tlw->parentWidget()) {
+ // ICCCM 4.1.2.6
+ QWidget *p = tlw->parentWidget()->window();
+ xcb_window_t parentWindow = p->winId();
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
+ XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
+ 1, &parentWindow);
+
+ }
+}
+
+QXcbWindow::~QXcbWindow()
+{
+ xcb_destroy_window(xcb_connection(), m_window);
+}
+
+void QXcbWindow::setGeometry(const QRect &rect)
+{
+ QPlatformWindow::setGeometry(rect);
+
+ const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
+ const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() };
+
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::setVisible(bool visible)
+{
+ xcb_wm_hints_t hints;
+ if (visible) {
+ if (widget()->isMinimized())
+ xcb_wm_hints_set_iconic(&hints);
+ else
+ xcb_wm_hints_set_normal(&hints);
+ xcb_set_wm_hints(xcb_connection(), m_window, &hints);
+ xcb_map_window(xcb_connection(), m_window);
+ } else {
+ xcb_unmap_window(xcb_connection(), m_window);
+
+ // send synthetic UnmapNotify event according to icccm 4.1.4
+ xcb_unmap_notify_event_t event;
+ event.response_type = XCB_UNMAP_NOTIFY;
+ event.sequence = 0; // does this matter?
+ event.event = m_screen->root();
+ event.window = m_window;
+ event.from_configure = false;
+ xcb_send_event(xcb_connection(), false, m_screen->root(),
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event);
+
+ xcb_flush(xcb_connection());
+ }
+}
+
+struct QtMWMHints {
+ quint32 flags, functions, decorations;
+ qint32 input_mode;
+ quint32 status;
+};
+
+enum {
+ MWM_HINTS_FUNCTIONS = (1L << 0),
+
+ MWM_FUNC_ALL = (1L << 0),
+ MWM_FUNC_RESIZE = (1L << 1),
+ MWM_FUNC_MOVE = (1L << 2),
+ MWM_FUNC_MINIMIZE = (1L << 3),
+ MWM_FUNC_MAXIMIZE = (1L << 4),
+ MWM_FUNC_CLOSE = (1L << 5),
+
+ MWM_HINTS_DECORATIONS = (1L << 1),
+
+ MWM_DECOR_ALL = (1L << 0),
+ MWM_DECOR_BORDER = (1L << 1),
+ MWM_DECOR_RESIZEH = (1L << 2),
+ MWM_DECOR_TITLE = (1L << 3),
+ MWM_DECOR_MENU = (1L << 4),
+ MWM_DECOR_MINIMIZE = (1L << 5),
+ MWM_DECOR_MAXIMIZE = (1L << 6),
+
+ MWM_HINTS_INPUT_MODE = (1L << 2),
+
+ MWM_INPUT_MODELESS = 0L,
+ MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L,
+ MWM_INPUT_FULL_APPLICATION_MODAL = 3L
+};
+
+Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+
+ if (type == Qt::ToolTip)
+ flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
+ if (type == Qt::Popup)
+ flags |= Qt::X11BypassWindowManagerHint;
+
+ bool topLevel = (flags & Qt::Window);
+ bool popup = (type == Qt::Popup);
+ bool dialog = (type == Qt::Dialog
+ || type == Qt::Sheet);
+ bool desktop = (type == Qt::Desktop);
+ bool tool = (type == Qt::Tool || type == Qt::SplashScreen
+ || type == Qt::ToolTip || type == Qt::Drawer);
+
+ Q_UNUSED(topLevel);
+ Q_UNUSED(dialog);
+ Q_UNUSED(desktop);
+ Q_UNUSED(tool);
+
+ bool tooltip = (type == Qt::ToolTip);
+
+ QtMWMHints mwmhints;
+ mwmhints.flags = 0L;
+ mwmhints.functions = 0L;
+ mwmhints.decorations = 0;
+ mwmhints.input_mode = 0L;
+ mwmhints.status = 0L;
+
+ if (type != Qt::SplashScreen) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+
+ bool customize = flags & Qt::CustomizeWindowHint;
+ if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
+ mwmhints.decorations |= MWM_DECOR_BORDER;
+ mwmhints.decorations |= MWM_DECOR_RESIZEH;
+
+ if (flags & Qt::WindowTitleHint)
+ mwmhints.decorations |= MWM_DECOR_TITLE;
+
+ if (flags & Qt::WindowSystemMenuHint)
+ mwmhints.decorations |= MWM_DECOR_MENU;
+
+ if (flags & Qt::WindowMinimizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MINIMIZE;
+ mwmhints.functions |= MWM_FUNC_MINIMIZE;
+ }
+
+ if (flags & Qt::WindowMaximizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
+ mwmhints.functions |= MWM_FUNC_MAXIMIZE;
+ }
+
+ if (flags & Qt::WindowCloseButtonHint)
+ mwmhints.functions |= MWM_FUNC_CLOSE;
+ }
+ } else {
+ // if type == Qt::SplashScreen
+ mwmhints.decorations = MWM_DECOR_ALL;
+ }
+
+ if (mwmhints.functions != 0) {
+ mwmhints.flags |= MWM_HINTS_FUNCTIONS;
+ mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ } else {
+ mwmhints.functions = MWM_FUNC_ALL;
+ }
+
+ if (!(flags & Qt::FramelessWindowHint)
+ && flags & Qt::CustomizeWindowHint
+ && flags & Qt::WindowTitleHint
+ && !(flags &
+ (Qt::WindowMinimizeButtonHint
+ | Qt::WindowMaximizeButtonHint
+ | Qt::WindowCloseButtonHint)))
+ {
+ // a special case - only the titlebar without any button
+ mwmhints.flags = MWM_HINTS_FUNCTIONS;
+ mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ mwmhints.decorations = 0;
+ }
+
+ if (mwmhints.flags != 0l) {
+ xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::_MOTIF_WM_HINTS),
+ atom(QXcbAtom::_MOTIF_WM_HINTS),
+ 32,
+ 5,
+ &mwmhints);
+ } else {
+ xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS));
+ }
+
+ if (popup || tooltip) {
+ const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER;
+ const quint32 values[] = { true, true };
+
+ xcb_change_window_attributes(xcb_connection(), m_window, mask, values);
+ }
+
+ return QPlatformWindow::setWindowFlags(flags);
+}
+
+WId QXcbWindow::winId() const
+{
+ return m_window;
+}
+
+void QXcbWindow::setParent(const QPlatformWindow *parent)
+{
+ QPoint topLeft = geometry().topLeft();
+ xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y());
+}
+
+void QXcbWindow::setWindowTitle(const QString &title)
+{
+ QByteArray ba = title.toUtf8();
+ xcb_change_property (xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::_NET_WM_NAME),
+ atom(QXcbAtom::UTF8_STRING),
+ 8,
+ ba.length(),
+ ba.constData());
+}
+
+void QXcbWindow::raise()
+{
+ const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
+ const quint32 values[] = { XCB_STACK_MODE_ABOVE };
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::lower()
+{
+ const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
+ const quint32 values[] = { XCB_STACK_MODE_BELOW };
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::requestActivateWindow()
+{
+ xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME);
+}
+
+QPlatformGLContext *QXcbWindow::glContext() const
+{
+ if (!QApplicationPrivate::platformIntegration()->hasOpenGL()) {
+ printf("no opengl\n");
+ return 0;
+ }
+#if defined(XCB_USE_GLX)
+ if (!m_context) {
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat());
+ }
+#elif defined(XCB_USE_EGL)
+ if (!m_context) {
+ EGLDisplay display = eglGetDisplay(DISPLAY_FROM_XCB(this));
+
+ EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true);
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)m_window,0);
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
+ }
+#elif defined(XCB_USE_DRI2)
+ if (!m_context) {
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QDri2Context(that);
+ }
+
+#endif
+ return m_context;
+}
+
+void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
+{
+ QWindowSurface *surface = widget()->windowSurface();
+ if (surface) {
+ QRect rect(event->x, event->y, event->width, event->height);
+
+ surface->flush(widget(), rect, QPoint());
+ }
+}
+
+void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event)
+{
+ if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
+ if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) {
+ QWindowSystemInterface::handleCloseEvent(widget());
+ }
+ }
+}
+
+void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
+{
+ int xpos = geometry().x();
+ int ypos = geometry().y();
+
+ if ((event->width == geometry().width() && event->height == geometry().height()) || event->x != 0 || event->y != 0) {
+ xpos = event->x;
+ ypos = event->y;
+ }
+
+ QRect rect(xpos, ypos, event->width, event->height);
+ QPlatformWindow::setGeometry(rect);
+
+ QWindowSystemInterface::handleGeometryChange(widget(), rect);
+
+#if XCB_USE_DRI2
+ if (m_context)
+ static_cast<QDri2Context *>(m_context)->resize(rect.size());
+#endif
+}
+
+static Qt::MouseButtons translateMouseButtons(int s)
+{
+ Qt::MouseButtons ret = 0;
+ if (s & XCB_BUTTON_MASK_1)
+ ret |= Qt::LeftButton;
+ if (s & XCB_BUTTON_MASK_2)
+ ret |= Qt::MidButton;
+ if (s & XCB_BUTTON_MASK_3)
+ ret |= Qt::RightButton;
+ return ret;
+}
+
+static Qt::MouseButton translateMouseButton(xcb_button_t s)
+{
+ switch (s) {
+ case 1:
+ return Qt::LeftButton;
+ case 2:
+ return Qt::MidButton;
+ case 3:
+ return Qt::RightButton;
+ default:
+ return Qt::NoButton;
+ }
+}
+
+void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ if (event->detail >= 4 && event->detail <= 7) {
+ //logic borrowed from qapplication_x11.cpp
+ int delta = 120 * ((event->detail == 4 || event->detail == 6) ? 1 : -1);
+ bool hor = (((event->detail == 4 || event->detail == 5)
+ && (modifiers & Qt::AltModifier))
+ || (event->detail == 6 || event->detail == 7));
+
+ QWindowSystemInterface::handleWheelEvent(widget(), event->time,
+ local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
+ return;
+ }
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global)
+{
+ Qt::MouseButtons buttons = translateMouseButtons(state);
+ Qt::MouseButton button = translateMouseButton(detail);
+
+ buttons ^= button; // X event uses state *before*, Qt uses state *after*
+
+ QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons);
+}
+
+void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
+{
+ QWindowSystemInterface::handleEnterEvent(widget());
+}
+
+void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
+{
+ QWindowSystemInterface::handleLeaveEvent(widget());
+}
+
+void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
+{
+ QWindowSystemInterface::handleWindowActivated(widget());
+}
+
+void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *)
+{
+ QWindowSystemInterface::handleWindowActivated(0);
+}
+
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
new file mode 100644
index 0000000..1e9930d
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBWINDOW_H
+#define QXCBWINDOW_H
+
+#include <QtGui/QPlatformWindow>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbScreen;
+
+class QXcbWindow : public QXcbObject, public QPlatformWindow
+{
+public:
+ QXcbWindow(QWidget *tlw);
+ ~QXcbWindow();
+
+ void setGeometry(const QRect &rect);
+
+ void setVisible(bool visible);
+ Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ WId winId() const;
+ void setParent(const QPlatformWindow *window);
+
+ void setWindowTitle(const QString &title);
+ void raise();
+ void lower();
+
+ void requestActivateWindow();
+
+ QPlatformGLContext *glContext() const;
+
+ xcb_window_t window() const { return m_window; }
+
+ void handleExposeEvent(const xcb_expose_event_t *event);
+ void handleClientMessageEvent(const xcb_client_message_event_t *event);
+ void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
+ void handleButtonPressEvent(const xcb_button_press_event_t *event);
+ void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
+ void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
+
+ void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
+ void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
+ void handleFocusInEvent(const xcb_focus_in_event_t *event);
+ void handleFocusOutEvent(const xcb_focus_out_event_t *event);
+
+ void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
+
+private:
+ QXcbScreen *m_screen;
+
+ xcb_window_t m_window;
+ QPlatformGLContext *m_context;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
new file mode 100644
index 0000000..7fed230
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxcbwindowsurface.h"
+
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+
+#include <xcb/shm.h>
+#include <xcb/xcb_image.h>
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <stdio.h>
+
+class QXcbShmImage : public QXcbObject
+{
+public:
+ QXcbShmImage(QXcbScreen *connection, const QSize &size);
+ ~QXcbShmImage() { destroy(); }
+
+ QImage *image() { return &m_qimage; }
+
+ void put(xcb_window_t window, const QPoint &dst, const QRect &source);
+ void preparePaint(const QRegion &region);
+
+private:
+ void destroy();
+
+ xcb_shm_segment_info_t m_shm_info;
+
+ xcb_image_t *m_xcb_image;
+
+ QImage m_qimage;
+
+ xcb_gcontext_t m_gc;
+ xcb_window_t m_gc_window;
+
+ QRegion m_dirty;
+};
+
+QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size)
+ : QXcbObject(screen->connection())
+ , m_gc(0)
+ , m_gc_window(0)
+{
+ m_xcb_image = xcb_image_create_native(xcb_connection(),
+ size.width(),
+ size.height(),
+ XCB_IMAGE_FORMAT_Z_PIXMAP,
+ screen->depth(),
+ 0,
+ ~0,
+ 0);
+ m_shm_info.shmid = shmget (IPC_PRIVATE,
+ m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0777);
+
+ m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0);
+ m_shm_info.shmseg = xcb_generate_id(xcb_connection());
+
+ xcb_shm_attach(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false);
+
+ m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format());
+}
+
+void QXcbShmImage::destroy()
+{
+ xcb_shm_detach(xcb_connection(), m_shm_info.shmseg);
+ xcb_image_destroy(m_xcb_image);
+ shmdt(m_shm_info.shmaddr);
+ shmctl(m_shm_info.shmid, IPC_RMID, 0);
+
+ xcb_free_gc(xcb_connection(), m_gc);
+}
+
+void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source)
+{
+ if (m_gc_window != window) {
+ xcb_free_gc(xcb_connection(), m_gc);
+
+ m_gc = xcb_generate_id(xcb_connection());
+ xcb_create_gc(xcb_connection(), m_gc, window, 0, 0);
+
+ m_gc_window = window;
+ }
+
+ xcb_image_shm_put(xcb_connection(),
+ window,
+ m_gc,
+ m_xcb_image,
+ m_shm_info,
+ source.x(),
+ source.y(),
+ target.x(),
+ target.y(),
+ source.width(),
+ source.height(),
+ false);
+
+ m_dirty = m_dirty | source;
+
+ xcb_flush(xcb_connection());
+}
+
+void QXcbShmImage::preparePaint(const QRegion &region)
+{
+ // to prevent X from reading from the image region while we're writing to it
+ if (m_dirty.intersects(region)) {
+ // from xcb_aux_sync
+ free(xcb_get_input_focus_reply(xcb_connection(), xcb_get_input_focus(xcb_connection()), 0));
+ m_dirty = QRegion();
+ }
+}
+
+QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface)
+ : QWindowSurface(widget, setDefaultSurface)
+ , m_image(0)
+{
+ setStaticContentsSupport(false);
+ setPartialUpdateSupport(true);
+
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ setConnection(screen->connection());
+}
+
+QXcbWindowSurface::~QXcbWindowSurface()
+{
+}
+
+QPaintDevice *QXcbWindowSurface::paintDevice()
+{
+ return m_image->image();
+}
+
+void QXcbWindowSurface::beginPaint(const QRegion &region)
+{
+ m_image->preparePaint(region);
+}
+
+void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
+
+ extern QWidgetData* qt_widget_data(QWidget *);
+ QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
+}
+
+void QXcbWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+
+ delete m_image;
+ m_image = new QXcbShmImage(screen, size);
+}
+
+extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
+
+bool QXcbWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ if (m_image->image()->isNull())
+ return false;
+
+ m_image->preparePaint(area);
+
+ const QVector<QRect> rects = area.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ qt_scrollRectInImage(*m_image->image(), rects.at(i), QPoint(dx, dy));
+
+ return true;
+}
+
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h
new file mode 100644
index 0000000..61689b1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXCBWINDOWSURFACE_H
+#define QXCBWINDOWSURFACE_H
+
+#include <private/qwindowsurface_p.h>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbShmImage;
+
+class QXcbWindowSurface : public QXcbObject, public QWindowSurface
+{
+public:
+ QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true);
+ ~QXcbWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+ bool scroll(const QRegion &area, int dx, int dy);
+
+ void beginPaint(const QRegion &);
+
+private:
+ QXcbShmImage *m_image;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
new file mode 100644
index 0000000..fdbe2cd
--- /dev/null
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -0,0 +1,69 @@
+TARGET = xcb
+
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = \
+ qxcbconnection.cpp \
+ qxcbintegration.cpp \
+ qxcbkeyboard.cpp \
+ qxcbscreen.cpp \
+ qxcbwindow.cpp \
+ qxcbwindowsurface.cpp \
+ main.cpp \
+ qxcbnativeinterface.cpp
+
+HEADERS = \
+ qxcbconnection.h \
+ qxcbintegration.h \
+ qxcbkeyboard.h \
+ qxcbobject.h \
+ qxcbscreen.h \
+ qxcbwindow.h \
+ qxcbwindowsurface.h \
+ qxcbnativeinterface.h
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+
+# DEFINES += XCB_USE_DRI2
+ contains(DEFINES, XCB_USE_DRI2) {
+ LIBS += -lxcb-dri2 -lxcb-xfixes -lEGL
+
+ CONFIG += link_pkgconfig
+ PKGCONFIG += libdrm
+
+ HEADERS += qdri2context.h
+ SOURCES += qdri2context.cpp
+
+ } else {
+ DEFINES += XCB_USE_XLIB
+ LIBS += -lX11 -lX11-xcb
+
+ contains(QT_CONFIG, opengles2) {
+ DEFINES += XCB_USE_EGL
+ HEADERS += \
+ ../eglconvenience/qeglplatformcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+ ../eglconvenience/qxlibeglintegration.h
+
+ SOURCES += \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ ../eglconvenience/qxlibeglintegration.cpp
+
+ LIBS += -lEGL
+ } else {
+ DEFINES += XCB_USE_GLX
+ HEADERS += qglxintegration.h
+ SOURCES += qglxintegration.cpp
+ }
+ }
+}
+
+LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm
+
+include (../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/xlib/main.cpp b/src/plugins/platforms/xlib/main.cpp
new file mode 100644
index 0000000..f0bf6ff
--- /dev/null
+++ b/src/plugins/platforms/xlib/main.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qxlibintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXlibIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QXlibIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "Xlib";
+#ifndef QT_NO_OPENGL
+ list << "XlibGL";
+#endif
+ return list;
+}
+
+QPlatformIntegration* QXlibIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "xlib")
+ return new QXlibIntegration;
+#ifndef QT_NO_OPENGL
+ if (system.toLower() == "xlibgl")
+ return new QXlibIntegration(true);
+#endif
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(xlib, QXlibIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp
new file mode 100644
index 0000000..80011d9
--- /dev/null
+++ b/src/plugins/platforms/xlib/qglxintegration.cpp
@@ -0,0 +1,377 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <QLibrary>
+#include <QGLFormat>
+
+#include "qxlibwindow.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
+
+#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+
+#include "qglxintegration.h"
+
+#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
+#include <dlfcn.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive);
+
+QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format)
+{
+ QVector<int> spec(48);
+ int i = 0;
+
+ spec[i++] = GLX_LEVEL;
+ spec[i++] = 0;
+ spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT;
+
+ if (format.rgba()) {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
+ spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
+ spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
+ spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
+ if (format.alpha()) {
+ spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
+ }
+
+ spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+
+ if (format.alpha()) {
+ spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ }
+
+ } else {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
+ spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
+ }
+
+ spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
+ spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
+
+ if (format.depth()) {
+ spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
+ }
+
+ if (format.stencil()) {
+ spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
+ }
+ if (format.sampleBuffers()) {
+ spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
+ spec[i++] = 1;
+ spec[i++] = GLX_SAMPLES_ARB;
+ spec[i++] = format.samples() == -1 ? 4 : format.samples();
+ }
+
+ spec[i++] = XNone;
+ return spec;
+}
+
+GLXFBConfig QGLXContext::findConfig(const QXlibScreen *screen, const QPlatformWindowFormat &format)
+{
+ bool reduced = true;
+ GLXFBConfig chosenConfig = 0;
+ QPlatformWindowFormat reducedFormat = format;
+ while (!chosenConfig && reduced) {
+ QVector<int> spec = buildSpec(reducedFormat);
+ int confcount = 0;
+ GLXFBConfig *configs;
+ configs = glXChooseFBConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),spec.constData(),&confcount);
+ if (confcount)
+ {
+ for (int i = 0; i < confcount; i++) {
+ chosenConfig = configs[i];
+ // Make sure we try to get an ARGB visual if the format asked for an alpha:
+ if (reducedFormat.alpha()) {
+ int alphaSize;
+ glXGetFBConfigAttrib(screen->display()->nativeDisplay(),configs[i],GLX_ALPHA_SIZE,&alphaSize);
+ if (alphaSize > 0)
+ break;
+ } else {
+ break; // Just choose the first in the list if there's no alpha requested
+ }
+ }
+
+ XFree(configs);
+ }
+ reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced);
+ }
+
+ if (!chosenConfig)
+ qWarning("Warning no context created");
+
+ return chosenConfig;
+}
+
+XVisualInfo *QGLXContext::findVisualInfo(const QXlibScreen *screen, const QPlatformWindowFormat &format)
+{
+ GLXFBConfig config = QGLXContext::findConfig(screen,format);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config);
+ return visualInfo;
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
+{
+ QPlatformWindowFormat format;
+ int redSize = 0;
+ int greenSize = 0;
+ int blueSize = 0;
+ int alphaSize = 0;
+ int depthSize = 0;
+ int stencilSize = 0;
+ int sampleBuffers = 0;
+ int sampleCount = 0;
+ int level = 0;
+ int rgba = 0;
+ int stereo = 0;
+ int accumSizeA = 0;
+ int accumSizeR = 0;
+ int accumSizeG = 0;
+ int accumSizeB = 0;
+
+ XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
+ glXGetConfig(display,vi,GLX_RGBA,&rgba);
+ XFree(vi);
+ glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
+ glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
+ glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize);
+ glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize);
+ glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
+ glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
+ glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
+ glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSampleBuffers(sampleBuffers);
+ if (format.sampleBuffers()) {
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
+ format.setSamples(sampleCount);
+ }
+
+ format.setDirectRendering(glXIsDirect(display, ctx));
+ format.setRgba(rgba);
+ format.setStereo(stereo);
+ format.setAccumBufferSize(accumSizeB);
+
+ return format;
+}
+
+QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
+{
+ QPlatformWindowFormat retFormat = format;
+ *reduced = true;
+
+ if (retFormat.sampleBuffers()) {
+ retFormat.setSampleBuffers(false);
+ } else if (retFormat.stereo()) {
+ retFormat.setStereo(false);
+ } else if (retFormat.accum()) {
+ retFormat.setAccum(false);
+ }else if (retFormat.stencil()) {
+ retFormat.setStencil(false);
+ }else if (retFormat.alpha()) {
+ retFormat.setAlpha(false);
+ }else if (retFormat.depth()) {
+ retFormat.setDepth(false);
+ }else if (retFormat.doubleBuffer()) {
+ retFormat.setDoubleBuffer(false);
+ }else{
+ *reduced = false;
+ }
+ return retFormat;
+}
+
+QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format)
+ : QPlatformGLContext()
+ , m_screen(screen)
+ , m_drawable((Drawable)window)
+ , m_context(0)
+{
+
+ const QPlatformGLContext *sharePlatformContext;
+ if (format.useDefaultSharedContext()) {
+ if (!QPlatformGLContext::defaultSharedContext()) {
+ if (m_defaultSharedContextMutex.tryLock()){
+ createDefaultSharedContex(screen);
+ m_defaultSharedContextMutex.unlock();
+ } else {
+ m_defaultSharedContextMutex.lock(); //wait to the the shared context is created
+ m_defaultSharedContextMutex.unlock();
+ }
+ }
+ sharePlatformContext = QPlatformGLContext::defaultSharedContext();
+ } else {
+ sharePlatformContext = format.sharedGLContext();
+ }
+ GLXContext shareGlxContext = 0;
+ if (sharePlatformContext)
+ shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
+
+ GLXFBConfig config = findConfig(screen,format);
+ m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
+ m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context);
+
+#ifdef MYX11_DEBUG
+ qDebug() << "QGLXGLContext::create context" << m_context;
+#endif
+}
+
+QGLXContext::QGLXContext(QXlibScreen *screen, Drawable drawable, GLXContext context)
+ : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
+{
+
+}
+
+QGLXContext::~QGLXContext()
+{
+ if (m_context) {
+ qDebug("Destroying GLX context 0x%p", m_context);
+ glXDestroyContext(m_screen->display()->nativeDisplay(), m_context);
+ }
+}
+
+void QGLXContext::createDefaultSharedContex(QXlibScreen *screen)
+{
+ int x = 0;
+ int y = 0;
+ int w = 3;
+ int h = 3;
+
+ QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat();
+ GLXContext context;
+ GLXFBConfig config = findConfig(screen,format);
+ if (config) {
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config);
+ Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone);
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ Window sharedWindow = XCreateWindow(screen->display()->nativeDisplay(), screen->rootWindow(),x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,0,TRUE);
+ QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context);
+ QPlatformGLContext::setDefaultSharedContext(sharedContext);
+ } else {
+ qWarning("Warning no shared context created");
+ }
+}
+
+void QGLXContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+#ifdef MYX11_DEBUG
+ qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context);
+#endif
+ glXMakeCurrent(m_screen->display()->nativeDisplay(), m_drawable, m_context);
+}
+
+void QGLXContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ glXMakeCurrent(m_screen->display()->nativeDisplay(), 0, 0);
+}
+
+void QGLXContext::swapBuffers()
+{
+ glXSwapBuffers(m_screen->display()->nativeDisplay(), m_drawable);
+}
+
+void* QGLXContext::getProcAddress(const QString& procName)
+{
+ typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
+ static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
+ static bool resolved = false;
+
+ if (resolved && !glXGetProcAddressARB)
+ return 0;
+ if (!glXGetProcAddressARB) {
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_screen->display()->nativeDisplay(), GLX_EXTENSIONS)).split(' ');
+ if (glxExt.contains("GLX_ARB_get_proc_address")) {
+#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
+ void *handle = dlopen(NULL, RTLD_LAZY);
+ if (handle) {
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB");
+ dlclose(handle);
+ }
+ if (!glXGetProcAddressARB)
+#endif
+ {
+ extern const QString qt_gl_library_name();
+// QLibrary lib(qt_gl_library_name());
+ QLibrary lib(QLatin1String("GL"));
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ }
+ }
+ resolved = true;
+ }
+ if (!glXGetProcAddressARB)
+ return 0;
+ return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFormat() const
+{
+ return m_windowFormat;
+}
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h
new file mode 100644
index 0000000..dbb5c2e
--- /dev/null
+++ b/src/plugins/platforms/xlib/qglxintegration.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef Q_GLX_CONTEXT_H
+#define Q_GLX_CONTEXT_H
+
+#include "qxlibwindow.h"
+
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <QtCore/QMutex>
+
+#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
+#include <GL/glx.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGLXContext : public QPlatformGLContext
+{
+public:
+ QGLXContext(Window window, QXlibScreen *xd, const QPlatformWindowFormat &format);
+ ~QGLXContext();
+
+ virtual void makeCurrent();
+ virtual void doneCurrent();
+ virtual void swapBuffers();
+ virtual void* getProcAddress(const QString& procName);
+
+ GLXContext glxContext() const {return m_context;}
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ static XVisualInfo *findVisualInfo(const QXlibScreen *xd, const QPlatformWindowFormat &format);
+private:
+ static GLXFBConfig findConfig(const QXlibScreen *xd,const QPlatformWindowFormat &format);
+ static QVector<int> buildSpec(const QPlatformWindowFormat &format);
+ static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
+ static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced);
+
+
+ QXlibScreen *m_screen;
+ Drawable m_drawable;
+ GLXContext m_context;
+ QPlatformWindowFormat m_windowFormat;
+
+ QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context);
+ static QMutex m_defaultSharedContextMutex;
+ static void createDefaultSharedContex(QXlibScreen *xd);
+};
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
+
+#endif
diff --git a/src/plugins/platforms/xlib/qxlibclipboard.cpp b/src/plugins/platforms/xlib/qxlibclipboard.cpp
new file mode 100644
index 0000000..dfaf552
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibclipboard.cpp
@@ -0,0 +1,677 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibclipboard.h"
+
+#include "qxlibscreen.h"
+#include "qxlibmime.h"
+#include "qxlibdisplay.h"
+
+#include <private/qapplication_p.h>
+
+#include <QtCore/QDebug>
+
+class QXlibClipboardMime : public QXlibMime
+{
+ Q_OBJECT
+public:
+ QXlibClipboardMime(QClipboard::Mode mode, QXlibClipboard *clipboard)
+ : QXlibMime()
+ , m_clipboard(clipboard)
+ {
+ switch (mode) {
+ case QClipboard::Selection:
+ modeAtom = XA_PRIMARY;
+ break;
+
+ case QClipboard::Clipboard:
+ modeAtom = QXlibStatic::atom(QXlibStatic::CLIPBOARD);
+ break;
+
+ default:
+ qWarning("QTestLiteMime: Internal error: Unsupported clipboard mode");
+ break;
+ }
+ }
+
+protected:
+ QStringList formats_sys() const
+ {
+ if (empty())
+ return QStringList();
+
+ if (!formatList.count()) {
+ QXlibClipboardMime *that = const_cast<QXlibClipboardMime *>(this);
+ // get the list of targets from the current clipboard owner - we do this
+ // once so that multiple calls to this function don't require multiple
+ // server round trips...
+ that->format_atoms = m_clipboard->getDataInFormat(modeAtom,QXlibStatic::atom(QXlibStatic::TARGETS));
+
+ if (format_atoms.size() > 0) {
+ Atom *targets = (Atom *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(Atom);
+
+ for (int i = 0; i < size; ++i) {
+ if (targets[i] == 0)
+ continue;
+
+ QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display()->nativeDisplay(),targets[i]);
+ for (int j = 0; j < formatsForAtom.size(); ++j) {
+ if (!formatList.contains(formatsForAtom.at(j)))
+ that->formatList.append(formatsForAtom.at(j));
+ }
+ }
+ }
+ }
+
+ return formatList;
+ }
+
+ bool hasFormat_sys(const QString &format) const
+ {
+ QStringList list = formats();
+ return list.contains(format);
+ }
+
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
+ {
+ if (fmt.isEmpty() || empty())
+ return QByteArray();
+
+ (void)formats(); // trigger update of format list
+
+ QList<Atom> atoms;
+ Atom *targets = (Atom *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(Atom);
+ for (int i = 0; i < size; ++i)
+ atoms.append(targets[i]);
+
+ QByteArray encoding;
+ Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display()->nativeDisplay(),fmt, requestedType, atoms, &encoding);
+
+ if (fmtatom == 0)
+ return QVariant();
+
+ return mimeConvertToFormat(m_clipboard->screen()->display()->nativeDisplay(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
+ }
+private:
+ bool empty() const
+ {
+ Window win = XGetSelectionOwner(m_clipboard->screen()->display()->nativeDisplay(), modeAtom);
+
+ return win == XNone;
+ }
+
+
+ Atom modeAtom;
+ QXlibClipboard *m_clipboard;
+ QStringList formatList;
+ QByteArray format_atoms;
+};
+
+const int QXlibClipboard::clipboard_timeout = 5000;
+
+QXlibClipboard::QXlibClipboard(QXlibScreen *screen)
+ : QPlatformClipboard()
+ , m_screen(screen)
+ , m_xClipboard(0)
+ , m_clientClipboard(0)
+ , m_xSelection(0)
+ , m_clientSelection(0)
+ , m_requestor(XNone)
+ , m_owner(XNone)
+{
+}
+
+const QMimeData * QXlibClipboard::mimeData(QClipboard::Mode mode) const
+{
+ if (mode == QClipboard::Clipboard) {
+ if (!m_xClipboard) {
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ that->m_xClipboard = new QXlibClipboardMime(mode,that);
+ }
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),QXlibStatic::atom(QXlibStatic::CLIPBOARD));
+ if (clipboardOwner == owner()) {
+ return m_clientClipboard;
+ } else {
+ return m_xClipboard;
+ }
+ } else if (mode == QClipboard::Selection) {
+ if (!m_xSelection) {
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ that->m_xSelection = new QXlibClipboardMime(mode,that);
+ }
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),XA_PRIMARY);
+ if (clipboardOwner == owner()) {
+ return m_clientSelection;
+ } else {
+ return m_xSelection;
+ }
+ }
+ return 0;
+}
+
+void QXlibClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ Atom modeAtom;
+ QMimeData **d;
+ switch (mode) {
+ case QClipboard::Selection:
+ modeAtom = XA_PRIMARY;
+ d = &m_clientSelection;
+ break;
+
+ case QClipboard::Clipboard:
+ modeAtom = QXlibStatic::atom(QXlibStatic::CLIPBOARD);
+ d = &m_clientClipboard;
+ break;
+
+ default:
+ qWarning("QClipboard::setMimeData: unsupported mode '%d'", mode);
+ return;
+ }
+
+ Window newOwner;
+
+ if (! data) { // no data, clear clipboard contents
+ newOwner = XNone;
+ } else {
+ newOwner = owner();
+
+ *d = data;
+ }
+
+ XSetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom, newOwner, CurrentTime);
+
+ if (XGetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom) != newOwner) {
+ qWarning("QClipboard::setData: Cannot set X11 selection owner");
+ }
+
+}
+
+bool QXlibClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ if (mode == QClipboard::Clipboard || mode == QClipboard::Selection)
+ return true;
+ return false;
+}
+
+
+QXlibScreen * QXlibClipboard::screen() const
+{
+ return m_screen;
+}
+
+Window QXlibClipboard::requestor() const
+{
+ if (!m_requestor) {
+ int x = 0, y = 0, w = 3, h = 3;
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ m_screen->blackPixel(), m_screen->whitePixel());
+ that->setRequestor(window);
+ }
+ return m_requestor;
+}
+
+void QXlibClipboard::setRequestor(Window window)
+{
+ if (m_requestor != XNone) {
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_requestor);
+ }
+ m_requestor = window;
+}
+
+Window QXlibClipboard::owner() const
+{
+ if (!m_owner) {
+ int x = 0, y = 0, w = 3, h = 3;
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ m_screen->blackPixel(), m_screen->whitePixel());
+ that->setOwner(window);
+ }
+ return m_owner;
+}
+
+void QXlibClipboard::setOwner(Window window)
+{
+ if (m_owner != XNone){
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_owner);
+ }
+ m_owner = window;
+}
+
+Atom QXlibClipboard::sendTargetsSelection(QMimeData *d, Window window, Atom property)
+{
+ QVector<Atom> types;
+ QStringList formats = QInternalMimeData::formatsHelper(d);
+ for (int i = 0; i < formats.size(); ++i) {
+ QList<Atom> atoms = QXlibMime::mimeAtomsForFormat(screen()->display()->nativeDisplay(),formats.at(i));
+ for (int j = 0; j < atoms.size(); ++j) {
+ if (!types.contains(atoms.at(j)))
+ types.append(atoms.at(j));
+ }
+ }
+ types.append(QXlibStatic::atom(QXlibStatic::TARGETS));
+ types.append(QXlibStatic::atom(QXlibStatic::MULTIPLE));
+ types.append(QXlibStatic::atom(QXlibStatic::TIMESTAMP));
+ types.append(QXlibStatic::atom(QXlibStatic::SAVE_TARGETS));
+
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property, XA_ATOM, 32,
+ PropModeReplace, (uchar *) types.data(), types.size());
+ return property;
+}
+
+Atom QXlibClipboard::sendSelection(QMimeData *d, Atom target, Window window, Atom property)
+{
+ Atom atomFormat = target;
+ int dataFormat = 0;
+ QByteArray data;
+
+ QString fmt = QXlibMime::mimeAtomToString(screen()->display()->nativeDisplay(), target);
+ if (fmt.isEmpty()) { // Not a MIME type we have
+ qDebug() << "QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.data();
+ return XNone;
+ }
+ qDebug() << "QClipboard: send_selection(): converting to type '%s'" << fmt.data();
+
+ if (QXlibMime::mimeDataForAtom(screen()->display()->nativeDisplay(),target, d, &data, &atomFormat, &dataFormat)) {
+
+ // don't allow INCR transfers when using MULTIPLE or to
+ // Motif clients (since Motif doesn't support INCR)
+ static Atom motif_clip_temporary = QXlibStatic::atom(QXlibStatic::CLIP_TEMPORARY);
+ bool allow_incr = property != motif_clip_temporary;
+
+ // X_ChangeProperty protocol request is 24 bytes
+ const int increment = (XMaxRequestSize(screen()->display()->nativeDisplay()) * 4) - 24;
+ if (data.size() > increment && allow_incr) {
+ long bytes = data.size();
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property,
+ QXlibStatic::atom(QXlibStatic::INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
+
+// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
+ qDebug() << "not implemented INCRT just YET!";
+ return property;
+ }
+
+ // make sure we can perform the XChangeProperty in a single request
+ if (data.size() > increment)
+ return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
+ int dataSize = data.size() / (dataFormat / 8);
+ // use a single request to transfer data
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property, atomFormat,
+ dataFormat, PropModeReplace, (uchar *) data.data(),
+ dataSize);
+ }
+ return property;
+}
+
+void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
+{
+ XSelectionRequestEvent *req = &xevent->xselectionrequest;
+
+ if (requestor() && req->requestor == requestor()) {
+ qDebug() << "This should be caught before";
+ return;
+ }
+
+ XEvent event;
+ event.xselection.type = SelectionNotify;
+ event.xselection.display = req->display;
+ event.xselection.requestor = req->requestor;
+ event.xselection.selection = req->selection;
+ event.xselection.target = req->target;
+ event.xselection.property = XNone;
+ event.xselection.time = req->time;
+
+ QMimeData *d;
+ if (req->selection == XA_PRIMARY) {
+ d = m_clientSelection;
+ } else if (req->selection == QXlibStatic::atom(QXlibStatic::CLIPBOARD)) {
+ d = m_clientClipboard;
+ } else {
+ qWarning("QClipboard: Unknown selection '%lx'", req->selection);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+
+ if (!d) {
+ qWarning("QClipboard: Cannot transfer data, no data available");
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+
+ Atom xa_targets = QXlibStatic::atom(QXlibStatic::TARGETS);
+ Atom xa_multiple = QXlibStatic::atom(QXlibStatic::MULTIPLE);
+ Atom xa_timestamp = QXlibStatic::atom(QXlibStatic::TIMESTAMP);
+
+ struct AtomPair { Atom target; Atom property; } *multi = 0;
+ Atom multi_type = XNone;
+ int multi_format = 0;
+ int nmulti = 0;
+ int imulti = -1;
+ bool multi_writeback = false;
+
+ if (req->target == xa_multiple) {
+ QByteArray multi_data;
+ if (req->property == XNone
+ || !clipboardReadProperty(req->requestor, req->property, false, &multi_data,
+ 0, &multi_type, &multi_format)
+ || multi_format != 32) {
+ // MULTIPLE property not formatted correctly
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+ nmulti = multi_data.size()/sizeof(*multi);
+ multi = new AtomPair[nmulti];
+ memcpy(multi,multi_data.data(),multi_data.size());
+ imulti = 0;
+ }
+
+ for (; imulti < nmulti; ++imulti) {
+ Atom target;
+ Atom property;
+
+ if (multi) {
+ target = multi[imulti].target;
+ property = multi[imulti].property;
+ } else {
+ target = req->target;
+ property = req->property;
+ if (property == XNone) // obsolete client
+ property = target;
+ }
+
+ Atom ret = XNone;
+ if (target == XNone || property == XNone) {
+ ;
+ } else if (target == xa_timestamp) {
+// if (d->timestamp != CurrentTime) {
+// XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, property, XA_INTEGER, 32,
+// PropModeReplace, CurrentTime, 1);
+// ret = property;
+// } else {
+// qWarning("QClipboard: Invalid data timestamp");
+// }
+ } else if (target == xa_targets) {
+ ret = sendTargetsSelection(d, req->requestor, property);
+ } else {
+ ret = sendSelection(d, target, req->requestor, property);
+ }
+
+ if (nmulti > 0) {
+ if (ret == XNone) {
+ multi[imulti].property = XNone;
+ multi_writeback = true;
+ }
+ } else {
+ event.xselection.property = ret;
+ break;
+ }
+ }
+
+ if (nmulti > 0) {
+ if (multi_writeback) {
+ // according to ICCCM 2.6.2 says to put None back
+ // into the original property on the requestor window
+ XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, req->property, multi_type, 32,
+ PropModeReplace, (uchar *) multi, nmulti * 2);
+ }
+
+ delete [] multi;
+ event.xselection.property = req->property;
+ }
+
+ // send selection notify to requestor
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
+}
+
+static inline int maxSelectionIncr(Display *dpy)
+{ return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; }
+
+bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
+{
+ int maxsize = maxSelectionIncr(screen()->display()->nativeDisplay());
+ ulong bytes_left; // bytes_after
+ ulong length; // nitems
+ uchar *data;
+ Atom dummy_type;
+ int dummy_format;
+ int r;
+
+ if (!type) // allow null args
+ type = &dummy_type;
+ if (!format)
+ format = &dummy_format;
+
+ // Don't read anything, just get the size of the property data
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, 0, 0, False,
+ AnyPropertyType, type, format,
+ &length, &bytes_left, &data);
+ if (r != Success || (type && *type == XNone)) {
+ buffer->resize(0);
+ return false;
+ }
+ XFree((char*)data);
+
+ int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left;
+
+ switch (*format) {
+ case 8:
+ default:
+ format_inc = sizeof(char) / 1;
+ break;
+
+ case 16:
+ format_inc = sizeof(short) / 2;
+ proplen *= sizeof(short) / 2;
+ break;
+
+ case 32:
+ format_inc = sizeof(long) / 4;
+ proplen *= sizeof(long) / 4;
+ break;
+ }
+
+ int newSize = proplen;
+ buffer->resize(newSize);
+
+ bool ok = (buffer->size() == newSize);
+
+ if (ok && newSize) {
+ // could allocate buffer
+
+ while (bytes_left) {
+ // more to read...
+
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, offset, maxsize/4,
+ False, AnyPropertyType, type, format,
+ &length, &bytes_left, &data);
+ if (r != Success || (type && *type == XNone))
+ break;
+
+ offset += length / (32 / *format);
+ length *= format_inc * (*format) / 8;
+
+ // Here we check if we get a buffer overflow and tries to
+ // recover -- this shouldn't normally happen, but it doesn't
+ // hurt to be defensive
+ if ((int)(buffer_offset + length) > buffer->size()) {
+ length = buffer->size() - buffer_offset;
+
+ // escape loop
+ bytes_left = 0;
+ }
+
+ memcpy(buffer->data() + buffer_offset, data, length);
+ buffer_offset += length;
+
+ XFree((char*)data);
+ }
+
+ if (*format == 8 && *type == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)) {
+ // convert COMPOUND_TEXT to a multibyte string
+ XTextProperty textprop;
+ textprop.encoding = *type;
+ textprop.format = *format;
+ textprop.nitems = buffer_offset;
+ textprop.value = (unsigned char *) buffer->data();
+
+ char **list_ret = 0;
+ int count;
+ if (XmbTextPropertyToTextList(screen()->display()->nativeDisplay(), &textprop, &list_ret,
+ &count) == Success && count && list_ret) {
+ offset = buffer_offset = strlen(list_ret[0]);
+ buffer->resize(offset);
+ memcpy(buffer->data(), list_ret[0], offset);
+ }
+ if (list_ret) XFreeStringList(list_ret);
+ }
+ }
+
+ // correct size, not 0-term.
+ if (size)
+ *size = buffer_offset;
+
+ if (deleteProperty)
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, property);
+
+ screen()->display()->flush();
+
+ return ok;
+}
+
+QByteArray QXlibClipboard::clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
+{
+ XEvent event;
+
+ QByteArray buf;
+ QByteArray tmp_buf;
+ bool alloc_error = false;
+ int length;
+ int offset = 0;
+
+ if (nbytes > 0) {
+ // Reserve buffer + zero-terminator (for text data)
+ // We want to complete the INCR transfer even if we cannot
+ // allocate more memory
+ buf.resize(nbytes+1);
+ alloc_error = buf.size() != nbytes+1;
+ }
+
+ for (;;) {
+ screen()->display()->flush();
+ if (!screen()->waitForClipboardEvent(win,PropertyNotify,&event,clipboard_timeout))
+ break;
+ if (event.xproperty.atom != property ||
+ event.xproperty.state != PropertyNewValue)
+ continue;
+ if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
+ if (length == 0) { // no more data, we're done
+ if (nullterm) {
+ buf.resize(offset+1);
+ buf[offset] = '\0';
+ } else {
+ buf.resize(offset);
+ }
+ return buf;
+ } else if (!alloc_error) {
+ if (offset+length > (int)buf.size()) {
+ buf.resize(offset+length+65535);
+ if (buf.size() != offset+length+65535) {
+ alloc_error = true;
+ length = buf.size() - offset;
+ }
+ }
+ memcpy(buf.data()+offset, tmp_buf.constData(), length);
+ tmp_buf.resize(0);
+ offset += length;
+ }
+ } else {
+ break;
+ }
+ }
+
+ // timed out ... create a new requestor window, otherwise the requestor
+ // could consider next request to be still part of this timed out request
+ setRequestor(0);
+
+ return QByteArray();
+}
+
+QByteArray QXlibClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
+{
+ QByteArray buf;
+
+ Window win = requestor();
+
+ XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask); // don't listen for any events
+
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION));
+ XConvertSelection(screen()->display()->nativeDisplay(), modeAtom, fmtatom, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), win, CurrentTime);
+ screen()->display()->sync();
+
+ XEvent xevent;
+ if (!screen()->waitForClipboardEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
+ xevent.xselection.property == XNone) {
+ return buf;
+ }
+
+ Atom type;
+ XSelectInput(screen()->display()->nativeDisplay(), win, PropertyChangeMask);
+
+ if (clipboardReadProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
+ if (type == QXlibStatic::atom(QXlibStatic::INCR)) {
+ int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
+ buf = clipboardReadIncrementalProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), nbytes, false);
+ }
+ }
+
+ XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask);
+
+
+ return buf;
+}
+
+#include "qxlibclipboard.moc"
diff --git a/src/plugins/platforms/xlib/qxlibclipboard.h b/src/plugins/platforms/xlib/qxlibclipboard.h
new file mode 100644
index 0000000..15901b0
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibclipboard.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITECLIPBOARD_H
+#define QTESTLITECLIPBOARD_H
+
+#include <QPlatformClipboard>
+#include "qxlibstatic.h"
+
+class QXlibScreen;
+class QXlibClipboard : public QPlatformClipboard
+{
+public:
+ QXlibClipboard(QXlibScreen *screen);
+
+ const QMimeData *mimeData(QClipboard::Mode mode) const;
+ void setMimeData(QMimeData *data, QClipboard::Mode mode);
+
+ bool supportsMode(QClipboard::Mode mode) const;
+
+ QXlibScreen *screen() const;
+
+ Window requestor() const;
+ void setRequestor(Window window);
+
+ Window owner() const;
+
+ void handleSelectionRequest(XEvent *event);
+
+ bool clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const;
+ QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm);
+
+ QByteArray getDataInFormat(Atom modeAtom, Atom fmtatom);
+
+private:
+ void setOwner(Window window);
+
+ Atom sendTargetsSelection(QMimeData *d, Window window, Atom property);
+ Atom sendSelection(QMimeData *d, Atom target, Window window, Atom property);
+
+ QXlibScreen *m_screen;
+
+ QMimeData *m_xClipboard;
+ QMimeData *m_clientClipboard;
+
+ QMimeData *m_xSelection;
+ QMimeData *m_clientSelection;
+
+ Window m_requestor;
+ Window m_owner;
+
+ static const int clipboard_timeout;
+
+};
+
+#endif // QTESTLITECLIPBOARD_H
diff --git a/src/plugins/platforms/xlib/qxlibcursor.cpp b/src/plugins/platforms/xlib/qxlibcursor.cpp
new file mode 100644
index 0000000..042cbc9
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibcursor.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibcursor.h"
+
+#include "qxlibintegration.h"
+#include "qxlibscreen.h"
+#include "qxlibwindow.h"
+#include "qxlibdisplay.h"
+
+#include <QtGui/QBitmap>
+
+#include <X11/cursorfont.h>
+
+QT_BEGIN_NAMESPACE
+
+QXlibCursor::QXlibCursor(QXlibScreen *screen)
+ : QPlatformCursor(screen)
+{
+}
+
+void QXlibCursor::changeCursor(QCursor *cursor, QWidget *widget)
+{
+ QXlibWindow *w = 0;
+ if (widget) {
+ QWidget *window = widget->window();
+ w = static_cast<QXlibWindow*>(window->platformWindow());
+ } else {
+ // No X11 cursor control when there is no widget under the cursor
+ return;
+ }
+
+ if (!w)
+ return;
+
+ int id = cursor->handle();
+
+ Cursor c;
+ if (!cursorMap.contains(id)) {
+ if (cursor->shape() == Qt::BitmapCursor)
+ c = createCursorBitmap(cursor);
+ else
+ c = createCursorShape(cursor->shape());
+ if (!c) {
+ return;
+ }
+ cursorMap.insert(id, c);
+ } else {
+ c = cursorMap.value(id);
+ }
+
+ w->setCursor(c);
+}
+
+Cursor QXlibCursor::createCursorBitmap(QCursor * cursor)
+{
+ XColor bg, fg;
+ bg.red = 255 << 8;
+ bg.green = 255 << 8;
+ bg.blue = 255 << 8;
+ fg.red = 0;
+ fg.green = 0;
+ fg.blue = 0;
+ QPoint spot = cursor->hotSpot();
+ Window rootwin = testLiteScreen()->rootWindow();
+
+ QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB);
+ QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB);
+
+ int width = cursor->bitmap()->width();
+ int height = cursor->bitmap()->height();
+ int bytesPerLine = mapImage.bytesPerLine();
+ int destLineSize = width / 8;
+ if (width % 8)
+ destLineSize++;
+
+ const uchar * map = mapImage.bits();
+ const uchar * mask = maskImage.bits();
+
+ char * mapBits = new char[height * destLineSize];
+ char * maskBits = new char[height * destLineSize];
+ for (int i = 0; i < height; i++) {
+ memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize);
+ memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize);
+ }
+
+ Pixmap cp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, mapBits, width, height);
+ Pixmap mp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, maskBits, width, height);
+ Cursor c = XCreatePixmapCursor(testLiteScreen()->display()->nativeDisplay(), cp, mp, &fg, &bg, spot.x(), spot.y());
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), cp);
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), mp);
+ delete[] mapBits;
+ delete[] maskBits;
+
+ return c;
+}
+
+Cursor QXlibCursor::createCursorShape(int cshape)
+{
+ Cursor cursor = 0;
+
+ if (cshape < 0 || cshape > Qt::LastCursor)
+ return 0;
+
+ switch (cshape) {
+ case Qt::ArrowCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_left_ptr);
+ break;
+ case Qt::UpArrowCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_center_ptr);
+ break;
+ case Qt::CrossCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_crosshair);
+ break;
+ case Qt::WaitCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
+ break;
+ case Qt::IBeamCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_xterm);
+ break;
+ case Qt::SizeAllCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_fleur);
+ break;
+ case Qt::PointingHandCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_hand2);
+ break;
+ case Qt::SizeBDiagCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_top_right_corner);
+ break;
+ case Qt::SizeFDiagCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_bottom_right_corner);
+ break;
+ case Qt::SizeVerCursor:
+ case Qt::SplitVCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_v_double_arrow);
+ break;
+ case Qt::SizeHorCursor:
+ case Qt::SplitHCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_h_double_arrow);
+ break;
+ case Qt::WhatsThisCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_question_arrow);
+ break;
+ case Qt::ForbiddenCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_circle);
+ break;
+ case Qt::BusyCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
+ break;
+
+ default: //default cursor for all the rest
+ break;
+ }
+ return cursor;
+}
+
+QXlibScreen * QXlibCursor::testLiteScreen() const
+{
+ return static_cast<QXlibScreen *>(screen);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibcursor.h b/src/plugins/platforms/xlib/qxlibcursor.h
new file mode 100644
index 0000000..62b13eb
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibcursor.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITECURSOR_H
+#define QTESTLITECURSOR_H
+
+#include <QtGui/QPlatformCursor>
+
+#include "qxlibintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXlibCursor : QPlatformCursor
+{
+public:
+ QXlibCursor(QXlibScreen *screen);
+
+ void changeCursor(QCursor * cursor, QWidget * widget);
+private:
+
+ Cursor createCursorBitmap(QCursor * cursor);
+ Cursor createCursorShape(int cshape);
+
+ QXlibScreen *testLiteScreen() const;
+ QMap<int, Cursor> cursorMap;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTESTLITECURSOR_H
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.cpp b/src/plugins/platforms/xlib/qxlibdisplay.cpp
new file mode 100644
index 0000000..d8aa230
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibdisplay.h"
+
+QXlibDisplay::QXlibDisplay(Display *display)
+ : mDisplay(display)
+{
+ if (!mDisplay) {
+ qFatal("Cannot connect to X server");
+ }
+ mDisplayName = QString::fromLocal8Bit(DisplayString(mDisplay));
+}
+
+QXlibDisplay::~QXlibDisplay()
+{
+ XCloseDisplay(mDisplay);
+}
+
+QString QXlibDisplay::displayName() const
+{
+ { return mDisplayName; }
+}
+
+
+
+Display * QXlibDisplay::nativeDisplay() const
+{
+ return mDisplay;
+}
+
+void QXlibDisplay::sync() const
+{
+ XSync(mDisplay, False);
+}
+
+void QXlibDisplay::flush() const
+{
+ XFlush(mDisplay);
+}
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.h b/src/plugins/platforms/xlib/qxlibdisplay.h
new file mode 100644
index 0000000..557ab52
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QXLIBDISPLAY_H
+#define QXLIBDISPLAY_H
+
+#include "qxlibintegration.h"
+
+class QXlibDisplay
+{
+public:
+ QXlibDisplay(Display *display);
+ ~QXlibDisplay();
+ QString displayName() const;
+
+ Display *nativeDisplay() const;
+
+ void sync() const;
+ void flush() const;
+private:
+ Display *mDisplay;
+ QString mDisplayName;
+};
+
+#endif // QXLIBDISPLAY_H
diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp
new file mode 100644
index 0000000..6733ed1
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibintegration.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibintegration.h"
+#include "qxlibwindowsurface.h"
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtCore/qdebug.h>
+
+#include "qxlibwindow.h"
+#include "qgenericunixfontdatabase.h"
+#include "qxlibscreen.h"
+#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
+
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+#include <GL/glx.h>
+#else
+#include <EGL/egl.h>
+#endif //!defined(QT_OPENGL_ES_2)
+#include <private/qwindowsurface_gl_p.h>
+#include <private/qpixmapdata_gl_p.h>
+#endif //QT_NO_OPENGL
+
+QT_BEGIN_NAMESPACE
+
+QXlibIntegration::QXlibIntegration(bool useOpenGL)
+ : mUseOpenGL(useOpenGL)
+ , mFontDb(new QGenericUnixFontDatabase())
+ , mClipboard(0)
+{
+ mPrimaryScreen = new QXlibScreen();
+ mScreens.append(mPrimaryScreen);
+}
+
+QPixmapData *QXlibIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+#ifndef QT_NO_OPENGL
+ if (mUseOpenGL)
+ return new QGLPixmapData(type);
+#endif
+ return new QRasterPixmapData(type);
+}
+
+QWindowSurface *QXlibIntegration::createWindowSurface(QWidget *widget, WId) const
+{
+#ifndef QT_NO_OPENGL
+ if (mUseOpenGL)
+ return new QGLWindowSurface(widget);
+#endif
+ return new QXlibWindowSurface(widget);
+}
+
+
+QPlatformWindow *QXlibIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
+{
+ return new QXlibWindow(widget);
+}
+
+
+
+QPixmap QXlibIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ QImage image;
+ QWidget *widget = QWidget::find(window);
+ if (widget) {
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
+ image = screen->grabWindow(window,x,y,width,height);
+ } else {
+ for (int i = 0; i < mScreens.size(); i++) {
+ QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens[i]);
+ if (screen->rootWindow() == window) {
+ image = screen->grabWindow(window,x,y,width,height);
+ }
+ }
+ }
+ return QPixmap::fromImage(image);
+}
+
+QPlatformFontDatabase *QXlibIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QPlatformClipboard * QXlibIntegration::clipboard() const
+{
+ //Use lazy init since clipboard needs QTestliteScreen
+ if (!mClipboard) {
+ QXlibIntegration *that = const_cast<QXlibIntegration *>(this);
+ that->mClipboard = new QXlibClipboard(mPrimaryScreen);
+ }
+ return mClipboard;
+}
+
+bool QXlibIntegration::hasOpenGL() const
+{
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
+ return glXQueryExtension(screen->display()->nativeDisplay(), 0, 0) != 0;
+#else
+ static bool eglHasbeenInitialized = false;
+ static bool wasEglInitialized = false;
+ if (!eglHasbeenInitialized) {
+ eglHasbeenInitialized = true;
+ const QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
+ EGLint major, minor;
+ eglBindAPI(EGL_OPENGL_ES_API);
+ EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay());
+ wasEglInitialized = eglInitialize(disp,&major,&minor);
+ }
+ return wasEglInitialized;
+#endif
+#endif
+ return false;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h
new file mode 100644
index 0000000..3bbf897
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibintegration.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSYSTEM_TESTLITE_H
+#define QGRAPHICSSYSTEM_TESTLITE_H
+
+//make sure textstream is included before any X11 headers
+#include <QtCore/QTextStream>
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+#include "qxlibstatic.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXlibScreen;
+
+class QXlibIntegration : public QPlatformIntegration
+{
+public:
+ QXlibIntegration(bool useOpenGL = false);
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QPlatformFontDatabase *fontDatabase() const;
+ QPlatformClipboard *clipboard() const;
+
+ bool hasOpenGL() const;
+
+private:
+ bool mUseOpenGL;
+ QXlibScreen *mPrimaryScreen;
+ QList<QPlatformScreen *> mScreens;
+ QPlatformFontDatabase *mFontDb;
+ QPlatformClipboard *mClipboard;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/xlib/qxlibkeyboard.cpp b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
new file mode 100644
index 0000000..8d94157
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
@@ -0,0 +1,1001 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibkeyboard.h"
+
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <QtCore/QTextCodec>
+
+#ifndef XK_ISO_Left_Tab
+#define XK_ISO_Left_Tab 0xFE20
+#endif
+
+#ifndef XK_dead_hook
+#define XK_dead_hook 0xFE61
+#endif
+
+#ifndef XK_dead_horn
+#define XK_dead_horn 0xFE62
+#endif
+
+#ifndef XK_Codeinput
+#define XK_Codeinput 0xFF37
+#endif
+
+#ifndef XK_Kanji_Bangou
+#define XK_Kanji_Bangou 0xFF37 /* same as codeinput */
+#endif
+
+// Fix old X libraries
+#ifndef XK_KP_Home
+#define XK_KP_Home 0xFF95
+#endif
+#ifndef XK_KP_Left
+#define XK_KP_Left 0xFF96
+#endif
+#ifndef XK_KP_Up
+#define XK_KP_Up 0xFF97
+#endif
+#ifndef XK_KP_Right
+#define XK_KP_Right 0xFF98
+#endif
+#ifndef XK_KP_Down
+#define XK_KP_Down 0xFF99
+#endif
+#ifndef XK_KP_Prior
+#define XK_KP_Prior 0xFF9A
+#endif
+#ifndef XK_KP_Next
+#define XK_KP_Next 0xFF9B
+#endif
+#ifndef XK_KP_End
+#define XK_KP_End 0xFF9C
+#endif
+#ifndef XK_KP_Insert
+#define XK_KP_Insert 0xFF9E
+#endif
+#ifndef XK_KP_Delete
+#define XK_KP_Delete 0xFF9F
+#endif
+
+// the next lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special
+// multimedia keys. They are included here as not every system has them.
+#define XF86XK_MonBrightnessUp 0x1008FF02
+#define XF86XK_MonBrightnessDown 0x1008FF03
+#define XF86XK_KbdLightOnOff 0x1008FF04
+#define XF86XK_KbdBrightnessUp 0x1008FF05
+#define XF86XK_KbdBrightnessDown 0x1008FF06
+#define XF86XK_Standby 0x1008FF10
+#define XF86XK_AudioLowerVolume 0x1008FF11
+#define XF86XK_AudioMute 0x1008FF12
+#define XF86XK_AudioRaiseVolume 0x1008FF13
+#define XF86XK_AudioPlay 0x1008FF14
+#define XF86XK_AudioStop 0x1008FF15
+#define XF86XK_AudioPrev 0x1008FF16
+#define XF86XK_AudioNext 0x1008FF17
+#define XF86XK_HomePage 0x1008FF18
+#define XF86XK_Mail 0x1008FF19
+#define XF86XK_Start 0x1008FF1A
+#define XF86XK_Search 0x1008FF1B
+#define XF86XK_AudioRecord 0x1008FF1C
+#define XF86XK_Calculator 0x1008FF1D
+#define XF86XK_Memo 0x1008FF1E
+#define XF86XK_ToDoList 0x1008FF1F
+#define XF86XK_Calendar 0x1008FF20
+#define XF86XK_PowerDown 0x1008FF21
+#define XF86XK_ContrastAdjust 0x1008FF22
+#define XF86XK_Back 0x1008FF26
+#define XF86XK_Forward 0x1008FF27
+#define XF86XK_Stop 0x1008FF28
+#define XF86XK_Refresh 0x1008FF29
+#define XF86XK_PowerOff 0x1008FF2A
+#define XF86XK_WakeUp 0x1008FF2B
+#define XF86XK_Eject 0x1008FF2C
+#define XF86XK_ScreenSaver 0x1008FF2D
+#define XF86XK_WWW 0x1008FF2E
+#define XF86XK_Sleep 0x1008FF2F
+#define XF86XK_Favorites 0x1008FF30
+#define XF86XK_AudioPause 0x1008FF31
+#define XF86XK_AudioMedia 0x1008FF32
+#define XF86XK_MyComputer 0x1008FF33
+#define XF86XK_LightBulb 0x1008FF35
+#define XF86XK_Shop 0x1008FF36
+#define XF86XK_History 0x1008FF37
+#define XF86XK_OpenURL 0x1008FF38
+#define XF86XK_AddFavorite 0x1008FF39
+#define XF86XK_HotLinks 0x1008FF3A
+#define XF86XK_BrightnessAdjust 0x1008FF3B
+#define XF86XK_Finance 0x1008FF3C
+#define XF86XK_Community 0x1008FF3D
+#define XF86XK_AudioRewind 0x1008FF3E
+#define XF86XK_BackForward 0x1008FF3F
+#define XF86XK_Launch0 0x1008FF40
+#define XF86XK_Launch1 0x1008FF41
+#define XF86XK_Launch2 0x1008FF42
+#define XF86XK_Launch3 0x1008FF43
+#define XF86XK_Launch4 0x1008FF44
+#define XF86XK_Launch5 0x1008FF45
+#define XF86XK_Launch6 0x1008FF46
+#define XF86XK_Launch7 0x1008FF47
+#define XF86XK_Launch8 0x1008FF48
+#define XF86XK_Launch9 0x1008FF49
+#define XF86XK_LaunchA 0x1008FF4A
+#define XF86XK_LaunchB 0x1008FF4B
+#define XF86XK_LaunchC 0x1008FF4C
+#define XF86XK_LaunchD 0x1008FF4D
+#define XF86XK_LaunchE 0x1008FF4E
+#define XF86XK_LaunchF 0x1008FF4F
+#define XF86XK_ApplicationLeft 0x1008FF50
+#define XF86XK_ApplicationRight 0x1008FF51
+#define XF86XK_Book 0x1008FF52
+#define XF86XK_CD 0x1008FF53
+#define XF86XK_Calculater 0x1008FF54
+#define XF86XK_Clear 0x1008FF55
+#define XF86XK_ClearGrab 0x1008FE21
+#define XF86XK_Close 0x1008FF56
+#define XF86XK_Copy 0x1008FF57
+#define XF86XK_Cut 0x1008FF58
+#define XF86XK_Display 0x1008FF59
+#define XF86XK_DOS 0x1008FF5A
+#define XF86XK_Documents 0x1008FF5B
+#define XF86XK_Excel 0x1008FF5C
+#define XF86XK_Explorer 0x1008FF5D
+#define XF86XK_Game 0x1008FF5E
+#define XF86XK_Go 0x1008FF5F
+#define XF86XK_iTouch 0x1008FF60
+#define XF86XK_LogOff 0x1008FF61
+#define XF86XK_Market 0x1008FF62
+#define XF86XK_Meeting 0x1008FF63
+#define XF86XK_MenuKB 0x1008FF65
+#define XF86XK_MenuPB 0x1008FF66
+#define XF86XK_MySites 0x1008FF67
+#define XF86XK_News 0x1008FF69
+#define XF86XK_OfficeHome 0x1008FF6A
+#define XF86XK_Option 0x1008FF6C
+#define XF86XK_Paste 0x1008FF6D
+#define XF86XK_Phone 0x1008FF6E
+#define XF86XK_Reply 0x1008FF72
+#define XF86XK_Reload 0x1008FF73
+#define XF86XK_RotateWindows 0x1008FF74
+#define XF86XK_RotationPB 0x1008FF75
+#define XF86XK_RotationKB 0x1008FF76
+#define XF86XK_Save 0x1008FF77
+#define XF86XK_Send 0x1008FF7B
+#define XF86XK_Spell 0x1008FF7C
+#define XF86XK_SplitScreen 0x1008FF7D
+#define XF86XK_Support 0x1008FF7E
+#define XF86XK_TaskPane 0x1008FF7F
+#define XF86XK_Terminal 0x1008FF80
+#define XF86XK_Tools 0x1008FF81
+#define XF86XK_Travel 0x1008FF82
+#define XF86XK_Video 0x1008FF87
+#define XF86XK_Word 0x1008FF89
+#define XF86XK_Xfer 0x1008FF8A
+#define XF86XK_ZoomIn 0x1008FF8B
+#define XF86XK_ZoomOut 0x1008FF8C
+#define XF86XK_Away 0x1008FF8D
+#define XF86XK_Messenger 0x1008FF8E
+#define XF86XK_WebCam 0x1008FF8F
+#define XF86XK_MailForward 0x1008FF90
+#define XF86XK_Pictures 0x1008FF91
+#define XF86XK_Music 0x1008FF92
+#define XF86XK_Battery 0x1008FF93
+#define XF86XK_Bluetooth 0x1008FF94
+#define XF86XK_WLAN 0x1008FF95
+#define XF86XK_UWB 0x1008FF96
+#define XF86XK_AudioForward 0x1008FF97
+#define XF86XK_AudioRepeat 0x1008FF98
+#define XF86XK_AudioRandomPlay 0x1008FF99
+#define XF86XK_Subtitle 0x1008FF9A
+#define XF86XK_AudioCycleTrack 0x1008FF9B
+#define XF86XK_Time 0x1008FF9F
+#define XF86XK_Select 0x1008FFA0
+#define XF86XK_View 0x1008FFA1
+#define XF86XK_TopMenu 0x1008FFA2
+#define XF86XK_Suspend 0x1008FFA7
+#define XF86XK_Hibernate 0x1008FFA8
+
+
+// end of XF86keysyms.h
+
+// Special keys used by Qtopia, mapped into the X11 private keypad range.
+#define QTOPIAXK_Select 0x11000601
+#define QTOPIAXK_Yes 0x11000602
+#define QTOPIAXK_No 0x11000603
+#define QTOPIAXK_Cancel 0x11000604
+#define QTOPIAXK_Printer 0x11000605
+#define QTOPIAXK_Execute 0x11000606
+#define QTOPIAXK_Sleep 0x11000607
+#define QTOPIAXK_Play 0x11000608
+#define QTOPIAXK_Zoom 0x11000609
+#define QTOPIAXK_Context1 0x1100060A
+#define QTOPIAXK_Context2 0x1100060B
+#define QTOPIAXK_Context3 0x1100060C
+#define QTOPIAXK_Context4 0x1100060D
+#define QTOPIAXK_Call 0x1100060E
+#define QTOPIAXK_Hangup 0x1100060F
+#define QTOPIAXK_Flip 0x11000610
+
+// keyboard mapping table
+static const unsigned int KeyTbl[] = {
+
+ // misc keys
+
+ XK_Escape, Qt::Key_Escape,
+ XK_Tab, Qt::Key_Tab,
+ XK_ISO_Left_Tab, Qt::Key_Backtab,
+ XK_BackSpace, Qt::Key_Backspace,
+ XK_Return, Qt::Key_Return,
+ XK_Insert, Qt::Key_Insert,
+ XK_Delete, Qt::Key_Delete,
+ XK_Clear, Qt::Key_Delete,
+ XK_Pause, Qt::Key_Pause,
+ XK_Print, Qt::Key_Print,
+ 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq
+ 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq
+
+ // cursor movement
+
+ XK_Home, Qt::Key_Home,
+ XK_End, Qt::Key_End,
+ XK_Left, Qt::Key_Left,
+ XK_Up, Qt::Key_Up,
+ XK_Right, Qt::Key_Right,
+ XK_Down, Qt::Key_Down,
+ XK_Prior, Qt::Key_PageUp,
+ XK_Next, Qt::Key_PageDown,
+
+ // modifiers
+
+ XK_Shift_L, Qt::Key_Shift,
+ XK_Shift_R, Qt::Key_Shift,
+ XK_Shift_Lock, Qt::Key_Shift,
+ XK_Control_L, Qt::Key_Control,
+ XK_Control_R, Qt::Key_Control,
+ XK_Meta_L, Qt::Key_Meta,
+ XK_Meta_R, Qt::Key_Meta,
+ XK_Alt_L, Qt::Key_Alt,
+ XK_Alt_R, Qt::Key_Alt,
+ XK_Caps_Lock, Qt::Key_CapsLock,
+ XK_Num_Lock, Qt::Key_NumLock,
+ XK_Scroll_Lock, Qt::Key_ScrollLock,
+ XK_Super_L, Qt::Key_Super_L,
+ XK_Super_R, Qt::Key_Super_R,
+ XK_Menu, Qt::Key_Menu,
+ XK_Hyper_L, Qt::Key_Hyper_L,
+ XK_Hyper_R, Qt::Key_Hyper_R,
+ XK_Help, Qt::Key_Help,
+ 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab
+ 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11)
+ 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12)
+
+ // numeric and function keypad keys
+
+ XK_KP_Space, Qt::Key_Space,
+ XK_KP_Tab, Qt::Key_Tab,
+ XK_KP_Enter, Qt::Key_Enter,
+ //XK_KP_F1, Qt::Key_F1,
+ //XK_KP_F2, Qt::Key_F2,
+ //XK_KP_F3, Qt::Key_F3,
+ //XK_KP_F4, Qt::Key_F4,
+ XK_KP_Home, Qt::Key_Home,
+ XK_KP_Left, Qt::Key_Left,
+ XK_KP_Up, Qt::Key_Up,
+ XK_KP_Right, Qt::Key_Right,
+ XK_KP_Down, Qt::Key_Down,
+ XK_KP_Prior, Qt::Key_PageUp,
+ XK_KP_Next, Qt::Key_PageDown,
+ XK_KP_End, Qt::Key_End,
+ XK_KP_Begin, Qt::Key_Clear,
+ XK_KP_Insert, Qt::Key_Insert,
+ XK_KP_Delete, Qt::Key_Delete,
+ XK_KP_Equal, Qt::Key_Equal,
+ XK_KP_Multiply, Qt::Key_Asterisk,
+ XK_KP_Add, Qt::Key_Plus,
+ XK_KP_Separator, Qt::Key_Comma,
+ XK_KP_Subtract, Qt::Key_Minus,
+ XK_KP_Decimal, Qt::Key_Period,
+ XK_KP_Divide, Qt::Key_Slash,
+
+ // International input method support keys
+
+ // International & multi-key character composition
+ XK_ISO_Level3_Shift, Qt::Key_AltGr,
+ XK_Multi_key, Qt::Key_Multi_key,
+ XK_Codeinput, Qt::Key_Codeinput,
+ XK_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_MultipleCandidate, Qt::Key_MultipleCandidate,
+ XK_PreviousCandidate, Qt::Key_PreviousCandidate,
+
+ // Misc Functions
+ XK_Mode_switch, Qt::Key_Mode_switch,
+ XK_script_switch, Qt::Key_Mode_switch,
+
+ // Japanese keyboard support
+ XK_Kanji, Qt::Key_Kanji,
+ XK_Muhenkan, Qt::Key_Muhenkan,
+ //XK_Henkan_Mode, Qt::Key_Henkan_Mode,
+ XK_Henkan_Mode, Qt::Key_Henkan,
+ XK_Henkan, Qt::Key_Henkan,
+ XK_Romaji, Qt::Key_Romaji,
+ XK_Hiragana, Qt::Key_Hiragana,
+ XK_Katakana, Qt::Key_Katakana,
+ XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana,
+ XK_Zenkaku, Qt::Key_Zenkaku,
+ XK_Hankaku, Qt::Key_Hankaku,
+ XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku,
+ XK_Touroku, Qt::Key_Touroku,
+ XK_Massyo, Qt::Key_Massyo,
+ XK_Kana_Lock, Qt::Key_Kana_Lock,
+ XK_Kana_Shift, Qt::Key_Kana_Shift,
+ XK_Eisu_Shift, Qt::Key_Eisu_Shift,
+ XK_Eisu_toggle, Qt::Key_Eisu_toggle,
+ //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou,
+ //XK_Zen_Koho, Qt::Key_Zen_Koho,
+ //XK_Mae_Koho, Qt::Key_Mae_Koho,
+ XK_Kanji_Bangou, Qt::Key_Codeinput,
+ XK_Zen_Koho, Qt::Key_MultipleCandidate,
+ XK_Mae_Koho, Qt::Key_PreviousCandidate,
+
+#ifdef XK_KOREAN
+ // Korean keyboard support
+ XK_Hangul, Qt::Key_Hangul,
+ XK_Hangul_Start, Qt::Key_Hangul_Start,
+ XK_Hangul_End, Qt::Key_Hangul_End,
+ XK_Hangul_Hanja, Qt::Key_Hangul_Hanja,
+ XK_Hangul_Jamo, Qt::Key_Hangul_Jamo,
+ XK_Hangul_Romaja, Qt::Key_Hangul_Romaja,
+ //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput,
+ XK_Hangul_Codeinput, Qt::Key_Codeinput,
+ XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja,
+ XK_Hangul_Banja, Qt::Key_Hangul_Banja,
+ XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja,
+ XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja,
+ //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate,
+ //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate,
+ //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate,
+ XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate,
+ XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate,
+ XK_Hangul_Special, Qt::Key_Hangul_Special,
+ //XK_Hangul_switch, Qt::Key_Hangul_switch,
+ XK_Hangul_switch, Qt::Key_Mode_switch,
+#endif // XK_KOREAN
+
+ // dead keys
+ XK_dead_grave, Qt::Key_Dead_Grave,
+ XK_dead_acute, Qt::Key_Dead_Acute,
+ XK_dead_circumflex, Qt::Key_Dead_Circumflex,
+ XK_dead_tilde, Qt::Key_Dead_Tilde,
+ XK_dead_macron, Qt::Key_Dead_Macron,
+ XK_dead_breve, Qt::Key_Dead_Breve,
+ XK_dead_abovedot, Qt::Key_Dead_Abovedot,
+ XK_dead_diaeresis, Qt::Key_Dead_Diaeresis,
+ XK_dead_abovering, Qt::Key_Dead_Abovering,
+ XK_dead_doubleacute, Qt::Key_Dead_Doubleacute,
+ XK_dead_caron, Qt::Key_Dead_Caron,
+ XK_dead_cedilla, Qt::Key_Dead_Cedilla,
+ XK_dead_ogonek, Qt::Key_Dead_Ogonek,
+ XK_dead_iota, Qt::Key_Dead_Iota,
+ XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
+ XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
+ XK_dead_belowdot, Qt::Key_Dead_Belowdot,
+ XK_dead_hook, Qt::Key_Dead_Hook,
+ XK_dead_horn, Qt::Key_Dead_Horn,
+
+ // Special keys from X.org - This include multimedia keys,
+ // wireless/bluetooth/uwb keys, special launcher keys, etc.
+ XF86XK_Back, Qt::Key_Back,
+ XF86XK_Forward, Qt::Key_Forward,
+ XF86XK_Stop, Qt::Key_Stop,
+ XF86XK_Refresh, Qt::Key_Refresh,
+ XF86XK_Favorites, Qt::Key_Favorites,
+ XF86XK_AudioMedia, Qt::Key_LaunchMedia,
+ XF86XK_OpenURL, Qt::Key_OpenUrl,
+ XF86XK_HomePage, Qt::Key_HomePage,
+ XF86XK_Search, Qt::Key_Search,
+ XF86XK_AudioLowerVolume, Qt::Key_VolumeDown,
+ XF86XK_AudioMute, Qt::Key_VolumeMute,
+ XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp,
+ XF86XK_AudioPlay, Qt::Key_MediaPlay,
+ XF86XK_AudioStop, Qt::Key_MediaStop,
+ XF86XK_AudioPrev, Qt::Key_MediaPrevious,
+ XF86XK_AudioNext, Qt::Key_MediaNext,
+ XF86XK_AudioRecord, Qt::Key_MediaRecord,
+ XF86XK_Mail, Qt::Key_LaunchMail,
+ XF86XK_MyComputer, Qt::Key_Launch0, // ### Qt 5: remap properly
+ XF86XK_Calculator, Qt::Key_Launch1,
+ XF86XK_Memo, Qt::Key_Memo,
+ XF86XK_ToDoList, Qt::Key_ToDoList,
+ XF86XK_Calendar, Qt::Key_Calendar,
+ XF86XK_PowerDown, Qt::Key_PowerDown,
+ XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust,
+ XF86XK_Standby, Qt::Key_Standby,
+ XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp,
+ XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown,
+ XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff,
+ XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp,
+ XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown,
+ XF86XK_PowerOff, Qt::Key_PowerOff,
+ XF86XK_WakeUp, Qt::Key_WakeUp,
+ XF86XK_Eject, Qt::Key_Eject,
+ XF86XK_ScreenSaver, Qt::Key_ScreenSaver,
+ XF86XK_WWW, Qt::Key_WWW,
+ XF86XK_Sleep, Qt::Key_Sleep,
+ XF86XK_LightBulb, Qt::Key_LightBulb,
+ XF86XK_Shop, Qt::Key_Shop,
+ XF86XK_History, Qt::Key_History,
+ XF86XK_AddFavorite, Qt::Key_AddFavorite,
+ XF86XK_HotLinks, Qt::Key_HotLinks,
+ XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust,
+ XF86XK_Finance, Qt::Key_Finance,
+ XF86XK_Community, Qt::Key_Community,
+ XF86XK_AudioRewind, Qt::Key_AudioRewind,
+ XF86XK_BackForward, Qt::Key_BackForward,
+ XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft,
+ XF86XK_ApplicationRight, Qt::Key_ApplicationRight,
+ XF86XK_Book, Qt::Key_Book,
+ XF86XK_CD, Qt::Key_CD,
+ XF86XK_Calculater, Qt::Key_Calculator,
+ XF86XK_Clear, Qt::Key_Clear,
+ XF86XK_ClearGrab, Qt::Key_ClearGrab,
+ XF86XK_Close, Qt::Key_Close,
+ XF86XK_Copy, Qt::Key_Copy,
+ XF86XK_Cut, Qt::Key_Cut,
+ XF86XK_Display, Qt::Key_Display,
+ XF86XK_DOS, Qt::Key_DOS,
+ XF86XK_Documents, Qt::Key_Documents,
+ XF86XK_Excel, Qt::Key_Excel,
+ XF86XK_Explorer, Qt::Key_Explorer,
+ XF86XK_Game, Qt::Key_Game,
+ XF86XK_Go, Qt::Key_Go,
+ XF86XK_iTouch, Qt::Key_iTouch,
+ XF86XK_LogOff, Qt::Key_LogOff,
+ XF86XK_Market, Qt::Key_Market,
+ XF86XK_Meeting, Qt::Key_Meeting,
+ XF86XK_MenuKB, Qt::Key_MenuKB,
+ XF86XK_MenuPB, Qt::Key_MenuPB,
+ XF86XK_MySites, Qt::Key_MySites,
+ XF86XK_News, Qt::Key_News,
+ XF86XK_OfficeHome, Qt::Key_OfficeHome,
+ XF86XK_Option, Qt::Key_Option,
+ XF86XK_Paste, Qt::Key_Paste,
+ XF86XK_Phone, Qt::Key_Phone,
+ XF86XK_Reply, Qt::Key_Reply,
+ XF86XK_Reload, Qt::Key_Reload,
+ XF86XK_RotateWindows, Qt::Key_RotateWindows,
+ XF86XK_RotationPB, Qt::Key_RotationPB,
+ XF86XK_RotationKB, Qt::Key_RotationKB,
+ XF86XK_Save, Qt::Key_Save,
+ XF86XK_Send, Qt::Key_Send,
+ XF86XK_Spell, Qt::Key_Spell,
+ XF86XK_SplitScreen, Qt::Key_SplitScreen,
+ XF86XK_Support, Qt::Key_Support,
+ XF86XK_TaskPane, Qt::Key_TaskPane,
+ XF86XK_Terminal, Qt::Key_Terminal,
+ XF86XK_Tools, Qt::Key_Tools,
+ XF86XK_Travel, Qt::Key_Travel,
+ XF86XK_Video, Qt::Key_Video,
+ XF86XK_Word, Qt::Key_Word,
+ XF86XK_Xfer, Qt::Key_Xfer,
+ XF86XK_ZoomIn, Qt::Key_ZoomIn,
+ XF86XK_ZoomOut, Qt::Key_ZoomOut,
+ XF86XK_Away, Qt::Key_Away,
+ XF86XK_Messenger, Qt::Key_Messenger,
+ XF86XK_WebCam, Qt::Key_WebCam,
+ XF86XK_MailForward, Qt::Key_MailForward,
+ XF86XK_Pictures, Qt::Key_Pictures,
+ XF86XK_Music, Qt::Key_Music,
+ XF86XK_Battery, Qt::Key_Battery,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_WLAN, Qt::Key_WLAN,
+ XF86XK_UWB, Qt::Key_UWB,
+ XF86XK_AudioForward, Qt::Key_AudioForward,
+ XF86XK_AudioRepeat, Qt::Key_AudioRepeat,
+ XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay,
+ XF86XK_Subtitle, Qt::Key_Subtitle,
+ XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack,
+ XF86XK_Time, Qt::Key_Time,
+ XF86XK_Select, Qt::Key_Select,
+ XF86XK_View, Qt::Key_View,
+ XF86XK_TopMenu, Qt::Key_TopMenu,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_Suspend, Qt::Key_Suspend,
+ XF86XK_Hibernate, Qt::Key_Hibernate,
+ XF86XK_Launch0, Qt::Key_Launch2, // ### Qt 5: remap properly
+ XF86XK_Launch1, Qt::Key_Launch3,
+ XF86XK_Launch2, Qt::Key_Launch4,
+ XF86XK_Launch3, Qt::Key_Launch5,
+ XF86XK_Launch4, Qt::Key_Launch6,
+ XF86XK_Launch5, Qt::Key_Launch7,
+ XF86XK_Launch6, Qt::Key_Launch8,
+ XF86XK_Launch7, Qt::Key_Launch9,
+ XF86XK_Launch8, Qt::Key_LaunchA,
+ XF86XK_Launch9, Qt::Key_LaunchB,
+ XF86XK_LaunchA, Qt::Key_LaunchC,
+ XF86XK_LaunchB, Qt::Key_LaunchD,
+ XF86XK_LaunchC, Qt::Key_LaunchE,
+ XF86XK_LaunchD, Qt::Key_LaunchF,
+ XF86XK_LaunchE, Qt::Key_LaunchG,
+ XF86XK_LaunchF, Qt::Key_LaunchH,
+
+ // Qtopia keys
+ QTOPIAXK_Select, Qt::Key_Select,
+ QTOPIAXK_Yes, Qt::Key_Yes,
+ QTOPIAXK_No, Qt::Key_No,
+ QTOPIAXK_Cancel, Qt::Key_Cancel,
+ QTOPIAXK_Printer, Qt::Key_Printer,
+ QTOPIAXK_Execute, Qt::Key_Execute,
+ QTOPIAXK_Sleep, Qt::Key_Sleep,
+ QTOPIAXK_Play, Qt::Key_Play,
+ QTOPIAXK_Zoom, Qt::Key_Zoom,
+ QTOPIAXK_Context1, Qt::Key_Context1,
+ QTOPIAXK_Context2, Qt::Key_Context2,
+ QTOPIAXK_Context3, Qt::Key_Context3,
+ QTOPIAXK_Context4, Qt::Key_Context4,
+ QTOPIAXK_Call, Qt::Key_Call,
+ QTOPIAXK_Hangup, Qt::Key_Hangup,
+ QTOPIAXK_Flip, Qt::Key_Flip,
+
+ 0, 0
+};
+
+static const unsigned short katakanaKeysymsToUnicode[] = {
+ 0x0000, 0x3002, 0x300C, 0x300D, 0x3001, 0x30FB, 0x30F2, 0x30A1,
+ 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3,
+ 0x30FC, 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD,
+ 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD,
+ 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC,
+ 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE,
+ 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9,
+ 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F3, 0x309B, 0x309C
+};
+
+static const unsigned short cyrillicKeysymsToUnicode[] = {
+ 0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f,
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a
+};
+
+static const unsigned short greekKeysymsToUnicode[] = {
+ 0x0000, 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c,
+ 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015,
+ 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc,
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
+ 0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
+ 0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
+ 0x03c8, 0x03c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short technicalKeysymsToUnicode[] = {
+ 0x0000, 0x23B7, 0x250C, 0x2500, 0x2320, 0x2321, 0x2502, 0x23A1,
+ 0x23A3, 0x23A4, 0x23A6, 0x239B, 0x239D, 0x239E, 0x23A0, 0x23A8,
+ 0x23AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222B,
+ 0x2234, 0x221D, 0x221E, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000,
+ 0x223C, 0x2243, 0x0000, 0x0000, 0x0000, 0x21D4, 0x21D2, 0x2261,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221A, 0x0000,
+ 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222A, 0x2227, 0x2228,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2202,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193, 0x0000
+};
+
+static const unsigned short specialKeysymsToUnicode[] = {
+ 0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x0000, 0x0000,
+ 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA,
+ 0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C,
+ 0x2502, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short publishingKeysymsToUnicode[] = {
+ 0x0000, 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009,
+ 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025,
+ 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a,
+ 0x2105, 0x0000, 0x0000, 0x2012, 0x2329, 0x0000, 0x232a, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000,
+ 0x0000, 0x2122, 0x2613, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25af,
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033,
+ 0x0000, 0x271d, 0x0000, 0x25ac, 0x25c0, 0x25b6, 0x25cf, 0x25ae,
+ 0x25e6, 0x25ab, 0x25ad, 0x25b3, 0x25bd, 0x2606, 0x2022, 0x25aa,
+ 0x25b2, 0x25bc, 0x261c, 0x261e, 0x2663, 0x2666, 0x2665, 0x0000,
+ 0x2720, 0x2020, 0x2021, 0x2713, 0x2717, 0x266f, 0x266d, 0x2642,
+ 0x2640, 0x260e, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e, 0x0000
+};
+
+static const unsigned short aplKeysymsToUnicode[] = {
+ 0x0000, 0x0000, 0x0000, 0x003c, 0x0000, 0x0000, 0x003e, 0x0000,
+ 0x2228, 0x2227, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x00af, 0x0000, 0x22a5, 0x2229, 0x230a, 0x0000, 0x005f, 0x0000,
+ 0x0000, 0x0000, 0x2218, 0x0000, 0x2395, 0x0000, 0x22a4, 0x25cb,
+ 0x0000, 0x0000, 0x0000, 0x2308, 0x0000, 0x0000, 0x222a, 0x0000,
+ 0x2283, 0x0000, 0x2282, 0x0000, 0x22a2, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x22a3, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short koreanKeysymsToUnicode[] = {
+ 0x0000, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137,
+ 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f,
+ 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147,
+ 0x3148, 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f,
+ 0x3150, 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157,
+ 0x3158, 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f,
+ 0x3160, 0x3161, 0x3162, 0x3163, 0x11a8, 0x11a9, 0x11aa, 0x11ab,
+ 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3,
+ 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb,
+ 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x316d,
+ 0x3171, 0x3178, 0x317f, 0x3181, 0x3184, 0x3186, 0x318d, 0x318e,
+ 0x11eb, 0x11f0, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9
+};
+
+static QChar keysymToUnicode(unsigned char byte3, unsigned char byte4)
+{
+ switch (byte3) {
+ case 0x04:
+ // katakana
+ if (byte4 > 0xa0 && byte4 < 0xe0)
+ return QChar(katakanaKeysymsToUnicode[byte4 - 0xa0]);
+ else if (byte4 == 0x7e)
+ return QChar(0x203e); // Overline
+ break;
+ case 0x06:
+ // russian, use lookup table
+ if (byte4 > 0xa0)
+ return QChar(cyrillicKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x07:
+ // greek
+ if (byte4 > 0xa0)
+ return QChar(greekKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x08:
+ // technical
+ if (byte4 > 0xa0)
+ return QChar(technicalKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x09:
+ // special
+ if (byte4 >= 0xe0)
+ return QChar(specialKeysymsToUnicode[byte4 - 0xe0]);
+ break;
+ case 0x0a:
+ // publishing
+ if (byte4 > 0xa0)
+ return QChar(publishingKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0b:
+ // APL
+ if (byte4 > 0xa0)
+ return QChar(aplKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0e:
+ // Korean
+ if (byte4 > 0xa0)
+ return QChar(koreanKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ default:
+ break;
+ }
+ return QChar(0x0);
+}
+
+Qt::KeyboardModifiers QXlibKeyboard::translateModifiers(int s)
+{
+ Qt::KeyboardModifiers ret = 0;
+ if (s & ShiftMask)
+ ret |= Qt::ShiftModifier;
+ if (s & ControlMask)
+ ret |= Qt::ControlModifier;
+ if (s & m_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & m_meta_mask)
+ ret |= Qt::MetaModifier;
+// if (s & m_mode_switch_mask) //doesn't seem to work correctly
+// ret |= Qt::GroupSwitchModifier;
+ return ret;
+}
+
+void QXlibKeyboard::setMask(KeySym sym, uint mask)
+{
+ if (m_alt_mask == 0
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Alt_L || sym == XK_Alt_R)) {
+ m_alt_mask = mask;
+ }
+ if (m_meta_mask == 0
+ && m_alt_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Meta_L || sym == XK_Meta_R)) {
+ m_meta_mask = mask;
+ }
+ if (m_super_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Super_L || sym == XK_Super_R)) {
+ m_super_mask = mask;
+ }
+ if (m_hyper_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && (sym == XK_Hyper_L || sym == XK_Hyper_R)) {
+ m_hyper_mask = mask;
+ }
+ if (m_mode_switch_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && sym == XK_Mode_switch) {
+ m_mode_switch_mask = mask;
+ }
+ if (m_num_lock_mask == 0
+ && sym == XK_Num_Lock) {
+ m_num_lock_mask = mask;
+ }
+}
+
+int QXlibKeyboard::translateKeySym(uint key) const
+{
+ int code = -1;
+ int i = 0; // any other keys
+ while (KeyTbl[i]) {
+ if (key == KeyTbl[i]) {
+ code = (int)KeyTbl[i+1];
+ break;
+ }
+ i += 2;
+ }
+ if (m_meta_mask) {
+ // translate Super/Hyper keys to Meta if we're using them as the MetaModifier
+ if (m_meta_mask == m_super_mask && (code == Qt::Key_Super_L || code == Qt::Key_Super_R)) {
+ code = Qt::Key_Meta;
+ } else if (m_meta_mask == m_hyper_mask && (code == Qt::Key_Hyper_L || code == Qt::Key_Hyper_R)) {
+ code = Qt::Key_Meta;
+ }
+ }
+ return code;
+}
+
+QString QXlibKeyboard::translateKeySym(KeySym keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count)
+{
+ // all keysyms smaller than 0xff00 are actally keys that can be mapped to unicode chars
+
+ QTextCodec *mapper = QTextCodec::codecForLocale();
+ QChar converted;
+
+ if (/*count == 0 &&*/ keysym < 0xff00) {
+ unsigned char byte3 = (unsigned char)(keysym >> 8);
+ int mib = -1;
+ switch(byte3) {
+ case 0: // Latin 1
+ case 1: // Latin 2
+ case 2: //latin 3
+ case 3: // latin4
+ mib = byte3 + 4; break;
+ case 5: // arabic
+ mib = 82; break;
+ case 12: // Hebrew
+ mib = 85; break;
+ case 13: // Thai
+ mib = 2259; break;
+ case 4: // kana
+ case 6: // cyrillic
+ case 7: // greek
+ case 8: // technical, no mapping here at the moment
+ case 9: // Special
+ case 10: // Publishing
+ case 11: // APL
+ case 14: // Korean, no mapping
+ mib = -1; // manual conversion
+ mapper= 0;
+#if !defined(QT_NO_XIM)
+ converted = keysymToUnicode(byte3, keysym & 0xff);
+#endif
+ case 0x20:
+ // currency symbols
+ if (keysym >= 0x20a0 && keysym <= 0x20ac) {
+ mib = -1; // manual conversion
+ mapper = 0;
+ converted = (uint)keysym;
+ }
+ break;
+ default:
+ break;
+ }
+ if (mib != -1) {
+ mapper = QTextCodec::codecForMib(mib);
+ if (chars.isEmpty())
+ chars.resize(1);
+ chars[0] = (unsigned char) (keysym & 0xff); // get only the fourth bit for conversion later
+ count = 1;
+ }
+ } else if (keysym >= 0x1000000 && keysym <= 0x100ffff) {
+ converted = (ushort) (keysym - 0x1000000);
+ mapper = 0;
+ }
+ if (count < (int)chars.size()-1)
+ chars[count] = '\0';
+
+ QString text;
+ if (!mapper && converted.unicode() != 0x0) {
+ text = converted;
+ } else if (!chars.isEmpty()) {
+ // convert chars (8bit) to text (unicode).
+ if (mapper)
+ text = mapper->toUnicode(chars.data(), count, 0);
+ if (text.isEmpty()) {
+ // no mapper, or codec couldn't convert to unicode (this
+ // can happen when running in the C locale or with no LANG
+ // set). try converting from latin-1
+ text = QString::fromLatin1(chars);
+ }
+ }
+
+ modifiers = translateModifiers(xmodifiers);
+
+ // Commentary in X11/keysymdef says that X codes match ASCII, so it
+ // is safe to use the locale functions to process X codes in ISO8859-1.
+ //
+ // This is mainly for compatibility - applications should not use the
+ // Qt keycodes between 128 and 255, but should rather use the
+ // QKeyEvent::text().
+ //
+ if (keysym < 128 || (keysym < 256 && (!mapper || mapper->mibEnum()==4))) {
+ // upper-case key, if known
+ code = isprint((int)keysym) ? toupper((int)keysym) : 0;
+ } else if (keysym >= XK_F1 && keysym <= XK_F35) {
+ // function keys
+ code = Qt::Key_F1 + ((int)keysym - XK_F1);
+ } else if (keysym >= XK_KP_Space && keysym <= XK_KP_9) {
+ if (keysym >= XK_KP_0) {
+ // numeric keypad keys
+ code = Qt::Key_0 + ((int)keysym - XK_KP_0);
+ } else {
+ code = translateKeySym(keysym);
+ }
+ modifiers |= Qt::KeypadModifier;
+ } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f && text.unicode()->unicode() != 0x7f && !(keysym >= XK_dead_grave && keysym <= XK_dead_horn)) {
+ code = text.unicode()->toUpper().unicode();
+ } else {
+ // any other keys
+ code = translateKeySym(keysym);
+
+ if (code == Qt::Key_Tab && (modifiers & Qt::ShiftModifier)) {
+ // map shift+tab to shift+backtab, QShortcutMap knows about it
+ // and will handle it.
+ code = Qt::Key_Backtab;
+ text = QString();
+ }
+ }
+
+ return text;
+}
+
+QXlibKeyboard::QXlibKeyboard(QXlibScreen *screen)
+ : m_screen(screen)
+ , m_alt_mask(0)
+ , m_super_mask(0)
+ , m_hyper_mask(0)
+ , m_meta_mask(0)
+{
+ changeLayout();
+}
+
+void QXlibKeyboard::changeLayout()
+{
+ XkbDescPtr xkbDesc = XkbGetMap(m_screen->display()->nativeDisplay(), XkbAllClientInfoMask, XkbUseCoreKbd);
+ for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) {
+ const uint mask = xkbDesc->map->modmap ? xkbDesc->map->modmap[i] : 0;
+ if (mask == 0) {
+ // key is not bound to a modifier
+ continue;
+ }
+
+ for (int j = 0; j < XkbKeyGroupsWidth(xkbDesc, i); ++j) {
+ KeySym keySym = XkbKeySym(xkbDesc, i, j);
+ if (keySym == NoSymbol)
+ continue;
+ setMask(keySym, mask);
+ }
+ }
+ XkbFreeKeyboard(xkbDesc, XkbAllComponentsMask, true);
+
+}
+
+static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode)
+{
+ switch (qtcode) {
+ case Qt::Key_Control:
+ return Qt::ControlModifier;
+ case Qt::Key_Alt:
+ return Qt::AltModifier;
+ case Qt::Key_Shift:
+ return Qt::ShiftModifier;
+ case Qt::Key_Meta:
+ return Qt::MetaModifier;
+ default:
+ return Qt::NoModifier;
+ }
+}
+
+void QXlibKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev)
+{
+ int qtcode = 0;
+ Qt::KeyboardModifiers modifiers = translateModifiers(ev->state);
+ QByteArray chars;
+ chars.resize(513);
+ int count = 0;
+ KeySym keySym;
+ count = XLookupString(ev,chars.data(),chars.size(),&keySym,0);
+ QString text = translateKeySym(keySym,ev->state,qtcode,modifiers,chars,count);
+ QWindowSystemInterface::handleExtendedKeyEvent(widget,ev->time,type,qtcode,modifiers,ev->keycode,0,ev->state,text.left(count));
+}
diff --git a/src/plugins/platforms/xlib/qxlibkeyboard.h b/src/plugins/platforms/xlib/qxlibkeyboard.h
new file mode 100644
index 0000000..5e0135a
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibkeyboard.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEKEYBOARD_H
+#define QTESTLITEKEYBOARD_H
+
+#include "qxlibintegration.h"
+
+class QXlibKeyboard
+{
+public:
+ QXlibKeyboard(QXlibScreen *screen);
+
+ void changeLayout();
+
+ void handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev);
+
+ Qt::KeyboardModifiers translateModifiers(int s);
+
+private:
+
+ void setMask(KeySym sym, uint mask);
+ int translateKeySym(uint key) const;
+ QString translateKeySym(KeySym keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count);
+
+ QXlibScreen *m_screen;
+
+ uint m_alt_mask;
+ uint m_super_mask;
+ uint m_hyper_mask;
+ uint m_meta_mask;
+ uint m_mode_switch_mask;
+ uint m_num_lock_mask;
+};
+
+#endif // QTESTLITEKEYBOARD_H
diff --git a/src/plugins/platforms/xlib/qxlibmime.cpp b/src/plugins/platforms/xlib/qxlibmime.cpp
new file mode 100644
index 0000000..e98983d
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibmime.cpp
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibmime.h"
+
+#include "qxlibstatic.h"
+#include "qxlibscreen.h"
+
+#include <QtCore/QTextCodec>
+#include <QtGui/QImageWriter>
+#include <QtCore/QBuffer>
+
+QXlibMime::QXlibMime()
+ : QInternalMimeData()
+{ }
+
+QXlibMime::~QXlibMime()
+{}
+
+
+
+
+
+QString QXlibMime::mimeAtomToString(Display *display, Atom a)
+{
+ if (!a) return 0;
+
+ if (a == XA_STRING || a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)) {
+ return "text/plain"; // some Xdnd clients are dumb
+ }
+ char *atom = XGetAtomName(display, a);
+ QString result = QString::fromLatin1(atom);
+ XFree(atom);
+ return result;
+}
+
+Atom QXlibMime::mimeStringToAtom(Display *display, const QString &mimeType)
+{
+ if (mimeType.isEmpty())
+ return 0;
+ return XInternAtom(display, mimeType.toLatin1().constData(), False);
+}
+
+QStringList QXlibMime::mimeFormatsForAtom(Display *display, Atom a)
+{
+ QStringList formats;
+ if (a) {
+ QString atomName = mimeAtomToString(display, a);
+ formats.append(atomName);
+
+ // special cases for string type
+ if (a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)
+ || a == XA_STRING
+ || a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
+ formats.append(QLatin1String("text/plain"));
+
+ // special cases for uris
+ if (atomName == QLatin1String("text/x-moz-url"))
+ formats.append(QLatin1String("text/uri-list"));
+
+ // special case for images
+ if (a == XA_PIXMAP)
+ formats.append(QLatin1String("image/ppm"));
+ }
+ return formats;
+}
+
+bool QXlibMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
+{
+ bool ret = false;
+ *atomFormat = a;
+ *dataFormat = 8;
+ QString atomName = mimeAtomToString(display, a);
+ if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
+ *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
+ if (atomName == QLatin1String("application/x-color"))
+ *dataFormat = 16;
+ ret = true;
+ } else {
+ if ((a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)
+ || a == XA_STRING
+ || a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
+ && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
+ if (a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)){
+ *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
+ ret = true;
+ } else if (a == XA_STRING) {
+ *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ ret = true;
+ } else if (a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)) {
+ // the ICCCM states that TEXT and COMPOUND_TEXT are in the
+ // encoding of choice, so we choose the encoding of the locale
+ QByteArray strData = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ char *list[] = { strData.data(), NULL };
+
+ XICCEncodingStyle style = (a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
+ ? XCompoundTextStyle : XStdICCTextStyle;
+ XTextProperty textprop;
+ if (list[0] != NULL
+ && XmbTextListToTextProperty(display, list, 1, style,
+ &textprop) == Success) {
+ *atomFormat = textprop.encoding;
+ *dataFormat = textprop.format;
+ *data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
+ ret = true;
+
+ XFree(textprop.value);
+ }
+ }
+ } else if (atomName == QLatin1String("text/x-moz-url") &&
+ QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
+ QByteArray uri = QInternalMimeData::renderDataHelper(
+ QLatin1String("text/uri-list"), mimeData).split('\n').first();
+ QString mozUri = QString::fromLatin1(uri, uri.size());
+ mozUri += QLatin1Char('\n');
+ *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
+ ret = true;
+ } else if ((a == XA_PIXMAP || a == XA_BITMAP) && mimeData->hasImage()) {
+ ret = true;
+ }
+ }
+ return ret && data != 0;
+}
+
+QList<Atom> QXlibMime::mimeAtomsForFormat(Display *display, const QString &format)
+{
+ QList<Atom> atoms;
+ atoms.append(mimeStringToAtom(display, format));
+
+ // special cases for strings
+ if (format == QLatin1String("text/plain")) {
+ atoms.append(QXlibStatic::atom(QXlibStatic::UTF8_STRING));
+ atoms.append(XA_STRING);
+ atoms.append(QXlibStatic::atom(QXlibStatic::TEXT));
+ atoms.append(QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT));
+ }
+
+ // special cases for uris
+ if (format == QLatin1String("text/uri-list")) {
+ atoms.append(mimeStringToAtom(display,QLatin1String("text/x-moz-url")));
+ }
+
+ //special cases for images
+ if (format == QLatin1String("image/ppm"))
+ atoms.append(XA_PIXMAP);
+ if (format == QLatin1String("image/pbm"))
+ atoms.append(XA_BITMAP);
+
+ return atoms;
+}
+
+QVariant QXlibMime::mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
+{
+ QString atomName = mimeAtomToString(display,a);
+ if (atomName == format)
+ return data;
+
+ if (!encoding.isEmpty()
+ && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
+
+ if (requestedType == QVariant::String) {
+ QTextCodec *codec = QTextCodec::codecForName(encoding);
+ if (codec)
+ return codec->toUnicode(data);
+ }
+
+ return data;
+ }
+
+ // special cases for string types
+ if (format == QLatin1String("text/plain")) {
+ if (a == QXlibStatic::atom(QXlibStatic::UTF8_STRING))
+ return QString::fromUtf8(data);
+ if (a == XA_STRING)
+ return QString::fromLatin1(data);
+ if (a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
+ // #### might be wrong for COMPUND_TEXT
+ return QString::fromLocal8Bit(data, data.size());
+ }
+
+ // special case for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ if (atomName == QLatin1String("text/x-moz-url")) {
+ // we expect this as utf16 <url><space><title>
+ // the first part is a url that should only contain ascci char
+ // so it should be safe to check that the second char is 0
+ // to verify that it is utf16
+ if (data.size() > 1 && data.at(1) == 0)
+ return QString::fromRawData((const QChar *)data.constData(),
+ data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
+ }
+ }
+
+ // special cas for images
+ if (format == QLatin1String("image/ppm")) {
+ if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
+ Pixmap xpm = *((Pixmap*)data.data());
+ if (!xpm)
+ return QByteArray();
+ Window root;
+ int x;
+ int y;
+ uint width;
+ uint height;
+ uint border_width;
+ uint depth;
+
+ XGetGeometry(display, xpm, &root, &x, &y, &width, &height, &border_width, &depth);
+ XImage *ximg = XGetImage(display,xpm,x,y,width,height,AllPlanes,depth==1 ? XYPixmap : ZPixmap);
+ QImage qimg = QXlibStatic::qimageFromXImage(ximg);
+ XDestroyImage(ximg);
+
+ QImageWriter imageWriter;
+ imageWriter.setFormat("PPMRAW");
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ imageWriter.setDevice(&buf);
+ imageWriter.write(qimg);
+ return buf.buffer();
+ }
+ }
+ return QVariant();
+}
+
+Atom QXlibMime::mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding)
+{
+ requestedEncoding->clear();
+
+ // find matches for string types
+ if (format == QLatin1String("text/plain")) {
+ if (atoms.contains(QXlibStatic::atom(QXlibStatic::UTF8_STRING)))
+ return QXlibStatic::atom(QXlibStatic::UTF8_STRING);
+ if (atoms.contains(QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)))
+ return QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT);
+ if (atoms.contains(QXlibStatic::atom(QXlibStatic::TEXT)))
+ return QXlibStatic::atom(QXlibStatic::TEXT);
+ if (atoms.contains(XA_STRING))
+ return XA_STRING;
+ }
+
+ // find matches for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ Atom a = mimeStringToAtom(display,format);
+ if (a && atoms.contains(a))
+ return a;
+ a = mimeStringToAtom(display,QLatin1String("text/x-moz-url"));
+ if (a && atoms.contains(a))
+ return a;
+ }
+
+ // find match for image
+ if (format == QLatin1String("image/ppm")) {
+ if (atoms.contains(XA_PIXMAP))
+ return XA_PIXMAP;
+ }
+
+ // for string/text requests try to use a format with a well-defined charset
+ // first to avoid encoding problems
+ if (requestedType == QVariant::String
+ && format.startsWith(QLatin1String("text/"))
+ && !format.contains(QLatin1String("charset="))) {
+
+ QString formatWithCharset = format;
+ formatWithCharset.append(QLatin1String(";charset=utf-8"));
+
+ Atom a = mimeStringToAtom(display,formatWithCharset);
+ if (a && atoms.contains(a)) {
+ *requestedEncoding = "utf-8";
+ return a;
+ }
+ }
+
+ Atom a = mimeStringToAtom(display,format);
+ if (a && atoms.contains(a))
+ return a;
+
+ return 0;
+}
diff --git a/src/plugins/platforms/xlib/qxlibmime.h b/src/plugins/platforms/xlib/qxlibmime.h
new file mode 100644
index 0000000..a9bc265
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibmime.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEMIME_H
+#define QTESTLITEMIME_H
+
+#include <private/qdnd_p.h>
+
+#include <QtGui/QClipboard>
+
+#include "qxlibintegration.h"
+#include "qxlibclipboard.h"
+
+class QXlibMime : public QInternalMimeData {
+ Q_OBJECT
+public:
+ QXlibMime();
+ ~QXlibMime();
+
+ static QList<Atom> mimeAtomsForFormat(Display *display, const QString &format);
+ static QString mimeAtomToString(Display *display, Atom a);
+ static bool mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat);
+ static QStringList mimeFormatsForAtom(Display *display, Atom a);
+ static Atom mimeStringToAtom(Display *display, const QString &mimeType);
+ static QVariant mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding);
+ static Atom mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding);
+};
+
+#endif // QTESTLITEMIME_H
diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp
new file mode 100644
index 0000000..23a2d07
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibscreen.cpp
@@ -0,0 +1,485 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibscreen.h"
+
+#include "qxlibcursor.h"
+#include "qxlibwindow.h"
+#include "qxlibkeyboard.h"
+#include "qxlibstatic.h"
+#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/QElapsedTimer>
+
+#include <private/qapplication_p.h>
+
+#include <X11/extensions/Xfixes.h>
+
+QT_BEGIN_NAMESPACE
+
+static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
+static bool seen_badwindow;
+
+static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
+{
+
+qDebug() << "qt_x_errhandler" << err->error_code;
+
+ switch (err->error_code) {
+ case BadAtom:
+#if 0
+ if (err->request_code == 20 /* X_GetProperty */
+ && (err->resourceid == XA_RESOURCE_MANAGER
+ || err->resourceid == XA_RGB_DEFAULT_MAP
+ || err->resourceid == ATOM(_NET_SUPPORTED)
+ || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
+ || err->resourceid == ATOM(KDE_FULL_SESSION)
+ || err->resourceid == ATOM(KWIN_RUNNING)
+ || err->resourceid == ATOM(XdndProxy)
+ || err->resourceid == ATOM(XdndAware))
+
+
+ ) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+#endif
+ qDebug() << "BadAtom";
+ break;
+
+ case BadWindow:
+ if (err->request_code == 2 /* X_ChangeWindowAttributes */
+ || err->request_code == 38 /* X_QueryPointer */) {
+ for (int i = 0; i < ScreenCount(dpy); ++i) {
+ if (err->resourceid == RootWindow(dpy, i)) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+ }
+ }
+ seen_badwindow = true;
+ if (err->request_code == 25 /* X_SendEvent */) {
+ for (int i = 0; i < ScreenCount(dpy); ++i) {
+ if (err->resourceid == RootWindow(dpy, i)) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+ }
+#if 0
+ if (X11->xdndHandleBadwindow()) {
+ qDebug("xdndHandleBadwindow returned true");
+ return 0;
+ }
+#endif
+ }
+#if 0
+ if (X11->ignore_badwindow)
+ return 0;
+#endif
+ break;
+
+ case BadMatch:
+ if (err->request_code == 42 /* X_SetInputFocus */)
+ return 0;
+ break;
+
+ default:
+#if 0 //!defined(QT_NO_XINPUT)
+ if (err->request_code == X11->xinput_major
+ && err->error_code == (X11->xinput_errorbase + XI_BadDevice)
+ && err->minor_code == 3 /* X_OpenDevice */) {
+ return 0;
+ }
+#endif
+ break;
+ }
+
+ char errstr[256];
+ XGetErrorText( dpy, err->error_code, errstr, 256 );
+ char buffer[256];
+ char request_str[256];
+ qsnprintf(buffer, 256, "%d", err->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256);
+ if (err->request_code < 128) {
+ // X error for a normal protocol request
+ qWarning( "X Error: %s %d\n"
+ " Major opcode: %d (%s)\n"
+ " Resource id: 0x%lx",
+ errstr, err->error_code,
+ err->request_code,
+ request_str,
+ err->resourceid );
+ } else {
+ // X error for an extension request
+ const char *extensionName = 0;
+#if 0
+ if (err->request_code == X11->xrender_major)
+ extensionName = "RENDER";
+ else if (err->request_code == X11->xrandr_major)
+ extensionName = "RANDR";
+ else if (err->request_code == X11->xinput_major)
+ extensionName = "XInputExtension";
+ else if (err->request_code == X11->mitshm_major)
+ extensionName = "MIT-SHM";
+#endif
+ char minor_str[256];
+ if (extensionName) {
+ qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256);
+ } else {
+ extensionName = "Uknown extension";
+ qsnprintf(minor_str, 256, "Unknown request");
+ }
+ qWarning( "X Error: %s %d\n"
+ " Extension: %d (%s)\n"
+ " Minor opcode: %d (%s)\n"
+ " Resource id: 0x%lx",
+ errstr, err->error_code,
+ err->request_code,
+ extensionName,
+ err->minor_code,
+ minor_str,
+ err->resourceid );
+ }
+
+ // ### we really should distinguish between severe, non-severe and
+ // ### application specific errors
+
+ return 0;
+}
+
+QXlibScreen::QXlibScreen()
+ : mFormat(QImage::Format_RGB32)
+{
+ char *display_name = getenv("DISPLAY");
+ Display *display = XOpenDisplay(display_name);
+ mDisplay = new QXlibDisplay(display);
+
+
+#ifndef DONT_USE_MIT_SHM
+ Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
+ Q_ASSERT(MIT_SHM_extension_supported == True);
+#endif
+ original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
+
+ if (qgetenv("DO_X_SYNCHRONIZE").toInt())
+ XSynchronize(mDisplay->nativeDisplay(), true);
+
+ mScreen = DefaultScreen(mDisplay->nativeDisplay());
+ XSelectInput(mDisplay->nativeDisplay(),rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
+ int width = DisplayWidth(mDisplay->nativeDisplay(), mScreen);
+ int height = DisplayHeight(mDisplay->nativeDisplay(), mScreen);
+ mGeometry = QRect(0,0,width,height);
+
+ int physicalWidth = DisplayWidthMM(mDisplay->nativeDisplay(), mScreen);
+ int physicalHeight = DisplayHeightMM(mDisplay->nativeDisplay(), mScreen);
+ mPhysicalSize = QSize(physicalWidth,physicalHeight);
+
+ int xSocketNumber = XConnectionNumber(mDisplay->nativeDisplay());
+
+ mDepth = DefaultDepth(mDisplay->nativeDisplay(),mScreen);
+#ifdef MYX11_DEBUG
+ qDebug() << "X socket:"<< xSocketNumber;
+#endif
+ QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this);
+ connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+
+ mCursor = new QXlibCursor(this);
+ mKeyboard = new QXlibKeyboard(this);
+}
+
+QXlibScreen::~QXlibScreen()
+{
+ delete mCursor;
+ delete mDisplay;
+}
+
+Window QXlibScreen::rootWindow()
+{
+ return RootWindow(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::blackPixel()
+{
+ return BlackPixel(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::whitePixel()
+{
+ return WhitePixel(mDisplay->nativeDisplay(), mScreen);
+}
+
+#ifdef KeyPress
+#undef KeyPress
+#endif
+#ifdef KeyRelease
+#undef KeyRelease
+#endif
+
+bool QXlibScreen::handleEvent(XEvent *xe)
+{
+ int quit = false;
+ QXlibWindow *platformWindow = 0;
+ QWidget *widget = QWidget::find(xe->xany.window);
+ if (widget) {
+ platformWindow = static_cast<QXlibWindow *>(widget->platformWindow());
+ }
+
+ Atom wmProtocolsAtom = QXlibStatic::atom(QXlibStatic::WM_PROTOCOLS);
+ Atom wmDeleteWindowAtom = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW);
+ switch (xe->type) {
+
+ case ClientMessage:
+ if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) {
+ Atom a = xe->xclient.data.l[0];
+ if (a == wmDeleteWindowAtom)
+ platformWindow->handleCloseEvent();
+ }
+ break;
+
+ case Expose:
+ if (platformWindow)
+ if (xe->xexpose.count == 0)
+ platformWindow->paintEvent();
+ break;
+ case ConfigureNotify:
+ if (platformWindow)
+ platformWindow->resizeEvent(&xe->xconfigure);
+ break;
+
+ case ButtonPress:
+ if (platformWindow)
+ platformWindow->mousePressEvent(&xe->xbutton);
+ break;
+
+ case ButtonRelease:
+ if (platformWindow)
+ platformWindow->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton);
+ break;
+
+ case MotionNotify:
+ if (platformWindow)
+ platformWindow->handleMouseEvent(QEvent::MouseMove, &xe->xbutton);
+ break;
+
+ case XKeyPress:
+ mKeyboard->handleKeyEvent(widget,QEvent::KeyPress, &xe->xkey);
+ break;
+
+ case XKeyRelease:
+ mKeyboard->handleKeyEvent(widget,QEvent::KeyRelease, &xe->xkey);
+ break;
+
+ case EnterNotify:
+ if (platformWindow)
+ platformWindow->handleEnterEvent();
+ break;
+
+ case LeaveNotify:
+ if (platformWindow)
+ platformWindow->handleLeaveEvent();
+ break;
+
+ case XFocusIn:
+ if (platformWindow)
+ platformWindow->handleFocusInEvent();
+ break;
+
+ case XFocusOut:
+ if (platformWindow)
+ platformWindow->handleFocusOutEvent();
+ break;
+
+ case PropertyNotify:
+ break;
+
+ case SelectionClear:
+ qDebug() << "Selection Clear!!!";
+ break;
+ case SelectionRequest:
+ handleSelectionRequest(xe);
+ break;
+ case SelectionNotify:
+ qDebug() << "Selection Notify!!!!";
+
+ break;
+
+
+ default:
+#ifdef MYX11_DEBUG
+ qDebug() << hex << xe->xany.window << "Other X event" << xe->type;
+#endif
+ break;
+ }
+
+ return quit;
+}
+
+static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer)
+{
+ Atom clipboard = QXlibStatic::atom(QXlibStatic::CLIPBOARD);
+ return ((e->type == SelectionRequest && (e->xselectionrequest.selection == XA_PRIMARY
+ || e->xselectionrequest.selection == clipboard))
+ || (e->type == SelectionClear && (e->xselectionclear.selection == XA_PRIMARY
+ || e->xselectionclear.selection == clipboard)));
+}
+
+bool QXlibScreen::waitForClipboardEvent(Window win, int type, XEvent *event, int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ do {
+ if (XCheckTypedWindowEvent(mDisplay->nativeDisplay(),win,type,event))
+ return true;
+
+ // process other clipboard events, since someone is probably requesting data from us
+ XEvent e;
+ if (XCheckIfEvent(mDisplay->nativeDisplay(), &e, checkForClipboardEvents, 0))
+ handleEvent(&e);
+
+ mDisplay->flush();
+
+ // sleep 50 ms, so we don't use up CPU cycles all the time.
+ struct timeval usleep_tv;
+ usleep_tv.tv_sec = 0;
+ usleep_tv.tv_usec = 50000;
+ select(0, 0, 0, 0, &usleep_tv);
+ } while (timer.elapsed() < timeout);
+ return false;
+}
+
+void QXlibScreen::eventDispatcher()
+{
+ ulong marker = XNextRequest(mDisplay->nativeDisplay());
+ // int i = 0;
+ while (XPending(mDisplay->nativeDisplay())) {
+ XEvent event;
+ XNextEvent(mDisplay->nativeDisplay(), &event);
+ /* done = */
+ handleEvent(&event);
+
+ if (event.xany.serial >= marker) {
+ #ifdef MYX11_DEBUG
+ qDebug() << "potential livelock averted";
+ #endif
+ #if 0
+ if (XEventsQueued(mDisplay->nativeDisplay(), QueuedAfterFlush)) {
+ qDebug() << " with events queued";
+ QTimer::singleShot(0, this, SLOT(eventDispatcher()));
+ }
+ #endif
+ break;
+ }
+ }
+}
+
+QImage QXlibScreen::grabWindow(Window window, int x, int y, int w, int h)
+{
+ if (w == 0 || h ==0)
+ return QImage();
+
+ //WinId 0 means the desktop widget
+ if (!window)
+ window = rootWindow();
+
+ XWindowAttributes window_attr;
+ if (!XGetWindowAttributes(mDisplay->nativeDisplay(), window, &window_attr))
+ return QImage();
+
+ if (w < 0)
+ w = window_attr.width - x;
+ if (h < 0)
+ h = window_attr.height - y;
+
+ // Ideally, we should also limit ourselves to the screen area, but the Qt docs say
+ // that it's "unsafe" to go outside the screen, so we can ignore that problem.
+
+ //We're definitely not optimizing for speed...
+ XImage *xi = XGetImage(mDisplay->nativeDisplay(), window, x, y, w, h, AllPlanes, ZPixmap);
+
+ if (!xi)
+ return QImage();
+
+ //taking a copy to make sure we have ownership -- not fast
+ QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy();
+
+ XDestroyImage(xi);
+
+ return result;
+}
+
+QXlibScreen * QXlibScreen::testLiteScreenForWidget(QWidget *widget)
+{
+ QPlatformScreen *platformScreen = platformScreenForWidget(widget);
+ return static_cast<QXlibScreen *>(platformScreen);
+}
+
+QXlibDisplay * QXlibScreen::display() const
+{
+ return mDisplay;
+}
+
+int QXlibScreen::xScreenNumber() const
+{
+ return mScreen;
+}
+
+Visual * QXlibScreen::defaultVisual() const
+{
+ DefaultVisual(display()->nativeDisplay(), xScreenNumber());
+}
+
+QXlibKeyboard * QXlibScreen::keyboard() const
+{
+ return mKeyboard;
+}
+
+void QXlibScreen::handleSelectionRequest(XEvent *event)
+{
+ QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
+ QXlibClipboard *clipboard = static_cast<QXlibClipboard *>(integration->clipboard());
+ clipboard->handleSelectionRequest(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h
new file mode 100644
index 0000000..35c0141
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibscreen.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITESCREEN_H
+#define QTESTLITESCREEN_H
+
+#include <QtGui/QPlatformScreen>
+#include "qxlibintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXlibCursor;
+class QXlibKeyboard;
+class QXlibDisplay;
+
+class QXlibScreen : public QPlatformScreen
+{
+ Q_OBJECT
+public:
+ QXlibScreen();
+
+ ~QXlibScreen();
+
+ QRect geometry() const { return mGeometry; }
+ int depth() const { return mDepth; }
+ QImage::Format format() const { return mFormat; }
+ QSize physicalSize() const { return mPhysicalSize; }
+
+ Window rootWindow();
+ unsigned long blackPixel();
+ unsigned long whitePixel();
+
+ bool handleEvent(XEvent *xe);
+ bool waitForClipboardEvent(Window win, int type, XEvent *event, int timeout);
+
+ QImage grabWindow(Window window, int x, int y, int w, int h);
+
+ static QXlibScreen *testLiteScreenForWidget(QWidget *widget);
+
+ QXlibDisplay *display() const;
+ int xScreenNumber() const;
+
+ Visual *defaultVisual() const;
+
+ QXlibKeyboard *keyboard() const;
+
+public slots:
+ void eventDispatcher();
+
+private:
+
+ void handleSelectionRequest(XEvent *event);
+ QRect mGeometry;
+ QSize mPhysicalSize;
+ int mDepth;
+ QImage::Format mFormat;
+ QXlibCursor *mCursor;
+ QXlibKeyboard *mKeyboard;
+
+ QXlibDisplay * mDisplay;
+ int mScreen;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTESTLITESCREEN_H
diff --git a/src/plugins/platforms/xlib/qxlibstatic.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp
new file mode 100644
index 0000000..6117781
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibstatic.cpp
@@ -0,0 +1,512 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibstatic.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
+
+#include <qplatformdefs.h>
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtCore/QBuffer>
+#include <QtCore/QLibrary>
+
+#include <QDebug>
+
+#ifndef QT_NO_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif // QT_NO_XFIXES
+
+static const char * x11_atomnames = {
+ // window-manager <-> client protocols
+ "WM_PROTOCOLS\0"
+ "WM_DELETE_WINDOW\0"
+ "WM_TAKE_FOCUS\0"
+ "_NET_WM_PING\0"
+ "_NET_WM_CONTEXT_HELP\0"
+ "_NET_WM_SYNC_REQUEST\0"
+ "_NET_WM_SYNC_REQUEST_COUNTER\0"
+
+ // ICCCM window state
+ "WM_STATE\0"
+ "WM_CHANGE_STATE\0"
+
+ // Session management
+ "WM_CLIENT_LEADER\0"
+ "WM_WINDOW_ROLE\0"
+ "SM_CLIENT_ID\0"
+
+ // Clipboard
+ "CLIPBOARD\0"
+ "INCR\0"
+ "TARGETS\0"
+ "MULTIPLE\0"
+ "TIMESTAMP\0"
+ "SAVE_TARGETS\0"
+ "CLIP_TEMPORARY\0"
+ "_QT_SELECTION\0"
+ "_QT_CLIPBOARD_SENTINEL\0"
+ "_QT_SELECTION_SENTINEL\0"
+ "CLIPBOARD_MANAGER\0"
+
+ "RESOURCE_MANAGER\0"
+
+ "_XSETROOT_ID\0"
+
+ "_QT_SCROLL_DONE\0"
+ "_QT_INPUT_ENCODING\0"
+
+ "_MOTIF_WM_HINTS\0"
+
+ "DTWM_IS_RUNNING\0"
+ "ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
+ "_SGI_DESKS_MANAGER\0"
+
+ // EWMH (aka NETWM)
+ "_NET_SUPPORTED\0"
+ "_NET_VIRTUAL_ROOTS\0"
+ "_NET_WORKAREA\0"
+
+ "_NET_MOVERESIZE_WINDOW\0"
+ "_NET_WM_MOVERESIZE\0"
+
+ "_NET_WM_NAME\0"
+ "_NET_WM_ICON_NAME\0"
+ "_NET_WM_ICON\0"
+
+ "_NET_WM_PID\0"
+
+ "_NET_WM_WINDOW_OPACITY\0"
+
+ "_NET_WM_STATE\0"
+ "_NET_WM_STATE_ABOVE\0"
+ "_NET_WM_STATE_BELOW\0"
+ "_NET_WM_STATE_FULLSCREEN\0"
+ "_NET_WM_STATE_MAXIMIZED_HORZ\0"
+ "_NET_WM_STATE_MAXIMIZED_VERT\0"
+ "_NET_WM_STATE_MODAL\0"
+ "_NET_WM_STATE_STAYS_ON_TOP\0"
+ "_NET_WM_STATE_DEMANDS_ATTENTION\0"
+
+ "_NET_WM_USER_TIME\0"
+ "_NET_WM_USER_TIME_WINDOW\0"
+ "_NET_WM_FULL_PLACEMENT\0"
+
+ "_NET_WM_WINDOW_TYPE\0"
+ "_NET_WM_WINDOW_TYPE_DESKTOP\0"
+ "_NET_WM_WINDOW_TYPE_DOCK\0"
+ "_NET_WM_WINDOW_TYPE_TOOLBAR\0"
+ "_NET_WM_WINDOW_TYPE_MENU\0"
+ "_NET_WM_WINDOW_TYPE_UTILITY\0"
+ "_NET_WM_WINDOW_TYPE_SPLASH\0"
+ "_NET_WM_WINDOW_TYPE_DIALOG\0"
+ "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU\0"
+ "_NET_WM_WINDOW_TYPE_POPUP_MENU\0"
+ "_NET_WM_WINDOW_TYPE_TOOLTIP\0"
+ "_NET_WM_WINDOW_TYPE_NOTIFICATION\0"
+ "_NET_WM_WINDOW_TYPE_COMBO\0"
+ "_NET_WM_WINDOW_TYPE_DND\0"
+ "_NET_WM_WINDOW_TYPE_NORMAL\0"
+ "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE\0"
+
+ "_KDE_NET_WM_FRAME_STRUT\0"
+
+ "_NET_STARTUP_INFO\0"
+ "_NET_STARTUP_INFO_BEGIN\0"
+
+ "_NET_SUPPORTING_WM_CHECK\0"
+
+ "_NET_WM_CM_S0\0"
+
+ "_NET_SYSTEM_TRAY_VISUAL\0"
+
+ "_NET_ACTIVE_WINDOW\0"
+
+ // Property formats
+ "COMPOUND_TEXT\0"
+ "TEXT\0"
+ "UTF8_STRING\0"
+
+ // xdnd
+ "XdndEnter\0"
+ "XdndPosition\0"
+ "XdndStatus\0"
+ "XdndLeave\0"
+ "XdndDrop\0"
+ "XdndFinished\0"
+ "XdndTypeList\0"
+ "XdndActionList\0"
+
+ "XdndSelection\0"
+
+ "XdndAware\0"
+ "XdndProxy\0"
+
+ "XdndActionCopy\0"
+ "XdndActionLink\0"
+ "XdndActionMove\0"
+ "XdndActionPrivate\0"
+
+ // Motif DND
+ "_MOTIF_DRAG_AND_DROP_MESSAGE\0"
+ "_MOTIF_DRAG_INITIATOR_INFO\0"
+ "_MOTIF_DRAG_RECEIVER_INFO\0"
+ "_MOTIF_DRAG_WINDOW\0"
+ "_MOTIF_DRAG_TARGETS\0"
+
+ "XmTRANSFER_SUCCESS\0"
+ "XmTRANSFER_FAILURE\0"
+
+ // Xkb
+ "_XKB_RULES_NAMES\0"
+
+ // XEMBED
+ "_XEMBED\0"
+ "_XEMBED_INFO\0"
+
+ // Wacom old. (before version 0.10)
+ "Wacom Stylus\0"
+ "Wacom Cursor\0"
+ "Wacom Eraser\0"
+
+ // Tablet
+ "STYLUS\0"
+ "ERASER\0"
+};
+
+/*!
+ \internal
+ Try to resolve a \a symbol from \a library with the version specified
+ by \a vernum.
+
+ Note that, in the case of the Xfixes library, \a vernum is not the same as
+ \c XFIXES_MAJOR - it is a part of soname and may differ from the Xfixes
+ version.
+*/
+static void* qt_load_library_runtime(const char *library, int vernum,
+ int highestVernum, const char *symbol)
+{
+ QList<int> versions;
+ // we try to load in the following order:
+ // explicit version -> the default one -> (from the highest (highestVernum) to the lowest (vernum) )
+ if (vernum != -1)
+ versions << vernum;
+ versions << -1;
+ if (vernum != -1) {
+ for(int i = highestVernum; i > vernum; --i)
+ versions << i;
+ }
+ Q_FOREACH(int version, versions) {
+ QLatin1String libName(library);
+ QLibrary xfixesLib(libName, version);
+ void *ptr = xfixesLib.resolve(symbol);
+ if (ptr)
+ return ptr;
+ }
+ return 0;
+}
+
+# define XFIXES_LOAD_RUNTIME(vernum, symbol, symbol_type) \
+ (symbol_type)qt_load_library_runtime("libXfixes", vernum, 4, #symbol);
+# define XFIXES_LOAD_V1(symbol) \
+ XFIXES_LOAD_RUNTIME(1, symbol, Ptr##symbol)
+# define XFIXES_LOAD_V2(symbol) \
+ XFIXES_LOAD_RUNTIME(2, symbol, Ptr##symbol)
+
+
+class QTestLiteStaticInfoPrivate
+{
+public:
+ QTestLiteStaticInfoPrivate()
+ : use_xfixes(false)
+ , xfixes_major(0)
+ , xfixes_eventbase(0)
+ , xfixes_errorbase(0)
+ {
+ QXlibScreen *screen = qobject_cast<QXlibScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
+ Q_ASSERT(screen);
+
+ initializeAllAtoms(screen);
+ initializeSupportedAtoms(screen);
+
+ resolveXFixes(screen);
+ }
+
+ bool isSupportedByWM(Atom atom)
+ {
+ if (!m_supportedAtoms)
+ return false;
+
+ bool supported = false;
+ int i = 0;
+ while (m_supportedAtoms[i] != 0) {
+ if (m_supportedAtoms[i++] == atom) {
+ supported = true;
+ break;
+ }
+ }
+
+ return supported;
+ }
+
+ Atom atom(QXlibStatic::X11Atom atom)
+ {
+ return m_allAtoms[atom];
+ }
+
+ bool useXFixes() const { return use_xfixes; }
+
+ int xFixesEventBase() const {return xfixes_eventbase; }
+
+ PtrXFixesSelectSelectionInput xFixesSelectSelectionInput() const
+ {
+ return ptrXFixesSelectSelectionInput;
+ }
+
+ QImage qimageFromXImage(XImage *xi)
+ {
+ QImage::Format format = QImage::Format_ARGB32_Premultiplied;
+ if (xi->depth == 24)
+ format = QImage::Format_RGB32;
+ else if (xi->depth == 16)
+ format = QImage::Format_RGB16;
+
+ QImage image = QImage((uchar *)xi->data, xi->width, xi->height, xi->bytes_per_line, format).copy();
+
+ // we may have to swap the byte order
+ if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst)
+ || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst))
+ {
+ for (int i=0; i < image.height(); i++) {
+ if (xi->depth == 16) {
+ ushort *p = (ushort*)image.scanLine(i);
+ ushort *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
+ p++;
+ }
+ } else {
+ uint *p = (uint*)image.scanLine(i);
+ uint *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
+ | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
+ p++;
+ }
+ }
+ }
+ }
+
+ // fix-up alpha channel
+ if (format == QImage::Format_RGB32) {
+ QRgb *p = (QRgb *)image.bits();
+ for (int y = 0; y < xi->height; ++y) {
+ for (int x = 0; x < xi->width; ++x)
+ p[x] |= 0xff000000;
+ p += xi->bytes_per_line / 4;
+ }
+ }
+
+ return image;
+ }
+
+
+private:
+
+ void initializeAllAtoms(QXlibScreen *screen) {
+ const char *names[QXlibStatic::NAtoms];
+ const char *ptr = x11_atomnames;
+
+ int i = 0;
+ while (*ptr) {
+ names[i++] = ptr;
+ while (*ptr)
+ ++ptr;
+ ++ptr;
+ }
+
+ Q_ASSERT(i == QXlibStatic::NPredefinedAtoms);
+
+ QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
+ settings_atom_name += XDisplayName(qPrintable(screen->display()->displayName()));
+ names[i++] = settings_atom_name;
+
+ Q_ASSERT(i == QXlibStatic::NAtoms);
+ #if 0//defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6)
+ XInternAtoms(screen->display(), (char **)names, i, False, m_allAtoms);
+ #else
+ for (i = 0; i < QXlibStatic::NAtoms; ++i)
+ m_allAtoms[i] = XInternAtom(screen->display()->nativeDisplay(), (char *)names[i], False);
+ #endif
+ }
+
+ void initializeSupportedAtoms(QXlibScreen *screen)
+ {
+ Atom type;
+ int format;
+ long offset = 0;
+ unsigned long nitems, after;
+ unsigned char *data = 0;
+
+ int e = XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
+ this->atom(QXlibStatic::_NET_SUPPORTED), 0, 0,
+ False, XA_ATOM, &type, &format, &nitems, &after, &data);
+ if (data)
+ XFree(data);
+
+ if (e == Success && type == XA_ATOM && format == 32) {
+ QBuffer ts;
+ ts.open(QIODevice::WriteOnly);
+
+ while (after > 0) {
+ XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
+ this->atom(QXlibStatic::_NET_SUPPORTED), offset, 1024,
+ False, XA_ATOM, &type, &format, &nitems, &after, &data);
+
+ if (type == XA_ATOM && format == 32) {
+ ts.write(reinterpret_cast<char *>(data), nitems * sizeof(long));
+ offset += nitems;
+ } else
+ after = 0;
+ if (data)
+ XFree(data);
+ }
+
+ // compute nitems
+ QByteArray buffer(ts.buffer());
+ nitems = buffer.size() / sizeof(Atom);
+ m_supportedAtoms = new Atom[nitems + 1];
+ Atom *a = (Atom *) buffer.data();
+ uint i;
+ for (i = 0; i < nitems; i++)
+ m_supportedAtoms[i] = a[i];
+ m_supportedAtoms[nitems] = 0;
+
+ }
+ }
+
+ void resolveXFixes(QXlibScreen *screen)
+ {
+#ifndef QT_NO_XFIXES
+ // See if Xfixes is supported on the connected display
+ if (XQueryExtension(screen->display()->nativeDisplay(), "XFIXES", &xfixes_major,
+ &xfixes_eventbase, &xfixes_errorbase)) {
+ ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
+ ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
+ ptrXFixesSetCursorName = XFIXES_LOAD_V2(XFixesSetCursorName);
+ ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
+
+ if(ptrXFixesQueryExtension && ptrXFixesQueryVersion
+ && ptrXFixesQueryExtension(screen->display()->nativeDisplay(), &xfixes_eventbase,
+ &xfixes_errorbase)) {
+ // Xfixes is supported.
+ // Note: the XFixes protocol version is negotiated using QueryVersion.
+ // We supply the highest version we support, the X server replies with
+ // the highest version it supports, but no higher than the version we
+ // asked for. The version sent back is the protocol version the X server
+ // will use to talk us. If this call is removed, the behavior of the
+ // X server when it receives an XFixes request is undefined.
+ int major = 3;
+ int minor = 0;
+ ptrXFixesQueryVersion(screen->display()->nativeDisplay(), &major, &minor);
+ use_xfixes = (major >= 1);
+ xfixes_major = major;
+ }
+ }
+#endif // QT_NO_XFIXES
+
+ }
+
+ Atom *m_supportedAtoms;
+ Atom m_allAtoms[QXlibStatic::NAtoms];
+
+#ifndef QT_NO_XFIXES
+ PtrXFixesQueryExtension ptrXFixesQueryExtension;
+ PtrXFixesQueryVersion ptrXFixesQueryVersion;
+ PtrXFixesSetCursorName ptrXFixesSetCursorName;
+ PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput;
+#endif
+
+ bool use_xfixes;
+ int xfixes_major;
+ int xfixes_eventbase;
+ int xfixes_errorbase;
+
+};
+Q_GLOBAL_STATIC(QTestLiteStaticInfoPrivate, qTestLiteStaticInfoPrivate);
+
+
+Atom QXlibStatic::atom(QXlibStatic::X11Atom atom)
+{
+ return qTestLiteStaticInfoPrivate()->atom(atom);
+}
+
+bool QXlibStatic::isSupportedByWM(Atom atom)
+{
+ return qTestLiteStaticInfoPrivate()->isSupportedByWM(atom);
+}
+
+bool QXlibStatic::useXFixes()
+{
+ return qTestLiteStaticInfoPrivate()->useXFixes();
+}
+
+int QXlibStatic::xFixesEventBase()
+{
+ return qTestLiteStaticInfoPrivate()->xFixesEventBase();
+}
+
+#ifndef QT_NO_XFIXES
+PtrXFixesSelectSelectionInput QXlibStatic::xFixesSelectSelectionInput()
+{
+ qDebug() << qTestLiteStaticInfoPrivate()->useXFixes();
+ if (!qTestLiteStaticInfoPrivate()->useXFixes())
+ return 0;
+
+ return qTestLiteStaticInfoPrivate()->xFixesSelectSelectionInput();
+}
+
+QImage QXlibStatic::qimageFromXImage(XImage *xi)
+{
+ return qTestLiteStaticInfoPrivate()->qimageFromXImage(xi);
+}
+#endif //QT_NO_XFIXES
diff --git a/src/plugins/platforms/xlib/qxlibstatic.h b/src/plugins/platforms/xlib/qxlibstatic.h
new file mode 100644
index 0000000..72cfaec
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibstatic.h
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITESTATICINFO_H
+#define QTESTLITESTATICINFO_H
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+
+#if defined(_XLIB_H_) // crude hack, but...
+#error "cannot include <X11/Xlib.h> before this file"
+#endif
+#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
+#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
+#define XSetIMValues qt_XSetIMValues
+#include <X11/Xlib.h>
+#undef XRegisterIMInstantiateCallback
+#undef XUnregisterIMInstantiateCallback
+#undef XSetIMValues
+
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#ifdef index
+# undef index
+#endif
+#ifdef rindex
+# undef rindex
+#endif
+#ifdef Q_OS_VXWORS
+# ifdef open
+# undef open
+# endif
+# ifdef getpid
+# undef getpid
+# endif
+#endif // Q_OS_VXWORKS
+#include <X11/Xatom.h>
+
+//#define QT_NO_SHAPE
+#ifdef QT_NO_SHAPE
+# define XShapeCombineRegion(a,b,c,d,e,f,g)
+# define XShapeCombineMask(a,b,c,d,e,f,g)
+#else
+# include <X11/extensions/shape.h>
+#endif // QT_NO_SHAPE
+
+
+#if !defined (QT_NO_TABLET)
+# include <X11/extensions/XInput.h>
+#if defined (Q_OS_IRIX)
+# include <X11/extensions/SGIMisc.h>
+# include <wacom.h>
+#endif
+#endif // QT_NO_TABLET
+
+
+// #define QT_NO_XINERAMA
+#ifndef QT_NO_XINERAMA
+// XFree86 does not C++ify Xinerama (at least up to XFree86 4.0.3).
+extern "C" {
+# include <X11/extensions/Xinerama.h>
+}
+#endif // QT_NO_XINERAMA
+
+// #define QT_NO_XRANDR
+#ifndef QT_NO_XRANDR
+# include <X11/extensions/Xrandr.h>
+#endif // QT_NO_XRANDR
+
+// #define QT_NO_XRENDER
+#ifndef QT_NO_XRENDER
+# include <X11/extensions/Xrender.h>
+#endif // QT_NO_XRENDER
+
+#ifndef QT_NO_XSYNC
+extern "C" {
+# include "X11/extensions/sync.h"
+}
+#endif
+
+// #define QT_NO_XKB
+#ifndef QT_NO_XKB
+# include <X11/XKBlib.h>
+#endif // QT_NO_XKB
+
+
+#if !defined(XlibSpecificationRelease)
+# define X11R4
+typedef char *XPointer;
+#else
+# undef X11R4
+#endif
+
+#ifndef QT_NO_XFIXES
+typedef Bool (*PtrXFixesQueryExtension)(Display *, int *, int *);
+typedef Status (*PtrXFixesQueryVersion)(Display *, int *, int *);
+typedef void (*PtrXFixesSetCursorName)(Display *dpy, Cursor cursor, const char *name);
+typedef void (*PtrXFixesSelectSelectionInput)(Display *dpy, Window win, Atom selection, unsigned long eventMask);
+#endif // QT_NO_XFIXES
+
+#ifndef QT_NO_XCURSOR
+#include <X11/Xcursor/Xcursor.h>
+typedef Cursor (*PtrXcursorLibraryLoadCursor)(Display *, const char *);
+#endif // QT_NO_XCURSOR
+
+#ifndef QT_NO_XINERAMA
+typedef Bool (*PtrXineramaQueryExtension)(Display *dpy, int *event_base, int *error_base);
+typedef Bool (*PtrXineramaIsActive)(Display *dpy);
+typedef XineramaScreenInfo *(*PtrXineramaQueryScreens)(Display *dpy, int *number);
+#endif // QT_NO_XINERAMA
+
+#ifndef QT_NO_XRANDR
+typedef void (*PtrXRRSelectInput)(Display *, Window, int);
+typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
+typedef int (*PtrXRRRootToScreen)(Display *, Window);
+typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
+#endif // QT_NO_XRANDR
+
+#ifndef QT_NO_XINPUT
+typedef int (*PtrXCloseDevice)(Display *, XDevice *);
+typedef XDeviceInfo* (*PtrXListInputDevices)(Display *, int *);
+typedef XDevice* (*PtrXOpenDevice)(Display *, XID);
+typedef void (*PtrXFreeDeviceList)(XDeviceInfo *);
+typedef int (*PtrXSelectExtensionEvent)(Display *, Window, XEventClass *, int);
+#endif // QT_NO_XINPUT
+
+/*
+ * Solaris patch 108652-47 and higher fixes crases in
+ * XRegisterIMInstantiateCallback, but the function doesn't seem to
+ * work.
+ *
+ * Instead, we disabled R6 input, and open the input method
+ * immediately at application start.
+ */
+
+//######### XFree86 has wrong declarations for XRegisterIMInstantiateCallback
+//######### and XUnregisterIMInstantiateCallback in at least version 3.3.2.
+//######### Many old X11R6 header files lack XSetIMValues.
+//######### Therefore, we have to declare these functions ourselves.
+
+extern "C" Bool XRegisterIMInstantiateCallback(
+ Display*,
+ struct _XrmHashBucketRec*,
+ char*,
+ char*,
+ XIMProc, //XFree86 has XIDProc, which has to be wrong
+ XPointer
+);
+
+extern "C" Bool XUnregisterIMInstantiateCallback(
+ Display*,
+ struct _XrmHashBucketRec*,
+ char*,
+ char*,
+ XIMProc, //XFree86 has XIDProc, which has to be wrong
+ XPointer
+);
+
+#ifndef X11R4
+# include <X11/Xlocale.h>
+#endif // X11R4
+
+
+#ifndef QT_NO_MITSHM
+# include <X11/extensions/XShm.h>
+#endif // QT_NO_MITSHM
+
+// rename a couple of X defines to get rid of name clashes
+// resolve the conflict between X11's FocusIn and QEvent::FocusIn
+enum {
+ XFocusOut = FocusOut,
+ XFocusIn = FocusIn,
+ XKeyPress = KeyPress,
+ XKeyRelease = KeyRelease,
+ XNone = None,
+ XRevertToParent = RevertToParent,
+ XGrayScale = GrayScale,
+ XCursorShape = CursorShape
+};
+#undef FocusOut
+#undef FocusIn
+#undef KeyPress
+#undef KeyRelease
+#undef None
+#undef RevertToParent
+#undef GrayScale
+#undef CursorShape
+
+#ifdef FontChange
+#undef FontChange
+#endif
+
+
+class QXlibStatic
+{
+public:
+ enum X11Atom {
+ // window-manager <-> client protocols
+ WM_PROTOCOLS,
+ WM_DELETE_WINDOW,
+ WM_TAKE_FOCUS,
+ _NET_WM_PING,
+ _NET_WM_CONTEXT_HELP,
+ _NET_WM_SYNC_REQUEST,
+ _NET_WM_SYNC_REQUEST_COUNTER,
+
+ // ICCCM window state
+ WM_STATE,
+ WM_CHANGE_STATE,
+
+ // Session management
+ WM_CLIENT_LEADER,
+ WM_WINDOW_ROLE,
+ SM_CLIENT_ID,
+
+ // Clipboard
+ CLIPBOARD,
+ INCR,
+ TARGETS,
+ MULTIPLE,
+ TIMESTAMP,
+ SAVE_TARGETS,
+ CLIP_TEMPORARY,
+ _QT_SELECTION,
+ _QT_CLIPBOARD_SENTINEL,
+ _QT_SELECTION_SENTINEL,
+ CLIPBOARD_MANAGER,
+
+ RESOURCE_MANAGER,
+
+ _XSETROOT_ID,
+
+ _QT_SCROLL_DONE,
+ _QT_INPUT_ENCODING,
+
+ _MOTIF_WM_HINTS,
+
+ DTWM_IS_RUNNING,
+ ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
+ _SGI_DESKS_MANAGER,
+
+ // EWMH (aka NETWM)
+ _NET_SUPPORTED,
+ _NET_VIRTUAL_ROOTS,
+ _NET_WORKAREA,
+
+ _NET_MOVERESIZE_WINDOW,
+ _NET_WM_MOVERESIZE,
+
+ _NET_WM_NAME,
+ _NET_WM_ICON_NAME,
+ _NET_WM_ICON,
+
+ _NET_WM_PID,
+
+ _NET_WM_WINDOW_OPACITY,
+
+ _NET_WM_STATE,
+ _NET_WM_STATE_ABOVE,
+ _NET_WM_STATE_BELOW,
+ _NET_WM_STATE_FULLSCREEN,
+ _NET_WM_STATE_MAXIMIZED_HORZ,
+ _NET_WM_STATE_MAXIMIZED_VERT,
+ _NET_WM_STATE_MODAL,
+ _NET_WM_STATE_STAYS_ON_TOP,
+ _NET_WM_STATE_DEMANDS_ATTENTION,
+
+ _NET_WM_USER_TIME,
+ _NET_WM_USER_TIME_WINDOW,
+ _NET_WM_FULL_PLACEMENT,
+
+ _NET_WM_WINDOW_TYPE,
+ _NET_WM_WINDOW_TYPE_DESKTOP,
+ _NET_WM_WINDOW_TYPE_DOCK,
+ _NET_WM_WINDOW_TYPE_TOOLBAR,
+ _NET_WM_WINDOW_TYPE_MENU,
+ _NET_WM_WINDOW_TYPE_UTILITY,
+ _NET_WM_WINDOW_TYPE_SPLASH,
+ _NET_WM_WINDOW_TYPE_DIALOG,
+ _NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+ _NET_WM_WINDOW_TYPE_POPUP_MENU,
+ _NET_WM_WINDOW_TYPE_TOOLTIP,
+ _NET_WM_WINDOW_TYPE_NOTIFICATION,
+ _NET_WM_WINDOW_TYPE_COMBO,
+ _NET_WM_WINDOW_TYPE_DND,
+ _NET_WM_WINDOW_TYPE_NORMAL,
+ _KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
+
+ _KDE_NET_WM_FRAME_STRUT,
+
+ _NET_STARTUP_INFO,
+ _NET_STARTUP_INFO_BEGIN,
+
+ _NET_SUPPORTING_WM_CHECK,
+
+ _NET_WM_CM_S0,
+
+ _NET_SYSTEM_TRAY_VISUAL,
+
+ _NET_ACTIVE_WINDOW,
+
+ // Property formats
+ COMPOUND_TEXT,
+ TEXT,
+ UTF8_STRING,
+
+ // Xdnd
+ XdndEnter,
+ XdndPosition,
+ XdndStatus,
+ XdndLeave,
+ XdndDrop,
+ XdndFinished,
+ XdndTypelist,
+ XdndActionList,
+
+ XdndSelection,
+
+ XdndAware,
+ XdndProxy,
+
+ XdndActionCopy,
+ XdndActionLink,
+ XdndActionMove,
+ XdndActionPrivate,
+
+ // Motif DND
+ _MOTIF_DRAG_AND_DROP_MESSAGE,
+ _MOTIF_DRAG_INITIATOR_INFO,
+ _MOTIF_DRAG_RECEIVER_INFO,
+ _MOTIF_DRAG_WINDOW,
+ _MOTIF_DRAG_TARGETS,
+
+ XmTRANSFER_SUCCESS,
+ XmTRANSFER_FAILURE,
+
+ // Xkb
+ _XKB_RULES_NAMES,
+
+ // XEMBED
+ _XEMBED,
+ _XEMBED_INFO,
+
+ XWacomStylus,
+ XWacomCursor,
+ XWacomEraser,
+
+ XTabletStylus,
+ XTabletEraser,
+
+ NPredefinedAtoms,
+
+ _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
+ NAtoms
+ };
+
+ static Atom atom(X11Atom atom);
+ static bool isSupportedByWM(Atom atom);
+
+ static bool useXFixes();
+ static int xFixesEventBase();
+
+ #ifndef QT_NO_XFIXES
+ static PtrXFixesSelectSelectionInput xFixesSelectSelectionInput();
+ #endif //QT_NO_XFIXES
+
+ static QImage qimageFromXImage(XImage *xi);
+
+
+};
+
+#endif // QTESTLITESTATICINFO_H
diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp
new file mode 100644
index 0000000..a7bc53c
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibwindow.cpp
@@ -0,0 +1,736 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibwindow.h"
+
+#include "qxlibintegration.h"
+#include "qxlibscreen.h"
+#include "qxlibkeyboard.h"
+#include "qxlibstatic.h"
+#include "qxlibdisplay.h"
+
+#include <QtGui/QWindowSystemInterface>
+#include <QSocketNotifier>
+#include <QApplication>
+#include <QDebug>
+
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qapplication_p.h>
+
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+#include "qglxintegration.h"
+#else
+#include "../eglconvenience/qeglconvenience.h"
+#include "../eglconvenience/qeglplatformcontext.h"
+#include "../eglconvenience/qxlibeglintegration.h"
+#endif //QT_OPENGL_ES_2
+#endif //QT_NO_OPENGL
+
+//#define MYX11_DEBUG
+
+QT_BEGIN_NAMESPACE
+
+QXlibWindow::QXlibWindow(QWidget *window)
+ : QPlatformWindow(window)
+ , mGLContext(0)
+ , mScreen(QXlibScreen::testLiteScreenForWidget(window))
+{
+ int x = window->x();
+ int y = window->y();
+ int w = window->width();
+ int h = window->height();
+
+ if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ && QApplicationPrivate::platformIntegration()->hasOpenGL() ) {
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat());
+#else
+ QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
+
+ EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay());
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+#endif //!defined(QT_OPENGL_ES_2)
+ if (visualInfo) {
+ Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+ } else {
+ qFatal("no window!");
+ }
+#endif //!defined(QT_NO_OPENGL)
+ } else {
+ x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ mScreen->blackPixel(), mScreen->whitePixel());
+ }
+
+#ifdef MYX11_DEBUG
+ qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
+#endif
+
+ XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone);
+
+ XSelectInput(mScreen->display()->nativeDisplay(), x_window,
+ ExposureMask | KeyPressMask | KeyReleaseMask |
+ EnterWindowMask | LeaveWindowMask | FocusChangeMask |
+ PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
+ ButtonMotionMask | PropertyChangeMask |
+ StructureNotifyMask);
+
+ gc = createGC();
+
+ Atom protocols[5];
+ int n = 0;
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol
+#ifndef QT_NO_XSYNC
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol
+#endif // QT_NO_XSYNC
+ if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
+ XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
+}
+
+
+
+QXlibWindow::~QXlibWindow()
+{
+#ifdef MYX11_DEBUG
+ qDebug() << "~QTestLiteWindow" << hex << x_window;
+#endif
+ delete mGLContext;
+ XFreeGC(mScreen->display()->nativeDisplay(), gc);
+ XDestroyWindow(mScreen->display()->nativeDisplay(), x_window);
+}
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// Mouse event stuff
+static Qt::MouseButtons translateMouseButtons(int s)
+{
+ Qt::MouseButtons ret = 0;
+ if (s & Button1Mask)
+ ret |= Qt::LeftButton;
+ if (s & Button2Mask)
+ ret |= Qt::MidButton;
+ if (s & Button3Mask)
+ ret |= Qt::RightButton;
+ return ret;
+}
+
+
+
+void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
+{
+ static QPoint mousePoint;
+
+ Qt::MouseButton button = Qt::NoButton;
+ Qt::MouseButtons buttons = translateMouseButtons(e->state);
+ Qt::KeyboardModifiers modifiers = mScreen->keyboard()->translateModifiers(e->state);
+ if (type != QEvent::MouseMove) {
+ switch (e->button) {
+ case Button1: button = Qt::LeftButton; break;
+ case Button2: button = Qt::MidButton; break;
+ case Button3: button = Qt::RightButton; break;
+ case Button4:
+ case Button5:
+ case 6:
+ case 7: {
+ //mouse wheel
+ if (type == QEvent::MouseButtonPress) {
+ //logic borrowed from qapplication_x11.cpp
+ int delta = 120 * ((e->button == Button4 || e->button == 6) ? 1 : -1);
+ bool hor = (((e->button == Button4 || e->button == Button5)
+ && (modifiers & Qt::AltModifier))
+ || (e->button == 6 || e->button == 7));
+ QWindowSystemInterface::handleWheelEvent(widget(), e->time,
+ QPoint(e->x, e->y),
+ QPoint(e->x_root, e->y_root),
+ delta, hor ? Qt::Horizontal : Qt::Vertical);
+ }
+ return;
+ }
+ default: break;
+ }
+ }
+
+ buttons ^= button; // X event uses state *before*, Qt uses state *after*
+
+ QWindowSystemInterface::handleMouseEvent(widget(), e->time, QPoint(e->x, e->y),
+ QPoint(e->x_root, e->y_root),
+ buttons);
+
+ mousePoint = QPoint(e->x_root, e->y_root);
+}
+
+void QXlibWindow::handleCloseEvent()
+{
+ QWindowSystemInterface::handleCloseEvent(widget());
+}
+
+
+void QXlibWindow::handleEnterEvent()
+{
+ QWindowSystemInterface::handleEnterEvent(widget());
+}
+
+void QXlibWindow::handleLeaveEvent()
+{
+ QWindowSystemInterface::handleLeaveEvent(widget());
+}
+
+void QXlibWindow::handleFocusInEvent()
+{
+ QWindowSystemInterface::handleWindowActivated(widget());
+}
+
+void QXlibWindow::handleFocusOutEvent()
+{
+ QWindowSystemInterface::handleWindowActivated(0);
+}
+
+
+
+void QXlibWindow::setGeometry(const QRect &rect)
+{
+ XMoveResizeWindow(mScreen->display()->nativeDisplay(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
+ QPlatformWindow::setGeometry(rect);
+}
+
+
+Qt::WindowFlags QXlibWindow::windowFlags() const
+{
+ return mWindowFlags;
+}
+
+WId QXlibWindow::winId() const
+{
+ return x_window;
+}
+
+void QXlibWindow::setParent(const QPlatformWindow *window)
+{
+ QPoint topLeft = geometry().topLeft();
+ XReparentWindow(mScreen->display()->nativeDisplay(),x_window,window->winId(),topLeft.x(),topLeft.y());
+}
+
+void QXlibWindow::raise()
+{
+ XRaiseWindow(mScreen->display()->nativeDisplay(), x_window);
+}
+
+void QXlibWindow::lower()
+{
+ XLowerWindow(mScreen->display()->nativeDisplay(), x_window);
+}
+
+void QXlibWindow::setWindowTitle(const QString &title)
+{
+ QByteArray ba = title.toLatin1(); //We're not making a general solution here...
+ XTextProperty windowName;
+ windowName.value = (unsigned char *)ba.constData();
+ windowName.encoding = XA_STRING;
+ windowName.format = 8;
+ windowName.nitems = ba.length();
+
+ XSetWMName(mScreen->display()->nativeDisplay(), x_window, &windowName);
+}
+
+GC QXlibWindow::createGC()
+{
+ GC gc;
+
+ gc = XCreateGC(mScreen->display()->nativeDisplay(), x_window, 0, 0);
+ if (gc < 0) {
+ qWarning("QTestLiteWindow::createGC() could not create GC");
+ }
+ return gc;
+}
+
+void QXlibWindow::paintEvent()
+{
+#ifdef MYX11_DEBUG
+// qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted;
+#endif
+
+ if (QWindowSurface *surface = widget()->windowSurface())
+ surface->flush(widget(), widget()->geometry(), QPoint());
+}
+
+void QXlibWindow::requestActivateWindow()
+{
+ XSetInputFocus(mScreen->display()->nativeDisplay(), x_window, XRevertToParent, CurrentTime);
+}
+
+void QXlibWindow::resizeEvent(XConfigureEvent *e)
+{
+ int xpos = geometry().x();
+ int ypos = geometry().y();
+ if ((e->width != geometry().width() || e->height != geometry().height()) && e->x == 0 && e->y == 0) {
+ //qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window;
+ } else {
+ //qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window;
+ xpos = e->x;
+ ypos = e->y;
+ }
+#ifdef MYX11_DEBUG
+ qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height;
+#endif
+
+ QRect newRect(xpos, ypos, e->width, e->height);
+ QWindowSystemInterface::handleGeometryChange(widget(), newRect);
+}
+
+void QXlibWindow::mousePressEvent(XButtonEvent *e)
+{
+ static long prevTime = 0;
+ static Window prevWindow;
+ static int prevX = -999;
+ static int prevY = -999;
+
+ QEvent::Type type = QEvent::MouseButtonPress;
+
+ if (e->window == prevWindow && long(e->time) - prevTime < QApplication::doubleClickInterval()
+ && qAbs(e->x - prevX) < 5 && qAbs(e->y - prevY) < 5) {
+ type = QEvent::MouseButtonDblClick;
+ prevTime = e->time - QApplication::doubleClickInterval(); //no double click next time
+ } else {
+ prevTime = e->time;
+ }
+ prevWindow = e->window;
+ prevX = e->x;
+ prevY = e->y;
+
+ handleMouseEvent(type, e);
+}
+
+QXlibMWMHints QXlibWindow::getMWMHints() const
+{
+ QXlibMWMHints mwmhints;
+
+ Atom type;
+ int format;
+ ulong nitems, bytesLeft;
+ uchar *data = 0;
+ Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
+ if ((XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints, 0, 5, false,
+ atomForMotifWmHints, &type, &format, &nitems, &bytesLeft,
+ &data) == Success)
+ && (type == atomForMotifWmHints
+ && format == 32
+ && nitems >= 5)) {
+ mwmhints = *(reinterpret_cast<QXlibMWMHints *>(data));
+ } else {
+ mwmhints.flags = 0L;
+ mwmhints.functions = MWM_FUNC_ALL;
+ mwmhints.decorations = MWM_DECOR_ALL;
+ mwmhints.input_mode = 0L;
+ mwmhints.status = 0L;
+ }
+
+ if (data)
+ XFree(data);
+
+ return mwmhints;
+}
+
+void QXlibWindow::setMWMHints(const QXlibMWMHints &mwmhints)
+{
+ Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
+ if (mwmhints.flags != 0l) {
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
+ atomForMotifWmHints, atomForMotifWmHints, 32,
+ PropModeReplace, (unsigned char *) &mwmhints, 5);
+ } else {
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints);
+ }
+}
+
+// Returns true if we should set WM_TRANSIENT_FOR on \a w
+static inline bool isTransient(const QWidget *w)
+{
+ return ((w->windowType() == Qt::Dialog
+ || w->windowType() == Qt::Sheet
+ || w->windowType() == Qt::Tool
+ || w->windowType() == Qt::SplashScreen
+ || w->windowType() == Qt::ToolTip
+ || w->windowType() == Qt::Drawer
+ || w->windowType() == Qt::Popup)
+ && !w->testAttribute(Qt::WA_X11BypassTransientForHint));
+}
+
+QVector<Atom> QXlibWindow::getNetWmState() const
+{
+ QVector<Atom> returnValue;
+
+ // Don't read anything, just get the size of the property data
+ Atom actualType;
+ int actualFormat;
+ ulong propertyLength;
+ ulong bytesLeft;
+ uchar *propertyData = 0;
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0, 0,
+ False, XA_ATOM, &actualType, &actualFormat,
+ &propertyLength, &bytesLeft, &propertyData) == Success
+ && actualType == XA_ATOM && actualFormat == 32) {
+ returnValue.resize(bytesLeft / 4);
+ XFree((char*) propertyData);
+
+ // fetch all data
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0,
+ returnValue.size(), False, XA_ATOM, &actualType, &actualFormat,
+ &propertyLength, &bytesLeft, &propertyData) != Success) {
+ returnValue.clear();
+ } else if (propertyLength != (ulong)returnValue.size()) {
+ returnValue.resize(propertyLength);
+ }
+
+ // put it into netWmState
+ if (!returnValue.isEmpty()) {
+ memcpy(returnValue.data(), propertyData, returnValue.size() * sizeof(Atom));
+ }
+ XFree((char*) propertyData);
+ }
+
+ return returnValue;
+}
+
+Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+// Q_ASSERT(flags & Qt::Window);
+ mWindowFlags = flags;
+
+#ifdef MYX11_DEBUG
+ qDebug() << "QTestLiteWindow::setWindowFlags" << hex << x_window << "flags" << flags;
+#endif
+ Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+
+ if (type == Qt::ToolTip)
+ flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
+ if (type == Qt::Popup)
+ flags |= Qt::X11BypassWindowManagerHint;
+
+ bool topLevel = (flags & Qt::Window);
+ bool popup = (type == Qt::Popup);
+ bool dialog = (type == Qt::Dialog
+ || type == Qt::Sheet);
+ bool desktop = (type == Qt::Desktop);
+ bool tool = (type == Qt::Tool || type == Qt::SplashScreen
+ || type == Qt::ToolTip || type == Qt::Drawer);
+
+ Q_UNUSED(topLevel);
+ Q_UNUSED(dialog);
+ Q_UNUSED(desktop);
+
+ bool tooltip = (type == Qt::ToolTip);
+
+ XSetWindowAttributes wsa;
+
+ QXlibMWMHints mwmhints;
+ mwmhints.flags = 0L;
+ mwmhints.functions = 0L;
+ mwmhints.decorations = 0;
+ mwmhints.input_mode = 0L;
+ mwmhints.status = 0L;
+
+
+ ulong wsa_mask = 0;
+ if (type != Qt::SplashScreen) { // && customize) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+
+ bool customize = flags & Qt::CustomizeWindowHint;
+ if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
+ mwmhints.decorations |= MWM_DECOR_BORDER;
+ mwmhints.decorations |= MWM_DECOR_RESIZEH;
+
+ if (flags & Qt::WindowTitleHint)
+ mwmhints.decorations |= MWM_DECOR_TITLE;
+
+ if (flags & Qt::WindowSystemMenuHint)
+ mwmhints.decorations |= MWM_DECOR_MENU;
+
+ if (flags & Qt::WindowMinimizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MINIMIZE;
+ mwmhints.functions |= MWM_FUNC_MINIMIZE;
+ }
+
+ if (flags & Qt::WindowMaximizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
+ mwmhints.functions |= MWM_FUNC_MAXIMIZE;
+ }
+
+ if (flags & Qt::WindowCloseButtonHint)
+ mwmhints.functions |= MWM_FUNC_CLOSE;
+ }
+ } else {
+ // if type == Qt::SplashScreen
+ mwmhints.decorations = MWM_DECOR_ALL;
+ }
+
+ if (tool) {
+ wsa.save_under = True;
+ wsa_mask |= CWSaveUnder;
+ }
+
+ if (flags & Qt::X11BypassWindowManagerHint) {
+ wsa.override_redirect = True;
+ wsa_mask |= CWOverrideRedirect;
+ }
+#if 0
+ if (wsa_mask && initializeWindow) {
+ Q_ASSERT(id);
+ XChangeWindowAttributes(dpy, id, wsa_mask, &wsa);
+ }
+#endif
+ if (mwmhints.functions != 0) {
+ mwmhints.flags |= MWM_HINTS_FUNCTIONS;
+ mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ } else {
+ mwmhints.functions = MWM_FUNC_ALL;
+ }
+
+ if (!(flags & Qt::FramelessWindowHint)
+ && flags & Qt::CustomizeWindowHint
+ && flags & Qt::WindowTitleHint
+ && !(flags &
+ (Qt::WindowMinimizeButtonHint
+ | Qt::WindowMaximizeButtonHint
+ | Qt::WindowCloseButtonHint))) {
+ // a special case - only the titlebar without any button
+ mwmhints.flags = MWM_HINTS_FUNCTIONS;
+ mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ mwmhints.decorations = 0;
+ }
+
+ if (widget()->windowModality() == Qt::WindowModal) {
+ mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
+ } else if (widget()->windowModality() == Qt::ApplicationModal) {
+ mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
+ }
+
+ setMWMHints(mwmhints);
+
+ QVector<Atom> netWmState = getNetWmState();
+
+ if (flags & Qt::WindowStaysOnTopHint) {
+ if (flags & Qt::WindowStaysOnBottomHint)
+ qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE));
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP));
+ } else if (flags & Qt::WindowStaysOnBottomHint) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW));
+ }
+ if (widget()->isFullScreen()) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN));
+ }
+ if (widget()->isMaximized()) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ));
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT));
+ }
+ if (widget()->windowModality() != Qt::NonModal) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL));
+ }
+
+ if (!netWmState.isEmpty()) {
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
+ QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) netWmState.data(), netWmState.size());
+ } else {
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE));
+ }
+
+//##### only if initializeWindow???
+
+ if (popup || tooltip) { // popup widget
+#ifdef MYX11_DEBUG
+ qDebug() << "Doing XChangeWindowAttributes for popup" << wsa.override_redirect;
+#endif
+ // set EWMH window types
+ // setNetWmWindowTypes();
+
+ wsa.override_redirect = True;
+ wsa.save_under = True;
+ XChangeWindowAttributes(mScreen->display()->nativeDisplay(), x_window, CWOverrideRedirect | CWSaveUnder,
+ &wsa);
+ } else {
+#ifdef MYX11_DEBUG
+ qDebug() << "Doing XChangeWindowAttributes for non-popup";
+#endif
+ }
+
+ return flags;
+}
+
+void QXlibWindow::setVisible(bool visible)
+{
+#ifdef MYX11_DEBUG
+ qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window;
+#endif
+ if (isTransient(widget())) {
+ Window parentXWindow = x_window;
+ if (widget()->parentWidget()) {
+ QWidget *widgetParent = widget()->parentWidget()->window();
+ if (widgetParent && widgetParent->platformWindow()) {
+ QXlibWindow *parentWidnow = static_cast<QXlibWindow *>(widgetParent->platformWindow());
+ parentXWindow = parentWidnow->x_window;
+ }
+ }
+ XSetTransientForHint(mScreen->display()->nativeDisplay(),x_window,parentXWindow);
+ }
+
+ if (visible) {
+ //ensure that the window is viewed in correct position.
+ doSizeHints();
+ XMapWindow(mScreen->display()->nativeDisplay(), x_window);
+ } else {
+ XUnmapWindow(mScreen->display()->nativeDisplay(), x_window);
+ }
+}
+
+void QXlibWindow::setCursor(const Cursor &cursor)
+{
+ XDefineCursor(mScreen->display()->nativeDisplay(), x_window, cursor);
+ mScreen->display()->flush();
+}
+
+QPlatformGLContext *QXlibWindow::glContext() const
+{
+ if (!QApplicationPrivate::platformIntegration()->hasOpenGL())
+ return 0;
+ if (!mGLContext) {
+ QXlibWindow *that = const_cast<QXlibWindow *>(this);
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat());
+#else
+ EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay());
+
+ QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
+
+ EGLConfig config = q_configFromQPlatformWindowFormat(display,windowFormat);
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)x_window,0);
+ that->mGLContext = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
+#endif
+#endif
+ }
+ return mGLContext;
+}
+
+Window QXlibWindow::xWindow() const
+{
+ return x_window;
+}
+
+GC QXlibWindow::graphicsContext() const
+{
+ return gc;
+}
+
+void QXlibWindow::doSizeHints()
+{
+ Q_ASSERT(widget()->testAttribute(Qt::WA_WState_Created));
+ XSizeHints s;
+ s.flags = 0;
+ QRect g = geometry();
+ s.x = g.x();
+ s.y = g.y();
+ s.width = g.width();
+ s.height = g.height();
+ s.flags |= USPosition;
+ s.flags |= PPosition;
+ s.flags |= USSize;
+ s.flags |= PSize;
+ s.flags |= PWinGravity;
+ s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
+ XSetWMNormalHints(mScreen->display()->nativeDisplay(), x_window, &s);
+}
+
+QPlatformWindowFormat QXlibWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
+{
+ // I have only tested this setup on a dodgy intel setup, where I didn't use standard libs,
+ // so this might be not what we want to do :)
+ if ( !(platformWindowFormat.redBufferSize() == -1 &&
+ platformWindowFormat.greenBufferSize() == -1 &&
+ platformWindowFormat.blueBufferSize() == -1))
+ return platformWindowFormat;
+
+ QPlatformWindowFormat windowFormat = platformWindowFormat;
+ if (mScreen->depth() == 16) {
+ windowFormat.setRedBufferSize(5);
+ windowFormat.setGreenBufferSize(6);
+ windowFormat.setBlueBufferSize(5);
+ } else {
+ windowFormat.setRedBufferSize(8);
+ windowFormat.setGreenBufferSize(8);
+ windowFormat.setBlueBufferSize(8);
+ }
+
+ return windowFormat;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibwindow.h b/src/plugins/platforms/xlib/qxlibwindow.h
new file mode 100644
index 0000000..08694a5
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibwindow.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEWINDOW_H
+#define QTESTLITEWINDOW_H
+
+#include "qxlibintegration.h"
+
+#include <QPlatformWindow>
+#include <QEvent>
+
+#include <QObject>
+#include <QImage>
+
+struct QXlibMWMHints {
+ ulong flags, functions, decorations;
+ long input_mode;
+ ulong status;
+};
+
+enum {
+ MWM_HINTS_FUNCTIONS = (1L << 0),
+
+ MWM_FUNC_ALL = (1L << 0),
+ MWM_FUNC_RESIZE = (1L << 1),
+ MWM_FUNC_MOVE = (1L << 2),
+ MWM_FUNC_MINIMIZE = (1L << 3),
+ MWM_FUNC_MAXIMIZE = (1L << 4),
+ MWM_FUNC_CLOSE = (1L << 5),
+
+ MWM_HINTS_DECORATIONS = (1L << 1),
+
+ MWM_DECOR_ALL = (1L << 0),
+ MWM_DECOR_BORDER = (1L << 1),
+ MWM_DECOR_RESIZEH = (1L << 2),
+ MWM_DECOR_TITLE = (1L << 3),
+ MWM_DECOR_MENU = (1L << 4),
+ MWM_DECOR_MINIMIZE = (1L << 5),
+ MWM_DECOR_MAXIMIZE = (1L << 6),
+
+ MWM_HINTS_INPUT_MODE = (1L << 2),
+
+ MWM_INPUT_MODELESS = 0L,
+ MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L,
+ MWM_INPUT_FULL_APPLICATION_MODAL = 3L
+};
+
+class QXlibWindow : public QPlatformWindow
+{
+public:
+ QXlibWindow(QWidget *window);
+ ~QXlibWindow();
+
+
+ void mousePressEvent(XButtonEvent*);
+ void handleMouseEvent(QEvent::Type, XButtonEvent *ev);
+
+ void handleCloseEvent();
+ void handleEnterEvent();
+ void handleLeaveEvent();
+ void handleFocusInEvent();
+ void handleFocusOutEvent();
+
+ void resizeEvent(XConfigureEvent *configure_event);
+ void paintEvent();
+
+ void requestActivateWindow();
+
+ void setGeometry(const QRect &rect);
+
+ Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
+ Qt::WindowFlags windowFlags() const;
+ void setVisible(bool visible);
+ WId winId() const;
+ void setParent(const QPlatformWindow *window);
+ void raise();
+ void lower();
+ void setWindowTitle(const QString &title);
+
+ void setCursor(const Cursor &cursor);
+
+ QPlatformGLContext *glContext() const;
+
+ Window xWindow() const;
+ GC graphicsContext() const;
+
+protected:
+ QVector<Atom> getNetWmState() const;
+ void setMWMHints(const QXlibMWMHints &mwmhints);
+ QXlibMWMHints getMWMHints() const;
+
+ void doSizeHints();
+
+private:
+ QPlatformWindowFormat correctColorBuffers(const QPlatformWindowFormat &windowFormat)const;
+
+ Window x_window;
+ GC gc;
+
+ GC createGC();
+
+ QPlatformGLContext *mGLContext;
+ QXlibScreen *mScreen;
+ Qt::WindowFlags mWindowFlags;
+};
+
+#endif
diff --git a/src/plugins/platforms/xlib/qxlibwindowsurface.cpp b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
new file mode 100644
index 0000000..513f10d
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qxlibwindowsurface.h"
+#include "qxlibintegration.h"
+
+#include <QtCore/qdebug.h>
+#include <QWindowSystemInterface>
+
+#include "qxlibwindow.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
+
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <X11/extensions/XShm.h>
+
+QT_BEGIN_NAMESPACE
+
+
+struct QXlibShmImageInfo {
+ QXlibShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {}
+ ~QXlibShmImageInfo() { destroy(); }
+
+ void destroy();
+
+ XShmSegmentInfo shminfo;
+ XImage *image;
+ Display *display;
+};
+
+
+#ifndef DONT_USE_MIT_SHM
+void QXlibShmImageInfo::destroy()
+{
+ XShmDetach (display, &shminfo);
+ XDestroyImage (image);
+ shmdt (shminfo.shmaddr);
+ shmctl (shminfo.shmid, IPC_RMID, 0);
+}
+#endif
+
+void QXlibWindowSurface::resizeShmImage(int width, int height)
+{
+
+#ifdef DONT_USE_MIT_SHM
+ shm_img = QImage(width, height, QImage::Format_RGB32);
+#else
+
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window());
+ if (image_info)
+ image_info->destroy();
+ else
+ image_info = new QXlibShmImageInfo(screen->display()->nativeDisplay());
+
+ Visual *visual = screen->defaultVisual();
+
+ XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), visual, 24, ZPixmap, 0,
+ &image_info->shminfo, width, height);
+
+
+ image_info->shminfo.shmid = shmget (IPC_PRIVATE,
+ image->bytes_per_line * image->height, IPC_CREAT|0777);
+
+ image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0);
+ image_info->shminfo.readOnly = False;
+
+ image_info->image = image;
+
+ Status shm_attach_status = XShmAttach(screen->display()->nativeDisplay(), &image_info->shminfo);
+
+ Q_ASSERT(shm_attach_status == True);
+
+ shm_img = QImage( (uchar*) image->data, image->width, image->height, image->bytes_per_line, QImage::Format_RGB32 );
+#endif
+ painted = false;
+}
+
+
+void QXlibWindowSurface::resizeBuffer(QSize s)
+{
+ if (shm_img.size() != s)
+ resizeShmImage(s.width(), s.height());
+}
+
+QSize QXlibWindowSurface::bufferSize() const
+{
+ return shm_img.size();
+}
+
+QXlibWindowSurface::QXlibWindowSurface (QWidget *window)
+ : QWindowSurface(window),
+ painted(false), image_info(0)
+{
+ xw = static_cast<QXlibWindow*>(window->platformWindow());
+// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window;
+}
+
+QXlibWindowSurface::~QXlibWindowSurface()
+{
+ delete image_info;
+}
+
+QPaintDevice *QXlibWindowSurface::paintDevice()
+{
+ return &shm_img;
+}
+
+
+void QXlibWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ if (!painted)
+ return;
+
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
+ GC gc = xw->graphicsContext();
+ Window window = xw->xWindow();
+#ifdef DONT_USE_MIT_SHM
+ // just convert the image every time...
+ if (!shm_img.isNull()) {
+ Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
+
+ QImage image = shm_img;
+ //img.convertToFormat(
+ XImage *xi = XCreateImage(screen->display(), visual, 24, ZPixmap,
+ 0, (char *) image.scanLine(0), image.width(), image.height(),
+ 32, image.bytesPerLine());
+
+ int x = 0;
+ int y = 0;
+
+ /*int r =*/ XPutImage(screen->display(), window, gc, xi, 0, 0, x, y, image.width(), image.height());
+
+ xi->data = 0; // QImage owns these bits
+ XDestroyImage(xi);
+ }
+#else
+ // Use MIT_SHM
+ if (image_info && image_info->image) {
+ //qDebug() << "Here we go" << image_info->image->width << image_info->image->height;
+ int x = 0;
+ int y = 0;
+
+ // We could set send_event to true, and then use the ShmCompletion to synchronize,
+ // but let's do like Qt/11 and just use XSync
+ XShmPutImage (screen->display()->nativeDisplay(), window, gc, image_info->image, 0, 0,
+ x, y, image_info->image->width, image_info->image->height,
+ /*send_event*/ False);
+
+ screen->display()->sync();
+ }
+#endif
+}
+
+// from qwindowsurface.cpp
+extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
+
+bool QXlibWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ if (shm_img.isNull())
+ return false;
+
+ const QVector<QRect> rects = area.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ qt_scrollRectInImage(shm_img, rects.at(i), QPoint(dx, dy));
+
+ return true;
+}
+
+
+void QXlibWindowSurface::beginPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+ resizeBuffer(size());
+}
+
+void QXlibWindowSurface::endPaint(const QRegion &region)
+{
+ Q_UNUSED(region);
+ painted = true; //there is content in the buffer
+}
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xlib/qxlibwindowsurface.h b/src/plugins/platforms/xlib/qxlibwindowsurface.h
new file mode 100644
index 0000000..d46b7b4
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibwindowsurface.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_TESTLITE_H
+#define QWINDOWSURFACE_TESTLITE_H
+
+#include <QtGui/private/qwindowsurface_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+class QXlibWindow;
+class QXlibIntegration;
+class QXlibScreen;
+class QXlibShmImageInfo;
+
+class QXlibWindowSurface : public QWindowSurface
+{
+public:
+ QXlibWindowSurface (QWidget *window);
+ ~QXlibWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ bool scroll(const QRegion &area, int dx, int dy);
+
+ void beginPaint(const QRegion &region);
+ void endPaint(const QRegion &region);
+
+private:
+ bool painted;
+ void resizeBuffer(QSize);
+ QSize bufferSize() const;
+
+
+ void resizeShmImage(int width, int height);
+
+ QImage shm_img;
+ QXlibShmImageInfo *image_info;
+
+ QXlibWindow *xw;
+
+};
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro
new file mode 100644
index 0000000..159fdbe
--- /dev/null
+++ b/src/plugins/platforms/xlib/xlib.pro
@@ -0,0 +1,59 @@
+TARGET = qxlib
+
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = \
+ main.cpp \
+ qxlibintegration.cpp \
+ qxlibwindowsurface.cpp \
+ qxlibwindow.cpp \
+ qxlibcursor.cpp \
+ qxlibscreen.cpp \
+ qxlibkeyboard.cpp \
+ qxlibclipboard.cpp \
+ qxlibmime.cpp \
+ qxlibstatic.cpp \
+ qxlibdisplay.cpp
+
+HEADERS = \
+ qxlibintegration.h \
+ qxlibwindowsurface.h \
+ qxlibwindow.h \
+ qxlibcursor.h \
+ qxlibscreen.h \
+ qxlibkeyboard.h \
+ qxlibclipboard.h \
+ qxlibmime.h \
+ qxlibstatic.h \
+ qxlibdisplay.h
+
+LIBS += -lX11 -lXext
+
+mac {
+ LIBS += -L/usr/X11/lib -lz -framework Carbon
+}
+
+include (../fontdatabases/genericunix/genericunix.pri)
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+ !contains(QT_CONFIG, opengles2) {
+ HEADERS += qglxintegration.h
+ SOURCES += qglxintegration.cpp
+ } else { # There is no easy way to detect if we'r suppose to use glx or not
+ HEADERS += \
+ ../eglconvenience/qeglplatformcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+ ../eglconvenience/qxlibeglintegration.h
+
+ SOURCES += \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ ../eglconvenience/qxlibeglintegration.cpp
+ LIBS += -lEGL
+ }
+}
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index e778ab7..7479d2f 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -2,15 +2,16 @@ TEMPLATE = subdirs
SUBDIRS *= sqldrivers script bearer
unix:!symbian {
- contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv):SUBDIRS *= codecs
+ contains(QT_CONFIG,iconv)|contains(QT_CONFIG,gnu-libiconv)|contains(QT_CONFIG,sun-libiconv):SUBDIRS *= codecs
} else {
SUBDIRS *= codecs
}
!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats iconengines
-!embedded:SUBDIRS *= graphicssystems
+!embedded:!qpa:SUBDIRS *= graphicssystems
embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods
!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible
symbian:SUBDIRS += s60
contains(QT_CONFIG, phonon): SUBDIRS *= phonon
+qpa:SUBDIRS += platforms
contains(QT_CONFIG, declarative): SUBDIRS *= qmltooling
diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
index 69c1ef5..e1298e8 100644
--- a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h
index a6e17e6..66a10e1 100644
--- a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri
index 6c33e92..45e3976 100644
--- a/src/plugins/qpluginbase.pri
+++ b/src/plugins/qpluginbase.pri
@@ -1,6 +1,6 @@
TEMPLATE = lib
isEmpty(QT_MAJOR_VERSION) {
- VERSION=4.7.4
+ VERSION=4.8.0
} else {
VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
}
diff --git a/src/qbase.pri b/src/qbase.pri
index 5d78336..ce69757 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -4,11 +4,10 @@ INCLUDEPATH *= $$QMAKE_INCDIR_QT/$$TARGET #just for today to have some compat
isEmpty(QT_ARCH):!isEmpty(ARCH):QT_ARCH=$$ARCH #another compat that will rot for change #215700
TEMPLATE = lib
isEmpty(QT_MAJOR_VERSION) {
- VERSION=4.7.4
+ VERSION=4.8.0
} else {
VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
}
-mac:!contains(QMAKE_EXT_C, .mm):QMAKE_EXT_C += .mm
#load up the headers info
CONFIG += qt_install_headers
@@ -152,6 +151,14 @@ unix:!symbian {
QMAKE_PKGCONFIG_INSTALL_REPLACE += include_replace lib_replace prefix_replace
}
+win32-g++* {
+ CONFIG += create_pc
+ QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS]
+ QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET
+ QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS]
+ QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+}
+
contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE
DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS
contains(QT_CONFIG, qt3support):DEFINES *= QT3_SUPPORT
@@ -201,7 +208,7 @@ symbian {
pu_header = "; Partial upgrade package for testing $${TARGET} changes without reinstalling everything" \
"$${LITERAL_HASH}{\"$${TARGET}\"}, ($$PARTIAL_UPGRADE_UID), $${QT_MAJOR_VERSION},$${QT_MINOR_VERSION},$${QT_PATCH_VERSION}, TYPE=PU"
partial_upgrade.pkg_prerules = pu_header vendorinfo
- partial_upgrade.sources = $$QMAKE_LIBDIR_QT/$${TARGET}.dll
+ partial_upgrade.files = $$QMAKE_LIBDIR_QT/$${TARGET}.dll
partial_upgrade.path = c:/sys/bin
DEPLOYMENT += partial_upgrade
}
diff --git a/src/qt3support/qt3support.pro b/src/qt3support/qt3support.pro
index a30117c..1e0717d 100644
--- a/src/qt3support/qt3support.pro
+++ b/src/qt3support/qt3support.pro
@@ -21,7 +21,7 @@ include(canvas/canvas.pri)
include(network/network.pri)
include(painting/painting.pri)
-unix {
+unix|win32-g++* {
QMAKE_PKGCONFIG_CFLAGS += -DQT3_SUPPORT
QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork QtSql
}
diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp
index 6c4834f..668a322 100644
--- a/src/qt3support/text/q3richtext.cpp
+++ b/src/qt3support/text/q3richtext.cpp
@@ -8078,9 +8078,9 @@ bool Q3TextTable::down(Q3TextCursor *c, Q3TextDocument *&doc, Q3TextParagraph *&
break;
}
}
- doc = cell->richText();
if (!cell)
return false;
+ doc = cell->richText();
parag = doc->firstParagraph();
idx = 0;
ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x();
@@ -8116,9 +8116,9 @@ bool Q3TextTable::up(Q3TextCursor *c, Q3TextDocument *&doc, Q3TextParagraph *&pa
break;
}
}
- doc = cell->richText();
if (!cell)
return false;
+ doc = cell->richText();
parag = doc->lastParagraph();
idx = parag->length() - 1;
ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x();
diff --git a/src/qt3support/text/q3textstream.h b/src/qt3support/text/q3textstream.h
index 768f65a..e37ff51 100644
--- a/src/qt3support/text/q3textstream.h
+++ b/src/qt3support/text/q3textstream.h
@@ -272,13 +272,13 @@ private:
int arg; // member function argument
};
-Q_COMPAT_EXPORT inline Q3TextStream &operator>>( Q3TextStream &s, Q3TSFUNC f )
+Q_COMPAT_EXPORT_INLINE Q3TextStream &operator>>( Q3TextStream &s, Q3TSFUNC f )
{ return (*f)( s ); }
-Q_COMPAT_EXPORT inline Q3TextStream &operator<<( Q3TextStream &s, Q3TSFUNC f )
+Q_COMPAT_EXPORT_INLINE Q3TextStream &operator<<( Q3TextStream &s, Q3TSFUNC f )
{ return (*f)( s ); }
-Q_COMPAT_EXPORT inline Q3TextStream &operator<<( Q3TextStream &s, Q3TSManip m )
+Q_COMPAT_EXPORT_INLINE Q3TextStream &operator<<( Q3TextStream &s, Q3TSManip m )
{ m.exec(s); return s; }
Q_COMPAT_EXPORT Q3TextStream &bin( Q3TextStream &s ); // set bin notation
diff --git a/src/qt3support/tools/q3cstring.h b/src/qt3support/tools/q3cstring.h
index 09f45a5..da31763 100644
--- a/src/qt3support/tools/q3cstring.h
+++ b/src/qt3support/tools/q3cstring.h
@@ -161,75 +161,75 @@ inline Q3CString &Q3CString::setNum(float n, char f, int prec)
Q3CString non-member operators
*****************************************************************************/
-Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator==(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) == 0; }
-Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator==(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) == 0; }
-Q_COMPAT_EXPORT inline bool operator==(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator==(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) == 0; }
-Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator!=(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) != 0; }
-Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator!=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) != 0; }
-Q_COMPAT_EXPORT inline bool operator!=(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator!=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) != 0; }
-Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const Q3CString& s2)
+Q_COMPAT_EXPORT_INLINE bool operator<(const Q3CString &s1, const Q3CString& s2)
{ return qstrcmp(s1, s2) < 0; }
-Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator<(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) < 0; }
-Q_COMPAT_EXPORT inline bool operator<(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator<(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) < 0; }
-Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator<=(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) <= 0; }
-Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator<=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) <= 0; }
-Q_COMPAT_EXPORT inline bool operator<=(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator<=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) <= 0; }
-Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator>(const Q3CString &s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) > 0; }
-Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator>(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) > 0; }
-Q_COMPAT_EXPORT inline bool operator>(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator>(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) > 0; }
-Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const Q3CString& s2)
+Q_COMPAT_EXPORT_INLINE bool operator>=(const Q3CString &s1, const Q3CString& s2)
{ return qstrcmp(s1, s2) >= 0; }
-Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE bool operator>=(const Q3CString &s1, const char *s2)
{ return qstrcmp(s1, s2) >= 0; }
-Q_COMPAT_EXPORT inline bool operator>=(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE bool operator>=(const char *s1, const Q3CString &s2)
{ return qstrcmp(s1, s2) >= 0; }
-Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1,
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1,
const Q3CString &s2)
{
Q3CString tmp(s1);
tmp += s2;
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1,
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1,
const QByteArray &s2)
{
QByteArray tmp(s1);
tmp += s2;
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1,
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const QByteArray &s1,
const Q3CString &s2)
{
QByteArray tmp(s1);
@@ -237,28 +237,28 @@ Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1,
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, const char *s2)
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, const char *s2)
{
Q3CString tmp(s1);
tmp += s2;
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(const char *s1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const char *s1, const Q3CString &s2)
{
Q3CString tmp(s1);
tmp += s2;
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, char c2)
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, char c2)
{
Q3CString tmp(s1);
tmp += c2;
return tmp;
}
-Q_COMPAT_EXPORT inline const Q3CString operator+(char c1, const Q3CString &s2)
+Q_COMPAT_EXPORT_INLINE const Q3CString operator+(char c1, const Q3CString &s2)
{
Q3CString tmp;
tmp += c1;
diff --git a/src/qt3support/tools/q3valuevector.h b/src/qt3support/tools/q3valuevector.h
index a564e0c..f2bae4b 100644
--- a/src/qt3support/tools/q3valuevector.h
+++ b/src/qt3support/tools/q3valuevector.h
@@ -84,9 +84,9 @@ public:
void resize(int n, const T& val = T())
{
if (n < this->size())
- erase(this->begin() + n, this->end());
+ this->erase(this->begin() + n, this->end());
else
- insert(this->end(), n - this->size(), val);
+ this->insert(this->end(), n - this->size(), val);
}
diff --git a/src/qt_install.pri b/src/qt_install.pri
index f906e92..268bb86 100644
--- a/src/qt_install.pri
+++ b/src/qt_install.pri
@@ -38,7 +38,7 @@ qt_install_headers {
}
}
-embedded:equals(TARGET, QtGui) {
+embedded|qpa: equals(TARGET, QtGui) {
# install fonts for embedded
INSTALLS += fonts
fonts.path = $$[QT_INSTALL_LIBS]/fonts
diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def
index b82f6e5..5579e5a 100644
--- a/src/s60installs/bwins/QtCoreu.def
+++ b/src/s60installs/bwins/QtCoreu.def
@@ -59,7 +59,7 @@ EXPORTS
??0QChildEvent@@QAE@W4Type@QEvent@@PAVQObject@@@Z @ 58 NONAME ; QChildEvent::QChildEvent(enum QEvent::Type, class QObject *)
??0QCoreApplication@@IAE@AAVQCoreApplicationPrivate@@@Z @ 59 NONAME ; QCoreApplication::QCoreApplication(class QCoreApplicationPrivate &)
??0QCoreApplication@@QAE@AAHPAPAD@Z @ 60 NONAME ; QCoreApplication::QCoreApplication(int &, char * *)
- ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *)
+ ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ABSENT ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *)
??0QCryptographicHash@@QAE@W4Algorithm@0@@Z @ 62 NONAME ; QCryptographicHash::QCryptographicHash(enum QCryptographicHash::Algorithm)
??0QDataStream@@QAE@ABVQByteArray@@@Z @ 63 NONAME ; QDataStream::QDataStream(class QByteArray const &)
??0QDataStream@@QAE@PAVQByteArray@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 64 NONAME ; QDataStream::QDataStream(class QByteArray *, class QFlags<enum QIODevice::OpenModeFlag>)
@@ -1380,7 +1380,7 @@ EXPORTS
?create@QAbstractFileEngine@@SAPAV1@ABVQString@@@Z @ 1379 NONAME ; class QAbstractFileEngine * QAbstractFileEngine::create(class QString const &)
?create@QNonContiguousByteDeviceFactory@@SAPAVQNonContiguousByteDevice@@PAVQByteArray@@@Z @ 1380 NONAME ; class QNonContiguousByteDevice * QNonContiguousByteDeviceFactory::create(class QByteArray *)
?create@QNonContiguousByteDeviceFactory@@SAPAVQNonContiguousByteDevice@@PAVQIODevice@@@Z @ 1381 NONAME ; class QNonContiguousByteDevice * QNonContiguousByteDeviceFactory::create(class QIODevice *)
- ?create@QNonContiguousByteDeviceFactory@@SAPAVQNonContiguousByteDevice@@PAVQRingBuffer@@@Z @ 1382 NONAME ; class QNonContiguousByteDevice * QNonContiguousByteDeviceFactory::create(class QRingBuffer *)
+ ?create@QNonContiguousByteDeviceFactory@@SAPAVQNonContiguousByteDevice@@PAVQRingBuffer@@@Z @ 1382 NONAME ABSENT ; class QNonContiguousByteDevice * QNonContiguousByteDeviceFactory::create(class QRingBuffer *)
?create@QSharedMemory@@QAE_NHW4AccessMode@1@@Z @ 1383 NONAME ; bool QSharedMemory::create(int, enum QSharedMemory::AccessMode)
?create@QTextCodecPlugin@@EAEPAVQTextCodec@@ABVQString@@@Z @ 1384 NONAME ; class QTextCodec * QTextCodecPlugin::create(class QString const &)
?create@QVariant@@IAEXHPBX@Z @ 1385 NONAME ; void QVariant::create(int, void const *)
@@ -3123,7 +3123,7 @@ EXPORTS
?reset@QMetaProperty@@QBE_NPAVQObject@@@Z @ 3122 NONAME ; bool QMetaProperty::reset(class QObject *) const
?reset@QTextStream@@QAEXXZ @ 3123 NONAME ; void QTextStream::reset(void)
?resetCurrentSender@QObjectPrivate@@SAXPAVQObject@@PAUSender@1@1@Z @ 3124 NONAME ; void QObjectPrivate::resetCurrentSender(class QObject *, struct QObjectPrivate::Sender *, struct QObjectPrivate::Sender *)
- ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int)
+ ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ABSENT ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int)
?resetStatus@QDataStream@@QAEXXZ @ 3126 NONAME ; void QDataStream::resetStatus(void)
?resetStatus@QTextStream@@QAEXXZ @ 3127 NONAME ; void QTextStream::resetStatus(void)
?resize@QBitArray@@QAEXH@Z @ 3128 NONAME ; void QBitArray::resize(int)
@@ -3296,7 +3296,7 @@ EXPORTS
?setDefault@QLocale@@SAXABV1@@Z @ 3295 NONAME ; void QLocale::setDefault(class QLocale const &)
?setDefaultFormat@QSettings@@SAXW4Format@1@@Z @ 3296 NONAME ; void QSettings::setDefaultFormat(enum QSettings::Format)
?setDefaultState@QHistoryState@@QAEXPAVQAbstractState@@@Z @ 3297 NONAME ; void QHistoryState::setDefaultState(class QAbstractState *)
- ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *)
+ ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ABSENT ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *)
?setDevice@QDataStream@@QAEXPAVQIODevice@@@Z @ 3299 NONAME ; void QDataStream::setDevice(class QIODevice *)
?setDevice@QTextStream@@QAEXPAVQIODevice@@@Z @ 3300 NONAME ; void QTextStream::setDevice(class QIODevice *)
?setDevice@QXmlStreamReader@@QAEXPAVQIODevice@@@Z @ 3301 NONAME ; void QXmlStreamReader::setDevice(class QIODevice *)
@@ -4486,7 +4486,127 @@ EXPORTS
?objectNameChanged@QAbstractDeclarativeData@@2P6AXPAV1@PAVQObject@@@ZA @ 4485 NONAME ; void (*QAbstractDeclarativeData::objectNameChanged)(class QAbstractDeclarativeData *, class QObject *)
?queueDeferredActiveObjectsCompletion@QEventDispatcherSymbian@@QAEXXZ @ 4486 NONAME ; void QEventDispatcherSymbian::queueDeferredActiveObjectsCompletion(void)
?reactivateDeferredActiveObjects@QEventDispatcherSymbian@@UAEXXZ @ 4487 NONAME ; void QEventDispatcherSymbian::reactivateDeferredActiveObjects(void)
- ?symbianCommandLine@QCoreApplicationPrivate@@SAPAVCApaCommandLine@@XZ @ 4488 NONAME ; class CApaCommandLine * QCoreApplicationPrivate::symbianCommandLine(void)
- ?revision@QMetaProperty@@QBEHXZ @ 4489 NONAME ; int QMetaProperty::revision(void) const
- ?revision@QMetaMethod@@QBEHXZ @ 4490 NONAME ; int QMetaMethod::revision(void) const
+ ?contains@QString@@QBE?AVQBool@@ABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4488 NONAME ; class QBool QString::contains(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?swap@QRegExp@@QAEXAAV1@@Z @ 4489 NONAME ; void QRegExp::swap(class QRegExp &)
+ ?indexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4490 NONAME ; int QStringRef::indexOf(class QString const &, int, enum Qt::CaseSensitivity) const
+ ?indexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4491 NONAME ; int QStringRef::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const
+ ?count@QString@@QBEHABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4492 NONAME ; int QString::count(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?swap@QString@@QAEXAAV1@@Z @ 4493 NONAME ; void QString::swap(class QString &)
+ ?trUtf8@QAnimationDriver@@SA?AVQString@@PBD0H@Z @ 4494 NONAME ; class QString QAnimationDriver::trUtf8(char const *, char const *, int)
+ ?startsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4495 NONAME ; bool QStringRef::startsWith(class QChar, enum Qt::CaseSensitivity) const
+ ?setNativeKey@QSharedMemory@@QAEXABVQString@@@Z @ 4496 NONAME ; void QSharedMemory::setNativeKey(class QString const &)
+ ??0QAnimationDriver@@IAE@AAVQAnimationDriverPrivate@@PAVQObject@@@Z @ 4497 NONAME ; QAnimationDriver::QAnimationDriver(class QAnimationDriverPrivate &, class QObject *)
+ ?timerEvent@QUnifiedTimer@@MAEXPAVQTimerEvent@@@Z @ 4498 NONAME ; void QUnifiedTimer::timerEvent(class QTimerEvent *)
+ ?registerAnimation@QUnifiedTimer@@SAXPAVQAbstractAnimation@@_N@Z @ 4499 NONAME ; void QUnifiedTimer::registerAnimation(class QAbstractAnimation *, bool)
+ ?startsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4500 NONAME ; bool QStringRef::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?contains@QStringRef@@QBE?AVQBool@@ABV1@W4CaseSensitivity@Qt@@@Z @ 4501 NONAME ; class QBool QStringRef::contains(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?startsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4502 NONAME ; bool QStringRef::startsWith(class QLatin1String, enum Qt::CaseSensitivity) const
+ ?cast@QMetaObject@@QBEPBVQObject@@PBV2@@Z @ 4503 NONAME ; class QObject const * QMetaObject::cast(class QObject const *) const
+ ?ensureTimerUpdate@QUnifiedTimer@@SAXXZ @ 4504 NONAME ; void QUnifiedTimer::ensureTimerUpdate(void)
+ ?contains@QStringRef@@QBE?AVQBool@@VQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4505 NONAME ; class QBool QStringRef::contains(class QLatin1String, enum Qt::CaseSensitivity) const
+ ?d_func@QAnimationDriver@@ABEPBVQAnimationDriverPrivate@@XZ @ 4506 NONAME ; class QAnimationDriverPrivate const * QAnimationDriver::d_func(void) const
+ ?swap@QVariant@@QAEXAAV1@@Z @ 4507 NONAME ; void QVariant::swap(class QVariant &)
+ ?lastIndexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4508 NONAME ; int QStringRef::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const
+ ?indexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4509 NONAME ; int QStringRef::indexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const
+ ?senderSignalIndex@QObject@@IBEHXZ @ 4510 NONAME ; int QObject::senderSignalIndex(void) const
+ ?toUtf8@QStringRef@@QBE?AVQByteArray@@XZ @ 4511 NONAME ; class QByteArray QStringRef::toUtf8(void) const
+ ?startsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4512 NONAME ; bool QString::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?unlockInternal@QMutex@@AAEXXZ @ 4513 NONAME ; void QMutex::unlockInternal(void)
+ ?updateAnimationsTime@QUnifiedTimer@@QAEXXZ @ 4514 NONAME ; void QUnifiedTimer::updateAnimationsTime(void)
+ ?swap@QBitArray@@QAEXAAV1@@Z @ 4515 NONAME ; void QBitArray::swap(class QBitArray &)
+ ?nativeKey@QSharedMemory@@QBE?AVQString@@XZ @ 4516 NONAME ; class QString QSharedMemory::nativeKey(void) const
+ ?connect@QObject@@SA_NPBV1@ABVQMetaMethod@@01W4ConnectionType@Qt@@@Z @ 4517 NONAME ; bool QObject::connect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &, enum Qt::ConnectionType)
+ ?registerRunningAnimation@QUnifiedTimer@@AAEXPAVQAbstractAnimation@@@Z @ 4518 NONAME ; void QUnifiedTimer::registerRunningAnimation(class QAbstractAnimation *)
+ ?disconnect@QObject@@SA_NPBV1@ABVQMetaMethod@@01@Z @ 4519 NONAME ; bool QObject::disconnect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &)
+ ?installAnimationDriver@QUnifiedTimer@@QAEXPAVQAnimationDriver@@@Z @ 4520 NONAME ; void QUnifiedTimer::installAnimationDriver(class QAnimationDriver *)
+ ?startsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4521 NONAME ; bool QStringRef::startsWith(class QString const &, enum Qt::CaseSensitivity) const
+ ?contains@QStringRef@@QBE?AVQBool@@VQChar@@W4CaseSensitivity@Qt@@@Z @ 4522 NONAME ; class QBool QStringRef::contains(class QChar, enum Qt::CaseSensitivity) const
+ ?unregisterAnimation@QUnifiedTimer@@SAXPAVQAbstractAnimation@@@Z @ 4523 NONAME ; void QUnifiedTimer::unregisterAnimation(class QAbstractAnimation *)
+ ?qt_metacast@QAnimationDriver@@UAEPAXPBD@Z @ 4524 NONAME ; void * QAnimationDriver::qt_metacast(char const *)
+ ?count@QStringRef@@QBEHABVQString@@W4CaseSensitivity@Qt@@@Z @ 4525 NONAME ; int QStringRef::count(class QString const &, enum Qt::CaseSensitivity) const
+ ?endsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4526 NONAME ; bool QStringRef::endsWith(class QChar, enum Qt::CaseSensitivity) const
+ ??0QUnifiedTimer@@AAE@XZ @ 4527 NONAME ; QUnifiedTimer::QUnifiedTimer(void)
+ ??0QCoreApplicationPrivate@@QAE@AAHPAPADI@Z @ 4528 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *, unsigned int)
+ ??0QCoreApplication@@QAE@AAHPAPADH@Z @ 4529 NONAME ; QCoreApplication::QCoreApplication(int &, char * *, int)
+ ??0QAnimationDriver@@QAE@PAVQObject@@@Z @ 4530 NONAME ; QAnimationDriver::QAnimationDriver(class QObject *)
+ ?lastIndexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4531 NONAME ; int QStringRef::lastIndexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const
+ ??0QAnimationDriverPrivate@@QAE@XZ @ 4532 NONAME ; QAnimationDriverPrivate::QAnimationDriverPrivate(void)
+ ?endsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4533 NONAME ; bool QString::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?trUtf8@QAnimationDriver@@SA?AVQString@@PBD0@Z @ 4534 NONAME ; class QString QAnimationDriver::trUtf8(char const *, char const *)
+ ?install@QAnimationDriver@@QAEXXZ @ 4535 NONAME ; void QAnimationDriver::install(void)
+ ?qt_metacall@QAnimationDriver@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 4536 NONAME ; int QAnimationDriver::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?endsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4537 NONAME ; bool QStringRef::endsWith(class QString const &, enum Qt::CaseSensitivity) const
+ ?lockInline@QMutex@@QAEXXZ @ 4538 NONAME ; void QMutex::lockInline(void)
+ ?endsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4539 NONAME ; bool QStringRef::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ??_EQUnifiedTimer@@UAE@I@Z @ 4540 NONAME ; QUnifiedTimer::~QUnifiedTimer(unsigned int)
+ ?setTimingInterval@QUnifiedTimer@@QAEXH@Z @ 4541 NONAME ; void QUnifiedTimer::setTimingInterval(int)
+ ?closestPauseAnimationTimeToFinish@QUnifiedTimer@@AAEHXZ @ 4542 NONAME ; int QUnifiedTimer::closestPauseAnimationTimeToFinish(void)
+ ??0QXmlStreamAttributes@@QAE@XZ @ 4543 NONAME ; QXmlStreamAttributes::QXmlStreamAttributes(void)
+ ?lastIndexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4544 NONAME ; int QString::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const
+ ??1QAnimationDriverPrivate@@UAE@XZ @ 4545 NONAME ; QAnimationDriverPrivate::~QAnimationDriverPrivate(void)
+ ?swap@QUrl@@QAEXAAV1@@Z @ 4546 NONAME ; void QUrl::swap(class QUrl &)
+ ??_EQAnimationDriverPrivate@@UAE@I@Z @ 4547 NONAME ; QAnimationDriverPrivate::~QAnimationDriverPrivate(unsigned int)
+ ??_EQAnimationDriver@@UAE@I@Z @ 4548 NONAME ; QAnimationDriver::~QAnimationDriver(unsigned int)
+ ?instance@QUnifiedTimer@@SAPAV1@_N@Z @ 4549 NONAME ; class QUnifiedTimer * QUnifiedTimer::instance(bool)
+ ?setSlowdownFactor@QUnifiedTimer@@QAEXM@Z @ 4550 NONAME ; void QUnifiedTimer::setSlowdownFactor(float)
+ ?isRunning@QAnimationDriver@@QBE_NXZ @ 4551 NONAME ; bool QAnimationDriver::isRunning(void) const
+ ?count@QStringRef@@QBEHABV1@W4CaseSensitivity@Qt@@@Z @ 4552 NONAME ; int QStringRef::count(class QStringRef const &, enum Qt::CaseSensitivity) const
+ ?contains@QStringRef@@QBE?AVQBool@@ABVQString@@W4CaseSensitivity@Qt@@@Z @ 4553 NONAME ; class QBool QStringRef::contains(class QString const &, enum Qt::CaseSensitivity) const
+ ?tryLockInline@QMutex@@QAE_NXZ @ 4554 NONAME ; bool QMutex::tryLockInline(void)
+ ?lastIndexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4555 NONAME ; int QStringRef::lastIndexOf(class QString const &, int, enum Qt::CaseSensitivity) const
+ ?lockInternal@QMutex@@AAEXXZ @ 4556 NONAME ; void QMutex::lockInternal(void)
+ ?toLocal8Bit@QStringRef@@QBE?AVQByteArray@@XZ @ 4557 NONAME ; class QByteArray QStringRef::toLocal8Bit(void) const
+ ?indexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4558 NONAME ; int QStringRef::indexOf(class QChar, int, enum Qt::CaseSensitivity) const
+ ?toUcs4@QStringRef@@QBE?AV?$QVector@I@@XZ @ 4559 NONAME ; class QVector<unsigned int> QStringRef::toUcs4(void) const
+ ?staticMetaObject@QAnimationDriver@@2UQMetaObject@@B @ 4560 NONAME ; struct QMetaObject const QAnimationDriver::staticMetaObject
+ ?unregisterRunningAnimation@QUnifiedTimer@@AAEXPAVQAbstractAnimation@@@Z @ 4561 NONAME ; void QUnifiedTimer::unregisterRunningAnimation(class QAbstractAnimation *)
+ ?isLocalFile@QUrl@@QBE_NXZ @ 4562 NONAME ; bool QUrl::isLocalFile(void) const
+ ?swap@QByteArray@@QAEXAAV1@@Z @ 4563 NONAME ; void QByteArray::swap(class QByteArray &)
+ ?tr@QAnimationDriver@@SA?AVQString@@PBD0H@Z @ 4564 NONAME ; class QString QAnimationDriver::tr(char const *, char const *, int)
+ ?toLatin1@QStringRef@@QBE?AVQByteArray@@XZ @ 4565 NONAME ; class QByteArray QStringRef::toLatin1(void) const
+ ??1QAnimationDriver@@UAE@XZ @ 4566 NONAME ; QAnimationDriver::~QAnimationDriver(void)
+ ?tr@QAnimationDriver@@SA?AVQString@@PBD0@Z @ 4567 NONAME ; class QString QAnimationDriver::tr(char const *, char const *)
+ ?waitForDone@QThreadPool@@QAE_NH@Z @ 4568 NONAME ; bool QThreadPool::waitForDone(int)
+ ?endsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4569 NONAME ; bool QStringRef::endsWith(class QLatin1String, enum Qt::CaseSensitivity) const
+ ?stop@QAnimationDriver@@AAEXXZ @ 4570 NONAME ; void QAnimationDriver::stop(void)
+ ?getStaticMetaObject@QAnimationDriver@@SAABUQMetaObject@@XZ @ 4571 NONAME ; struct QMetaObject const & QAnimationDriver::getStaticMetaObject(void)
+ ?metaObject@QAnimationDriver@@UBEPBUQMetaObject@@XZ @ 4572 NONAME ; struct QMetaObject const * QAnimationDriver::metaObject(void) const
+ ?d_func@QAnimationDriver@@AAEPAVQAnimationDriverPrivate@@XZ @ 4573 NONAME ; class QAnimationDriverPrivate * QAnimationDriver::d_func(void)
+ ?app_compile_version@QCoreApplicationPrivate@@2HA @ 4574 NONAME ; int QCoreApplicationPrivate::app_compile_version
+ ?restartAnimationTimer@QUnifiedTimer@@QAEXXZ @ 4575 NONAME ; void QUnifiedTimer::restartAnimationTimer(void)
+ ?count@QStringRef@@QBEHVQChar@@W4CaseSensitivity@Qt@@@Z @ 4576 NONAME ; int QStringRef::count(class QChar, enum Qt::CaseSensitivity) const
+ ?toAscii@QStringRef@@QBE?AVQByteArray@@XZ @ 4577 NONAME ; class QByteArray QStringRef::toAscii(void) const
+ ?setConsistentTiming@QUnifiedTimer@@QAEX_N@Z @ 4578 NONAME ; void QUnifiedTimer::setConsistentTiming(bool)
+ ??1QUnifiedTimer@@UAE@XZ @ 4579 NONAME ; QUnifiedTimer::~QUnifiedTimer(void)
+ ?setSlowModeEnabled@QUnifiedTimer@@QAEX_N@Z @ 4580 NONAME ; void QUnifiedTimer::setSlowModeEnabled(bool)
+ ?updateAnimationTimer@QUnifiedTimer@@SAXXZ @ 4581 NONAME ; void QUnifiedTimer::updateAnimationTimer(void)
+ ?indexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4582 NONAME ; int QString::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const
+ ?lastIndexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4583 NONAME ; int QStringRef::lastIndexOf(class QChar, int, enum Qt::CaseSensitivity) const
+ ?advance@QAnimationDriver@@QAEXXZ @ 4584 NONAME ; void QAnimationDriver::advance(void)
+ ?start@QAnimationDriver@@AAEXXZ @ 4585 NONAME ; void QAnimationDriver::start(void)
+ ?unlockInline@QMutex@@QAEXXZ @ 4586 NONAME ; void QMutex::unlockInline(void)
+ ??0QSystemError@@QAE@HW4ErrorScope@0@@Z @ 4587 NONAME ; QSystemError::QSystemError(int, enum QSystemError::ErrorScope)
+ ??0QSystemError@@QAE@XZ @ 4588 NONAME ; QSystemError::QSystemError(void)
+ ?error@QSystemError@@QAEHXZ @ 4589 NONAME ; int QSystemError::error(void)
+ ?scope@QSystemError@@QAE?AW4ErrorScope@1@XZ @ 4590 NONAME ; enum QSystemError::ErrorScope QSystemError::scope(void)
+ ?toString@QSystemError@@QAE?AVQString@@XZ @ 4591 NONAME ; class QString QSystemError::toString(void)
+ ??0QFileInfo@@QAE@PAVQFileInfoPrivate@@@Z @ 4592 NONAME ; QFileInfo::QFileInfo(class QFileInfoPrivate *)
+ ?currentUnicodeVersion@QChar@@SA?AW4UnicodeVersion@1@XZ @ 4593 NONAME ; enum QChar::UnicodeVersion QChar::currentUnicodeVersion(void)
+ ?open@QFSFileEngine@@QAE_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@ABVRFile@@V?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4594 NONAME ; bool QFSFileEngine::open(class QFlags<enum QIODevice::OpenModeFlag>, class RFile const &, class QFlags<enum QFile::FileHandleFlag>)
+ ?open@QFSFileEngine@@QAE_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@HV?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4595 NONAME ; bool QFSFileEngine::open(class QFlags<enum QIODevice::OpenModeFlag>, int, class QFlags<enum QFile::FileHandleFlag>)
+ ?open@QFSFileEngine@@QAE_NV?$QFlags@W4OpenModeFlag@QIODevice@@@@PAU__sFILE@@V?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4596 NONAME ; bool QFSFileEngine::open(class QFlags<enum QIODevice::OpenModeFlag>, struct __sFILE *, class QFlags<enum QFile::FileHandleFlag>)
+ ?open@QFile@@QAE_NABVRFile@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@V?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4597 NONAME ; bool QFile::open(class RFile const &, class QFlags<enum QIODevice::OpenModeFlag>, class QFlags<enum QFile::FileHandleFlag>)
+ ?open@QFile@@QAE_NHV?$QFlags@W4OpenModeFlag@QIODevice@@@@V?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4598 NONAME ; bool QFile::open(int, class QFlags<enum QIODevice::OpenModeFlag>, class QFlags<enum QFile::FileHandleFlag>)
+ ?open@QFile@@QAE_NPAU__sFILE@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@V?$QFlags@W4FileHandleFlag@QFile@@@@@Z @ 4599 NONAME ; bool QFile::open(struct __sFILE *, class QFlags<enum QIODevice::OpenModeFlag>, class QFlags<enum QFile::FileHandleFlag>)
+ ?symbianCommandLine@QCoreApplicationPrivate@@SAPAVCApaCommandLine@@XZ @ 4600 NONAME ; class CApaCommandLine * QCoreApplicationPrivate::symbianCommandLine(void)
+ ?nsecsElapsed@QElapsedTimer@@QBE_JXZ @ 4601 NONAME ; long long QElapsedTimer::nsecsElapsed(void) const
+ ??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
+ ?started@QAnimationDriver@@MAEXXZ @ 4607 NONAME ; void QAnimationDriver::started(void)
+ ?stopped@QAnimationDriver@@MAEXXZ @ 4608 NONAME ; void QAnimationDriver::stopped(void)
+ ?isResetDisabled@QNonContiguousByteDevice@@QAE_NXZ @ 4609 NONAME ; bool QNonContiguousByteDevice::isResetDisabled(void)
+ ?create@QNonContiguousByteDeviceFactory@@SAPAVQNonContiguousByteDevice@@V?$QSharedPointer@VQRingBuffer@@@@@Z @ 4610 NONAME ; class QNonContiguousByteDevice * QNonContiguousByteDeviceFactory::create(class QSharedPointer<class QRingBuffer>)
diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def
index 26a0761..8f56e20 100644
--- a/src/s60installs/bwins/QtGuiu.def
+++ b/src/s60installs/bwins/QtGuiu.def
@@ -35,7 +35,7 @@ EXPORTS
??0QApplication@@QAE@AAHPAPADW4Type@0@H@Z @ 34 NONAME ; QApplication::QApplication(int &, char * *, enum QApplication::Type, int)
??0QApplication@@QAE@AAHPAPAD_NH@Z @ 35 NONAME ; QApplication::QApplication(int &, char * *, bool, int)
??0QApplication@@QAE@P6APAVCApaApplication@@XZAAHPAPADH@Z @ 36 NONAME ; QApplication::QApplication(class CApaApplication * (*)(void), int &, char * *, int)
- ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type)
+ ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ABSENT ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type)
??0QBitmap@@QAE@ABVQPixmap@@@Z @ 38 NONAME ; QBitmap::QBitmap(class QPixmap const &)
??0QBitmap@@QAE@ABVQSize@@@Z @ 39 NONAME ; QBitmap::QBitmap(class QSize const &)
??0QBitmap@@QAE@ABVQString@@PBD@Z @ 40 NONAME ; QBitmap::QBitmap(class QString const &, char const *)
@@ -464,7 +464,7 @@ EXPORTS
??0QRadioButton@@QAE@ABVQString@@PAVQWidget@@@Z @ 463 NONAME ; QRadioButton::QRadioButton(class QString const &, class QWidget *)
??0QRadioButton@@QAE@PAVQWidget@@@Z @ 464 NONAME ; QRadioButton::QRadioButton(class QWidget *)
??0QRasterPixmapData@@QAE@W4PixelType@QPixmapData@@@Z @ 465 NONAME ; QRasterPixmapData::QRasterPixmapData(enum QPixmapData::PixelType)
- ??0QRasterWindowSurface@@QAE@PAVQWidget@@@Z @ 466 NONAME ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *)
+ ??0QRasterWindowSurface@@QAE@PAVQWidget@@@Z @ 466 NONAME ABSENT ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *)
??0QRegExpValidator@@QAE@ABVQRegExp@@PAVQObject@@@Z @ 467 NONAME ; QRegExpValidator::QRegExpValidator(class QRegExp const &, class QObject *)
??0QRegExpValidator@@QAE@PAVQObject@@@Z @ 468 NONAME ; QRegExpValidator::QRegExpValidator(class QObject *)
??0QRegion@@QAE@ABV0@@Z @ 469 NONAME ; QRegion::QRegion(class QRegion const &)
@@ -845,7 +845,7 @@ EXPORTS
??0QWidgetResizeHandler@@QAE@PAVQWidget@@0@Z @ 844 NONAME ; QWidgetResizeHandler::QWidgetResizeHandler(class QWidget *, class QWidget *)
??0QWindowStateChangeEvent@@QAE@V?$QFlags@W4WindowState@Qt@@@@@Z @ 845 NONAME ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QFlags<enum Qt::WindowState>)
??0QWindowStateChangeEvent@@QAE@V?$QFlags@W4WindowState@Qt@@@@_N@Z @ 846 NONAME ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QFlags<enum Qt::WindowState>, bool)
- ??0QWindowSurface@@QAE@PAVQWidget@@@Z @ 847 NONAME ; QWindowSurface::QWindowSurface(class QWidget *)
+ ??0QWindowSurface@@QAE@PAVQWidget@@@Z @ 847 NONAME ABSENT ; QWindowSurface::QWindowSurface(class QWidget *)
??0QWindowsStyle@@IAE@AAVQWindowsStylePrivate@@@Z @ 848 NONAME ; QWindowsStyle::QWindowsStyle(class QWindowsStylePrivate &)
??0QWindowsStyle@@QAE@XZ @ 849 NONAME ; QWindowsStyle::QWindowsStyle(void)
??0QWizard@@QAE@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z @ 850 NONAME ; QWizard::QWizard(class QWidget *, class QFlags<enum Qt::WindowType>)
@@ -2195,7 +2195,7 @@ EXPORTS
?alphaF@QColor@@QBEMXZ @ 2194 NONAME ; float QColor::alphaF(void) const
?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@I@Z @ 2195 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int)
?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IABVQTransform@@@Z @ 2196 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, class QTransform const &)
- ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IHABVQTransform@@@Z @ 2197 NONAME ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, int, class QTransform const &)
+ ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IHABVQTransform@@@Z @ 2197 NONAME ABSENT ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, int, class QTransform const &)
?alterCharForCapitalization@QFontPrivate@@QBEXAAVQChar@@@Z @ 2198 NONAME ; void QFontPrivate::alterCharForCapitalization(class QChar &) const
?alternateBase@QPalette@@QBEABVQBrush@@XZ @ 2199 NONAME ; class QBrush const & QPalette::alternateBase(void) const
?alternatingRowColors@QAbstractItemView@@QBE_NXZ @ 2200 NONAME ; bool QAbstractItemView::alternatingRowColors(void) const
@@ -5028,7 +5028,7 @@ EXPORTS
?hasSelection@QItemSelectionModel@@QBE_NXZ @ 5027 NONAME ; bool QItemSelectionModel::hasSelection(void) const
?hasSelection@QTextCursor@@QBE_NXZ @ 5028 NONAME ; bool QTextCursor::hasSelection(void) const
?hasStaticContents@QWindowSurface@@IBE_NXZ @ 5029 NONAME ; bool QWindowSurface::hasStaticContents(void) const
- ?hasStaticContentsSupport@QWindowSurface@@QBE_NXZ @ 5030 NONAME ; bool QWindowSurface::hasStaticContentsSupport(void) const
+ ?hasStaticContentsSupport@QWindowSurface@@UBE_NXZ @ 5030 NONAME ; bool QWindowSurface::hasStaticContentsSupport(void) const
?hasThemeIcon@QIcon@@SA_NABVQString@@@Z @ 5031 NONAME ; bool QIcon::hasThemeIcon(class QString const &)
?hasTracking@QAbstractSlider@@QBE_NXZ @ 5032 NONAME ; bool QAbstractSlider::hasTracking(void) const
?hasTranslateOnlySceneTransform@QGraphicsItemPrivate@@QAE_NXZ @ 5033 NONAME ; bool QGraphicsItemPrivate::hasTranslateOnlySceneTransform(void)
@@ -9875,7 +9875,7 @@ EXPORTS
?setState@QPaintEngineEx@@UAEXPAVQPainterState@@@Z @ 9874 NONAME ; void QPaintEngineEx::setState(class QPainterState *)
?setState@TouchPoint@QTouchEvent@@QAEXV?$QFlags@W4TouchPointState@Qt@@@@@Z @ 9875 NONAME ; void QTouchEvent::TouchPoint::setState(class QFlags<enum Qt::TouchPointState>)
?setStaticContents@QWindowSurface@@QAEXABVQRegion@@@Z @ 9876 NONAME ; void QWindowSurface::setStaticContents(class QRegion const &)
- ?setStaticContentsSupport@QWindowSurface@@IAEX_N@Z @ 9877 NONAME ; void QWindowSurface::setStaticContentsSupport(bool)
+ ?setStaticContentsSupport@QWindowSurface@@IAEX_N@Z @ 9877 NONAME ABSENT ; void QWindowSurface::setStaticContentsSupport(bool)
?setStatus@QPictureIO@@QAEXH@Z @ 9878 NONAME ; void QPictureIO::setStatus(int)
?setStatusBar@QMainWindow@@QAEXPAVQStatusBar@@@Z @ 9879 NONAME ; void QMainWindow::setStatusBar(class QStatusBar *)
?setStatusTip@QAction@@QAEXABVQString@@@Z @ 9880 NONAME ; void QAction::setStatusTip(class QString const &)
@@ -10909,7 +10909,7 @@ EXPORTS
?textWidth@QTextDocument@@QBEMXZ @ 10908 NONAME ; float QTextDocument::textWidth(void) const
?texture@QBrush@@QBE?AVQPixmap@@XZ @ 10909 NONAME ; class QPixmap QBrush::texture(void) const
?textureImage@QBrush@@QBE?AVQImage@@XZ @ 10910 NONAME ; class QImage QBrush::textureImage(void) const
- ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@I@Z @ 10911 NONAME ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int) const
+ ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@I@Z @ 10911 NONAME ABSENT ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int) const
?themeName@QIcon@@SA?AVQString@@XZ @ 10912 NONAME ; class QString QIcon::themeName(void)
?themeSearchPaths@QIcon@@SA?AVQStringList@@XZ @ 10913 NONAME ; class QStringList QIcon::themeSearchPaths(void)
?tickInterval@QSlider@@QBEHXZ @ 10914 NONAME ; int QSlider::tickInterval(void) const
@@ -12511,7 +12511,7 @@ EXPORTS
?staticMetaObject@QFileSystemModel@@2UQMetaObject@@B @ 12510 NONAME ; struct QMetaObject const QFileSystemModel::staticMetaObject
?staticMetaObject@QKeyEventTransition@@2UQMetaObject@@B @ 12511 NONAME ; struct QMetaObject const QKeyEventTransition::staticMetaObject
?staticMetaObject@QLayout@@2UQMetaObject@@B @ 12512 NONAME ; struct QMetaObject const QLayout::staticMetaObject
- ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ; int QApplicationPrivate::app_compile_version
+ ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ABSENT ; int QApplicationPrivate::app_compile_version
?spacerItemFactoryMethod@QLayoutPrivate@@2P6APAVQSpacerItem@@PBVQLayout@@HHW4Policy@QSizePolicy@@1@ZA @ 12514 NONAME ; class QSpacerItem * (*QLayoutPrivate::spacerItemFactoryMethod)(class QLayout const *, int, int, enum QSizePolicy::Policy, enum QSizePolicy::Policy)
?allWidgets@QWidgetPrivate@@2PAV?$QSet@PAVQWidget@@@@A @ 12515 NONAME ; class QSet<class QWidget *> * QWidgetPrivate::allWidgets
?effectiveFocusWidget@QWidgetPrivate@@QAEPAVQWidget@@XZ @ 12516 NONAME ; class QWidget * QWidgetPrivate::effectiveFocusWidget(void)
@@ -12522,7 +12522,7 @@ EXPORTS
?addCacheData@QVectorPath@@QBEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX01@Z@Z @ 12521 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(class QPaintEngineEx *, void *)) const
?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N00@Z @ 12522 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool) const
?makeCacheable@QVectorPath@@QBEXXZ @ 12523 NONAME ; void QVectorPath::makeCacheable(void) const
- ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ; QTextOption::Tab::Tab(struct QTextOption::Tab const &)
+ ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ABSENT ; QTextOption::Tab::Tab(struct QTextOption::Tab const &)
?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@ABV2@@Z @ 12525 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QRectF const &) const
?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXW4Type@2@ABVQTransform@@@Z @ 12526 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, enum QFontEngineGlyphCache::Type, class QTransform const &) const
?qt_blurImage@@YAXAAVQImage@@M_NH@Z @ 12527 NONAME ; void qt_blurImage(class QImage &, float, bool, int)
@@ -12651,7 +12651,7 @@ EXPORTS
?toImage@QRuntimePixmapData@@UBE?AVQImage@@XZ @ 12650 NONAME ; class QImage QRuntimePixmapData::toImage(void) const
??0QAbstractScrollAreaPrivate@@QAE@XZ @ 12651 NONAME ; QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate(void)
?resizeEvent@QSplitterHandle@@MAEXPAVQResizeEvent@@@Z @ 12652 NONAME ; void QSplitterHandle::resizeEvent(class QResizeEvent *)
- ?setPartialUpdateSupport@QWindowSurface@@IAEX_N@Z @ 12653 NONAME ; void QWindowSurface::setPartialUpdateSupport(bool)
+ ?setPartialUpdateSupport@QWindowSurface@@IAEX_N@Z @ 12653 NONAME ABSENT ; void QWindowSurface::setPartialUpdateSupport(bool)
?HandleForegroundEventL@QS60MainAppUi@@MAEXH@Z @ 12654 NONAME ; void QS60MainAppUi::HandleForegroundEventL(int)
?curveThreshold@QStrokerOps@@QBEMXZ @ 12655 NONAME ; float QStrokerOps::curveThreshold(void) const
?createTextureData@QImageTextureGlyphCache@@UAEXHH@Z @ 12656 NONAME ; void QImageTextureGlyphCache::createTextureData(int, int)
@@ -12824,7 +12824,7 @@ EXPORTS
?fromImageReader@QPixmapData@@UAEXPAVQImageReader@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12823 NONAME ; void QPixmapData::fromImageReader(class QImageReader *, class QFlags<enum Qt::ImageConversionFlag>)
?toPolygon@QBezier@@QBE?AVQPolygonF@@M@Z @ 12824 NONAME ; class QPolygonF QBezier::toPolygon(float) const
?prepare@QStaticText@@QAEXABVQTransform@@ABVQFont@@@Z @ 12825 NONAME ; void QStaticText::prepare(class QTransform const &, class QFont const &)
- ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 12826 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int)
+ ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 12826 NONAME ABSENT ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int)
?OpenFileL@QS60MainDocument@@UAEXAAPAVCFileStore@@AAVRFile@@@Z @ 12827 NONAME ; void QS60MainDocument::OpenFileL(class CFileStore * &, class RFile &)
?fixup@QIntValidator@@UBEXAAVQString@@@Z @ 12828 NONAME ; void QIntValidator::fixup(class QString &) const
?resetHeight@QGraphicsItemPrivate@@UAEXXZ @ 12829 NONAME ; void QGraphicsItemPrivate::resetHeight(void)
@@ -12853,7 +12853,7 @@ EXPORTS
?updateAll@QGraphicsViewPrivate@@QAEXXZ @ 12852 NONAME ; void QGraphicsViewPrivate::updateAll(void)
?updateMicroFocus@QGraphicsItem@@IAEXXZ @ 12853 NONAME ; void QGraphicsItem::updateMicroFocus(void)
?populate@QTextureGlyphCache@@QAEXPAVQFontEngine@@HPBIPBUQFixedPoint@@@Z @ 12854 NONAME ABSENT ; void QTextureGlyphCache::populate(class QFontEngine *, int, unsigned int const *, struct QFixedPoint const *)
- ?hasPartialUpdateSupport@QWindowSurface@@QBE_NXZ @ 12855 NONAME ; bool QWindowSurface::hasPartialUpdateSupport(void) const
+ ?hasPartialUpdateSupport@QWindowSurface@@UBE_NXZ @ 12855 NONAME ; bool QWindowSurface::hasPartialUpdateSupport(void) const
?scroll@QRuntimePixmapData@@UAE_NHHABVQRect@@@Z @ 12856 NONAME ; bool QRuntimePixmapData::scroll(int, int, class QRect const &)
?qt_draw_glyphs@@YAXPAVQPainter@@PBIPBVQPointF@@H@Z @ 12857 NONAME ; void qt_draw_glyphs(class QPainter *, unsigned int const *, class QPointF const *, int)
?nativeDisplay@QEgl@@YAHXZ @ 12858 NONAME ; int QEgl::nativeDisplay(void)
@@ -12908,46 +12908,46 @@ EXPORTS
?resetCursorBlinkTimer@QLineControl@@QAEXXZ @ 12907 NONAME ; void QLineControl::resetCursorBlinkTimer(void)
?setSubFocus@QGraphicsItemPrivate@@QAEXPAVQGraphicsItem@@0@Z @ 12908 NONAME ; void QGraphicsItemPrivate::setSubFocus(class QGraphicsItem *, class QGraphicsItem *)
?clearSubFocus@QGraphicsItemPrivate@@QAEXPAVQGraphicsItem@@0@Z @ 12909 NONAME ; void QGraphicsItemPrivate::clearSubFocus(class QGraphicsItem *, class QGraphicsItem *)
- ?hitTest@QTextDocumentLayout@@UBEHABVQPointF@@W4HitTestAccuracy@Qt@@@Z @ 12910 NONAME ; int QTextDocumentLayout::hitTest(class QPointF const &, enum Qt::HitTestAccuracy) const
- ?positionInlineObject@QTextDocumentLayout@@MAEXVQTextInlineObject@@HABVQTextFormat@@@Z @ 12911 NONAME ; void QTextDocumentLayout::positionInlineObject(class QTextInlineObject, int, class QTextFormat const &)
- ?timerEvent@QTextDocumentLayout@@MAEXPAVQTimerEvent@@@Z @ 12912 NONAME ; void QTextDocumentLayout::timerEvent(class QTimerEvent *)
- ?draw@QTextDocumentLayout@@UAEXPAVQPainter@@ABUPaintContext@QAbstractTextDocumentLayout@@@Z @ 12913 NONAME ; void QTextDocumentLayout::draw(class QPainter *, struct QAbstractTextDocumentLayout::PaintContext const &)
- ?documentSize@QTextDocumentLayout@@UBE?AVQSizeF@@XZ @ 12914 NONAME ; class QSizeF QTextDocumentLayout::documentSize(void) const
- ?drawInlineObject@QTextDocumentLayout@@MAEXPAVQPainter@@ABVQRectF@@VQTextInlineObject@@HABVQTextFormat@@@Z @ 12915 NONAME ; void QTextDocumentLayout::drawInlineObject(class QPainter *, class QRectF const &, class QTextInlineObject, int, class QTextFormat const &)
- ?resizeInlineObject@QTextDocumentLayout@@MAEXVQTextInlineObject@@HABVQTextFormat@@@Z @ 12916 NONAME ; void QTextDocumentLayout::resizeInlineObject(class QTextInlineObject, int, class QTextFormat const &)
- ?dynamicDocumentSize@QTextDocumentLayout@@QBE?AVQSizeF@@XZ @ 12917 NONAME ; class QSizeF QTextDocumentLayout::dynamicDocumentSize(void) const
- ?metaObject@QTextDocumentLayout@@UBEPBUQMetaObject@@XZ @ 12918 NONAME ; struct QMetaObject const * QTextDocumentLayout::metaObject(void) const
- ?getStaticMetaObject@QTextDocumentLayout@@SAABUQMetaObject@@XZ @ 12919 NONAME ; struct QMetaObject const & QTextDocumentLayout::getStaticMetaObject(void)
- ?blockBoundingRect@QTextDocumentLayout@@UBE?AVQRectF@@ABVQTextBlock@@@Z @ 12920 NONAME ; class QRectF QTextDocumentLayout::blockBoundingRect(class QTextBlock const &) const
- ?qt_metacall@QTextDocumentLayout@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 12921 NONAME ; int QTextDocumentLayout::qt_metacall(enum QMetaObject::Call, int, void * *)
- ?d_func@QTextDocumentLayout@@AAEPAVQTextDocumentLayoutPrivate@@XZ @ 12922 NONAME ; class QTextDocumentLayoutPrivate * QTextDocumentLayout::d_func(void)
+ ?hitTest@QTextDocumentLayout@@UBEHABVQPointF@@W4HitTestAccuracy@Qt@@@Z @ 12910 NONAME ABSENT ; int QTextDocumentLayout::hitTest(class QPointF const &, enum Qt::HitTestAccuracy) const
+ ?positionInlineObject@QTextDocumentLayout@@MAEXVQTextInlineObject@@HABVQTextFormat@@@Z @ 12911 NONAME ABSENT ; void QTextDocumentLayout::positionInlineObject(class QTextInlineObject, int, class QTextFormat const &)
+ ?timerEvent@QTextDocumentLayout@@MAEXPAVQTimerEvent@@@Z @ 12912 NONAME ABSENT ; void QTextDocumentLayout::timerEvent(class QTimerEvent *)
+ ?draw@QTextDocumentLayout@@UAEXPAVQPainter@@ABUPaintContext@QAbstractTextDocumentLayout@@@Z @ 12913 NONAME ABSENT ; void QTextDocumentLayout::draw(class QPainter *, struct QAbstractTextDocumentLayout::PaintContext const &)
+ ?documentSize@QTextDocumentLayout@@UBE?AVQSizeF@@XZ @ 12914 NONAME ABSENT ; class QSizeF QTextDocumentLayout::documentSize(void) const
+ ?drawInlineObject@QTextDocumentLayout@@MAEXPAVQPainter@@ABVQRectF@@VQTextInlineObject@@HABVQTextFormat@@@Z @ 12915 NONAME ABSENT ; void QTextDocumentLayout::drawInlineObject(class QPainter *, class QRectF const &, class QTextInlineObject, int, class QTextFormat const &)
+ ?resizeInlineObject@QTextDocumentLayout@@MAEXVQTextInlineObject@@HABVQTextFormat@@@Z @ 12916 NONAME ABSENT ; void QTextDocumentLayout::resizeInlineObject(class QTextInlineObject, int, class QTextFormat const &)
+ ?dynamicDocumentSize@QTextDocumentLayout@@QBE?AVQSizeF@@XZ @ 12917 NONAME ABSENT ; class QSizeF QTextDocumentLayout::dynamicDocumentSize(void) const
+ ?metaObject@QTextDocumentLayout@@UBEPBUQMetaObject@@XZ @ 12918 NONAME ABSENT ; struct QMetaObject const * QTextDocumentLayout::metaObject(void) const
+ ?getStaticMetaObject@QTextDocumentLayout@@SAABUQMetaObject@@XZ @ 12919 NONAME ABSENT ; struct QMetaObject const & QTextDocumentLayout::getStaticMetaObject(void)
+ ?blockBoundingRect@QTextDocumentLayout@@UBE?AVQRectF@@ABVQTextBlock@@@Z @ 12920 NONAME ABSENT ; class QRectF QTextDocumentLayout::blockBoundingRect(class QTextBlock const &) const
+ ?qt_metacall@QTextDocumentLayout@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 12921 NONAME ABSENT ; int QTextDocumentLayout::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?d_func@QTextDocumentLayout@@AAEPAVQTextDocumentLayoutPrivate@@XZ @ 12922 NONAME ABSENT ; class QTextDocumentLayoutPrivate * QTextDocumentLayout::d_func(void)
?isDragEnabled@QTextControl@@QBE_NXZ @ 12923 NONAME ; bool QTextControl::isDragEnabled(void) const
- ?staticMetaObject@QTextDocumentLayout@@2UQMetaObject@@B @ 12924 NONAME ; struct QMetaObject const QTextDocumentLayout::staticMetaObject
- ?qt_metacast@QTextDocumentLayout@@UAEPAXPBD@Z @ 12925 NONAME ; void * QTextDocumentLayout::qt_metacast(char const *)
- ?documentChanged@QTextDocumentLayout@@MAEXHHH@Z @ 12926 NONAME ; void QTextDocumentLayout::documentChanged(int, int, int)
- ??1QTextDocumentLayout@@UAE@XZ @ 12927 NONAME ; QTextDocumentLayout::~QTextDocumentLayout(void)
- ?layoutStatus@QTextDocumentLayout@@QBEHXZ @ 12928 NONAME ; int QTextDocumentLayout::layoutStatus(void) const
+ ?staticMetaObject@QTextDocumentLayout@@2UQMetaObject@@B @ 12924 NONAME ABSENT ; struct QMetaObject const QTextDocumentLayout::staticMetaObject
+ ?qt_metacast@QTextDocumentLayout@@UAEPAXPBD@Z @ 12925 NONAME ABSENT ; void * QTextDocumentLayout::qt_metacast(char const *)
+ ?documentChanged@QTextDocumentLayout@@MAEXHHH@Z @ 12926 NONAME ABSENT ; void QTextDocumentLayout::documentChanged(int, int, int)
+ ??1QTextDocumentLayout@@UAE@XZ @ 12927 NONAME ABSENT ; QTextDocumentLayout::~QTextDocumentLayout(void)
+ ?layoutStatus@QTextDocumentLayout@@QBEHXZ @ 12928 NONAME ABSENT ; int QTextDocumentLayout::layoutStatus(void) const
?setDragEnabled@QTextControl@@QAEX_N@Z @ 12929 NONAME ; void QTextControl::setDragEnabled(bool)
- ?d_func@QTextDocumentLayout@@ABEPBVQTextDocumentLayoutPrivate@@XZ @ 12930 NONAME ; class QTextDocumentLayoutPrivate const * QTextDocumentLayout::d_func(void) const
- ?idealWidth@QTextDocumentLayout@@QBEMXZ @ 12931 NONAME ; float QTextDocumentLayout::idealWidth(void) const
- ?setFixedColumnWidth@QTextDocumentLayout@@QAEXH@Z @ 12932 NONAME ; void QTextDocumentLayout::setFixedColumnWidth(int)
- ?cursorWidth@QTextDocumentLayout@@QBEHXZ @ 12933 NONAME ; int QTextDocumentLayout::cursorWidth(void) const
- ?trUtf8@QTextDocumentLayout@@SA?AVQString@@PBD0H@Z @ 12934 NONAME ; class QString QTextDocumentLayout::trUtf8(char const *, char const *, int)
- ?pageCount@QTextDocumentLayout@@UBEHXZ @ 12935 NONAME ; int QTextDocumentLayout::pageCount(void) const
- ?setViewport@QTextDocumentLayout@@QAEXABVQRectF@@@Z @ 12936 NONAME ; void QTextDocumentLayout::setViewport(class QRectF const &)
- ?contentHasAlignment@QTextDocumentLayout@@QBE_NXZ @ 12937 NONAME ; bool QTextDocumentLayout::contentHasAlignment(void) const
- ?tr@QTextDocumentLayout@@SA?AVQString@@PBD0@Z @ 12938 NONAME ; class QString QTextDocumentLayout::tr(char const *, char const *)
- ?setLineHeight@QTextDocumentLayout@@IAEXMW4LineHeightMode@1@@Z @ 12939 NONAME ; void QTextDocumentLayout::setLineHeight(float, enum QTextDocumentLayout::LineHeightMode)
- ?tr@QTextDocumentLayout@@SA?AVQString@@PBD0H@Z @ 12940 NONAME ; class QString QTextDocumentLayout::tr(char const *, char const *, int)
- ?trUtf8@QTextDocumentLayout@@SA?AVQString@@PBD0@Z @ 12941 NONAME ; class QString QTextDocumentLayout::trUtf8(char const *, char const *)
- ?frameBoundingRect@QTextDocumentLayout@@UBE?AVQRectF@@PAVQTextFrame@@@Z @ 12942 NONAME ; class QRectF QTextDocumentLayout::frameBoundingRect(class QTextFrame *) const
- ?setCursorWidth@QTextDocumentLayout@@QAEXH@Z @ 12943 NONAME ; void QTextDocumentLayout::setCursorWidth(int)
- ??_EQTextDocumentLayout@@UAE@I@Z @ 12944 NONAME ; QTextDocumentLayout::~QTextDocumentLayout(unsigned int)
- ??0QTextDocumentLayout@@QAE@PAVQTextDocument@@@Z @ 12945 NONAME ; QTextDocumentLayout::QTextDocumentLayout(class QTextDocument *)
- ?doLayout@QTextDocumentLayout@@AAE?AVQRectF@@HHH@Z @ 12946 NONAME ; class QRectF QTextDocumentLayout::doLayout(int, int, int)
- ?ensureLayouted@QTextDocumentLayout@@QAEXM@Z @ 12947 NONAME ; void QTextDocumentLayout::ensureLayouted(float)
- ?layoutFinished@QTextDocumentLayout@@AAEXXZ @ 12948 NONAME ; void QTextDocumentLayout::layoutFinished(void)
- ?dynamicPageCount@QTextDocumentLayout@@QBEHXZ @ 12949 NONAME ; int QTextDocumentLayout::dynamicPageCount(void) const
+ ?d_func@QTextDocumentLayout@@ABEPBVQTextDocumentLayoutPrivate@@XZ @ 12930 NONAME ABSENT ; class QTextDocumentLayoutPrivate const * QTextDocumentLayout::d_func(void) const
+ ?idealWidth@QTextDocumentLayout@@QBEMXZ @ 12931 NONAME ABSENT ; float QTextDocumentLayout::idealWidth(void) const
+ ?setFixedColumnWidth@QTextDocumentLayout@@QAEXH@Z @ 12932 NONAME ABSENT ; void QTextDocumentLayout::setFixedColumnWidth(int)
+ ?cursorWidth@QTextDocumentLayout@@QBEHXZ @ 12933 NONAME ABSENT ; int QTextDocumentLayout::cursorWidth(void) const
+ ?trUtf8@QTextDocumentLayout@@SA?AVQString@@PBD0H@Z @ 12934 NONAME ABSENT ; class QString QTextDocumentLayout::trUtf8(char const *, char const *, int)
+ ?pageCount@QTextDocumentLayout@@UBEHXZ @ 12935 NONAME ABSENT ; int QTextDocumentLayout::pageCount(void) const
+ ?setViewport@QTextDocumentLayout@@QAEXABVQRectF@@@Z @ 12936 NONAME ABSENT ; void QTextDocumentLayout::setViewport(class QRectF const &)
+ ?contentHasAlignment@QTextDocumentLayout@@QBE_NXZ @ 12937 NONAME ABSENT ; bool QTextDocumentLayout::contentHasAlignment(void) const
+ ?tr@QTextDocumentLayout@@SA?AVQString@@PBD0@Z @ 12938 NONAME ABSENT ; class QString QTextDocumentLayout::tr(char const *, char const *)
+ ?setLineHeight@QTextDocumentLayout@@IAEXMW4LineHeightMode@1@@Z @ 12939 NONAME ABSENT ; void QTextDocumentLayout::setLineHeight(float, enum QTextDocumentLayout::LineHeightMode)
+ ?tr@QTextDocumentLayout@@SA?AVQString@@PBD0H@Z @ 12940 NONAME ABSENT ; class QString QTextDocumentLayout::tr(char const *, char const *, int)
+ ?trUtf8@QTextDocumentLayout@@SA?AVQString@@PBD0@Z @ 12941 NONAME ABSENT ; class QString QTextDocumentLayout::trUtf8(char const *, char const *)
+ ?frameBoundingRect@QTextDocumentLayout@@UBE?AVQRectF@@PAVQTextFrame@@@Z @ 12942 NONAME ABSENT ; class QRectF QTextDocumentLayout::frameBoundingRect(class QTextFrame *) const
+ ?setCursorWidth@QTextDocumentLayout@@QAEXH@Z @ 12943 NONAME ABSENT ; void QTextDocumentLayout::setCursorWidth(int)
+ ??_EQTextDocumentLayout@@UAE@I@Z @ 12944 NONAME ABSENT ; QTextDocumentLayout::~QTextDocumentLayout(unsigned int)
+ ??0QTextDocumentLayout@@QAE@PAVQTextDocument@@@Z @ 12945 NONAME ABSENT ; QTextDocumentLayout::QTextDocumentLayout(class QTextDocument *)
+ ?doLayout@QTextDocumentLayout@@AAE?AVQRectF@@HHH@Z @ 12946 NONAME ABSENT ; class QRectF QTextDocumentLayout::doLayout(int, int, int)
+ ?ensureLayouted@QTextDocumentLayout@@QAEXM@Z @ 12947 NONAME ABSENT ; void QTextDocumentLayout::ensureLayouted(float)
+ ?layoutFinished@QTextDocumentLayout@@AAEXXZ @ 12948 NONAME ABSENT ; void QTextDocumentLayout::layoutFinished(void)
+ ?dynamicPageCount@QTextDocumentLayout@@QBEHXZ @ 12949 NONAME ABSENT ; int QTextDocumentLayout::dynamicPageCount(void) const
?setWordSelectionEnabled@QTextControl@@QAEX_N@Z @ 12950 NONAME ; void QTextControl::setWordSelectionEnabled(bool)
?isWordSelectionEnabled@QTextControl@@QBE_NXZ @ 12951 NONAME ; bool QTextControl::isWordSelectionEnabled(void) const
?assignedInputContext@QWidgetPrivate@@QBEPAVQInputContext@@XZ @ 12952 NONAME ; class QInputContext * QWidgetPrivate::assignedInputContext(void) const
@@ -12981,4 +12981,394 @@ EXPORTS
?depth@QVolatileImage@@QBEHXZ @ 12980 NONAME ; int QVolatileImage::depth(void) const
?releaseCachedResources@QGraphicsSystem@@UAEXXZ @ 12981 NONAME ; void QGraphicsSystem::releaseCachedResources(void)
?qt_s60_setPartialScreenInputMode@@YAX_N@Z @ 12982 NONAME ; void qt_s60_setPartialScreenInputMode(bool)
+ ?clipEnabledChanged@QBlitterPaintEngine@@UAEXXZ @ 12983 NONAME ; void QBlitterPaintEngine::clipEnabledChanged(void)
+ ?supportsSubPixelPositions@QFontEngine@@UBE_NXZ @ 12984 NONAME ; bool QFontEngine::supportsSubPixelPositions(void) const
+ ??_EQScrollerProperties@@UAE@I@Z @ 12985 NONAME ; QScrollerProperties::~QScrollerProperties(unsigned int)
+ ??_EQFontPrivate@@QAE@I@Z @ 12986 NONAME ABSENT ; QFontPrivate::~QFontPrivate(unsigned int)
+ ??0QMimeSource@@QAE@XZ @ 12987 NONAME ABSENT ; QMimeSource::QMimeSource(void)
+ ??0QStyleFactoryInterface@@QAE@XZ @ 12988 NONAME ABSENT ; QStyleFactoryInterface::QStyleFactoryInterface(void)
+ ?d_func@QScrollEvent@@AAEPAVQScrollEventPrivate@@XZ @ 12989 NONAME ; class QScrollEventPrivate * QScrollEvent::d_func(void)
+ ??0QFileOpenEvent@@QAE@ABV0@@Z @ 12990 NONAME ABSENT ; QFileOpenEvent::QFileOpenEvent(class QFileOpenEvent const &)
+ ??4QStyleOptionViewItemV2@@QAEAAV0@ABV0@@Z @ 12991 NONAME ABSENT ; class QStyleOptionViewItemV2 & QStyleOptionViewItemV2::operator=(class QStyleOptionViewItemV2 const &)
+ ?heightForWidth@QTabWidget@@UBEHH@Z @ 12992 NONAME ; int QTabWidget::heightForWidth(int) const
+ ??1QFlickGesture@@UAE@XZ @ 12993 NONAME ; QFlickGesture::~QFlickGesture(void)
+ ??0QRasterWindowSurface@@QAE@PAVQWidget@@_N@Z @ 12994 NONAME ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *, bool)
+ ?brushChanged@QBlitterPaintEngine@@UAEXXZ @ 12995 NONAME ; void QBlitterPaintEngine::brushChanged(void)
+ ?clip@QBlitterPaintEngine@@UAEXABVQRect@@W4ClipOperation@Qt@@@Z @ 12996 NONAME ; void QBlitterPaintEngine::clip(class QRect const &, enum Qt::ClipOperation)
+ ?detach@QGlyphs@@AAEXXZ @ 12997 NONAME ; void QGlyphs::detach(void)
+ ?trUtf8@QInternalMimeData@@SA?AVQString@@PBD0@Z @ 12998 NONAME ; class QString QInternalMimeData::trUtf8(char const *, char const *)
+ ??0QShowEvent@@QAE@ABV0@@Z @ 12999 NONAME ABSENT ; QShowEvent::QShowEvent(class QShowEvent const &)
+ ??0QMouseEvent@@QAE@ABV0@@Z @ 13000 NONAME ABSENT ; QMouseEvent::QMouseEvent(class QMouseEvent const &)
+ ?setHintingPreference@QFont@@QAEXW4HintingPreference@1@@Z @ 13001 NONAME ; void QFont::setHintingPreference(enum QFont::HintingPreference)
+ ??0QActionEvent@@QAE@ABV0@@Z @ 13002 NONAME ABSENT ; QActionEvent::QActionEvent(class QActionEvent const &)
+ ??0QTouchEvent@@QAE@ABV0@@Z @ 13003 NONAME ABSENT ; QTouchEvent::QTouchEvent(class QTouchEvent const &)
+ ?capabilities@QBlittable@@QBE?AV?$QFlags@W4Capability@QBlittable@@@@XZ @ 13004 NONAME ; class QFlags<enum QBlittable::Capability> QBlittable::capabilities(void) const
+ ?setContentPosRange@QScrollPrepareEvent@@QAEXABVQRectF@@@Z @ 13005 NONAME ; void QScrollPrepareEvent::setContentPosRange(class QRectF const &)
+ ??_EQImageData@@QAE@I@Z @ 13006 NONAME ABSENT ; QImageData::~QImageData(unsigned int)
+ ?swap@QBrush@@QAEXAAV1@@Z @ 13007 NONAME ; void QBrush::swap(class QBrush &)
+ ?trUtf8@QFlickGesture@@SA?AVQString@@PBD0H@Z @ 13008 NONAME ; class QString QFlickGesture::trUtf8(char const *, char const *, int)
+ ?fontHintingPreference@QTextCharFormat@@QBE?AW4HintingPreference@QFont@@XZ @ 13009 NONAME ; enum QFont::HintingPreference QTextCharFormat::fontHintingPreference(void) const
+ ?swap@QPixmap@@QAEXAAV1@@Z @ 13010 NONAME ; void QPixmap::swap(class QPixmap &)
+ ??0QBlitterPaintEngine@@QAE@PAVQBlittablePixmapData@@@Z @ 13011 NONAME ; QBlitterPaintEngine::QBlitterPaintEngine(class QBlittablePixmapData *)
+ ?numberPrefix@QTextListFormat@@QBE?AVQString@@XZ @ 13012 NONAME ; class QString QTextListFormat::numberPrefix(void) const
+ ?setSnapPositionsX@QScroller@@QAEXMM@Z @ 13013 NONAME ; void QScroller::setSnapPositionsX(float, float)
+ ?scroller@QScroller@@SAPBV1@PBVQObject@@@Z @ 13014 NONAME ; class QScroller const * QScroller::scroller(class QObject const *)
+ ?qt_metacall@QScroller@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 13015 NONAME ; int QScroller::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?tr@QFlickGesture@@SA?AVQString@@PBD0@Z @ 13016 NONAME ; class QString QFlickGesture::tr(char const *, char const *)
+ ??4QBezier@@QAEAAV0@ABV0@@Z @ 13017 NONAME ABSENT ; class QBezier & QBezier::operator=(class QBezier const &)
+ ?setScrollerProperties@QScroller@@QAEXABVQScrollerProperties@@@Z @ 13018 NONAME ; void QScroller::setScrollerProperties(class QScrollerProperties const &)
+ ??0QIconEngineV2@@QAE@XZ @ 13019 NONAME ABSENT ; QIconEngineV2::QIconEngineV2(void)
+ ??4iterator@QTextBlock@@QAEAAV01@ABV01@@Z @ 13020 NONAME ABSENT ; class QTextBlock::iterator & QTextBlock::iterator::operator=(class QTextBlock::iterator const &)
+ ??MQItemSelectionRange@@QBE_NABV0@@Z @ 13021 NONAME ; bool QItemSelectionRange::operator<(class QItemSelectionRange const &) const
+ ?setWidthForHeight@QSizePolicy@@QAEX_N@Z @ 13022 NONAME ; void QSizePolicy::setWidthForHeight(bool)
+ ?qt_fontdata_from_index@@YA?AVQByteArray@@H@Z @ 13023 NONAME ; class QByteArray qt_fontdata_from_index(int)
+ ??0QIconEngineV2@@QAE@ABV0@@Z @ 13024 NONAME ABSENT ; QIconEngineV2::QIconEngineV2(class QIconEngineV2 const &)
+ ?swap@QImage@@QAEXAAV1@@Z @ 13025 NONAME ; void QImage::swap(class QImage &)
+ ??0QIconEngineFactoryInterfaceV2@@QAE@XZ @ 13026 NONAME ABSENT ; QIconEngineFactoryInterfaceV2::QIconEngineFactoryInterfaceV2(void)
+ ??0QScroller@@AAE@PAVQObject@@@Z @ 13027 NONAME ; QScroller::QScroller(class QObject *)
+ ?compositionModeChanged@QBlitterPaintEngine@@UAEXXZ @ 13028 NONAME ; void QBlitterPaintEngine::compositionModeChanged(void)
+ ?contentPosRange@QScrollPrepareEvent@@QBE?AVQRectF@@XZ @ 13029 NONAME ; class QRectF QScrollPrepareEvent::contentPosRange(void) const
+ ?grabGesture@QScroller@@SA?AW4GestureType@Qt@@PAVQObject@@W4ScrollerGestureType@1@@Z @ 13030 NONAME ; enum Qt::GestureType QScroller::grabGesture(class QObject *, enum QScroller::ScrollerGestureType)
+ ??_EQFlickGesture@@UAE@I@Z @ 13031 NONAME ; QFlickGesture::~QFlickGesture(unsigned int)
+ ?drawRects@QBlitterPaintEngine@@UAEXPBVQRectF@@H@Z @ 13032 NONAME ; void QBlitterPaintEngine::drawRects(class QRectF const *, int)
+ ??4QTextLine@@QAEAAV0@ABV0@@Z @ 13033 NONAME ABSENT ; class QTextLine & QTextLine::operator=(class QTextLine const &)
+ ??0QToolBarChangeEvent@@QAE@ABV0@@Z @ 13034 NONAME ABSENT ; QToolBarChangeEvent::QToolBarChangeEvent(class QToolBarChangeEvent const &)
+ ??1QBlitterPaintEngine@@UAE@XZ @ 13035 NONAME ; QBlitterPaintEngine::~QBlitterPaintEngine(void)
+ ?markRasterOverlay@QBlittablePixmapData@@QAEXPBVQRectF@@H@Z @ 13036 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRectF const *, int)
+ ??0QResizeEvent@@QAE@ABV0@@Z @ 13037 NONAME ABSENT ; QResizeEvent::QResizeEvent(class QResizeEvent const &)
+ ??0QIconEngineFactoryInterface@@QAE@XZ @ 13038 NONAME ABSENT ; QIconEngineFactoryInterface::QIconEngineFactoryInterface(void)
+ ?drawTextItem@QBlitterPaintEngine@@UAEXABVQPointF@@ABVQTextItem@@@Z @ 13039 NONAME ; void QBlitterPaintEngine::drawTextItem(class QPointF const &, class QTextItem const &)
+ ??0QPictureFormatInterface@@QAE@XZ @ 13040 NONAME ABSENT ; QPictureFormatInterface::QPictureFormatInterface(void)
+ ?trUtf8@QFlickGesture@@SA?AVQString@@PBD0@Z @ 13041 NONAME ; class QString QFlickGesture::trUtf8(char const *, char const *)
+ ?stop@QScroller@@QAEXXZ @ 13042 NONAME ; void QScroller::stop(void)
+ ?retrieveData@QInternalMimeData@@MBE?AVQVariant@@ABVQString@@W4Type@2@@Z @ 13043 NONAME ; class QVariant QInternalMimeData::retrieveData(class QString const &, enum QVariant::Type) const
+ ??8QGlyphs@@QBE_NABV0@@Z @ 13044 NONAME ; bool QGlyphs::operator==(class QGlyphs const &) const
+ ?drawImage@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQImage@@0V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 13045 NONAME ; void QBlitterPaintEngine::drawImage(class QRectF const &, class QImage const &, class QRectF const &, class QFlags<enum Qt::ImageConversionFlag>)
+ ?contentPos@QScrollEvent@@QBE?AVQPointF@@XZ @ 13046 NONAME ; class QPointF QScrollEvent::contentPos(void) const
+ ?mimeTypes@QAbstractProxyModel@@UBE?AVQStringList@@XZ @ 13047 NONAME ; class QStringList QAbstractProxyModel::mimeTypes(void) const
+ ?createState@QBlitterPaintEngine@@UBEPAVQPainterState@@PAV2@@Z @ 13048 NONAME ; class QPainterState * QBlitterPaintEngine::createState(class QPainterState *) const
+ ?removeItem@QGraphicsGridLayout@@QAEXPAVQGraphicsLayoutItem@@@Z @ 13049 NONAME ; void QGraphicsGridLayout::removeItem(class QGraphicsLayoutItem *)
+ ?clipBoundingRect@QPainter@@QBE?AVQRectF@@XZ @ 13050 NONAME ; class QRectF QPainter::clipBoundingRect(void) const
+ ?formats@QInternalMimeData@@UBE?AVQStringList@@XZ @ 13051 NONAME ; class QStringList QInternalMimeData::formats(void) const
+ ?stateChanged@QScroller@@IAEXW4State@1@@Z @ 13052 NONAME ; void QScroller::stateChanged(enum QScroller::State)
+ ?raster@QBlitterPaintEngine@@ABEPAVQRasterPaintEngine@@XZ @ 13053 NONAME ; class QRasterPaintEngine * QBlitterPaintEngine::raster(void) const
+ ?sort@QAbstractProxyModel@@UAEXHW4SortOrder@Qt@@@Z @ 13054 NONAME ; void QAbstractProxyModel::sort(int, enum Qt::SortOrder)
+ ?d_func@QBlittable@@AAEPAVQBlittablePrivate@@XZ @ 13055 NONAME ; class QBlittablePrivate * QBlittable::d_func(void)
+ ?setDefaultScrollerProperties@QScrollerProperties@@SAXABV1@@Z @ 13056 NONAME ; void QScrollerProperties::setDefaultScrollerProperties(class QScrollerProperties const &)
+ ??_EQPolygon@@QAE@I@Z @ 13057 NONAME ABSENT ; QPolygon::~QPolygon(unsigned int)
+ ?type@QBlitterPaintEngine@@UBE?AW4Type@QPaintEngine@@XZ @ 13058 NONAME ; enum QPaintEngine::Type QBlitterPaintEngine::type(void) const
+ ?qt_metacast@QScroller@@UAEPAXPBD@Z @ 13059 NONAME ; void * QScroller::qt_metacast(char const *)
+ ??_EQImageReader@@QAE@I@Z @ 13060 NONAME ABSENT ; QImageReader::~QImageReader(unsigned int)
+ ?buddy@QAbstractProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 13061 NONAME ; class QModelIndex QAbstractProxyModel::buddy(class QModelIndex const &) const
+ ?tr@QScroller@@SA?AVQString@@PBD0H@Z @ 13062 NONAME ; class QString QScroller::tr(char const *, char const *, int)
+ ?fill@QImage@@QAEXABVQColor@@@Z @ 13063 NONAME ; void QImage::fill(class QColor const &)
+ ?scrollMetric@QScrollerProperties@@QBE?AVQVariant@@W4ScrollMetric@1@@Z @ 13064 NONAME ; class QVariant QScrollerProperties::scrollMetric(enum QScrollerProperties::ScrollMetric) const
+ ?fill@QImage@@QAEXW4GlobalColor@Qt@@@Z @ 13065 NONAME ; void QImage::fill(enum Qt::GlobalColor)
+ ??4QStyleOptionGraphicsItem@@QAEAAV0@ABV0@@Z @ 13066 NONAME ABSENT ; class QStyleOptionGraphicsItem & QStyleOptionGraphicsItem::operator=(class QStyleOptionGraphicsItem const &)
+ ?canFetchMore@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 13067 NONAME ; bool QAbstractProxyModel::canFetchMore(class QModelIndex const &) const
+ ??4QStyleOptionProgressBarV2@@QAEAAV0@ABV0@@Z @ 13068 NONAME ABSENT ; class QStyleOptionProgressBarV2 & QStyleOptionProgressBarV2::operator=(class QStyleOptionProgressBarV2 const &)
+ ??1QScroller@@EAE@XZ @ 13069 NONAME ; QScroller::~QScroller(void)
+ ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 13070 NONAME ; void QGlyphs::setFont(class QFont const &)
+ ?startPos@QScrollPrepareEvent@@QBE?AVQPointF@@XZ @ 13071 NONAME ; class QPointF QScrollPrepareEvent::startPos(void) const
+ ?resize@QBlittablePixmapData@@UAEXHH@Z @ 13072 NONAME ; void QBlittablePixmapData::resize(int, int)
+ ?setTabsClosable@QMdiArea@@QAEX_N@Z @ 13073 NONAME ; void QMdiArea::setTabsClosable(bool)
+ ?ensureVisible@QScroller@@QAEXABVQRectF@@MM@Z @ 13074 NONAME ; void QScroller::ensureVisible(class QRectF const &, float, float)
+ ?getText@QInputDialog@@SA?AVQString@@PAVQWidget@@ABV2@1W4EchoMode@QLineEdit@@1PA_NV?$QFlags@W4WindowType@Qt@@@@V?$QFlags@W4InputMethodHint@Qt@@@@@Z @ 13075 NONAME ; class QString QInputDialog::getText(class QWidget *, class QString const &, class QString const &, enum QLineEdit::EchoMode, class QString const &, bool *, class QFlags<enum Qt::WindowType>, class QFlags<enum Qt::InputMethodHint>)
+ ?hasWidthForHeight@QSizePolicy@@QBE_NXZ @ 13076 NONAME ; bool QSizePolicy::hasWidthForHeight(void) const
+ ?transformChanged@QBlitterPaintEngine@@UAEXXZ @ 13077 NONAME ; void QBlitterPaintEngine::transformChanged(void)
+ ??0QDragEnterEvent@@QAE@ABV0@@Z @ 13078 NONAME ABSENT ; QDragEnterEvent::QDragEnterEvent(class QDragEnterEvent const &)
+ ??0QBlittablePixmapData@@QAE@XZ @ 13079 NONAME ; QBlittablePixmapData::QBlittablePixmapData(void)
+ ??_EKey@QPixmapCache@@QAE@I@Z @ 13080 NONAME ABSENT ; QPixmapCache::Key::~Key(unsigned int)
+ ??_EQCursor@@QAE@I@Z @ 13081 NONAME ABSENT ; QCursor::~QCursor(unsigned int)
+ ?size@QBlittable@@QBE?AVQSize@@XZ @ 13082 NONAME ; class QSize QBlittable::size(void) const
+ ??0QShortcutEvent@@QAE@ABV0@@Z @ 13083 NONAME ABSENT ; QShortcutEvent::QShortcutEvent(class QShortcutEvent const &)
+ ?setBlittable@QBlittablePixmapData@@QAEXPAVQBlittable@@@Z @ 13084 NONAME ; void QBlittablePixmapData::setBlittable(class QBlittable *)
+ ?opacityChanged@QBlitterPaintEngine@@UAEXXZ @ 13085 NONAME ; void QBlitterPaintEngine::opacityChanged(void)
+ ?tr@QFlickGesture@@SA?AVQString@@PBD0H@Z @ 13086 NONAME ; class QString QFlickGesture::tr(char const *, char const *, int)
+ ??_EQTextCursor@@QAE@I@Z @ 13087 NONAME ABSENT ; QTextCursor::~QTextCursor(unsigned int)
+ ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 13088 NONAME ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const
+ ?setState@QBlitterPaintEngine@@UAEXPAVQPainterState@@@Z @ 13089 NONAME ; void QBlitterPaintEngine::setState(class QPainterState *)
+ ?clip@QBlitterPaintEngine@@UAEXABVQRegion@@W4ClipOperation@Qt@@@Z @ 13090 NONAME ; void QBlitterPaintEngine::clip(class QRegion const &, enum Qt::ClipOperation)
+ ?subPixelPositionForX@QTextureGlyphCache@@QBE?AUQFixed@@U2@@Z @ 13091 NONAME ; struct QFixed QTextureGlyphCache::subPixelPositionForX(struct QFixed) const
+ ?hasAlphaChannel@QBlittablePixmapData@@UBE_NXZ @ 13092 NONAME ; bool QBlittablePixmapData::hasAlphaChannel(void) const
+ ?setSnapPositionsX@QScroller@@QAEXABV?$QList@M@@@Z @ 13093 NONAME ; void QScroller::setSnapPositionsX(class QList<float> const &)
+ ?numberSuffix@QTextListFormat@@QBE?AVQString@@XZ @ 13094 NONAME ; class QString QTextListFormat::numberSuffix(void) const
+ ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 13095 NONAME ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const
+ ??0QGradient@@QAE@ABV0@@Z @ 13096 NONAME ABSENT ; QGradient::QGradient(class QGradient const &)
+ ?tabsMovable@QMdiArea@@QBE_NXZ @ 13097 NONAME ; bool QMdiArea::tabsMovable(void) const
+ ??4QInputMethodEvent@@QAEAAV0@ABV0@@Z @ 13098 NONAME ABSENT ; class QInputMethodEvent & QInputMethodEvent::operator=(class QInputMethodEvent const &)
+ ?contentPos@QScrollPrepareEvent@@QBE?AVQPointF@@XZ @ 13099 NONAME ; class QPointF QScrollPrepareEvent::contentPos(void) const
+ ?getStaticMetaObject@QScroller@@SAABUQMetaObject@@XZ @ 13100 NONAME ; struct QMetaObject const & QScroller::getStaticMetaObject(void)
+ ?end@QBlitterPaintEngine@@UAE_NXZ @ 13101 NONAME ; bool QBlitterPaintEngine::end(void)
+ ??1QScrollerProperties@@UAE@XZ @ 13102 NONAME ; QScrollerProperties::~QScrollerProperties(void)
+ ??0QFlickGesture@@QAE@PAVQObject@@W4MouseButton@Qt@@0@Z @ 13103 NONAME ; QFlickGesture::QFlickGesture(class QObject *, enum Qt::MouseButton, class QObject *)
+ ?fill@QBlitterPaintEngine@@UAEXABVQVectorPath@@ABVQBrush@@@Z @ 13104 NONAME ; void QBlitterPaintEngine::fill(class QVectorPath const &, class QBrush const &)
+ ?drawPixmap@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQPixmap@@0@Z @ 13105 NONAME ; void QBlitterPaintEngine::drawPixmap(class QRectF const &, class QPixmap const &, class QRectF const &)
+ ??0QVector2D@@QAE@ABV0@@Z @ 13106 NONAME ABSENT ; QVector2D::QVector2D(class QVector2D const &)
+ ?setSnapPositionsY@QScroller@@QAEXABV?$QList@M@@@Z @ 13107 NONAME ; void QScroller::setSnapPositionsY(class QList<float> const &)
+ ??4QStyleOptionFocusRect@@QAEAAV0@ABV0@@Z @ 13108 NONAME ABSENT ; class QStyleOptionFocusRect & QStyleOptionFocusRect::operator=(class QStyleOptionFocusRect const &)
+ ??_EQPen@@QAE@I@Z @ 13109 NONAME ABSENT ; QPen::~QPen(unsigned int)
+ ??_EQKeySequence@@QAE@I@Z @ 13110 NONAME ABSENT ; QKeySequence::~QKeySequence(unsigned int)
+ ?tr@QInternalMimeData@@SA?AVQString@@PBD0H@Z @ 13111 NONAME ; class QString QInternalMimeData::tr(char const *, char const *, int)
+ ?velocity@QScroller@@QBE?AVQPointF@@XZ @ 13112 NONAME ; class QPointF QScroller::velocity(void) const
+ ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 13113 NONAME ; class QVector<unsigned int> QGlyphs::glyphIndexes(void) const
+ ?get@QFontPrivate@@SAPAV1@ABVQFont@@@Z @ 13114 NONAME ; class QFontPrivate * QFontPrivate::get(class QFont const &)
+ ?setScrollMetric@QScrollerProperties@@QAEXW4ScrollMetric@1@ABVQVariant@@@Z @ 13115 NONAME ; void QScrollerProperties::setScrollMetric(enum QScrollerProperties::ScrollMetric, class QVariant const &)
+ ??4QGradient@@QAEAAV0@ABV0@@Z @ 13116 NONAME ABSENT ; class QGradient & QGradient::operator=(class QGradient const &)
+ ??0QScrollEvent@@QAE@ABVQPointF@@0W4ScrollState@0@@Z @ 13117 NONAME ; QScrollEvent::QScrollEvent(class QPointF const &, class QPointF const &, enum QScrollEvent::ScrollState)
+ ?d_func@QFlickGesture@@AAEPAVQFlickGesturePrivate@@XZ @ 13118 NONAME ; class QFlickGesturePrivate * QFlickGesture::d_func(void)
+ ?scrollState@QScrollEvent@@QBE?AW4ScrollState@1@XZ @ 13119 NONAME ; enum QScrollEvent::ScrollState QScrollEvent::scrollState(void) const
+ ??0QTextTableFormat@@QAE@ABV0@@Z @ 13120 NONAME ABSENT ; QTextTableFormat::QTextTableFormat(class QTextTableFormat const &)
+ ??_EQImagePixmapCleanupHooks@@QAE@I@Z @ 13121 NONAME ABSENT ; QImagePixmapCleanupHooks::~QImagePixmapCleanupHooks(unsigned int)
+ ?fetchMore@QAbstractProxyModel@@UAEXABVQModelIndex@@@Z @ 13122 NONAME ; void QAbstractProxyModel::fetchMore(class QModelIndex const &)
+ ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 13123 NONAME ; class QList<class QGlyphs> QTextLine::glyphs(int, int) const
+ ?getStaticMetaObject@QFlickGesture@@SAABUQMetaObject@@XZ @ 13124 NONAME ; struct QMetaObject const & QFlickGesture::getStaticMetaObject(void)
+ ?setViewportSize@QScrollPrepareEvent@@QAEXABVQSizeF@@@Z @ 13125 NONAME ; void QScrollPrepareEvent::setViewportSize(class QSizeF const &)
+ ??0QStatusTipEvent@@QAE@ABV0@@Z @ 13126 NONAME ABSENT ; QStatusTipEvent::QStatusTipEvent(class QStatusTipEvent const &)
+ ??0Value@QCss@@QAE@ABU01@@Z @ 13127 NONAME ABSENT ; QCss::Value::Value(struct QCss::Value const &)
+ ?d_func@QScrollPrepareEvent@@AAEPAVQScrollPrepareEventPrivate@@XZ @ 13128 NONAME ; class QScrollPrepareEventPrivate * QScrollPrepareEvent::d_func(void)
+ ?overshootDistance@QScrollEvent@@QBE?AVQPointF@@XZ @ 13129 NONAME ; class QPointF QScrollEvent::overshootDistance(void) const
+ ?resolveFontFamilyAlias@QFontDatabase@@CA?AVQString@@ABV2@@Z @ 13130 NONAME ; class QString QFontDatabase::resolveFontFamilyAlias(class QString const &)
+ ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@HABVQTransform@@@Z @ 13131 NONAME ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, struct QFixed, int, class QTransform const &)
+ ??4QSizePolicy@@QAEAAV0@ABV0@@Z @ 13132 NONAME ABSENT ; class QSizePolicy & QSizePolicy::operator=(class QSizePolicy const &)
+ ?swap@QBitmap@@QAEXAAV1@@Z @ 13133 NONAME ; void QBitmap::swap(class QBitmap &)
+ ?hasFormat@QInternalMimeData@@UBE_NABVQString@@@Z @ 13134 NONAME ; bool QInternalMimeData::hasFormat(class QString const &) const
+ ?renderDataHelper@QInternalMimeData@@SA?AVQByteArray@@ABVQString@@PBVQMimeData@@@Z @ 13135 NONAME ; class QByteArray QInternalMimeData::renderDataHelper(class QString const &, class QMimeData const *)
+ ??_ETouchPoint@QTouchEvent@@QAE@I@Z @ 13136 NONAME ABSENT ; QTouchEvent::TouchPoint::~TouchPoint(unsigned int)
+ ??0QWindowSurface@@QAE@PAVQWidget@@_N@Z @ 13137 NONAME ; QWindowSurface::QWindowSurface(class QWidget *, bool)
+ ?fill@QBlittablePixmapData@@UAEXABVQColor@@@Z @ 13138 NONAME ; void QBlittablePixmapData::fill(class QColor const &)
+ ?metric@QBlittablePixmapData@@UBEHW4PaintDeviceMetric@QPaintDevice@@@Z @ 13139 NONAME ; int QBlittablePixmapData::metric(enum QPaintDevice::PaintDeviceMetric) const
+ ??4QItemSelection@@QAEAAV0@ABV0@@Z @ 13140 NONAME ABSENT ; class QItemSelection & QItemSelection::operator=(class QItemSelection const &)
+ ?fillRect@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQColor@@@Z @ 13141 NONAME ; void QBlitterPaintEngine::fillRect(class QRectF const &, class QColor const &)
+ ??4QStyleOptionQ3ListView@@QAEAAV0@ABV0@@Z @ 13142 NONAME ABSENT ; class QStyleOptionQ3ListView & QStyleOptionQ3ListView::operator=(class QStyleOptionQ3ListView const &)
+ ??6@YA?AVQDebug@@V0@PBVQSymbianEvent@@@Z @ 13143 NONAME ; class QDebug operator<<(class QDebug, class QSymbianEvent const *)
+ ??0QSizePolicy@@QAE@ABV0@@Z @ 13144 NONAME ABSENT ; QSizePolicy::QSizePolicy(class QSizePolicy const &)
+ ?ProcessCommandParametersL@QS60MainAppUi@@UAEHW4TApaCommand@@AAV?$TBuf@$0BAA@@@ABVTDesC8@@@Z @ 13145 NONAME ; int QS60MainAppUi::ProcessCommandParametersL(enum TApaCommand, class TBuf<256> &, class TDesC8 const &)
+ ?scrollerProperties@QScroller@@QBE?AVQScrollerProperties@@XZ @ 13146 NONAME ; class QScrollerProperties QScroller::scrollerProperties(void) const
+ ??_EQBlittablePixmapData@@UAE@I@Z @ 13147 NONAME ; QBlittablePixmapData::~QBlittablePixmapData(unsigned int)
+ ?mimeData@QAbstractProxyModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 13148 NONAME ; class QMimeData * QAbstractProxyModel::mimeData(class QList<class QModelIndex> const &) const
+ ??4QStyleOptionFrameV2@@QAEAAV0@ABV0@@Z @ 13149 NONAME ABSENT ; class QStyleOptionFrameV2 & QStyleOptionFrameV2::operator=(class QStyleOptionFrameV2 const &)
+ ??_EQScroller@@UAE@I@Z @ 13150 NONAME ; QScroller::~QScroller(unsigned int)
+ ??1QScrollPrepareEvent@@UAE@XZ @ 13151 NONAME ; QScrollPrepareEvent::~QScrollPrepareEvent(void)
+ ??4QVector3D@@QAEAAV0@ABV0@@Z @ 13152 NONAME ABSENT ; class QVector3D & QVector3D::operator=(class QVector3D const &)
+ ?setTabsMovable@QMdiArea@@QAEX_N@Z @ 13153 NONAME ; void QMdiArea::setTabsMovable(bool)
+ ?minimumSizeHint@QRadioButton@@UBE?AVQSize@@XZ @ 13154 NONAME ; class QSize QRadioButton::minimumSizeHint(void) const
+ ??4QStyleOptionQ3DockWindow@@QAEAAV0@ABV0@@Z @ 13155 NONAME ABSENT ; class QStyleOptionQ3DockWindow & QStyleOptionQ3DockWindow::operator=(class QStyleOptionQ3DockWindow const &)
+ ?qt_metacast@QFlickGesture@@UAEPAXPBD@Z @ 13156 NONAME ; void * QFlickGesture::qt_metacast(char const *)
+ ??_EQFont@@QAE@I@Z @ 13157 NONAME ABSENT ; QFont::~QFont(unsigned int)
+ ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 13158 NONAME ; void QGlyphs::setPositions(class QVector<class QPointF> const &)
+ ??4QStyleOptionDockWidget@@QAEAAV0@ABV0@@Z @ 13159 NONAME ABSENT ; class QStyleOptionDockWidget & QStyleOptionDockWidget::operator=(class QStyleOptionDockWidget const &)
+ ??0QPainterState@@QAE@ABV0@@Z @ 13160 NONAME ABSENT ; QPainterState::QPainterState(class QPainterState const &)
+ ??4QStyleOptionFrame@@QAEAAV0@ABV0@@Z @ 13161 NONAME ABSENT ; class QStyleOptionFrame & QStyleOptionFrame::operator=(class QStyleOptionFrame const &)
+ ?drawRects@QBlitterPaintEngine@@UAEXPBVQRect@@H@Z @ 13162 NONAME ; void QBlitterPaintEngine::drawRects(class QRect const *, int)
+ ?fillInPendingGlyphs@QTextureGlyphCache@@QAEXXZ @ 13163 NONAME ; void QTextureGlyphCache::fillInPendingGlyphs(void)
+ ?metaObject@QFlickGesture@@UBEPBUQMetaObject@@XZ @ 13164 NONAME ; struct QMetaObject const * QFlickGesture::metaObject(void) const
+ ?renderHintsChanged@QBlitterPaintEngine@@UAEXXZ @ 13165 NONAME ; void QBlitterPaintEngine::renderHintsChanged(void)
+ ?supportedDropActions@QAbstractProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 13166 NONAME ; class QFlags<enum Qt::DropAction> QAbstractProxyModel::supportedDropActions(void) const
+ ?hasStaticContentsSupport@QRasterWindowSurface@@UBE_NXZ @ 13167 NONAME ; bool QRasterWindowSurface::hasStaticContentsSupport(void) const
+ ?fillRect@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQBrush@@@Z @ 13168 NONAME ; void QBlitterPaintEngine::fillRect(class QRectF const &, class QBrush const &)
+ ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 13169 NONAME ; void QGlyphs::setGlyphIndexes(class QVector<unsigned int> const &)
+ ?alphaMapBoundingBox@QFontEngine@@UAE?AUglyph_metrics_t@@IABVQTransform@@W4GlyphFormat@1@@Z @ 13170 NONAME ; struct glyph_metrics_t QFontEngine::alphaMapBoundingBox(unsigned int, class QTransform const &, enum QFontEngine::GlyphFormat)
+ ?resendPrepareEvent@QScroller@@QAEXXZ @ 13171 NONAME ; void QScroller::resendPrepareEvent(void)
+ ??4QTextLength@@QAEAAV0@ABV0@@Z @ 13172 NONAME ABSENT ; class QTextLength & QTextLength::operator=(class QTextLength const &)
+ ??0QHelpEvent@@QAE@ABV0@@Z @ 13173 NONAME ABSENT ; QHelpEvent::QHelpEvent(class QHelpEvent const &)
+ ??0QContextMenuEvent@@QAE@ABV0@@Z @ 13174 NONAME ABSENT ; QContextMenuEvent::QContextMenuEvent(class QContextMenuEvent const &)
+ ?d_func@QBlittable@@ABEPBVQBlittablePrivate@@XZ @ 13175 NONAME ; class QBlittablePrivate const * QBlittable::d_func(void) const
+ ?state@QBlitterPaintEngine@@QBEPBVQPainterState@@XZ @ 13176 NONAME ; class QPainterState const * QBlitterPaintEngine::state(void) const
+ ??0QScrollPrepareEvent@@QAE@ABVQPointF@@@Z @ 13177 NONAME ; QScrollPrepareEvent::QScrollPrepareEvent(class QPointF const &)
+ ??0QWhatsThisClickedEvent@@QAE@ABV0@@Z @ 13178 NONAME ABSENT ; QWhatsThisClickedEvent::QWhatsThisClickedEvent(class QWhatsThisClickedEvent const &)
+ ??4QStyleOptionTab@@QAEAAV0@ABV0@@Z @ 13179 NONAME ABSENT ; class QStyleOptionTab & QStyleOptionTab::operator=(class QStyleOptionTab const &)
+ ??0QTabletEvent@@QAE@ABV0@@Z @ 13180 NONAME ABSENT ; QTabletEvent::QTabletEvent(class QTabletEvent const &)
+ ?scrollTo@QScroller@@QAEXABVQPointF@@H@Z @ 13181 NONAME ; void QScroller::scrollTo(class QPointF const &, int)
+ ?ungrabGesture@QScroller@@SAXPAVQObject@@@Z @ 13182 NONAME ; void QScroller::ungrabGesture(class QObject *)
+ ??4QItemSelectionRange@@QAEAAV0@ABV0@@Z @ 13183 NONAME ABSENT ; class QItemSelectionRange & QItemSelectionRange::operator=(class QItemSelectionRange const &)
+ ?clear@QGlyphs@@QAEXXZ @ 13184 NONAME ; void QGlyphs::clear(void)
+ ??_EQStyleOptionViewItemV4@@QAE@I@Z @ 13185 NONAME ABSENT ; QStyleOptionViewItemV4::~QStyleOptionViewItemV4(unsigned int)
+ ??1QBlittablePixmapData@@UAE@XZ @ 13186 NONAME ; QBlittablePixmapData::~QBlittablePixmapData(void)
+ ?formatsHelper@QInternalMimeData@@SA?AVQStringList@@PBVQMimeData@@@Z @ 13187 NONAME ; class QStringList QInternalMimeData::formatsHelper(class QMimeData const *)
+ ?qt_metacast@QInternalMimeData@@UAEPAXPBD@Z @ 13188 NONAME ; void * QInternalMimeData::qt_metacast(char const *)
+ ?font@QGlyphs@@QBE?AVQFont@@XZ @ 13189 NONAME ; class QFont QGlyphs::font(void) const
+ ?paintEngine@QBlittablePixmapData@@UBEPAVQPaintEngine@@XZ @ 13190 NONAME ; class QPaintEngine * QBlittablePixmapData::paintEngine(void) const
+ ?unsetDefaultScrollerProperties@QScrollerProperties@@SAXXZ @ 13191 NONAME ; void QScrollerProperties::unsetDefaultScrollerProperties(void)
+ ?hasChildren@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 13192 NONAME ; bool QAbstractProxyModel::hasChildren(class QModelIndex const &) const
+ ?swap@QPen@@QAEXAAV1@@Z @ 13193 NONAME ; void QPen::swap(class QPen &)
+ ?span@QAbstractProxyModel@@UBE?AVQSize@@ABVQModelIndex@@@Z @ 13194 NONAME ; class QSize QAbstractProxyModel::span(class QModelIndex const &) const
+ ??4QEglProperties@@QAEAAV0@ABV0@@Z @ 13195 NONAME ABSENT ; class QEglProperties & QEglProperties::operator=(class QEglProperties const &)
+ ??0QHoverEvent@@QAE@ABV0@@Z @ 13196 NONAME ABSENT ; QHoverEvent::QHoverEvent(class QHoverEvent const &)
+ ??0QPaintEngineState@@QAE@XZ @ 13197 NONAME ABSENT ; QPaintEngineState::QPaintEngineState(void)
+ ?setSnapPositionsY@QScroller@@QAEXMM@Z @ 13198 NONAME ; void QScroller::setSnapPositionsY(float, float)
+ ?d_func@QScrollPrepareEvent@@ABEPBVQScrollPrepareEventPrivate@@XZ @ 13199 NONAME ; class QScrollPrepareEventPrivate const * QScrollPrepareEvent::d_func(void) const
+ ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@IUQFixed@@@Z @ 13200 NONAME ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int, struct QFixed) const
+ ??0QKeyEvent@@QAE@ABV0@@Z @ 13201 NONAME ABSENT ; QKeyEvent::QKeyEvent(class QKeyEvent const &)
+ ??0QIconEngine@@QAE@ABV0@@Z @ 13202 NONAME ABSENT ; QIconEngine::QIconEngine(class QIconEngine const &)
+ ??4QStyleOptionToolBoxV2@@QAEAAV0@ABV0@@Z @ 13203 NONAME ABSENT ; class QStyleOptionToolBoxV2 & QStyleOptionToolBoxV2::operator=(class QStyleOptionToolBoxV2 const &)
+ ?qt_metacall@QInternalMimeData@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 13204 NONAME ; int QInternalMimeData::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?lineHeightType@QTextBlockFormat@@QBEHXZ @ 13205 NONAME ; int QTextBlockFormat::lineHeightType(void) const
+ ?hintingPreference@QFont@@QBE?AW4HintingPreference@1@XZ @ 13206 NONAME ; enum QFont::HintingPreference QFont::hintingPreference(void) const
+ ??0QGlyphs@@QAE@XZ @ 13207 NONAME ; QGlyphs::QGlyphs(void)
+ ?trUtf8@QInternalMimeData@@SA?AVQString@@PBD0H@Z @ 13208 NONAME ; class QString QInternalMimeData::trUtf8(char const *, char const *, int)
+ ??0QImageIOHandlerFactoryInterface@@QAE@XZ @ 13209 NONAME ABSENT ; QImageIOHandlerFactoryInterface::QImageIOHandlerFactoryInterface(void)
+ ??_EQRegion@@QAE@I@Z @ 13210 NONAME ABSENT ; QRegion::~QRegion(unsigned int)
+ ?begin@QBlitterPaintEngine@@UAE_NPAVQPaintDevice@@@Z @ 13211 NONAME ; bool QBlitterPaintEngine::begin(class QPaintDevice *)
+ ?inFontUcs4@QFontMetricsF@@QBE_NI@Z @ 13212 NONAME ; bool QFontMetricsF::inFontUcs4(unsigned int) const
+ ?viewportSize@QScrollPrepareEvent@@QBE?AVQSizeF@@XZ @ 13213 NONAME ; class QSizeF QScrollPrepareEvent::viewportSize(void) const
+ ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQRectF@@@Z @ 13214 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRectF const &)
+ ?d_func@QBlitterPaintEngine@@AAEPAVQBlitterPaintEnginePrivate@@XZ @ 13215 NONAME ; class QBlitterPaintEnginePrivate * QBlitterPaintEngine::d_func(void)
+ ?setNumberPrefix@QTextListFormat@@QAEXABVQString@@@Z @ 13216 NONAME ; void QTextListFormat::setNumberPrefix(class QString const &)
+ ?lineHeight@QTextBlockFormat@@QBEMMM@Z @ 13217 NONAME ; float QTextBlockFormat::lineHeight(float, float) const
+ ??4QStyleOptionComplex@@QAEAAV0@ABV0@@Z @ 13218 NONAME ABSENT ; class QStyleOptionComplex & QStyleOptionComplex::operator=(class QStyleOptionComplex const &)
+ ?getItem@QInputDialog@@SA?AVQString@@PAVQWidget@@ABV2@1ABVQStringList@@H_NPA_NV?$QFlags@W4WindowType@Qt@@@@V?$QFlags@W4InputMethodHint@Qt@@@@@Z @ 13219 NONAME ; class QString QInputDialog::getItem(class QWidget *, class QString const &, class QString const &, class QStringList const &, int, bool, bool *, class QFlags<enum Qt::WindowType>, class QFlags<enum Qt::InputMethodHint>)
+ ??_EFileInfo@QZipReader@@QAE@I@Z @ 13220 NONAME ABSENT ; QZipReader::FileInfo::~FileInfo(unsigned int)
+ ?qGamma_correct_back_to_linear_cs@@YAXPAVQImage@@@Z @ 13221 NONAME ; void qGamma_correct_back_to_linear_cs(class QImage *)
+ ??0QBitmap@@QAE@ABV0@@Z @ 13222 NONAME ABSENT ; QBitmap::QBitmap(class QBitmap const &)
+ ?clip@QBlitterPaintEngine@@UAEXABVQVectorPath@@W4ClipOperation@Qt@@@Z @ 13223 NONAME ; void QBlitterPaintEngine::clip(class QVectorPath const &, enum Qt::ClipOperation)
+ ??1QScrollEvent@@UAE@XZ @ 13224 NONAME ; QScrollEvent::~QScrollEvent(void)
+ ?state@QScroller@@QBE?AW4State@1@XZ @ 13225 NONAME ; enum QScroller::State QScroller::state(void) const
+ ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 13226 NONAME ; class QVector<class QPointF> QGlyphs::positions(void) const
+ ?tr@QScroller@@SA?AVQString@@PBD0@Z @ 13227 NONAME ; class QString QScroller::tr(char const *, char const *)
+ ?canReadData@QInternalMimeData@@SA_NABVQString@@@Z @ 13228 NONAME ; bool QInternalMimeData::canReadData(class QString const &)
+ ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13229 NONAME ; class QList<class QGlyphs> QTextLayout::glyphs(void) const
+ ??_EQTextFormat@@QAE@I@Z @ 13230 NONAME ABSENT ; QTextFormat::~QTextFormat(unsigned int)
+ ??4QStyleOptionTabWidgetFrame@@QAEAAV0@ABV0@@Z @ 13231 NONAME ABSENT ; class QStyleOptionTabWidgetFrame & QStyleOptionTabWidgetFrame::operator=(class QStyleOptionTabWidgetFrame const &)
+ ?trUtf8@QScroller@@SA?AVQString@@PBD0H@Z @ 13232 NONAME ; class QString QScroller::trUtf8(char const *, char const *, int)
+ ?d_func@QFlickGesture@@ABEPBVQFlickGesturePrivate@@XZ @ 13233 NONAME ; class QFlickGesturePrivate const * QFlickGesture::d_func(void) const
+ ??4QMouseEvent@@QAEAAV0@ABV0@@Z @ 13234 NONAME ABSENT ; class QMouseEvent & QMouseEvent::operator=(class QMouseEvent const &)
+ ??_EQPainter@@QAE@I@Z @ 13235 NONAME ABSENT ; QPainter::~QPainter(unsigned int)
+ ??4QStyleOptionTabBarBaseV2@@QAEAAV0@ABV0@@Z @ 13236 NONAME ABSENT ; class QStyleOptionTabBarBaseV2 & QStyleOptionTabBarBaseV2::operator=(class QStyleOptionTabBarBaseV2 const &)
+ ??4QInputEvent@@QAEAAV0@ABV0@@Z @ 13237 NONAME ABSENT ; class QInputEvent & QInputEvent::operator=(class QInputEvent const &)
+ ?hasScroller@QScroller@@SA_NPAVQObject@@@Z @ 13238 NONAME ; bool QScroller::hasScroller(class QObject *)
+ ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@ABVQTransform@@@Z @ 13239 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, struct QFixed, class QTransform const &)
+ ??_EQPainterPath@@QAE@I@Z @ 13240 NONAME ABSENT ; QPainterPath::~QPainterPath(unsigned int)
+ ??_EQGlyphs@@QAE@I@Z @ 13241 NONAME ABSENT ; QGlyphs::~QGlyphs(unsigned int)
+ ?fromImage@QBlittablePixmapData@@UAEXABVQImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 13242 NONAME ; void QBlittablePixmapData::fromImage(class QImage const &, class QFlags<enum Qt::ImageConversionFlag>)
+ ??0QInternalMimeData@@QAE@XZ @ 13243 NONAME ; QInternalMimeData::QInternalMimeData(void)
+ ??_EQScrollEvent@@UAE@I@Z @ 13244 NONAME ; QScrollEvent::~QScrollEvent(unsigned int)
+ ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 13245 NONAME ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &)
+ ??4QQuaternion@@QAEAAV0@ABV0@@Z @ 13246 NONAME ABSENT ; class QQuaternion & QQuaternion::operator=(class QQuaternion const &)
+ ??4Symbol@QCss@@QAEAAU01@ABU01@@Z @ 13247 NONAME ABSENT ; struct QCss::Symbol & QCss::Symbol::operator=(struct QCss::Symbol const &)
+ ??0QBlittable@@QAE@ABVQSize@@V?$QFlags@W4Capability@QBlittable@@@@@Z @ 13248 NONAME ; QBlittable::QBlittable(class QSize const &, class QFlags<enum QBlittable::Capability>)
+ ??0QIconDragEvent@@QAE@ABV0@@Z @ 13249 NONAME ABSENT ; QIconDragEvent::QIconDragEvent(class QIconDragEvent const &)
+ ?scroller@QScroller@@SAPAV1@PAVQObject@@@Z @ 13250 NONAME ; class QScroller * QScroller::scroller(class QObject *)
+ ??4QScrollerProperties@@QAEAAV0@ABV0@@Z @ 13251 NONAME ; class QScrollerProperties & QScrollerProperties::operator=(class QScrollerProperties const &)
+ ?d_func@QScroller@@AAEPAVQScrollerPrivate@@XZ @ 13252 NONAME ; class QScrollerPrivate * QScroller::d_func(void)
+ ?scrollerPropertiesChanged@QScroller@@IAEXABVQScrollerProperties@@@Z @ 13253 NONAME ; void QScroller::scrollerPropertiesChanged(class QScrollerProperties const &)
+ ?markRasterOverlay@QBlittablePixmapData@@QAEXPBVQRect@@H@Z @ 13254 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRect const *, int)
+ ?tabsClosable@QMdiArea@@QBE_NXZ @ 13255 NONAME ; bool QMdiArea::tabsClosable(void) const
+ ?canStartScrollingAt@QAbstractScrollAreaPrivate@@QAE_NABVQPoint@@@Z @ 13256 NONAME ; bool QAbstractScrollAreaPrivate::canStartScrollingAt(class QPoint const &)
+ ??0QScrollerProperties@@QAE@XZ @ 13257 NONAME ; QScrollerProperties::QScrollerProperties(void)
+ ?setLineHeight@QTextBlockFormat@@QAEXMH@Z @ 13258 NONAME ; void QTextBlockFormat::setLineHeight(float, int)
+ ?calculateSubPixelPositionCount@QTextureGlyphCache@@IBEHI@Z @ 13259 NONAME ; int QTextureGlyphCache::calculateSubPixelPositionCount(unsigned int) const
+ ??0QTextImageFormat@@QAE@ABV0@@Z @ 13260 NONAME ABSENT ; QTextImageFormat::QTextImageFormat(class QTextImageFormat const &)
+ ??0QMoveEvent@@QAE@ABV0@@Z @ 13261 NONAME ABSENT ; QMoveEvent::QMoveEvent(class QMoveEvent const &)
+ ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 13262 NONAME ; class QList<class QGlyphs> QTextFragment::glyphs(void) const
+ ??0QInputContextFactoryInterface@@QAE@XZ @ 13263 NONAME ABSENT ; QInputContextFactoryInterface::QInputContextFactoryInterface(void)
+ ??0QTextFrameFormat@@QAE@ABV0@@Z @ 13264 NONAME ABSENT ; QTextFrameFormat::QTextFrameFormat(class QTextFrameFormat const &)
+ ?resetInternalData@QAbstractProxyModel@@IAEXXZ @ 13265 NONAME ; void QAbstractProxyModel::resetInternalData(void)
+ ??0Symbol@QCss@@QAE@ABU01@@Z @ 13266 NONAME ABSENT ; QCss::Symbol::Symbol(struct QCss::Symbol const &)
+ ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQVectorPath@@@Z @ 13267 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QVectorPath const &)
+ ??4QStyleOptionFrameV3@@QAEAAV0@ABV0@@Z @ 13268 NONAME ABSENT ; class QStyleOptionFrameV3 & QStyleOptionFrameV3::operator=(class QStyleOptionFrameV3 const &)
+ ?scrollTo@QScroller@@QAEXABVQPointF@@@Z @ 13269 NONAME ; void QScroller::scrollTo(class QPointF const &)
+ ??0QGraphicsSystem@@QAE@XZ @ 13270 NONAME ABSENT ; QGraphicsSystem::QGraphicsSystem(void)
+ ??4QStyleOptionViewItem@@QAEAAV0@ABV0@@Z @ 13271 NONAME ABSENT ; class QStyleOptionViewItem & QStyleOptionViewItem::operator=(class QStyleOptionViewItem const &)
+ ??4QStyleOptionProgressBar@@QAEAAV0@ABV0@@Z @ 13272 NONAME ABSENT ; class QStyleOptionProgressBar & QStyleOptionProgressBar::operator=(class QStyleOptionProgressBar const &)
+ ?clip@QBlitterPaintEngine@@QAEPBVQClipData@@XZ @ 13273 NONAME ; class QClipData const * QBlitterPaintEngine::clip(void)
+ ?d_func@QScroller@@ABEPBVQScrollerPrivate@@XZ @ 13274 NONAME ; class QScrollerPrivate const * QScroller::d_func(void) const
+ ?setNumberSuffix@QTextListFormat@@QAEXABVQString@@@Z @ 13275 NONAME ; void QTextListFormat::setNumberSuffix(class QString const &)
+ ?swap@QPicture@@QAEXAAV1@@Z @ 13276 NONAME ; void QPicture::swap(class QPicture &)
+ ?swap@QPainterPath@@QAEXAAV1@@Z @ 13277 NONAME ; void QPainterPath::swap(class QPainterPath &)
+ ??4QStyleOptionRubberBand@@QAEAAV0@ABV0@@Z @ 13278 NONAME ABSENT ; class QStyleOptionRubberBand & QStyleOptionRubberBand::operator=(class QStyleOptionRubberBand const &)
+ ?minimumSizeHint@QCheckBox@@UBE?AVQSize@@XZ @ 13279 NONAME ; class QSize QCheckBox::minimumSizeHint(void) const
+ ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 13280 NONAME ; class QFont QFontEngine::createExplicitFont(void) const
+ ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@@Z @ 13281 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, struct QFixed)
+ ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@IUQFixed@@@Z @ 13282 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int, struct QFixed)
+ ?swap@QIcon@@QAEXAAV1@@Z @ 13283 NONAME ; void QIcon::swap(class QIcon &)
+ ?unmarkRasterOverlay@QBlittablePixmapData@@QAEXABVQRectF@@@Z @ 13284 NONAME ; void QBlittablePixmapData::unmarkRasterOverlay(class QRectF const &)
+ ??0QDragResponseEvent@@QAE@ABV0@@Z @ 13285 NONAME ABSENT ; QDragResponseEvent::QDragResponseEvent(class QDragResponseEvent const &)
+ ??0QIconEngine@@QAE@XZ @ 13286 NONAME ABSENT ; QIconEngine::QIconEngine(void)
+ ?brushOriginChanged@QBlitterPaintEngine@@UAEXXZ @ 13287 NONAME ; void QBlitterPaintEngine::brushOriginChanged(void)
+ ?openFile@QFileOpenEvent@@QBE_NAAVQFile@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 13288 NONAME ; bool QFileOpenEvent::openFile(class QFile &, class QFlags<enum QIODevice::OpenModeFlag>) const
+ ??_EQBrush@@QAE@I@Z @ 13289 NONAME ABSENT ; QBrush::~QBrush(unsigned int)
+ ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@H@Z @ 13290 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type, int)
+ ?handleInput@QScroller@@QAE_NW4Input@1@ABVQPointF@@_J@Z @ 13291 NONAME ; bool QScroller::handleInput(enum QScroller::Input, class QPointF const &, long long)
+ ??8QScrollerProperties@@QBE_NABV0@@Z @ 13292 NONAME ; bool QScrollerProperties::operator==(class QScrollerProperties const &) const
+ ?inFontUcs4@QFontMetrics@@QBE_NI@Z @ 13293 NONAME ; bool QFontMetrics::inFontUcs4(unsigned int) const
+ ??_EQTableWidgetSelectionRange@@QAE@I@Z @ 13294 NONAME ABSENT ; QTableWidgetSelectionRange::~QTableWidgetSelectionRange(unsigned int)
+ ??4QStyleOptionTabBarBase@@QAEAAV0@ABV0@@Z @ 13295 NONAME ABSENT ; class QStyleOptionTabBarBase & QStyleOptionTabBarBase::operator=(class QStyleOptionTabBarBase const &)
+ ??0QTextObjectInterface@@QAE@XZ @ 13296 NONAME ABSENT ; QTextObjectInterface::QTextObjectInterface(void)
+ ?unlock@QBlittable@@QAEXXZ @ 13297 NONAME ; void QBlittable::unlock(void)
+ ?metaObject@QScroller@@UBEPBUQMetaObject@@XZ @ 13298 NONAME ; struct QMetaObject const * QScroller::metaObject(void) const
+ ?d_func@QScrollEvent@@ABEPBVQScrollEventPrivate@@XZ @ 13299 NONAME ; class QScrollEventPrivate const * QScrollEvent::d_func(void) const
+ ?swap@QRegion@@QAEXAAV1@@Z @ 13300 NONAME ; void QRegion::swap(class QRegion &)
+ ??0QHideEvent@@QAE@ABV0@@Z @ 13301 NONAME ABSENT ; QHideEvent::QHideEvent(class QHideEvent const &)
+ ?ensureVisible@QScroller@@QAEXABVQRectF@@MMH@Z @ 13302 NONAME ; void QScroller::ensureVisible(class QRectF const &, float, float, int)
+ ?qt_metacall@QFlickGesture@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 13303 NONAME ; int QFlickGesture::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?setItemData@QAbstractProxyModel@@UAE_NABVQModelIndex@@ABV?$QMap@HVQVariant@@@@@Z @ 13304 NONAME ; bool QAbstractProxyModel::setItemData(class QModelIndex const &, class QMap<int, class QVariant> const &)
+ ?getStaticMetaObject@QInternalMimeData@@SAABUQMetaObject@@XZ @ 13305 NONAME ; struct QMetaObject const & QInternalMimeData::getStaticMetaObject(void)
+ ?swap@QPolygonF@@QAEXAAV1@@Z @ 13306 NONAME ; void QPolygonF::swap(class QPolygonF &)
+ ?swap@QPolygon@@QAEXAAV1@@Z @ 13307 NONAME ; void QPolygon::swap(class QPolygon &)
+ ??_EQScrollPrepareEvent@@UAE@I@Z @ 13308 NONAME ; QScrollPrepareEvent::~QScrollPrepareEvent(unsigned int)
+ ?d_func@QBlitterPaintEngine@@ABEPBVQBlitterPaintEnginePrivate@@XZ @ 13309 NONAME ; class QBlitterPaintEnginePrivate const * QBlitterPaintEngine::d_func(void) const
+ ?pixelPerMeter@QScroller@@QBE?AVQPointF@@XZ @ 13310 NONAME ; class QPointF QScroller::pixelPerMeter(void) const
+ ?target@QScroller@@QBEPAVQObject@@XZ @ 13311 NONAME ; class QObject * QScroller::target(void) const
+ ?swap@QKeySequence@@QAEXAAV1@@Z @ 13312 NONAME ; void QKeySequence::swap(class QKeySequence &)
+ ??1QGlyphs@@QAE@XZ @ 13313 NONAME ; QGlyphs::~QGlyphs(void)
+ ?lineHeight@QTextBlockFormat@@QBEMXZ @ 13314 NONAME ; float QTextBlockFormat::lineHeight(void) const
+ ?stroke@QBlitterPaintEngine@@UAEXABVQVectorPath@@ABVQPen@@@Z @ 13315 NONAME ; void QBlitterPaintEngine::stroke(class QVectorPath const &, class QPen const &)
+ ?tr@QInternalMimeData@@SA?AVQString@@PBD0@Z @ 13316 NONAME ; class QString QInternalMimeData::tr(char const *, char const *)
+ ??9QGlyphs@@QBE_NABV0@@Z @ 13317 NONAME ; bool QGlyphs::operator!=(class QGlyphs const &) const
+ ??1QBlittable@@UAE@XZ @ 13318 NONAME ; QBlittable::~QBlittable(void)
+ ??_EQBlitterPaintEngine@@UAE@I@Z @ 13319 NONAME ; QBlitterPaintEngine::~QBlitterPaintEngine(unsigned int)
+ ??0QCloseEvent@@QAE@ABV0@@Z @ 13320 NONAME ABSENT ; QCloseEvent::QCloseEvent(class QCloseEvent const &)
+ ?grabbedGesture@QScroller@@SA?AW4GestureType@Qt@@PAVQObject@@@Z @ 13321 NONAME ; enum Qt::GestureType QScroller::grabbedGesture(class QObject *)
+ ?buffer@QBlittablePixmapData@@UAEPAVQImage@@XZ @ 13322 NONAME ; class QImage * QBlittablePixmapData::buffer(void)
+ ??0QTextFrameLayoutData@@QAE@XZ @ 13323 NONAME ABSENT ; QTextFrameLayoutData::QTextFrameLayoutData(void)
+ ?staticMetaObject@QFlickGesture@@2UQMetaObject@@B @ 13324 NONAME ; struct QMetaObject const QFlickGesture::staticMetaObject
+ ?finalPosition@QScroller@@QBE?AVQPointF@@XZ @ 13325 NONAME ; class QPointF QScroller::finalPosition(void) const
+ ??4QStyleOptionTabWidgetFrameV2@@QAEAAV0@ABV0@@Z @ 13326 NONAME ABSENT ; class QStyleOptionTabWidgetFrameV2 & QStyleOptionTabWidgetFrameV2::operator=(class QStyleOptionTabWidgetFrameV2 const &)
+ ?drawStaticTextItem@QBlitterPaintEngine@@UAEXPAVQStaticTextItem@@@Z @ 13327 NONAME ; void QBlitterPaintEngine::drawStaticTextItem(class QStaticTextItem *)
+ ??0QGlyphs@@QAE@ABV0@@Z @ 13328 NONAME ; QGlyphs::QGlyphs(class QGlyphs const &)
+ ?lock@QBlittable@@QAEPAVQImage@@XZ @ 13329 NONAME ; class QImage * QBlittable::lock(void)
+ ?setFontHintingPreference@QTextCharFormat@@QAEXW4HintingPreference@QFont@@@Z @ 13330 NONAME ; void QTextCharFormat::setFontHintingPreference(enum QFont::HintingPreference)
+ ??4QStyleOptionTabV2@@QAEAAV0@ABV0@@Z @ 13331 NONAME ABSENT ; class QStyleOptionTabV2 & QStyleOptionTabV2::operator=(class QStyleOptionTabV2 const &)
+ ??_EQInternalMimeData@@UAE@I@Z @ 13332 NONAME ; QInternalMimeData::~QInternalMimeData(unsigned int)
+ ??4QTextListFormat@@QAEAAV0@ABV0@@Z @ 13333 NONAME ABSENT ; class QTextListFormat & QTextListFormat::operator=(class QTextListFormat const &)
+ ??_EQPalette@@QAE@I@Z @ 13334 NONAME ABSENT ; QPalette::~QPalette(unsigned int)
+ ??0QFocusEvent@@QAE@ABV0@@Z @ 13335 NONAME ABSENT ; QFocusEvent::QFocusEvent(class QFocusEvent const &)
+ ??4QStyleOptionQ3ListViewItem@@QAEAAV0@ABV0@@Z @ 13336 NONAME ABSENT ; class QStyleOptionQ3ListViewItem & QStyleOptionQ3ListViewItem::operator=(class QStyleOptionQ3ListViewItem const &)
+ ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQPointF@@ABVQTextItem@@@Z @ 13337 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QPointF const &, class QTextItem const &)
+ ?trUtf8@QScroller@@SA?AVQString@@PBD0@Z @ 13338 NONAME ; class QString QScroller::trUtf8(char const *, char const *)
+ ??_EQIcon@@QAE@I@Z @ 13339 NONAME ABSENT ; QIcon::~QIcon(unsigned int)
+ ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 13340 NONAME ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &)
+ ??9QScrollerProperties@@QBE_NABV0@@Z @ 13341 NONAME ; bool QScrollerProperties::operator!=(class QScrollerProperties const &) const
+ ??0QTextListFormat@@QAE@ABV0@@Z @ 13342 NONAME ABSENT ; QTextListFormat::QTextListFormat(class QTextListFormat const &)
+ ?drawEllipse@QBlitterPaintEngine@@UAEXABVQRectF@@@Z @ 13343 NONAME ; void QBlitterPaintEngine::drawEllipse(class QRectF const &)
+ ??0QGuiPlatformPluginInterface@@QAE@XZ @ 13344 NONAME ABSENT ; QGuiPlatformPluginInterface::QGuiPlatformPluginInterface(void)
+ ??_EQTextLayout@@QAE@I@Z @ 13345 NONAME ABSENT ; QTextLayout::~QTextLayout(unsigned int)
+ ??0QWheelEvent@@QAE@ABV0@@Z @ 13346 NONAME ABSENT ; QWheelEvent::QWheelEvent(class QWheelEvent const &)
+ ?blittable@QBlittablePixmapData@@QBEPAVQBlittable@@XZ @ 13347 NONAME ; class QBlittable * QBlittablePixmapData::blittable(void) const
+ ?resizeCache@QTextureGlyphCache@@QAEXHH@Z @ 13348 NONAME ; void QTextureGlyphCache::resizeCache(int, int)
+ ??0QScrollerProperties@@QAE@ABV0@@Z @ 13349 NONAME ; QScrollerProperties::QScrollerProperties(class QScrollerProperties const &)
+ ??0QWindowStateChangeEvent@@QAE@ABV0@@Z @ 13350 NONAME ABSENT ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QWindowStateChangeEvent const &)
+ ?metaObject@QInternalMimeData@@UBEPBUQMetaObject@@XZ @ 13351 NONAME ; struct QMetaObject const * QInternalMimeData::metaObject(void) const
+ ?setContentPos@QScrollPrepareEvent@@QAEXABVQPointF@@@Z @ 13352 NONAME ; void QScrollPrepareEvent::setContentPos(class QPointF const &)
+ ??_EQTextEngine@@QAE@I@Z @ 13353 NONAME ABSENT ; QTextEngine::~QTextEngine(unsigned int)
+ ??4QStyleOptionTitleBar@@QAEAAV0@ABV0@@Z @ 13354 NONAME ABSENT ; class QStyleOptionTitleBar & QStyleOptionTitleBar::operator=(class QStyleOptionTitleBar const &)
+ ??4Value@QCss@@QAEAAU01@ABU01@@Z @ 13355 NONAME ABSENT ; struct QCss::Value & QCss::Value::operator=(struct QCss::Value const &)
+ ?staticMetaObject@QScroller@@2UQMetaObject@@B @ 13356 NONAME ; struct QMetaObject const QScroller::staticMetaObject
+ ?hasFormatHelper@QInternalMimeData@@SA_NABVQString@@PBVQMimeData@@@Z @ 13357 NONAME ; bool QInternalMimeData::hasFormatHelper(class QString const &, class QMimeData const *)
+ ?state@QBlitterPaintEngine@@QAEPAVQPainterState@@XZ @ 13358 NONAME ; class QPainterState * QBlitterPaintEngine::state(void)
+ ?penChanged@QBlitterPaintEngine@@UAEXXZ @ 13359 NONAME ; void QBlitterPaintEngine::penChanged(void)
+ ??0QFileOpenEvent@@QAE@ABVRFile@@@Z @ 13360 NONAME ; QFileOpenEvent::QFileOpenEvent(class RFile const &)
+ ?hasHeightForWidth@QWidgetPrivate@@UBE_NXZ @ 13361 NONAME ; bool QWidgetPrivate::hasHeightForWidth(void) const
+ ??0QDragLeaveEvent@@QAE@ABV0@@Z @ 13362 NONAME ABSENT ; QDragLeaveEvent::QDragLeaveEvent(class QDragLeaveEvent const &)
+ ?toImage@QBlittablePixmapData@@UBE?AVQImage@@XZ @ 13363 NONAME ; class QImage QBlittablePixmapData::toImage(void) const
+ ??_EQBlittable@@UAE@I@Z @ 13364 NONAME ; QBlittable::~QBlittable(unsigned int)
+ ??4QBitmap@@QAEAAV0@ABV0@@Z @ 13365 NONAME ABSENT ; class QBitmap & QBitmap::operator=(class QBitmap const &)
+ ??1QInternalMimeData@@UAE@XZ @ 13366 NONAME ; QInternalMimeData::~QInternalMimeData(void)
+ ??0QItemSelection@@QAE@ABV0@@Z @ 13367 NONAME ABSENT ; QItemSelection::QItemSelection(class QItemSelection const &)
+ ?qt_addBitmapToPath@@YAXMMPBEHHHPAVQPainterPath@@@Z @ 13368 NONAME ; void qt_addBitmapToPath(float, float, unsigned char const *, int, int, int, class QPainterPath *)
+ ?staticMetaObject@QInternalMimeData@@2UQMetaObject@@B @ 13369 NONAME ; struct QMetaObject const QInternalMimeData::staticMetaObject
+ ?activeScrollers@QScroller@@SA?AV?$QList@PAVQScroller@@@@XZ @ 13370 NONAME ; class QList<class QScroller *> QScroller::activeScrollers(void)
+ ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 13371 NONAME ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &)
+ ??4QTextFrameFormat@@QAEAAV0@ABV0@@Z @ 13372 NONAME ABSENT ; class QTextFrameFormat & QTextFrameFormat::operator=(class QTextFrameFormat const &)
diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def
index 21718d3..633c8ef 100644
--- a/src/s60installs/bwins/QtNetworku.def
+++ b/src/s60installs/bwins/QtNetworku.def
@@ -1001,7 +1001,7 @@ EXPORTS
?staticMetaObject@QNetworkSession@@2UQMetaObject@@B @ 1000 NONAME ; struct QMetaObject const QNetworkSession::staticMetaObject
?trUtf8@QBearerEngine@@SA?AVQString@@PBD0@Z @ 1001 NONAME ; class QString QBearerEngine::trUtf8(char const *, char const *)
?privateConfiguration@QNetworkSessionPrivate@@IBE?AV?$QExplicitlySharedDataPointer@VQNetworkConfigurationPrivate@@@@ABVQNetworkConfiguration@@@Z @ 1002 NONAME ; class QExplicitlySharedDataPointer<class QNetworkConfigurationPrivate> QNetworkSessionPrivate::privateConfiguration(class QNetworkConfiguration const &) const
- ?isOnline@QNetworkConfigurationManagerPrivate@@QAE_NXZ @ 1003 NONAME ; bool QNetworkConfigurationManagerPrivate::isOnline(void)
+ ?isOnline@QNetworkConfigurationManagerPrivate@@QAE_NXZ @ 1003 NONAME ABSENT ; bool QNetworkConfigurationManagerPrivate::isOnline(void)
?state@QNetworkConfiguration@@QBE?AV?$QFlags@W4StateFlag@QNetworkConfiguration@@@@XZ @ 1004 NONAME ; class QFlags<enum QNetworkConfiguration::StateFlag> QNetworkConfiguration::state(void) const
?configurationAdded@QNetworkConfigurationManagerPrivate@@IAEXABVQNetworkConfiguration@@@Z @ 1005 NONAME ; void QNetworkConfigurationManagerPrivate::configurationAdded(class QNetworkConfiguration const &)
?defaultConfiguration@QNetworkConfigurationManager@@QBE?AVQNetworkConfiguration@@XZ @ 1006 NONAME ; class QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration(void) const
@@ -1027,7 +1027,7 @@ EXPORTS
?staticMetaObject@QBearerEngine@@2UQMetaObject@@B @ 1026 NONAME ; struct QMetaObject const QBearerEngine::staticMetaObject
?networkSessionConnected@QNetworkAccessManager@@IAEXXZ @ 1027 NONAME ; void QNetworkAccessManager::networkSessionConnected(void)
??1QBearerEngine@@UAE@XZ @ 1028 NONAME ; QBearerEngine::~QBearerEngine(void)
- ?capabilities@QNetworkConfigurationManagerPrivate@@QAE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1029 NONAME ; class QFlags<enum QNetworkConfigurationManager::Capability> QNetworkConfigurationManagerPrivate::capabilities(void)
+ ?capabilities@QNetworkConfigurationManagerPrivate@@QAE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1029 NONAME ABSENT ; class QFlags<enum QNetworkConfigurationManager::Capability> QNetworkConfigurationManagerPrivate::capabilities(void)
??1QNetworkConfiguration@@QAE@XZ @ 1030 NONAME ; QNetworkConfiguration::~QNetworkConfiguration(void)
?bearerTypeName@QNetworkConfiguration@@QBE?AVQString@@XZ @ 1031 NONAME ; class QString QNetworkConfiguration::bearerTypeName(void) const
??0QNetworkConfigurationManagerPrivate@@QAE@XZ @ 1032 NONAME ; QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate(void)
@@ -1041,7 +1041,7 @@ EXPORTS
?name@QNetworkConfiguration@@QBE?AVQString@@XZ @ 1040 NONAME ; class QString QNetworkConfiguration::name(void) const
?close@QNetworkSession@@QAEXXZ @ 1041 NONAME ; void QNetworkSession::close(void)
?sessionProperty@QNetworkSession@@QBE?AVQVariant@@ABVQString@@@Z @ 1042 NONAME ; class QVariant QNetworkSession::sessionProperty(class QString const &) const
- ?engines@QNetworkConfigurationManagerPrivate@@QAE?AV?$QList@PAVQBearerEngine@@@@XZ @ 1043 NONAME ; class QList<class QBearerEngine *> QNetworkConfigurationManagerPrivate::engines(void)
+ ?engines@QNetworkConfigurationManagerPrivate@@QAE?AV?$QList@PAVQBearerEngine@@@@XZ @ 1043 NONAME ABSENT ; class QList<class QBearerEngine *> QNetworkConfigurationManagerPrivate::engines(void)
?isOnline@QNetworkConfigurationManager@@QBE_NXZ @ 1044 NONAME ; bool QNetworkConfigurationManager::isOnline(void) const
?capabilities@QNetworkConfigurationManager@@QBE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1045 NONAME ; class QFlags<enum QNetworkConfigurationManager::Capability> QNetworkConfigurationManager::capabilities(void) const
?configurationRemoved@QNetworkConfigurationManagerPrivate@@AAEXV?$QExplicitlySharedDataPointer@VQNetworkConfigurationPrivate@@@@@Z @ 1046 NONAME ; void QNetworkConfigurationManagerPrivate::configurationRemoved(class QExplicitlySharedDataPointer<class QNetworkConfigurationPrivate>)
@@ -1095,7 +1095,7 @@ EXPORTS
??_EQBearerEnginePlugin@@UAE@I@Z @ 1094 NONAME ; QBearerEnginePlugin::~QBearerEnginePlugin(unsigned int)
?children@QNetworkConfiguration@@QBE?AV?$QList@VQNetworkConfiguration@@@@XZ @ 1095 NONAME ; class QList<class QNetworkConfiguration> QNetworkConfiguration::children(void) const
?activeConfiguration@QNetworkAccessManager@@QBE?AVQNetworkConfiguration@@XZ @ 1096 NONAME ; class QNetworkConfiguration QNetworkAccessManager::activeConfiguration(void) const
- ?defaultConfiguration@QNetworkConfigurationManagerPrivate@@QAE?AVQNetworkConfiguration@@XZ @ 1097 NONAME ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(void)
+ ?defaultConfiguration@QNetworkConfigurationManagerPrivate@@QAE?AVQNetworkConfiguration@@XZ @ 1097 NONAME ABSENT ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(void)
?getStaticMetaObject@QNetworkSession@@SAABUQMetaObject@@XZ @ 1098 NONAME ; struct QMetaObject const & QNetworkSession::getStaticMetaObject(void)
?qt_metacast@QNetworkSession@@UAEPAXPBD@Z @ 1099 NONAME ; void * QNetworkSession::qt_metacast(char const *)
?updateCompleted@QBearerEngine@@IAEXXZ @ 1100 NONAME ; void QBearerEngine::updateCompleted(void)
@@ -1109,8 +1109,8 @@ EXPORTS
?qt_metacast@QNetworkConfigurationManagerPrivate@@UAEPAXPBD@Z @ 1108 NONAME ; void * QNetworkConfigurationManagerPrivate::qt_metacast(char const *)
?newConfigurationActivated@QNetworkSessionPrivate@@IAEXXZ @ 1109 NONAME ; void QNetworkSessionPrivate::newConfigurationActivated(void)
?qt_metacast@QNetworkSessionPrivate@@UAEPAXPBD@Z @ 1110 NONAME ; void * QNetworkSessionPrivate::qt_metacast(char const *)
- ?startPolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1111 NONAME ; void QNetworkConfigurationManagerPrivate::startPolling(void)
- ?allConfigurations@QNetworkConfigurationManagerPrivate@@QAE?AV?$QList@VQNetworkConfiguration@@@@V?$QFlags@W4StateFlag@QNetworkConfiguration@@@@@Z @ 1112 NONAME ; class QList<class QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(class QFlags<enum QNetworkConfiguration::StateFlag>)
+ ?startPolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1111 NONAME ABSENT ; void QNetworkConfigurationManagerPrivate::startPolling(void)
+ ?allConfigurations@QNetworkConfigurationManagerPrivate@@QAE?AV?$QList@VQNetworkConfiguration@@@@V?$QFlags@W4StateFlag@QNetworkConfiguration@@@@@Z @ 1112 NONAME ABSENT ; class QList<class QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(class QFlags<enum QNetworkConfiguration::StateFlag>)
?connectNotify@QNetworkSession@@MAEXPBD@Z @ 1113 NONAME ; void QNetworkSession::connectNotify(char const *)
?onlineStateChanged@QNetworkConfigurationManagerPrivate@@IAEX_N@Z @ 1114 NONAME ; void QNetworkConfigurationManagerPrivate::onlineStateChanged(bool)
?bytesWritten@QNetworkSession@@QBE_KXZ @ 1115 NONAME ; unsigned long long QNetworkSession::bytesWritten(void) const
@@ -1132,8 +1132,8 @@ EXPORTS
?reject@QNetworkSession@@QAEXXZ @ 1131 NONAME ; void QNetworkSession::reject(void)
?options@QAuthenticator@@QBE?AV?$QHash@VQString@@VQVariant@@@@XZ @ 1132 NONAME ; class QHash<class QString, class QVariant> QAuthenticator::options(void) const
?purpose@QNetworkConfiguration@@QBE?AW4Purpose@1@XZ @ 1133 NONAME ; enum QNetworkConfiguration::Purpose QNetworkConfiguration::purpose(void) const
- ?configurationFromIdentifier@QNetworkConfigurationManagerPrivate@@QAE?AVQNetworkConfiguration@@ABVQString@@@Z @ 1134 NONAME ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(class QString const &)
- ?abort@QNetworkConfigurationManagerPrivate@@IAEXXZ @ 1135 NONAME ; void QNetworkConfigurationManagerPrivate::abort(void)
+ ?configurationFromIdentifier@QNetworkConfigurationManagerPrivate@@QAE?AVQNetworkConfiguration@@ABVQString@@@Z @ 1134 NONAME ABSENT ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(class QString const &)
+ ?abort@QNetworkConfigurationManagerPrivate@@IAEXXZ @ 1135 NONAME ABSENT ; void QNetworkConfigurationManagerPrivate::abort(void)
?tr@QNetworkConfigurationManager@@SA?AVQString@@PBD0@Z @ 1136 NONAME ; class QString QNetworkConfigurationManager::tr(char const *, char const *)
?trUtf8@QNetworkSession@@SA?AVQString@@PBD0H@Z @ 1137 NONAME ; class QString QNetworkSession::trUtf8(char const *, char const *, int)
?trUtf8@QBearerEnginePlugin@@SA?AVQString@@PBD0@Z @ 1138 NONAME ; class QString QBearerEnginePlugin::trUtf8(char const *, char const *)
@@ -1145,4 +1145,20 @@ EXPORTS
?setNetworkAccessible@QNetworkAccessManager@@QAEXW4NetworkAccessibility@1@@Z @ 1144 NONAME ; void QNetworkAccessManager::setNetworkAccessible(enum QNetworkAccessManager::NetworkAccessibility)
??_EQBearerEngineFactoryInterface@@UAE@I@Z @ 1145 NONAME ; QBearerEngineFactoryInterface::~QBearerEngineFactoryInterface(unsigned int)
?enablePolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1146 NONAME ; void QNetworkConfigurationManagerPrivate::enablePolling(void)
+ ?joinMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@ABVQNetworkInterface@@@Z @ 1147 NONAME ; bool QUdpSocket::joinMulticastGroup(class QHostAddress const &, class QNetworkInterface const &)
+ ?setMulticastInterface@QUdpSocket@@QAEXABVQNetworkInterface@@@Z @ 1148 NONAME ; void QUdpSocket::setMulticastInterface(class QNetworkInterface const &)
+ ?setFinished@QNetworkReply@@IAEX_N@Z @ 1149 NONAME ; void QNetworkReply::setFinished(bool)
+ ?multicastInterface@QUdpSocket@@QBE?AVQNetworkInterface@@XZ @ 1150 NONAME ; class QNetworkInterface QUdpSocket::multicastInterface(void) const
+ ?joinMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@@Z @ 1151 NONAME ; bool QUdpSocket::joinMulticastGroup(class QHostAddress const &)
+ ?leaveMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@ABVQNetworkInterface@@@Z @ 1152 NONAME ; bool QUdpSocket::leaveMulticastGroup(class QHostAddress const &, class QNetworkInterface const &)
+ ?leaveMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@@Z @ 1153 NONAME ; bool QUdpSocket::leaveMulticastGroup(class QHostAddress const &)
+ ?allConfigurations@QNetworkConfigurationManagerPrivate@@QBE?AV?$QList@VQNetworkConfiguration@@@@V?$QFlags@W4StateFlag@QNetworkConfiguration@@@@@Z @ 1154 NONAME ; class QList<class QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(class QFlags<enum QNetworkConfiguration::StateFlag>) const
+ ?capabilities@QNetworkConfigurationManagerPrivate@@QBE?AV?$QFlags@W4Capability@QNetworkConfigurationManager@@@@XZ @ 1155 NONAME ; class QFlags<enum QNetworkConfigurationManager::Capability> QNetworkConfigurationManagerPrivate::capabilities(void) const
+ ?configurationFromIdentifier@QNetworkConfigurationManagerPrivate@@QBE?AVQNetworkConfiguration@@ABVQString@@@Z @ 1156 NONAME ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(class QString const &) const
+ ?defaultConfiguration@QNetworkConfigurationManagerPrivate@@QBE?AVQNetworkConfiguration@@XZ @ 1157 NONAME ; class QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(void) const
+ ?engines@QNetworkConfigurationManagerPrivate@@QBE?AV?$QList@PAVQBearerEngine@@@@XZ @ 1158 NONAME ; class QList<class QBearerEngine *> QNetworkConfigurationManagerPrivate::engines(void) const
+ ?isOnline@QNetworkConfigurationManagerPrivate@@QBE_NXZ @ 1159 NONAME ; bool QNetworkConfigurationManagerPrivate::isOnline(void) const
+ ?startPolling@QNetworkConfigurationManagerPrivate@@AAEXXZ @ 1160 NONAME ; void QNetworkConfigurationManagerPrivate::startPolling(void)
+ ?setPeerVerifyName@QSslSocket@@QAEXABVQString@@@Z @ 1161 NONAME ; void QSslSocket::setPeerVerifyName(class QString const &)
+ ?peerVerifyName@QSslSocket@@QBE?AVQString@@XZ @ 1162 NONAME ; class QString QSslSocket::peerVerifyName(void) const
diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def
index d7c8394..d16ff06 100644
--- a/src/s60installs/bwins/QtOpenGLu.def
+++ b/src/s60installs/bwins/QtOpenGLu.def
@@ -98,7 +98,7 @@ EXPORTS
?metaObject@QGLWindowSurface@@UBEPBUQMetaObject@@XZ @ 97 NONAME ; struct QMetaObject const * QGLWindowSurface::metaObject(void) const
?setAttributeBuffer@QGLShaderProgram@@QAEXHIHHH@Z @ 98 NONAME ; void QGLShaderProgram::setAttributeBuffer(int, unsigned int, int, int, int)
?getProcAddress@QGLContext@@QBEPAXABVQString@@@Z @ 99 NONAME ; void * QGLContext::getProcAddress(class QString const &) const
- ?qt_metacall@QGLTextureGlyphCache@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 100 NONAME ; int QGLTextureGlyphCache::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ?qt_metacall@QGLTextureGlyphCache@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 100 NONAME ABSENT ; int QGLTextureGlyphCache::qt_metacall(enum QMetaObject::Call, int, void * *)
??1QGLPixelBuffer@@UAE@XZ @ 101 NONAME ; QGLPixelBuffer::~QGLPixelBuffer(void)
?setUniformValueArray@QGLShaderProgram@@QAEXHPBVQVector4D@@H@Z @ 102 NONAME ; void QGLShaderProgram::setUniformValueArray(int, class QVector4D const *, int)
?releaseFromDynamicTexture@QGLPixelBuffer@@QAEXXZ @ 103 NONAME ; void QGLPixelBuffer::releaseFromDynamicTexture(void)
@@ -115,7 +115,7 @@ EXPORTS
?setUniformValue@QGLShaderProgram@@QAEXPBDABV?$QGenericMatrix@$01$02M@@@Z @ 114 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QGenericMatrix<2, 3, float> const &)
?useCorrectShaderProg@QGLEngineShaderManager@@QAE_NXZ @ 115 NONAME ; bool QGLEngineShaderManager::useCorrectShaderProg(void)
?setAlphaBufferSize@QGLFormat@@QAEXH@Z @ 116 NONAME ; void QGLFormat::setAlphaBufferSize(int)
- ??0QGLContextResource@@QAE@P6AXPAX@Z@Z @ 117 NONAME ; QGLContextResource::QGLContextResource(void (*)(void *))
+ ??0QGLContextResource@@QAE@P6AXPAX@Z@Z @ 117 NONAME ABSENT ; QGLContextResource::QGLContextResource(void (*)(void *))
?tr@QGLEngineShaderManager@@SA?AVQString@@PBD0H@Z @ 118 NONAME ; class QString QGLEngineShaderManager::tr(char const *, char const *, int)
?setUniformValue@QGLShaderProgram@@QAEXHABVQVector4D@@@Z @ 119 NONAME ; void QGLShaderProgram::setUniformValue(int, class QVector4D const &)
?d_func@QGLContext@@ABEPBVQGLContextPrivate@@XZ @ 120 NONAME ; class QGLContextPrivate const * QGLContext::d_func(void) const
@@ -125,7 +125,7 @@ EXPORTS
?bindTexture@QGLWidget@@QAEIABVQImage@@IHV?$QFlags@W4BindOption@QGLContext@@@@@Z @ 124 NONAME ; unsigned int QGLWidget::bindTexture(class QImage const &, unsigned int, int, class QFlags<enum QGLContext::BindOption>)
?ensureCreated@QGLPixmapData@@ABEXXZ @ 125 NONAME ; void QGLPixmapData::ensureCreated(void) const
?setSource@QGLCustomShaderStage@@IAEXABVQByteArray@@@Z @ 126 NONAME ; void QGLCustomShaderStage::setSource(class QByteArray const &)
- ?trUtf8@QGLTextureGlyphCache@@SA?AVQString@@PBD0@Z @ 127 NONAME ; class QString QGLTextureGlyphCache::trUtf8(char const *, char const *)
+ ?trUtf8@QGLTextureGlyphCache@@SA?AVQString@@PBD0@Z @ 127 NONAME ABSENT ; class QString QGLTextureGlyphCache::trUtf8(char const *, char const *)
?removeFromPainter@QGLCustomShaderStage@@QAEXPAVQPainter@@@Z @ 128 NONAME ; void QGLCustomShaderStage::removeFromPainter(class QPainter *)
?qt_metacall@QGLWindowSurface@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 129 NONAME ; int QGLWindowSurface::qt_metacall(enum QMetaObject::Call, int, void * *)
??0QGLBuffer@@QAE@W4Type@0@@Z @ 130 NONAME ; QGLBuffer::QGLBuffer(enum QGLBuffer::Type)
@@ -207,7 +207,7 @@ EXPORTS
?setUniformValue@QGLShaderProgram@@QAEXPBDABV?$QGenericMatrix@$02$02M@@@Z @ 206 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QGenericMatrix<3, 3, float> const &)
?setUniformValue@QGLShaderProgram@@QAEXPBDMMMM@Z @ 207 NONAME ; void QGLShaderProgram::setUniformValue(char const *, float, float, float, float)
?requestedFormat@QGLContext@@QBE?AVQGLFormat@@XZ @ 208 NONAME ; class QGLFormat QGLContext::requestedFormat(void) const
- ?fillTexture@QGLTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 209 NONAME ; void QGLTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int)
+ ?fillTexture@QGLTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 209 NONAME ABSENT ; void QGLTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int)
?isNativePaintingActive@QGL2PaintEngineEx@@QBE_NXZ @ 210 NONAME ; bool QGL2PaintEngineEx::isNativePaintingActive(void) const
?accumBufferSize@QGLFormat@@QBEHXZ @ 211 NONAME ; int QGLFormat::accumBufferSize(void) const
?setAttributeValue@QGLShaderProgram@@QAEXHPBMHH@Z @ 212 NONAME ; void QGLShaderProgram::setAttributeValue(int, float const *, int, int)
@@ -231,7 +231,7 @@ EXPORTS
??1QGLPaintDevice@@UAE@XZ @ 230 NONAME ; QGLPaintDevice::~QGLPaintDevice(void)
?setGeometryInputType@QGLShaderProgram@@QAEXI@Z @ 231 NONAME ; void QGLShaderProgram::setGeometryInputType(unsigned int)
?isValid@QGLPixmapData@@ABE_NXZ @ 232 NONAME ; bool QGLPixmapData::isValid(void) const
- ?cleanup@QGLContextResource@@QAEXPBVQGLContext@@PAX@Z @ 233 NONAME ; void QGLContextResource::cleanup(class QGLContext const *, void *)
+ ?cleanup@QGLContextResource@@QAEXPBVQGLContext@@PAX@Z @ 233 NONAME ABSENT ; void QGLContextResource::cleanup(class QGLContext const *, void *)
?context@QGLWidget@@QBEPBVQGLContext@@XZ @ 234 NONAME ; class QGLContext const * QGLWidget::context(void) const
?tr@QGLShaderProgram@@SA?AVQString@@PBD0H@Z @ 235 NONAME ; class QString QGLShaderProgram::tr(char const *, char const *, int)
??0QGLPixelBuffer@@QAE@HHABVQGLFormat@@PAVQGLWidget@@@Z @ 236 NONAME ; QGLPixelBuffer::QGLPixelBuffer(int, int, class QGLFormat const &, class QGLWidget *)
@@ -282,13 +282,13 @@ EXPORTS
??0QGLShaderProgram@@QAE@PBVQGLContext@@PAVQObject@@@Z @ 281 NONAME ; QGLShaderProgram::QGLShaderProgram(class QGLContext const *, class QObject *)
?setUniformValueArray@QGLShaderProgram@@QAEXPBDPBV?$QGenericMatrix@$03$02M@@H@Z @ 282 NONAME ; void QGLShaderProgram::setUniformValueArray(char const *, class QGenericMatrix<4, 3, float> const *, int)
??0QGLShaderProgram@@QAE@PAVQObject@@@Z @ 283 NONAME ; QGLShaderProgram::QGLShaderProgram(class QObject *)
- ?qt_metacast@QGLTextureGlyphCache@@UAEPAXPBD@Z @ 284 NONAME ; void * QGLTextureGlyphCache::qt_metacast(char const *)
+ ?qt_metacast@QGLTextureGlyphCache@@UAEPAXPBD@Z @ 284 NONAME ABSENT ; void * QGLTextureGlyphCache::qt_metacast(char const *)
?staticMetaObject@QGLEngineShaderManager@@2UQMetaObject@@B @ 285 NONAME ; struct QMetaObject const QGLEngineShaderManager::staticMetaObject
?setDevice@QGLContext@@IAEXPAVQPaintDevice@@@Z @ 286 NONAME ; void QGLContext::setDevice(class QPaintDevice *)
?setUniformValueArray@QGLShaderProgram@@QAEXHPBV?$QGenericMatrix@$02$01M@@H@Z @ 287 NONAME ; void QGLShaderProgram::setUniformValueArray(int, class QGenericMatrix<3, 2, float> const *, int)
?setUniformValue@QGLShaderProgram@@QAEXPBDABV?$QGenericMatrix@$03$02M@@@Z @ 288 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QGenericMatrix<4, 3, float> const &)
?setAttributeArray@QGLShaderProgram@@QAEXHIPBXHH@Z @ 289 NONAME ; void QGLShaderProgram::setAttributeArray(int, unsigned int, void const *, int, int)
- ?tr@QGLTextureGlyphCache@@SA?AVQString@@PBD0H@Z @ 290 NONAME ; class QString QGLTextureGlyphCache::tr(char const *, char const *, int)
+ ?tr@QGLTextureGlyphCache@@SA?AVQString@@PBD0H@Z @ 290 NONAME ABSENT ; class QString QGLTextureGlyphCache::tr(char const *, char const *, int)
?setDefaultOverlayFormat@QGLFormat@@SAXABV1@@Z @ 291 NONAME ; void QGLFormat::setDefaultOverlayFormat(class QGLFormat const &)
?qt_gl_share_widget@@YAPAVQGLWidget@@XZ @ 292 NONAME ; class QGLWidget * qt_gl_share_widget(void)
?initializeOverlayGL@QGLWidget@@MAEXXZ @ 293 NONAME ; void QGLWidget::initializeOverlayGL(void)
@@ -365,7 +365,7 @@ EXPORTS
?samples@QGLFramebufferObjectFormat@@QBEHXZ @ 364 NONAME ; int QGLFramebufferObjectFormat::samples(void) const
?setInactive@QGLCustomShaderStage@@QAEXXZ @ 365 NONAME ; void QGLCustomShaderStage::setInactive(void)
?extensionFuncs@QGLContextPrivate@@SAAAUQGLExtensionFuncs@@PBVQGLContext@@@Z @ 366 NONAME ; struct QGLExtensionFuncs & QGLContextPrivate::extensionFuncs(class QGLContext const *)
- ?value@QGLContextResource@@QAEPAXPBVQGLContext@@@Z @ 367 NONAME ; void * QGLContextResource::value(class QGLContext const *)
+ ?value@QGLContextResource@@QAEPAXPBVQGLContext@@@Z @ 367 NONAME ABSENT ; void * QGLContextResource::value(class QGLContext const *)
?majorVersion@QGLFormat@@QBEHXZ @ 368 NONAME ; int QGLFormat::majorVersion(void) const
?rgba@QGLFormat@@QBE_NXZ @ 369 NONAME ; bool QGLFormat::rgba(void) const
?paintDevice@QGLWindowSurface@@UAEPAVQPaintDevice@@XZ @ 370 NONAME ; class QPaintDevice * QGLWindowSurface::paintDevice(void)
@@ -401,7 +401,7 @@ EXPORTS
?isValid@QGLWidget@@QBE_NXZ @ 400 NONAME ; bool QGLWidget::isValid(void) const
?shared_null@QGLColormap@@0UQGLColormapData@1@A @ 401 NONAME ; struct QGLColormap::QGLColormapData QGLColormap::shared_null
?setUniformValue@QGLShaderProgram@@QAEXPBDQAY01M@Z @ 402 NONAME ; void QGLShaderProgram::setUniformValue(char const *, float [2] * const)
- ?insert@QGLContextResource@@QAEXPBVQGLContext@@PAX@Z @ 403 NONAME ; void QGLContextResource::insert(class QGLContext const *, void *)
+ ?insert@QGLContextResource@@QAEXPBVQGLContext@@PAX@Z @ 403 NONAME ABSENT ; void QGLContextResource::insert(class QGLContext const *, void *)
??0QGLCustomShaderStage@@QAE@XZ @ 404 NONAME ; QGLCustomShaderStage::QGLCustomShaderStage(void)
?setDefaultFormat@QGLFormat@@SAXABV1@@Z @ 405 NONAME ; void QGLFormat::setDefaultFormat(class QGLFormat const &)
?sourceCode@QGLShader@@QBE?AVQByteArray@@XZ @ 406 NONAME ; class QByteArray QGLShader::sourceCode(void) const
@@ -421,7 +421,7 @@ EXPORTS
??_EQGLShaderProgram@@UAE@I@Z @ 420 NONAME ; QGLShaderProgram::~QGLShaderProgram(unsigned int)
?pixmapFilter@QGL2PaintEngineEx@@UAEPAVQPixmapFilter@@HPBV2@@Z @ 421 NONAME ; class QPixmapFilter * QGL2PaintEngineEx::pixmapFilter(int, class QPixmapFilter const *)
?scroll@QGLPixmapData@@UAE_NHHABVQRect@@@Z @ 422 NONAME ; bool QGLPixmapData::scroll(int, int, class QRect const &)
- ?contextDestroyed@QGLTextureGlyphCache@@QAEXPBVQGLContext@@@Z @ 423 NONAME ; void QGLTextureGlyphCache::contextDestroyed(class QGLContext const *)
+ ?contextDestroyed@QGLTextureGlyphCache@@QAEXPBVQGLContext@@@Z @ 423 NONAME ABSENT ; void QGLTextureGlyphCache::contextDestroyed(class QGLContext const *)
??0QGLColormap@@QAE@XZ @ 424 NONAME ; QGLColormap::QGLColormap(void)
?metric@QGLFramebufferObject@@MBEHW4PaintDeviceMetric@QPaintDevice@@@Z @ 425 NONAME ; int QGLFramebufferObject::metric(enum QPaintDevice::PaintDeviceMetric) const
?devType@QGLFramebufferObject@@MBEHXZ @ 426 NONAME ; int QGLFramebufferObject::devType(void) const
@@ -468,7 +468,7 @@ EXPORTS
?d_func@QGL2PaintEngineEx@@AAEPAVQGL2PaintEngineExPrivate@@XZ @ 467 NONAME ; class QGL2PaintEngineExPrivate * QGL2PaintEngineEx::d_func(void)
?resize@QGLPixmapData@@UAEXHH@Z @ 468 NONAME ; void QGLPixmapData::resize(int, int)
?setUniformValue@QGLShaderProgram@@QAEXPBDABV?$QGenericMatrix@$01$01M@@@Z @ 469 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QGenericMatrix<2, 2, float> const &)
- ?trUtf8@QGLTextureGlyphCache@@SA?AVQString@@PBD0H@Z @ 470 NONAME ; class QString QGLTextureGlyphCache::trUtf8(char const *, char const *, int)
+ ?trUtf8@QGLTextureGlyphCache@@SA?AVQString@@PBD0H@Z @ 470 NONAME ABSENT ; class QString QGLTextureGlyphCache::trUtf8(char const *, char const *, int)
?begin@QGL2PaintEngineEx@@UAE_NPAVQPaintDevice@@@Z @ 471 NONAME ; bool QGL2PaintEngineEx::begin(class QPaintDevice *)
?samples@QGLFormat@@QBEHXZ @ 472 NONAME ; int QGLFormat::samples(void) const
?setFormat@QGLContext@@QAEXABVQGLFormat@@@Z @ 473 NONAME ; void QGLContext::setFormat(class QGLFormat const &)
@@ -495,7 +495,7 @@ EXPORTS
?setGeometryOutputVertexCount@QGLShaderProgram@@QAEXH@Z @ 494 NONAME ; void QGLShaderProgram::setGeometryOutputVertexCount(int)
?setUniformValue@QGLShaderProgram@@QAEXPBDABVQSize@@@Z @ 495 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QSize const &)
?convertToGLFormat@QGLWidget@@SA?AVQImage@@ABV2@@Z @ 496 NONAME ; class QImage QGLWidget::convertToGLFormat(class QImage const &)
- ?staticMetaObject@QGLTextureGlyphCache@@2UQMetaObject@@B @ 497 NONAME ; struct QMetaObject const QGLTextureGlyphCache::staticMetaObject
+ ?staticMetaObject@QGLTextureGlyphCache@@2UQMetaObject@@B @ 497 NONAME ABSENT ; struct QMetaObject const QGLTextureGlyphCache::staticMetaObject
??_EQGLContextResource@@QAE@I@Z @ 498 NONAME ABSENT ; QGLContextResource::~QGLContextResource(unsigned int)
?handle@QGLColormap@@IAEKXZ @ 499 NONAME ; unsigned long QGLColormap::handle(void)
?isCreated@QGLBuffer@@QBE_NXZ @ 500 NONAME ; bool QGLBuffer::isCreated(void) const
@@ -549,7 +549,7 @@ EXPORTS
?setUniformValue@QGLShaderProgram@@QAEXPBDABVQPointF@@@Z @ 548 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QPointF const &)
?getDevice@QGLPaintDevice@@SAPAV1@PAVQPaintDevice@@@Z @ 549 NONAME ; class QGLPaintDevice * QGLPaintDevice::getDevice(class QPaintDevice *)
?setUniformValue@QGLShaderProgram@@QAEXHQAY02M@Z @ 550 NONAME ; void QGLShaderProgram::setUniformValue(int, float [3] * const)
- ?getStaticMetaObject@QGLTextureGlyphCache@@SAABUQMetaObject@@XZ @ 551 NONAME ; struct QMetaObject const & QGLTextureGlyphCache::getStaticMetaObject(void)
+ ?getStaticMetaObject@QGLTextureGlyphCache@@SAABUQMetaObject@@XZ @ 551 NONAME ABSENT ; struct QMetaObject const & QGLTextureGlyphCache::getStaticMetaObject(void)
?swapBuffers@QGLContext@@UBEXXZ @ 552 NONAME ; void QGLContext::swapBuffers(void) const
?renderText@QGLWidget@@QAEXHHABVQString@@ABVQFont@@H@Z @ 553 NONAME ; void QGLWidget::renderText(int, int, class QString const &, class QFont const &, int)
?defaultFormat@QGLFormat@@SA?AV1@XZ @ 554 NONAME ; class QGLFormat QGLFormat::defaultFormat(void)
@@ -558,7 +558,7 @@ EXPORTS
?bindTexture@QGLContext@@QAEIABVQImage@@IHV?$QFlags@W4BindOption@QGLContext@@@@@Z @ 557 NONAME ; unsigned int QGLContext::bindTexture(class QImage const &, unsigned int, int, class QFlags<enum QGLContext::BindOption>)
?initialized@QGLContext@@IBE_NXZ @ 558 NONAME ; bool QGLContext::initialized(void) const
?cleanup@QGLColormap@@CAXPAUQGLColormapData@1@@Z @ 559 NONAME ; void QGLColormap::cleanup(struct QGLColormap::QGLColormapData *)
- ??1QGLContextResource@@QAE@XZ @ 560 NONAME ; QGLContextResource::~QGLContextResource(void)
+ ??1QGLContextResource@@QAE@XZ @ 560 NONAME ABSENT ; QGLContextResource::~QGLContextResource(void)
?bindTexture@QGLWidget@@QAEIABVQPixmap@@IHV?$QFlags@W4BindOption@QGLContext@@@@@Z @ 561 NONAME ; unsigned int QGLWidget::bindTexture(class QPixmap const &, unsigned int, int, class QFlags<enum QGLContext::BindOption>)
?setUniformValue@QGLShaderProgram@@QAEXPBDABV?$QGenericMatrix@$02$01M@@@Z @ 562 NONAME ; void QGLShaderProgram::setUniformValue(char const *, class QGenericMatrix<3, 2, float> const &)
?setUniformValueArray@QGLShaderProgram@@QAEXHPBMHH@Z @ 563 NONAME ; void QGLShaderProgram::setUniformValueArray(int, float const *, int, int)
@@ -589,7 +589,7 @@ EXPORTS
?setUniforms@QGraphicsShaderEffect@@MAEXPAVQGLShaderProgram@@@Z @ 588 NONAME ; void QGraphicsShaderEffect::setUniforms(class QGLShaderProgram *)
?drawImage@QGL2PaintEngineEx@@UAEXABVQRectF@@ABVQImage@@0V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 589 NONAME ; void QGL2PaintEngineEx::drawImage(class QRectF const &, class QImage const &, class QRectF const &, class QFlags<enum Qt::ImageConversionFlag>)
?flush@QGLWindowSurface@@UAEXPAVQWidget@@ABVQRegion@@ABVQPoint@@@Z @ 590 NONAME ; void QGLWindowSurface::flush(class QWidget *, class QRegion const &, class QPoint const &)
- ??0QGLTextureGlyphCache@@QAE@PAVQGLContext@@W4Type@QFontEngineGlyphCache@@ABVQTransform@@@Z @ 591 NONAME ; QGLTextureGlyphCache::QGLTextureGlyphCache(class QGLContext *, enum QFontEngineGlyphCache::Type, class QTransform const &)
+ ??0QGLTextureGlyphCache@@QAE@PAVQGLContext@@W4Type@QFontEngineGlyphCache@@ABVQTransform@@@Z @ 591 NONAME ABSENT ; QGLTextureGlyphCache::QGLTextureGlyphCache(class QGLContext *, enum QFontEngineGlyphCache::Type, class QTransform const &)
??_EQGLTextureGlyphCache@@UAE@I@Z @ 592 NONAME ; QGLTextureGlyphCache::~QGLTextureGlyphCache(unsigned int)
??1QGLShareContextScope@@QAE@XZ @ 593 NONAME ; QGLShareContextScope::~QGLShareContextScope(void)
?alpha@QGLFormat@@QBE_NXZ @ 594 NONAME ; bool QGLFormat::alpha(void) const
@@ -633,8 +633,8 @@ EXPORTS
?qt_metacast@QGLEngineShaderManager@@UAEPAXPBD@Z @ 632 NONAME ; void * QGLEngineShaderManager::qt_metacast(char const *)
?sampleBuffers@QGLFormat@@QBE_NXZ @ 633 NONAME ; bool QGLFormat::sampleBuffers(void) const
?trUtf8@QGLWindowSurface@@SA?AVQString@@PBD0H@Z @ 634 NONAME ; class QString QGLWindowSurface::trUtf8(char const *, char const *, int)
- ?shaderProgNeedsChangingSlot@QGLEngineShaderManager@@AAEXXZ @ 635 NONAME ; void QGLEngineShaderManager::shaderProgNeedsChangingSlot(void)
- ?metaObject@QGLTextureGlyphCache@@UBEPBUQMetaObject@@XZ @ 636 NONAME ; struct QMetaObject const * QGLTextureGlyphCache::metaObject(void) const
+ ?shaderProgNeedsChangingSlot@QGLEngineShaderManager@@AAEXXZ @ 635 NONAME ABSENT ; void QGLEngineShaderManager::shaderProgNeedsChangingSlot(void)
+ ?metaObject@QGLTextureGlyphCache@@UBEPBUQMetaObject@@XZ @ 636 NONAME ABSENT ; struct QMetaObject const * QGLTextureGlyphCache::metaObject(void) const
?paintEvent@QGLWidget@@MAEXPAVQPaintEvent@@@Z @ 637 NONAME ; void QGLWidget::paintEvent(class QPaintEvent *)
?uniformLocation@QGLShaderProgram@@QBEHABVQByteArray@@@Z @ 638 NONAME ; int QGLShaderProgram::uniformLocation(class QByteArray const &) const
?currentContext@QGLContext@@SAPBV1@XZ @ 639 NONAME ; class QGLContext const * QGLContext::currentContext(void)
@@ -643,7 +643,7 @@ EXPORTS
?setUniformValueArray@QGLShaderProgram@@QAEXPBDPBV?$QGenericMatrix@$01$01M@@H@Z @ 642 NONAME ; void QGLShaderProgram::setUniformValueArray(char const *, class QGenericMatrix<2, 2, float> const *, int)
?drawStaticTextItem@QGL2PaintEngineEx@@UAEXPAVQStaticTextItem@@@Z @ 643 NONAME ; void QGL2PaintEngineEx::drawStaticTextItem(class QStaticTextItem *)
?metaObject@QGLShader@@UBEPBUQMetaObject@@XZ @ 644 NONAME ; struct QMetaObject const * QGLShader::metaObject(void) const
- ?tr@QGLTextureGlyphCache@@SA?AVQString@@PBD0@Z @ 645 NONAME ; class QString QGLTextureGlyphCache::tr(char const *, char const *)
+ ?tr@QGLTextureGlyphCache@@SA?AVQString@@PBD0@Z @ 645 NONAME ABSENT ; class QString QGLTextureGlyphCache::tr(char const *, char const *)
?drawTexture@QGLFramebufferObject@@QAEXABVQRectF@@II@Z @ 646 NONAME ; void QGLFramebufferObject::drawTexture(class QRectF const &, unsigned int, unsigned int)
?openGLVersionFlags@QGLFormat@@SA?AV?$QFlags@W4OpenGLVersionFlag@QGLFormat@@@@XZ @ 647 NONAME ; class QFlags<enum QGLFormat::OpenGLVersionFlag> QGLFormat::openGLVersionFlags(void)
?setRedBufferSize@QGLFormat@@QAEXH@Z @ 648 NONAME ; void QGLFormat::setRedBufferSize(int)
@@ -703,23 +703,134 @@ EXPORTS
?maxTextureWidth@QGLTextureGlyphCache@@UBEHXZ @ 702 NONAME ; int QGLTextureGlyphCache::maxTextureWidth(void) const
?filterMode@QGLTextureGlyphCache@@QBE?AW4FilterMode@1@XZ @ 703 NONAME ; enum QGLTextureGlyphCache::FilterMode QGLTextureGlyphCache::filterMode(void) const
?setFilterMode@QGLTextureGlyphCache@@QAEXW4FilterMode@1@@Z @ 704 NONAME ; void QGLTextureGlyphCache::setFilterMode(enum QGLTextureGlyphCache::FilterMode)
- ?toNativeType@QGLPixmapData@@UAEPAXW4NativeType@QPixmapData@@@Z @ 705 NONAME ; void * QGLPixmapData::toNativeType(enum QPixmapData::NativeType)
- ?fromNativeType@QGLPixmapData@@UAEXPAXW4NativeType@QPixmapData@@@Z @ 706 NONAME ; void QGLPixmapData::fromNativeType(void *, enum QPixmapData::NativeType)
- ?clear@QGLTextureGlyphCache@@QAEXXZ @ 707 NONAME ; void QGLTextureGlyphCache::clear(void)
- ?context@QGLTextureGlyphCache@@QBEPAVQGLContext@@XZ @ 708 NONAME ; class QGLContext * QGLTextureGlyphCache::context(void) const
- ?swapBehavior@QGLWindowSurface@@2W4SwapMode@1@A @ 709 NONAME ; enum QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior
- ?createPixmapForImage@QGLPixmapData@@AAEXAAVQImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@_N@Z @ 710 NONAME ; void QGLPixmapData::createPixmapForImage(class QImage &, class QFlags<enum Qt::ImageConversionFlag>, bool)
- ?fromImageReader@QGLPixmapData@@UAEXPAVQImageReader@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 711 NONAME ; void QGLPixmapData::fromImageReader(class QImageReader *, class QFlags<enum Qt::ImageConversionFlag>)
- ?setContext@QGLTextureGlyphCache@@QAEXPAVQGLContext@@@Z @ 712 NONAME ; void QGLTextureGlyphCache::setContext(class QGLContext *)
- ?hibernate@QGLPixmapData@@QAEXXZ @ 713 NONAME ; void QGLPixmapData::hibernate(void)
- ?detachTextureFromPool@QGLPixmapData@@QAEXXZ @ 714 NONAME ; void QGLPixmapData::detachTextureFromPool(void)
- ?reclaimTexture@QGLPixmapData@@QAEXXZ @ 715 NONAME ; void QGLPixmapData::reclaimTexture(void)
- ?destroyTexture@QGLPixmapData@@QAEXXZ @ 716 NONAME ; void QGLPixmapData::destroyTexture(void)
- ?releaseCachedResources@QGLGraphicsSystem@@UAEXXZ @ 717 NONAME ; void QGLGraphicsSystem::releaseCachedResources(void)
- ?serialNumber@QGLTextureGlyphCache@@QBEHXZ @ 718 NONAME ; int QGLTextureGlyphCache::serialNumber(void) const
- ?forceToImage@QGLPixmapData@@QAEXXZ @ 719 NONAME ; void QGLPixmapData::forceToImage(void)
- ?idealFormat@QGLPixmapData@@QAE?AW4Format@QImage@@AAV3@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 720 NONAME ; enum QImage::Format QGLPixmapData::idealFormat(class QImage &, class QFlags<enum Qt::ImageConversionFlag>)
- ?releaseNativeImageHandle@QGLPixmapData@@QAEXXZ @ 721 NONAME ; void QGLPixmapData::releaseNativeImageHandle(void)
- ?createFromNativeImageHandleProvider@QGLPixmapData@@QAEXXZ @ 722 NONAME ; void QGLPixmapData::createFromNativeImageHandleProvider(void)
- ?initFromNativeImageHandle@QGLPixmapData@@QAE_NPAXABVQString@@@Z @ 723 NONAME ; bool QGLPixmapData::initFromNativeImageHandle(void *, class QString const &)
+ ?glVertexAttrib3f@QGLFunctions@@QAEXIMMM@Z @ 705 NONAME ; void QGLFunctions::glVertexAttrib3f(unsigned int, float, float, float)
+ ?glVertexAttrib1fv@QGLFunctions@@QAEXIPBM@Z @ 706 NONAME ; void QGLFunctions::glVertexAttrib1fv(unsigned int, float const *)
+ ?glIsBuffer@QGLFunctions@@QAEEI@Z @ 707 NONAME ; unsigned char QGLFunctions::glIsBuffer(unsigned int)
+ ?glGetActiveAttrib@QGLFunctions@@QAEXIIHPAH0PAIPAD@Z @ 708 NONAME ; void QGLFunctions::glGetActiveAttrib(unsigned int, unsigned int, int, int *, int *, unsigned int *, char *)
+ ?glBindFramebuffer@QGLFunctions@@QAEXII@Z @ 709 NONAME ; void QGLFunctions::glBindFramebuffer(unsigned int, unsigned int)
+ ?glBufferData@QGLFunctions@@QAEXIHPBXI@Z @ 710 NONAME ; void QGLFunctions::glBufferData(unsigned int, int, void const *, unsigned int)
+ ?glValidateProgram@QGLFunctions@@QAEXI@Z @ 711 NONAME ; void QGLFunctions::glValidateProgram(unsigned int)
+ ?glUniform1f@QGLFunctions@@QAEXHM@Z @ 712 NONAME ; void QGLFunctions::glUniform1f(int, float)
+ ?glDetachShader@QGLFunctions@@QAEXII@Z @ 713 NONAME ; void QGLFunctions::glDetachShader(unsigned int, unsigned int)
+ ?glDeleteProgram@QGLFunctions@@QAEXI@Z @ 714 NONAME ; void QGLFunctions::glDeleteProgram(unsigned int)
+ ??_EQGLContextResourceBase@@UAE@I@Z @ 715 NONAME ; QGLContextResourceBase::~QGLContextResourceBase(unsigned int)
+ ?glUniform2f@QGLFunctions@@QAEXHMM@Z @ 716 NONAME ; void QGLFunctions::glUniform2f(int, float, float)
+ ?glIsProgram@QGLFunctions@@QAEEI@Z @ 717 NONAME ; unsigned char QGLFunctions::glIsProgram(unsigned int)
+ ?openGLFeatures@QGLFunctions@@QBE?AV?$QFlags@W4OpenGLFeature@QGLFunctions@@@@XZ @ 718 NONAME ; class QFlags<enum QGLFunctions::OpenGLFeature> QGLFunctions::openGLFeatures(void) const
+ ?toNativeType@QGLPixmapData@@UAEPAXW4NativeType@QPixmapData@@@Z @ 719 NONAME ; void * QGLPixmapData::toNativeType(enum QPixmapData::NativeType)
+ ?glReleaseShaderCompiler@QGLFunctions@@QAEXXZ @ 720 NONAME ; void QGLFunctions::glReleaseShaderCompiler(void)
+ ??0QGLTextureGlyphCache@@QAE@PBVQGLContext@@W4Type@QFontEngineGlyphCache@@ABVQTransform@@@Z @ 721 NONAME ; QGLTextureGlyphCache::QGLTextureGlyphCache(class QGLContext const *, enum QFontEngineGlyphCache::Type, class QTransform const &)
+ ?context@QGLTextureGlyphCache@@QBEPBVQGLContext@@XZ @ 722 NONAME ; class QGLContext const * QGLTextureGlyphCache::context(void) const
+ ?glGenRenderbuffers@QGLFunctions@@QAEXHPAI@Z @ 723 NONAME ; void QGLFunctions::glGenRenderbuffers(int, unsigned int *)
+ ?glBindBuffer@QGLFunctions@@QAEXII@Z @ 724 NONAME ; void QGLFunctions::glBindBuffer(unsigned int, unsigned int)
+ ?glUniformMatrix3fv@QGLFunctions@@QAEXHHEPBM@Z @ 725 NONAME ; void QGLFunctions::glUniformMatrix3fv(int, int, unsigned char, float const *)
+ ?glGenerateMipmap@QGLFunctions@@QAEXI@Z @ 726 NONAME ; void QGLFunctions::glGenerateMipmap(unsigned int)
+ ?hasOpenGLFeature@QGLFunctions@@QBE_NW4OpenGLFeature@1@@Z @ 727 NONAME ; bool QGLFunctions::hasOpenGLFeature(enum QGLFunctions::OpenGLFeature) const
+ ?glGetAttachedShaders@QGLFunctions@@QAEXIHPAHPAI@Z @ 728 NONAME ; void QGLFunctions::glGetAttachedShaders(unsigned int, int, int *, unsigned int *)
+ ?glDeleteShader@QGLFunctions@@QAEXI@Z @ 729 NONAME ; void QGLFunctions::glDeleteShader(unsigned int)
+ ?glLinkProgram@QGLFunctions@@QAEXI@Z @ 730 NONAME ; void QGLFunctions::glLinkProgram(unsigned int)
+ ?glUseProgram@QGLFunctions@@QAEXI@Z @ 731 NONAME ; void QGLFunctions::glUseProgram(unsigned int)
+ ??0QGLFunctions@@QAE@PBVQGLContext@@@Z @ 732 NONAME ; QGLFunctions::QGLFunctions(class QGLContext const *)
+ ?glGetBufferParameteriv@QGLFunctions@@QAEXIIPAH@Z @ 733 NONAME ; void QGLFunctions::glGetBufferParameteriv(unsigned int, unsigned int, int *)
+ ?glGenBuffers@QGLFunctions@@QAEXHPAI@Z @ 734 NONAME ; void QGLFunctions::glGenBuffers(int, unsigned int *)
+ ?glGetShaderiv@QGLFunctions@@QAEXIIPAH@Z @ 735 NONAME ; void QGLFunctions::glGetShaderiv(unsigned int, unsigned int, int *)
+ ?fillTexture@QGLTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@IUQFixed@@@Z @ 736 NONAME ; void QGLTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int, struct QFixed)
+ ?glUniform2fv@QGLFunctions@@QAEXHHPBM@Z @ 737 NONAME ; void QGLFunctions::glUniform2fv(int, int, float const *)
+ ?fromNativeType@QGLPixmapData@@UAEXPAXW4NativeType@QPixmapData@@@Z @ 738 NONAME ; void QGLPixmapData::fromNativeType(void *, enum QPixmapData::NativeType)
+ ??0QGLContextGroupResourceBase@@QAE@XZ @ 739 NONAME ; QGLContextGroupResourceBase::QGLContextGroupResourceBase(void)
+ ?glGetFramebufferAttachmentParameteriv@QGLFunctions@@QAEXIIIPAH@Z @ 740 NONAME ; void QGLFunctions::glGetFramebufferAttachmentParameteriv(unsigned int, unsigned int, unsigned int, int *)
+ ?cleanup@QGLContextGroupResourceBase@@QAEXPBVQGLContext@@PAX@Z @ 741 NONAME ; void QGLContextGroupResourceBase::cleanup(class QGLContext const *, void *)
+ ?glUniform2iv@QGLFunctions@@QAEXHHPBH@Z @ 742 NONAME ; void QGLFunctions::glUniform2iv(int, int, int const *)
+ ?glCompileShader@QGLFunctions@@QAEXI@Z @ 743 NONAME ; void QGLFunctions::glCompileShader(unsigned int)
+ ?isFlipped@QGLPaintDevice@@UBE_NXZ @ 744 NONAME ; bool QGLPaintDevice::isFlipped(void) const
+ ?glGetProgramiv@QGLFunctions@@QAEXIIPAH@Z @ 745 NONAME ; void QGLFunctions::glGetProgramiv(unsigned int, unsigned int, int *)
+ ?glClearDepthf@QGLFunctions@@QAEXM@Z @ 746 NONAME ; void QGLFunctions::glClearDepthf(float)
+ ?glIsFramebuffer@QGLFunctions@@QAEEI@Z @ 747 NONAME ; unsigned char QGLFunctions::glIsFramebuffer(unsigned int)
+ ?glUniform4f@QGLFunctions@@QAEXHMMMM@Z @ 748 NONAME ; void QGLFunctions::glUniform4f(int, float, float, float, float)
+ ?glUniform3f@QGLFunctions@@QAEXHMMM@Z @ 749 NONAME ; void QGLFunctions::glUniform3f(int, float, float, float)
+ ?glDeleteRenderbuffers@QGLFunctions@@QAEXHPBI@Z @ 750 NONAME ; void QGLFunctions::glDeleteRenderbuffers(int, unsigned int const *)
+ ?glVertexAttrib1f@QGLFunctions@@QAEXIM@Z @ 751 NONAME ; void QGLFunctions::glVertexAttrib1f(unsigned int, float)
+ ?glVertexAttrib4f@QGLFunctions@@QAEXIMMMM@Z @ 752 NONAME ; void QGLFunctions::glVertexAttrib4f(unsigned int, float, float, float, float)
+ ?glSampleCoverage@QGLFunctions@@QAEXME@Z @ 753 NONAME ; void QGLFunctions::glSampleCoverage(float, unsigned char)
+ ?glGetActiveUniform@QGLFunctions@@QAEXIIHPAH0PAIPAD@Z @ 754 NONAME ; void QGLFunctions::glGetActiveUniform(unsigned int, unsigned int, int, int *, int *, unsigned int *, char *)
+ ??_EQGLContextGroupResourceBase@@UAE@I@Z @ 755 NONAME ; QGLContextGroupResourceBase::~QGLContextGroupResourceBase(unsigned int)
+ ?glStencilOpSeparate@QGLFunctions@@QAEXIIII@Z @ 756 NONAME ; void QGLFunctions::glStencilOpSeparate(unsigned int, unsigned int, unsigned int, unsigned int)
+ ?glCheckFramebufferStatus@QGLFunctions@@QAEII@Z @ 757 NONAME ; unsigned int QGLFunctions::glCheckFramebufferStatus(unsigned int)
+ ?glDepthRangef@QGLFunctions@@QAEXMM@Z @ 758 NONAME ; void QGLFunctions::glDepthRangef(float, float)
+ ??1QGLFunctions@@QAE@XZ @ 759 NONAME ; QGLFunctions::~QGLFunctions(void)
+ ?glStencilMaskSeparate@QGLFunctions@@QAEXII@Z @ 760 NONAME ; void QGLFunctions::glStencilMaskSeparate(unsigned int, unsigned int)
+ ?glBlendColor@QGLFunctions@@QAEXMMMM@Z @ 761 NONAME ; void QGLFunctions::glBlendColor(float, float, float, float)
+ ?glUniform1fv@QGLFunctions@@QAEXHHPBM@Z @ 762 NONAME ; void QGLFunctions::glUniform1fv(int, int, float const *)
+ ??1QGLContextResourceBase@@UAE@XZ @ 763 NONAME ; QGLContextResourceBase::~QGLContextResourceBase(void)
+ ?glCreateProgram@QGLFunctions@@QAEIXZ @ 764 NONAME ; unsigned int QGLFunctions::glCreateProgram(void)
+ ?glVertexAttrib2f@QGLFunctions@@QAEXIMM@Z @ 765 NONAME ; void QGLFunctions::glVertexAttrib2f(unsigned int, float, float)
+ ?glUniformMatrix2fv@QGLFunctions@@QAEXHHEPBM@Z @ 766 NONAME ; void QGLFunctions::glUniformMatrix2fv(int, int, unsigned char, float const *)
+ ?glBufferSubData@QGLFunctions@@QAEXIHHPBX@Z @ 767 NONAME ; void QGLFunctions::glBufferSubData(unsigned int, int, int, void const *)
+ ?glUniform1iv@QGLFunctions@@QAEXHHPBH@Z @ 768 NONAME ; void QGLFunctions::glUniform1iv(int, int, int const *)
+ ?qt_resolve_buffer_extensions@@YA_NPAVQGLContext@@@Z @ 769 NONAME ; bool qt_resolve_buffer_extensions(class QGLContext *)
+ ?glUniform1i@QGLFunctions@@QAEXHH@Z @ 770 NONAME ; void QGLFunctions::glUniform1i(int, int)
+ ?glVertexAttrib4fv@QGLFunctions@@QAEXIPBM@Z @ 771 NONAME ; void QGLFunctions::glVertexAttrib4fv(unsigned int, float const *)
+ ?glDeleteFramebuffers@QGLFunctions@@QAEXHPBI@Z @ 772 NONAME ; void QGLFunctions::glDeleteFramebuffers(int, unsigned int const *)
+ ?glGetVertexAttribfv@QGLFunctions@@QAEXIIPAM@Z @ 773 NONAME ; void QGLFunctions::glGetVertexAttribfv(unsigned int, unsigned int, float *)
+ ?glGetProgramInfoLog@QGLFunctions@@QAEXIHPAHPAD@Z @ 774 NONAME ; void QGLFunctions::glGetProgramInfoLog(unsigned int, int, int *, char *)
+ ?glGetShaderInfoLog@QGLFunctions@@QAEXIHPAHPAD@Z @ 775 NONAME ; void QGLFunctions::glGetShaderInfoLog(unsigned int, int, int *, char *)
+ ?glEnableVertexAttribArray@QGLFunctions@@QAEXI@Z @ 776 NONAME ; void QGLFunctions::glEnableVertexAttribArray(unsigned int)
+ ?glGetVertexAttribiv@QGLFunctions@@QAEXIIPAH@Z @ 777 NONAME ; void QGLFunctions::glGetVertexAttribiv(unsigned int, unsigned int, int *)
+ ?swapBehavior@QGLWindowSurface@@2W4SwapMode@1@A @ 778 NONAME ; enum QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior
+ ?glCompressedTexImage2D@QGLFunctions@@QAEXIHIHHHHPBX@Z @ 779 NONAME ; void QGLFunctions::glCompressedTexImage2D(unsigned int, int, unsigned int, int, int, int, int, void const *)
+ ?glGetAttribLocation@QGLFunctions@@QAEHIPBD@Z @ 780 NONAME ; int QGLFunctions::glGetAttribLocation(unsigned int, char const *)
+ ?glActiveTexture@QGLFunctions@@QAEXI@Z @ 781 NONAME ; void QGLFunctions::glActiveTexture(unsigned int)
+ ?glUniform4fv@QGLFunctions@@QAEXHHPBM@Z @ 782 NONAME ; void QGLFunctions::glUniform4fv(int, int, float const *)
+ ?glCreateShader@QGLFunctions@@QAEII@Z @ 783 NONAME ; unsigned int QGLFunctions::glCreateShader(unsigned int)
+ ?glAttachShader@QGLFunctions@@QAEXII@Z @ 784 NONAME ; void QGLFunctions::glAttachShader(unsigned int, unsigned int)
+ ?glRenderbufferStorage@QGLFunctions@@QAEXIIHH@Z @ 785 NONAME ; void QGLFunctions::glRenderbufferStorage(unsigned int, unsigned int, int, int)
+ ?glVertexAttribPointer@QGLFunctions@@QAEXIHIEHPBX@Z @ 786 NONAME ; void QGLFunctions::glVertexAttribPointer(unsigned int, int, unsigned int, unsigned char, int, void const *)
+ ?glUniform4iv@QGLFunctions@@QAEXHHPBH@Z @ 787 NONAME ; void QGLFunctions::glUniform4iv(int, int, int const *)
+ ?glDisableVertexAttribArray@QGLFunctions@@QAEXI@Z @ 788 NONAME ; void QGLFunctions::glDisableVertexAttribArray(unsigned int)
+ ?glIsShader@QGLFunctions@@QAEEI@Z @ 789 NONAME ; unsigned char QGLFunctions::glIsShader(unsigned int)
+ ?glShaderBinary@QGLFunctions@@QAEXHPBIIPBXH@Z @ 790 NONAME ; void QGLFunctions::glShaderBinary(int, unsigned int const *, unsigned int, void const *, int)
+ ?glGenFramebuffers@QGLFunctions@@QAEXHPAI@Z @ 791 NONAME ; void QGLFunctions::glGenFramebuffers(int, unsigned int *)
+ ?glVertexAttrib3fv@QGLFunctions@@QAEXIPBM@Z @ 792 NONAME ; void QGLFunctions::glVertexAttrib3fv(unsigned int, float const *)
+ ?glGetVertexAttribPointerv@QGLFunctions@@QAEXIIPAPAX@Z @ 793 NONAME ; void QGLFunctions::glGetVertexAttribPointerv(unsigned int, unsigned int, void * *)
+ ?glUniformMatrix4fv@QGLFunctions@@QAEXHHEPBM@Z @ 794 NONAME ; void QGLFunctions::glUniformMatrix4fv(int, int, unsigned char, float const *)
+ ?setContext@QGLTextureGlyphCache@@QAEXPBVQGLContext@@@Z @ 795 NONAME ; void QGLTextureGlyphCache::setContext(class QGLContext const *)
+ ?glDeleteBuffers@QGLFunctions@@QAEXHPBI@Z @ 796 NONAME ; void QGLFunctions::glDeleteBuffers(int, unsigned int const *)
+ ?glBindRenderbuffer@QGLFunctions@@QAEXII@Z @ 797 NONAME ; void QGLFunctions::glBindRenderbuffer(unsigned int, unsigned int)
+ ?glStencilFuncSeparate@QGLFunctions@@QAEXIIHI@Z @ 798 NONAME ; void QGLFunctions::glStencilFuncSeparate(unsigned int, unsigned int, int, unsigned int)
+ ?createPixmapForImage@QGLPixmapData@@AAEXAAVQImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@_N@Z @ 799 NONAME ; void QGLPixmapData::createPixmapForImage(class QImage &, class QFlags<enum Qt::ImageConversionFlag>, bool)
+ ?glGetUniformLocation@QGLFunctions@@QAEHIPBD@Z @ 800 NONAME ; int QGLFunctions::glGetUniformLocation(unsigned int, char const *)
+ ?glGetRenderbufferParameteriv@QGLFunctions@@QAEXIIPAH@Z @ 801 NONAME ; void QGLFunctions::glGetRenderbufferParameteriv(unsigned int, unsigned int, int *)
+ ?glBindAttribLocation@QGLFunctions@@QAEXIIPBD@Z @ 802 NONAME ; void QGLFunctions::glBindAttribLocation(unsigned int, unsigned int, char const *)
+ ?glGetShaderSource@QGLFunctions@@QAEXIHPAHPAD@Z @ 803 NONAME ; void QGLFunctions::glGetShaderSource(unsigned int, int, int *, char *)
+ ?setMipmap@QGLFramebufferObjectFormat@@QAEX_N@Z @ 804 NONAME ; void QGLFramebufferObjectFormat::setMipmap(bool)
+ ??1QGLContextGroupResourceBase@@UAE@XZ @ 805 NONAME ; QGLContextGroupResourceBase::~QGLContextGroupResourceBase(void)
+ ?glFramebufferTexture2D@QGLFunctions@@QAEXIIIIH@Z @ 806 NONAME ; void QGLFunctions::glFramebufferTexture2D(unsigned int, unsigned int, unsigned int, unsigned int, int)
+ ?glBlendEquationSeparate@QGLFunctions@@QAEXII@Z @ 807 NONAME ; void QGLFunctions::glBlendEquationSeparate(unsigned int, unsigned int)
+ ?insert@QGLContextResourceBase@@QAEXPBVQGLContext@@PAX@Z @ 808 NONAME ; void QGLContextResourceBase::insert(class QGLContext const *, void *)
+ ?glUniform2i@QGLFunctions@@QAEXHHH@Z @ 809 NONAME ; void QGLFunctions::glUniform2i(int, int, int)
+ ?glGetUniformfv@QGLFunctions@@QAEXIHPAM@Z @ 810 NONAME ; void QGLFunctions::glGetUniformfv(unsigned int, int, float *)
+ ?glUniform3i@QGLFunctions@@QAEXHHHH@Z @ 811 NONAME ; void QGLFunctions::glUniform3i(int, int, int, int)
+ ?glIsRenderbuffer@QGLFunctions@@QAEEI@Z @ 812 NONAME ; unsigned char QGLFunctions::glIsRenderbuffer(unsigned int)
+ ?initializeGLFunctions@QGLFunctions@@QAEXPBVQGLContext@@@Z @ 813 NONAME ; void QGLFunctions::initializeGLFunctions(class QGLContext const *)
+ ??0QGLFunctions@@QAE@XZ @ 814 NONAME ; QGLFunctions::QGLFunctions(void)
+ ?glVertexAttrib2fv@QGLFunctions@@QAEXIPBM@Z @ 815 NONAME ; void QGLFunctions::glVertexAttrib2fv(unsigned int, float const *)
+ ?isInitialized@QGLFunctions@@CA_NPBUQGLFunctionsPrivate@@@Z @ 816 NONAME ; bool QGLFunctions::isInitialized(struct QGLFunctionsPrivate const *)
+ ?glGetUniformiv@QGLFunctions@@QAEXIHPAH@Z @ 817 NONAME ; void QGLFunctions::glGetUniformiv(unsigned int, int, int *)
+ ?glBlendEquation@QGLFunctions@@QAEXI@Z @ 818 NONAME ; void QGLFunctions::glBlendEquation(unsigned int)
+ ?glFramebufferRenderbuffer@QGLFunctions@@QAEXIIII@Z @ 819 NONAME ; void QGLFunctions::glFramebufferRenderbuffer(unsigned int, unsigned int, unsigned int, unsigned int)
+ ?glUniform4i@QGLFunctions@@QAEXHHHHH@Z @ 820 NONAME ; void QGLFunctions::glUniform4i(int, int, int, int, int)
+ ?glUniform3fv@QGLFunctions@@QAEXHHPBM@Z @ 821 NONAME ; void QGLFunctions::glUniform3fv(int, int, float const *)
+ ?value@QGLContextResourceBase@@QAEPAXPBVQGLContext@@@Z @ 822 NONAME ; void * QGLContextResourceBase::value(class QGLContext const *)
+ ?glBlendFuncSeparate@QGLFunctions@@QAEXIIII@Z @ 823 NONAME ; void QGLFunctions::glBlendFuncSeparate(unsigned int, unsigned int, unsigned int, unsigned int)
+ ?glCompressedTexSubImage2D@QGLFunctions@@QAEXIHHHHHIHPBX@Z @ 824 NONAME ; void QGLFunctions::glCompressedTexSubImage2D(unsigned int, int, int, int, int, int, unsigned int, int, void const *)
+ ?freeResource@QGLTextureGlyphCache@@UAEXPAX@Z @ 825 NONAME ; void QGLTextureGlyphCache::freeResource(void *)
+ ?value@QGLContextGroupResourceBase@@QAEPAXPBVQGLContext@@@Z @ 826 NONAME ; void * QGLContextGroupResourceBase::value(class QGLContext const *)
+ ?glUniform3iv@QGLFunctions@@QAEXHHPBH@Z @ 827 NONAME ; void QGLFunctions::glUniform3iv(int, int, int const *)
+ ?mipmap@QGLFramebufferObjectFormat@@QBE_NXZ @ 828 NONAME ; bool QGLFramebufferObjectFormat::mipmap(void) const
+ ?serialNumber@QGLTextureGlyphCache@@QBEHXZ @ 829 NONAME ; int QGLTextureGlyphCache::serialNumber(void) const
+ ?fromImageReader@QGLPixmapData@@UAEXPAVQImageReader@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 830 NONAME ; void QGLPixmapData::fromImageReader(class QImageReader *, class QFlags<enum Qt::ImageConversionFlag>)
+ ?qt_extensionFuncs@QGLContextPrivate@@2UQGLExtensionFuncs@@A @ 831 NONAME ; struct QGLExtensionFuncs QGLContextPrivate::qt_extensionFuncs
+ ?glShaderSource@QGLFunctions@@QAEXIHPAPBDPBH@Z @ 832 NONAME ; void QGLFunctions::glShaderSource(unsigned int, int, char const * *, int const *)
+ ?glGetShaderPrecisionFormat@QGLFunctions@@QAEXIIPAH0@Z @ 833 NONAME ; void QGLFunctions::glGetShaderPrecisionFormat(unsigned int, unsigned int, int *, int *)
+ ?insert@QGLContextGroupResourceBase@@QAEXPBVQGLContext@@PAX@Z @ 834 NONAME ; void QGLContextGroupResourceBase::insert(class QGLContext const *, void *)
diff --git a/src/s60installs/bwins/QtTestu.def b/src/s60installs/bwins/QtTestu.def
index a7bb9cd..60a7a4c 100644
--- a/src/s60installs/bwins/QtTestu.def
+++ b/src/s60installs/bwins/QtTestu.def
@@ -77,4 +77,93 @@ EXPORTS
?staticMetaObject@QTestEventLoop@@2UQMetaObject@@B @ 76 NONAME ; struct QMetaObject const QTestEventLoop::staticMetaObject
?setBenchmarkResult@QTest@@YAXMW4QBenchmarkMetric@1@@Z @ 77 NONAME ; void QTest::setBenchmarkResult(float, enum QTest::QBenchmarkMetric)
?endBenchmarkMeasurement@QTest@@YA_KXZ @ 78 NONAME ; unsigned long long QTest::endBenchmarkMeasurement(void)
+ ?addBenchmarkResult@QTestLog@@SAXABVQBenchmarkResult@@@Z @ 79 NONAME ; void QTestLog::addBenchmarkResult(class QBenchmarkResult const &)
+ ?currentTestLocation@QTestResult@@SA?AW4TestLocation@1@XZ @ 80 NONAME ; enum QTestResult::TestLocation QTestResult::currentTestLocation(void)
+ ?setCurrentTestLocation@QTestResult@@SAXW4TestLocation@1@@Z @ 81 NONAME ; void QTestResult::setCurrentTestLocation(enum QTestResult::TestLocation)
+ ?testFailed@QTestResult@@SA_NXZ @ 82 NONAME ; bool QTestResult::testFailed(void)
+ ?setVerboseLevel@QTestLog@@SAXH@Z @ 83 NONAME ; void QTestLog::setVerboseLevel(int)
+ ?setCurrentTestObject@QTestResult@@SAXPBD@Z @ 84 NONAME ; void QTestResult::setCurrentTestObject(char const *)
+ ?isEmpty@QTestTable@@QBE_NXZ @ 85 NONAME ; bool QTestTable::isEmpty(void) const
+ ?reset@QTestResult@@SAXXZ @ 86 NONAME ; void QTestResult::reset(void)
+ ?info@QTestLog@@SAXPBD0H@Z @ 87 NONAME ; void QTestLog::info(char const *, char const *, int)
+ ?adjustMedianIterationCount@QBenchmarkGlobalData@@QAEHXZ @ 88 NONAME ; int QBenchmarkGlobalData::adjustMedianIterationCount(void)
+ ?addColumn@QTestTable@@QAEXHPBD@Z @ 89 NONAME ; void QTestTable::addColumn(int, char const *)
+ ?setMode@QBenchmarkGlobalData@@QAEXW4Mode@1@@Z @ 90 NONAME ; void QBenchmarkGlobalData::setMode(enum QBenchmarkGlobalData::Mode)
+ ?addFailure@QTestResult@@SAXPBD0H@Z @ 91 NONAME ; void QTestResult::addFailure(char const *, char const *, int)
+ ?indexOf@QTestTable@@QBEHPBD@Z @ 92 NONAME ; int QTestTable::indexOf(char const *) const
+ ?warn@QTestLog@@SAXPBD@Z @ 93 NONAME ; void QTestLog::warn(char const *)
+ ?currentTestData@QTestResult@@SAPAVQTestData@@XZ @ 94 NONAME ; class QTestData * QTestResult::currentTestData(void)
+ ?startLogging@QTestLog@@SAXI@Z @ 95 NONAME ; void QTestLog::startLogging(unsigned int)
+ ?endDataRun@QBenchmarkTestMethodData@@QAEXXZ @ 96 NONAME ; void QBenchmarkTestMethodData::endDataRun(void)
+ ?globalTestTable@QTestTable@@SAPAV1@XZ @ 97 NONAME ; class QTestTable * QTestTable::globalTestTable(void)
+ ?elementCount@QTestTable@@QBEHXZ @ 98 NONAME ; int QTestTable::elementCount(void) const
+ ??0QTestLog@@AAE@XZ @ 99 NONAME ; QTestLog::QTestLog(void)
+ ?allDataPassed@QTestResult@@SA_NXZ @ 100 NONAME ; bool QTestResult::allDataPassed(void)
+ ??0QBenchmarkTestMethodData@@QAE@XZ @ 101 NONAME ; QBenchmarkTestMethodData::QBenchmarkTestMethodData(void)
+ ?qtest_qParseArgs@QTest@@YAXHQAPAD_N@Z @ 102 NONAME ; void QTest::qtest_qParseArgs(int, char * * const, bool)
+ ?unhandledIgnoreMessages@QTestLog@@SAHXZ @ 103 NONAME ; int QTestLog::unhandledIgnoreMessages(void)
+ ?setCurrentTestFunction@QTestResult@@SAXPBD@Z @ 104 NONAME ; void QTestResult::setCurrentTestFunction(char const *)
+ ?enterTestFunction@QTestLog@@SAXPBD@Z @ 105 NONAME ; void QTestLog::enterTestFunction(char const *)
+ ?testFunctions@QTest@@3VQStringList@@A @ 106 NONAME ; class QStringList QTest::testFunctions
+ ?addSkip@QTestResult@@SAXPBDW4SkipMode@QTest@@0H@Z @ 107 NONAME ; void QTestResult::addSkip(char const *, enum QTest::SkipMode, char const *, int)
+ ?currentGlobalDataTag@QTestResult@@SAPBDXZ @ 108 NONAME ; char const * QTestResult::currentGlobalDataTag(void)
+ ?stopLogging@QTestLog@@SAXXZ @ 109 NONAME ; void QTestLog::stopLogging(void)
+ ??1QTestLog@@AAE@XZ @ 110 NONAME ; QTestLog::~QTestLog(void)
+ ?skipCount@QTestResult@@SAHXZ @ 111 NONAME ; int QTestResult::skipCount(void)
+ ?setCurrentGlobalTestData@QTestResult@@SAXPAVQTestData@@@Z @ 112 NONAME ; void QTestResult::setCurrentGlobalTestData(class QTestData *)
+ ?elementTypeId@QTestTable@@QBEHH@Z @ 113 NONAME ; int QTestTable::elementTypeId(int) const
+ ?dataTag@QTestTable@@QBEPBDH@Z @ 114 NONAME ; char const * QTestTable::dataTag(int) const
+ ?dataCount@QTestTable@@QBEHXZ @ 115 NONAME ; int QTestTable::dataCount(void) const
+ ?printUnhandledIgnoreMessages@QTestLog@@SAXXZ @ 116 NONAME ; void QTestLog::printUnhandledIgnoreMessages(void)
+ ??1QBenchmarkTestMethodData@@QAE@XZ @ 117 NONAME ; QBenchmarkTestMethodData::~QBenchmarkTestMethodData(void)
+ ??1QTestTable@@QAE@XZ @ 118 NONAME ; QTestTable::~QTestTable(void)
+ ?current@QBenchmarkGlobalData@@2PAV1@A @ 119 NONAME ; class QBenchmarkGlobalData * QBenchmarkGlobalData::current
+ ?setFlushMode@QTestLog@@SAXW4FlushMode@1@@Z @ 120 NONAME ; void QTestLog::setFlushMode(enum QTestLog::FlushMode)
+ ?ignoreMessage@QTestResult@@SAXW4QtMsgType@@PBD@Z @ 121 NONAME ; void QTestResult::ignoreMessage(enum QtMsgType, char const *)
+ ?failCount@QTestResult@@SAHXZ @ 122 NONAME ; int QTestResult::failCount(void)
+ ?mode@QBenchmarkGlobalData@@QBE?AW4Mode@1@XZ @ 123 NONAME ; enum QBenchmarkGlobalData::Mode QBenchmarkGlobalData::mode(void) const
+ ?addSkip@QTestLog@@SAXPBDW4SkipMode@QTest@@0H@Z @ 124 NONAME ; void QTestLog::addSkip(char const *, enum QTest::SkipMode, char const *, int)
+ ?outputFileName@QTestLog@@SAPBDXZ @ 125 NONAME ; char const * QTestLog::outputFileName(void)
+ ?expectFail@QTestResult@@SA_NPBD0W4TestFailMode@QTest@@0H@Z @ 126 NONAME ; bool QTestResult::expectFail(char const *, char const *, enum QTest::TestFailMode, char const *, int)
+ ?passCount@QTestResult@@SAHXZ @ 127 NONAME ; int QTestResult::passCount(void)
+ ?logMode@QTestLog@@SA?AW4LogMode@1@XZ @ 128 NONAME ; enum QTestLog::LogMode QTestLog::logMode(void)
+ ?skipCurrentTest@QTestResult@@SA_NXZ @ 129 NONAME ; bool QTestResult::skipCurrentTest(void)
+ ?addXPass@QTestLog@@SAXPBD0H@Z @ 130 NONAME ; void QTestLog::addXPass(char const *, char const *, int)
+ ?testTags@QTest@@3VQStringList@@A @ 131 NONAME ; class QStringList QTest::testTags
+ ?isBenchmark@QBenchmarkTestMethodData@@QBE_NXZ @ 132 NONAME ; bool QBenchmarkTestMethodData::isBenchmark(void) const
+ ?adjustIterationCount@QBenchmarkTestMethodData@@QAEHH@Z @ 133 NONAME ; int QBenchmarkTestMethodData::adjustIterationCount(int)
+ ??1QBenchmarkGlobalData@@QAE@XZ @ 134 NONAME ; QBenchmarkGlobalData::~QBenchmarkGlobalData(void)
+ ?printAvailableFunctions@QTest@@3_NA @ 135 NONAME ; bool QTest::printAvailableFunctions
+ ?testData@QTestTable@@QBEPAVQTestData@@H@Z @ 136 NONAME ; class QTestData * QTestTable::testData(int) const
+ ?setCurrentTestData@QTestResult@@SAXPAVQTestData@@@Z @ 137 NONAME ; void QTestResult::setCurrentTestData(class QTestData *)
+ ?compare@QTestResult@@SA_N_NPBD1H@Z @ 138 NONAME ; bool QTestResult::compare(bool, char const *, char const *, int)
+ ?currentTestFailed@QTestResult@@SA_NXZ @ 139 NONAME ; bool QTestResult::currentTestFailed(void)
+ ?compare@QTestResult@@SA_N_NPBDPAD2111H@Z @ 140 NONAME ; bool QTestResult::compare(bool, char const *, char *, char *, char const *, char const *, char const *, int)
+ ?addXFail@QTestLog@@SAXPBD0H@Z @ 141 NONAME ; void QTestLog::addXFail(char const *, char const *, int)
+ ??0QBenchmarkGlobalData@@QAE@XZ @ 142 NONAME ; QBenchmarkGlobalData::QBenchmarkGlobalData(void)
+ ?beginDataRun@QBenchmarkTestMethodData@@QAEXXZ @ 143 NONAME ; void QBenchmarkTestMethodData::beginDataRun(void)
+ ?resultsAccepted@QBenchmarkTestMethodData@@QBE_NXZ @ 144 NONAME ; bool QBenchmarkTestMethodData::resultsAccepted(void) const
+ ?addIgnoreMessage@QTestLog@@SAXW4QtMsgType@@PBD@Z @ 145 NONAME ; void QTestLog::addIgnoreMessage(enum QtMsgType, char const *)
+ ?startLogging@QTestLog@@SAXXZ @ 146 NONAME ; void QTestLog::startLogging(void)
+ ?currentDataTag@QTestResult@@SAPBDXZ @ 147 NONAME ; char const * QTestResult::currentDataTag(void)
+ ?redirectOutput@QTestLog@@SAXPBD@Z @ 148 NONAME ; void QTestLog::redirectOutput(char const *)
+ ?currentTestObjectName@QTestResult@@SAPBDXZ @ 149 NONAME ; char const * QTestResult::currentTestObjectName(void)
+ ?newData@QTestTable@@QAEPAVQTestData@@PBD@Z @ 150 NONAME ; class QTestData * QTestTable::newData(char const *)
+ ?addPass@QTestLog@@SAXPBD@Z @ 151 NONAME ; void QTestLog::addPass(char const *)
+ ?verboseLevel@QTestLog@@SAHXZ @ 152 NONAME ; int QTestLog::verboseLevel(void)
+ ?createMeasurer@QBenchmarkGlobalData@@QAEPAVQBenchmarkMeasurerBase@@XZ @ 153 NONAME ; class QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer(void)
+ ?currentGlobalTestData@QTestResult@@SAPAVQTestData@@XZ @ 154 NONAME ; class QTestData * QTestResult::currentGlobalTestData(void)
+ ?setSkipCurrentTest@QTestResult@@SAX_N@Z @ 155 NONAME ; void QTestResult::setSkipCurrentTest(bool)
+ ?setResult@QBenchmarkTestMethodData@@QAEXMW4QBenchmarkMetric@QTest@@_N@Z @ 156 NONAME ; void QBenchmarkTestMethodData::setResult(float, enum QTest::QBenchmarkMetric, bool)
+ ?verify@QTestResult@@SA_N_NPBD11H@Z @ 157 NONAME ; bool QTestResult::verify(bool, char const *, char const *, char const *, int)
+ ?leaveTestFunction@QTestLog@@SAXXZ @ 158 NONAME ; void QTestLog::leaveTestFunction(void)
+ ?finishedCurrentTestFunction@QTestResult@@SAXXZ @ 159 NONAME ; void QTestResult::finishedCurrentTestFunction(void)
+ ?currentTestTable@QTestTable@@SAPAV1@XZ @ 160 NONAME ; class QTestTable * QTestTable::currentTestTable(void)
+ ?currentTestFunction@QTestResult@@SAPBDXZ @ 161 NONAME ; char const * QTestResult::currentTestFunction(void)
+ ?setLogMode@QTestLog@@SAXW4LogMode@1@@Z @ 162 NONAME ; void QTestLog::setLogMode(enum QTestLog::LogMode)
+ ?clearGlobalTestTable@QTestTable@@SAXXZ @ 163 NONAME ; void QTestTable::clearGlobalTestTable(void)
+ ?addFail@QTestLog@@SAXPBD0H@Z @ 164 NONAME ; void QTestLog::addFail(char const *, char const *, int)
+ ??0QTestTable@@QAE@XZ @ 165 NONAME ; QTestTable::QTestTable(void)
+ ?setMaxWarnings@QTestLog@@SAXH@Z @ 166 NONAME ; void QTestLog::setMaxWarnings(int)
+ ?current@QBenchmarkTestMethodData@@2PAV1@A @ 167 NONAME ; class QBenchmarkTestMethodData * QBenchmarkTestMethodData::current
diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def
index fce55dd..cfdd9ee 100644
--- a/src/s60installs/eabi/QtCoreu.def
+++ b/src/s60installs/eabi/QtCoreu.def
@@ -620,8 +620,8 @@ EXPORTS
_ZN14QObjectPrivate11clearGuardsEP7QObject @ 619 NONAME
_ZN14QObjectPrivate13addConnectionEiPNS_10ConnectionE @ 620 NONAME
_ZN14QObjectPrivate14deleteChildrenEv @ 621 NONAME
- _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME
- _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME
+ _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME ABSENT
+ _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME ABSENT
_ZN14QObjectPrivate16setCurrentSenderEP7QObjectPNS_6SenderE @ 624 NONAME ABSENT
_ZN14QObjectPrivate16setParent_helperEP7QObject @ 625 NONAME
_ZN14QObjectPrivate18resetCurrentSenderEP7QObjectPNS_6SenderES3_ @ 626 NONAME ABSENT
@@ -1274,8 +1274,8 @@ EXPORTS
_ZN23QCoreApplicationPrivate34sendThroughApplicationEventFiltersEP7QObjectP6QEvent @ 1273 NONAME
_ZN23QCoreApplicationPrivate35appendApplicationPathToLibraryPathsEv @ 1274 NONAME
_ZN23QCoreApplicationPrivate7attribsE @ 1275 NONAME DATA 4
- _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME
- _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME
+ _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME ABSENT
+ _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME ABSENT
_ZN23QCoreApplicationPrivateD0Ev @ 1278 NONAME
_ZN23QCoreApplicationPrivateD1Ev @ 1279 NONAME
_ZN23QCoreApplicationPrivateD2Ev @ 1280 NONAME
@@ -1439,7 +1439,7 @@ EXPORTS
_ZN31QAbstractEventDispatcherPrivate4initEv @ 1438 NONAME
_ZN31QNonContiguousByteDeviceFactory4wrapEP24QNonContiguousByteDevice @ 1439 NONAME
_ZN31QNonContiguousByteDeviceFactory6createEP10QByteArray @ 1440 NONAME
- _ZN31QNonContiguousByteDeviceFactory6createEP11QRingBuffer @ 1441 NONAME
+ _ZN31QNonContiguousByteDeviceFactory6createEP11QRingBuffer @ 1441 NONAME ABSENT
_ZN31QNonContiguousByteDeviceFactory6createEP9QIODevice @ 1442 NONAME
_ZN4QDir10setCurrentERK7QString @ 1443 NONAME
_ZN4QDir10setSortingE6QFlagsINS_8SortFlagEE @ 1444 NONAME
@@ -3714,7 +3714,99 @@ EXPORTS
_Z26qt_symbian_SetupThreadHeapiR24SStdEpocThreadCreateInfo @ 3713 NONAME
_ZN24QAbstractDeclarativeData17objectNameChangedE @ 3714 NONAME DATA 4
_ZN23QEventDispatcherSymbian36queueDeferredActiveObjectsCompletionEv @ 3715 NONAME
- _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3716 NONAME
- _ZNK11QMetaMethod8revisionEv @ 3717 NONAME
- _ZNK13QMetaProperty8revisionEv @ 3718 NONAME
+ _ZN11QThreadPool11waitForDoneEi @ 3716 NONAME
+ _ZN13QSharedMemory12setNativeKeyERK7QString @ 3717 NONAME
+ _ZN13QUnifiedTimer10timerEventEP11QTimerEvent @ 3718 NONAME
+ _ZN13QUnifiedTimer17ensureTimerUpdateEv @ 3719 NONAME
+ _ZN13QUnifiedTimer17registerAnimationEP18QAbstractAnimationb @ 3720 NONAME
+ _ZN13QUnifiedTimer17setTimingIntervalEi @ 3721 NONAME
+ _ZN13QUnifiedTimer19unregisterAnimationEP18QAbstractAnimation @ 3722 NONAME
+ _ZN13QUnifiedTimer20updateAnimationTimerEv @ 3723 NONAME
+ _ZN13QUnifiedTimer20updateAnimationsTimeEv @ 3724 NONAME
+ _ZN13QUnifiedTimer21restartAnimationTimerEv @ 3725 NONAME
+ _ZN13QUnifiedTimer22installAnimationDriverEP16QAnimationDriver @ 3726 NONAME
+ _ZN13QUnifiedTimer24registerRunningAnimationEP18QAbstractAnimation @ 3727 NONAME
+ _ZN13QUnifiedTimer26unregisterRunningAnimationEP18QAbstractAnimation @ 3728 NONAME
+ _ZN13QUnifiedTimer33closestPauseAnimationTimeToFinishEv @ 3729 NONAME
+ _ZN13QUnifiedTimer8instanceEb @ 3730 NONAME
+ _ZN13QUnifiedTimerC1Ev @ 3731 NONAME
+ _ZN13QUnifiedTimerC2Ev @ 3732 NONAME
+ _ZN16QAnimationDriver11qt_metacallEN11QMetaObject4CallEiPPv @ 3733 NONAME
+ _ZN16QAnimationDriver11qt_metacastEPKc @ 3734 NONAME
+ _ZN16QAnimationDriver16staticMetaObjectE @ 3735 NONAME DATA 16
+ _ZN16QAnimationDriver19getStaticMetaObjectEv @ 3736 NONAME
+ _ZN16QAnimationDriver4stopEv @ 3737 NONAME
+ _ZN16QAnimationDriver5startEv @ 3738 NONAME
+ _ZN16QAnimationDriver7advanceEv @ 3739 NONAME
+ _ZN16QAnimationDriver7installEv @ 3740 NONAME
+ _ZN16QAnimationDriverC2EP7QObject @ 3741 NONAME
+ _ZN16QAnimationDriverC2ER23QAnimationDriverPrivateP7QObject @ 3742 NONAME
+ _ZN16QCoreApplicationC1ERiPPci @ 3743 NONAME
+ _ZN16QCoreApplicationC2ERiPPci @ 3744 NONAME
+ _ZN23QCoreApplicationPrivate19app_compile_versionE @ 3745 NONAME DATA 4
+ _ZN23QCoreApplicationPrivateC1ERiPPcj @ 3746 NONAME
+ _ZN23QCoreApplicationPrivateC2ERiPPcj @ 3747 NONAME
+ _ZN6QMutex12lockInternalEv @ 3748 NONAME
+ _ZN6QMutex14unlockInternalEv @ 3749 NONAME
+ _ZN7QObject10disconnectEPKS_RK11QMetaMethodS1_S4_ @ 3750 NONAME
+ _ZN7QObject7connectEPKS_RK11QMetaMethodS1_S4_N2Qt14ConnectionTypeE @ 3751 NONAME
+ _ZNK10QStringRef10startsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3752 NONAME
+ _ZNK10QStringRef10startsWithE5QCharN2Qt15CaseSensitivityE @ 3753 NONAME
+ _ZNK10QStringRef10startsWithERK7QStringN2Qt15CaseSensitivityE @ 3754 NONAME
+ _ZNK10QStringRef10startsWithERKS_N2Qt15CaseSensitivityE @ 3755 NONAME
+ _ZNK10QStringRef11lastIndexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3756 NONAME
+ _ZNK10QStringRef11lastIndexOfE5QChariN2Qt15CaseSensitivityE @ 3757 NONAME
+ _ZNK10QStringRef11lastIndexOfERK7QStringiN2Qt15CaseSensitivityE @ 3758 NONAME
+ _ZNK10QStringRef11lastIndexOfERKS_iN2Qt15CaseSensitivityE @ 3759 NONAME
+ _ZNK10QStringRef11toLocal8BitEv @ 3760 NONAME
+ _ZNK10QStringRef5countE5QCharN2Qt15CaseSensitivityE @ 3761 NONAME
+ _ZNK10QStringRef5countERK7QStringN2Qt15CaseSensitivityE @ 3762 NONAME
+ _ZNK10QStringRef5countERKS_N2Qt15CaseSensitivityE @ 3763 NONAME
+ _ZNK10QStringRef6toUcs4Ev @ 3764 NONAME
+ _ZNK10QStringRef6toUtf8Ev @ 3765 NONAME
+ _ZNK10QStringRef7indexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3766 NONAME
+ _ZNK10QStringRef7indexOfE5QChariN2Qt15CaseSensitivityE @ 3767 NONAME
+ _ZNK10QStringRef7indexOfERK7QStringiN2Qt15CaseSensitivityE @ 3768 NONAME
+ _ZNK10QStringRef7indexOfERKS_iN2Qt15CaseSensitivityE @ 3769 NONAME
+ _ZNK10QStringRef7toAsciiEv @ 3770 NONAME
+ _ZNK10QStringRef8endsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3771 NONAME
+ _ZNK10QStringRef8endsWithE5QCharN2Qt15CaseSensitivityE @ 3772 NONAME
+ _ZNK10QStringRef8endsWithERK7QStringN2Qt15CaseSensitivityE @ 3773 NONAME
+ _ZNK10QStringRef8endsWithERKS_N2Qt15CaseSensitivityE @ 3774 NONAME
+ _ZNK10QStringRef8toLatin1Ev @ 3775 NONAME
+ _ZNK11QMetaObject4castEPK7QObject @ 3776 NONAME
+ _ZNK13QSharedMemory9nativeKeyEv @ 3777 NONAME
+ _ZNK16QAnimationDriver10metaObjectEv @ 3778 NONAME
+ _ZNK16QAnimationDriver9isRunningEv @ 3779 NONAME
+ _ZNK4QUrl11isLocalFileEv @ 3780 NONAME
+ _ZNK7QObject17senderSignalIndexEv @ 3781 NONAME
+ _ZNK7QString10startsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3782 NONAME
+ _ZNK7QString11lastIndexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3783 NONAME
+ _ZNK7QString5countERK10QStringRefN2Qt15CaseSensitivityE @ 3784 NONAME
+ _ZNK7QString7indexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3785 NONAME
+ _ZNK7QString8endsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3786 NONAME
+ _ZTI13QUnifiedTimer @ 3787 NONAME
+ _ZTI16QAnimationDriver @ 3788 NONAME
+ _ZTI23QAnimationDriverPrivate @ 3789 NONAME
+ _ZTV13QUnifiedTimer @ 3790 NONAME
+ _ZTV16QAnimationDriver @ 3791 NONAME
+ _ZTV23QAnimationDriverPrivate @ 3792 NONAME
+ _ZN12QSystemError8toStringEv @ 3793 NONAME
+ _ZN5QChar21currentUnicodeVersionEv @ 3794 NONAME
+ _ZN9QFileInfoC1EP16QFileInfoPrivate @ 3795 NONAME
+ _ZN9QFileInfoC2EP16QFileInfoPrivate @ 3796 NONAME
+ _ZN13QFSFileEngine4openE6QFlagsIN9QIODevice12OpenModeFlagEEP7__sFILES0_IN5QFile14FileHandleFlagEE @ 3797 NONAME
+ _ZN13QFSFileEngine4openE6QFlagsIN9QIODevice12OpenModeFlagEERK5RFileS0_IN5QFile14FileHandleFlagEE @ 3798 NONAME
+ _ZN13QFSFileEngine4openE6QFlagsIN9QIODevice12OpenModeFlagEEiS0_IN5QFile14FileHandleFlagEE @ 3799 NONAME
+ _ZN5QFile4openEP7__sFILE6QFlagsIN9QIODevice12OpenModeFlagEES2_INS_14FileHandleFlagEE @ 3800 NONAME
+ _ZN5QFile4openERK5RFile6QFlagsIN9QIODevice12OpenModeFlagEES3_INS_14FileHandleFlagEE @ 3801 NONAME
+ _ZN5QFile4openEi6QFlagsIN9QIODevice12OpenModeFlagEES0_INS_14FileHandleFlagEE @ 3802 NONAME
+ _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3803 NONAME
+ _ZNK16QXmlStreamWriter8hasErrorEv @ 3804 NONAME
+ _ZNK13QElapsedTimer12nsecsElapsedEv @ 3805 NONAME
+ _ZNK11QMetaMethod8revisionEv @ 3806 NONAME
+ _ZNK13QMetaProperty8revisionEv @ 3807 NONAME
+ _ZN16QAnimationDriverC1EP7QObject @ 3808 NONAME
+ _ZN16QAnimationDriverC1ER23QAnimationDriverPrivateP7QObject @ 3809 NONAME
+ _ZN31QNonContiguousByteDeviceFactory6createE14QSharedPointerI11QRingBufferE @ 3810 NONAME
diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def
index b6a24ab..fc256e4 100644
--- a/src/s60installs/eabi/QtGuiu.def
+++ b/src/s60installs/eabi/QtGuiu.def
@@ -711,7 +711,7 @@ EXPORTS
_ZN11QFontEngine17getGlyphPositionsERK12QGlyphLayoutRK10QTransform6QFlagsIN9QTextItem10RenderFlagEER15QVarLengthArrayIjLi256EERSA_I11QFixedPointLi256EE @ 710 NONAME
_ZN11QFontEngine17getPointInOutlineEjijPiS0_Pj @ 711 NONAME
_ZN11QFontEngine19addBitmapFontToPathEffRK12QGlyphLayoutP12QPainterPath6QFlagsIN9QTextItem10RenderFlagEE @ 712 NONAME
- _ZN11QFontEngine19alphaRGBMapForGlyphEjiRK10QTransform @ 713 NONAME
+ _ZN11QFontEngine19alphaRGBMapForGlyphEjiRK10QTransform @ 713 NONAME ABSENT
_ZN11QFontEngine20removeGlyphFromCacheEj @ 714 NONAME
_ZN11QFontEngine21getTrueTypeGlyphIndexEPKhj @ 715 NONAME
_ZN11QFontEngine7getCMapEPKhjPbPi @ 716 NONAME
@@ -3164,11 +3164,11 @@ EXPORTS
_ZN14QWindowSurface10beginPaintERK7QRegion @ 3163 NONAME
_ZN14QWindowSurface11setGeometryERK5QRect @ 3164 NONAME
_ZN14QWindowSurface17setStaticContentsERK7QRegion @ 3165 NONAME
- _ZN14QWindowSurface24setStaticContentsSupportEb @ 3166 NONAME
+ _ZN14QWindowSurface24setStaticContentsSupportEb @ 3166 NONAME ABSENT
_ZN14QWindowSurface6bufferEPK7QWidget @ 3167 NONAME
_ZN14QWindowSurface6scrollERK7QRegionii @ 3168 NONAME
_ZN14QWindowSurface8endPaintERK7QRegion @ 3169 NONAME
- _ZN14QWindowSurfaceC2EP7QWidget @ 3170 NONAME
+ _ZN14QWindowSurfaceC2EP7QWidget @ 3170 NONAME ABSENT
_ZN14QWindowSurfaceD0Ev @ 3171 NONAME
_ZN14QWindowSurfaceD1Ev @ 3172 NONAME
_ZN14QWindowSurfaceD2Ev @ 3173 NONAME
@@ -4324,7 +4324,7 @@ EXPORTS
_ZN19QApplicationPrivate18dispatchEnterLeaveEP7QWidgetS1_ @ 4323 NONAME
_ZN19QApplicationPrivate18resolveS60ScanCodeEij @ 4324 NONAME
_ZN19QApplicationPrivate18wheel_scroll_linesE @ 4325 NONAME DATA 4
- _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4
+ _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4 ABSENT
_ZN19QApplicationPrivate19hidden_focus_widgetE @ 4327 NONAME DATA 4
_ZN19QApplicationPrivate19keyboard_input_timeE @ 4328 NONAME DATA 4
_ZN19QApplicationPrivate20emitLastWindowClosedEv @ 4329 NONAME
@@ -4356,8 +4356,8 @@ EXPORTS
_ZN19QApplicationPrivate9constructEv @ 4355 NONAME
_ZN19QApplicationPrivate9fade_menuE @ 4356 NONAME DATA 1
_ZN19QApplicationPrivate9openPopupEP7QWidget @ 4357 NONAME
- _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME
- _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME
+ _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME ABSENT
+ _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME ABSENT
_ZN19QApplicationPrivateD0Ev @ 4360 NONAME
_ZN19QApplicationPrivateD1Ev @ 4361 NONAME
_ZN19QApplicationPrivateD2Ev @ 4362 NONAME
@@ -4768,8 +4768,8 @@ EXPORTS
_ZN20QRasterWindowSurface13prepareBufferEN6QImage6FormatEP7QWidget @ 4767 NONAME
_ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint @ 4768 NONAME
_ZN20QRasterWindowSurface6scrollERK7QRegionii @ 4769 NONAME
- _ZN20QRasterWindowSurfaceC1EP7QWidget @ 4770 NONAME
- _ZN20QRasterWindowSurfaceC2EP7QWidget @ 4771 NONAME
+ _ZN20QRasterWindowSurfaceC1EP7QWidget @ 4770 NONAME ABSENT
+ _ZN20QRasterWindowSurfaceC2EP7QWidget @ 4771 NONAME ABSENT
_ZN20QRasterWindowSurfaceD0Ev @ 4772 NONAME
_ZN20QRasterWindowSurfaceD1Ev @ 4773 NONAME
_ZN20QRasterWindowSurfaceD2Ev @ 4774 NONAME
@@ -9242,7 +9242,7 @@ EXPORTS
_ZNK18QSyntaxHighlighter20currentBlockUserDataEv @ 9241 NONAME
_ZNK18QSyntaxHighlighter6formatEi @ 9242 NONAME
_ZNK18QSyntaxHighlighter8documentEv @ 9243 NONAME
- _ZNK18QTextureGlyphCache18textureMapForGlyphEj @ 9244 NONAME
+ _ZNK18QTextureGlyphCache18textureMapForGlyphEj @ 9244 NONAME ABSENT
_ZNK19QAbstractProxyModel10headerDataEiN2Qt11OrientationEi @ 9245 NONAME
_ZNK19QAbstractProxyModel10metaObjectEv @ 9246 NONAME
_ZNK19QAbstractProxyModel11sourceModelEv @ 9247 NONAME
@@ -11887,7 +11887,7 @@ EXPORTS
_ZN14QGraphicsScale13zScaleChangedEv @ 11886 NONAME
_ZN14QPaintEngineEx19drawPixmapFragmentsEPKN8QPainter14PixmapFragmentEiRK7QPixmap6QFlagsINS0_18PixmapFragmentHintEE @ 11887 NONAME
_ZN14QWidgetPrivate6renderEP12QPaintDeviceRK6QPointRK7QRegion6QFlagsIN7QWidget10RenderFlagEEb @ 11888 NONAME
- _ZN14QWindowSurface23setPartialUpdateSupportEb @ 11889 NONAME
+ _ZN14QWindowSurface23setPartialUpdateSupportEb @ 11889 NONAME ABSENT
_ZN15QGraphicsObject12widthChangedEv @ 11890 NONAME
_ZN15QGraphicsObject13heightChangedEv @ 11891 NONAME
_ZN15QGraphicsObject15childrenChangedEv @ 11892 NONAME
@@ -11961,7 +11961,7 @@ EXPORTS
_ZN20QGraphicsViewPrivate28updateInputMethodSensitivityEv @ 11960 NONAME
_ZN20QGraphicsViewPrivateC1Ev @ 11961 NONAME
_ZN20QGraphicsViewPrivateC2Ev @ 11962 NONAME
- _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 11963 NONAME
+ _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 11963 NONAME ABSENT
_ZN23QImageTextureGlyphCache17createTextureDataEii @ 11964 NONAME
_ZN23QImageTextureGlyphCache17resizeTextureDataEii @ 11965 NONAME
_ZN26QAbstractScrollAreaPrivate14layoutChildrenEv @ 11966 NONAME
@@ -12109,40 +12109,40 @@ EXPORTS
_ZN20QGraphicsItemPrivate13clearSubFocusEP13QGraphicsItemS1_ @ 12108 NONAME
_ZN12QLineControl21resetCursorBlinkTimerEv @ 12109 NONAME
_ZN12QTextControl14setDragEnabledEb @ 12110 NONAME
- _ZN19QTextDocumentLayout10timerEventEP11QTimerEvent @ 12111 NONAME
- _ZN19QTextDocumentLayout11qt_metacallEN11QMetaObject4CallEiPPv @ 12112 NONAME
- _ZN19QTextDocumentLayout11qt_metacastEPKc @ 12113 NONAME
- _ZN19QTextDocumentLayout11setViewportERK6QRectF @ 12114 NONAME
- _ZN19QTextDocumentLayout13setLineHeightEfNS_14LineHeightModeE @ 12115 NONAME
- _ZN19QTextDocumentLayout14ensureLayoutedEf @ 12116 NONAME
- _ZN19QTextDocumentLayout14layoutFinishedEv @ 12117 NONAME
- _ZN19QTextDocumentLayout14setCursorWidthEi @ 12118 NONAME
- _ZN19QTextDocumentLayout15documentChangedEiii @ 12119 NONAME
- _ZN19QTextDocumentLayout16drawInlineObjectEP8QPainterRK6QRectF17QTextInlineObjectiRK11QTextFormat @ 12120 NONAME
- _ZN19QTextDocumentLayout16staticMetaObjectE @ 12121 NONAME DATA 16
- _ZN19QTextDocumentLayout18resizeInlineObjectE17QTextInlineObjectiRK11QTextFormat @ 12122 NONAME
- _ZN19QTextDocumentLayout19getStaticMetaObjectEv @ 12123 NONAME
- _ZN19QTextDocumentLayout19setFixedColumnWidthEi @ 12124 NONAME
- _ZN19QTextDocumentLayout20positionInlineObjectE17QTextInlineObjectiRK11QTextFormat @ 12125 NONAME
- _ZN19QTextDocumentLayout4drawEP8QPainterRKN27QAbstractTextDocumentLayout12PaintContextE @ 12126 NONAME
- _ZN19QTextDocumentLayout8doLayoutEiii @ 12127 NONAME
- _ZN19QTextDocumentLayoutC1EP13QTextDocument @ 12128 NONAME
- _ZN19QTextDocumentLayoutC2EP13QTextDocument @ 12129 NONAME
+ _ZN19QTextDocumentLayout10timerEventEP11QTimerEvent @ 12111 NONAME ABSENT
+ _ZN19QTextDocumentLayout11qt_metacallEN11QMetaObject4CallEiPPv @ 12112 NONAME ABSENT
+ _ZN19QTextDocumentLayout11qt_metacastEPKc @ 12113 NONAME ABSENT
+ _ZN19QTextDocumentLayout11setViewportERK6QRectF @ 12114 NONAME ABSENT
+ _ZN19QTextDocumentLayout13setLineHeightEfNS_14LineHeightModeE @ 12115 NONAME ABSENT
+ _ZN19QTextDocumentLayout14ensureLayoutedEf @ 12116 NONAME ABSENT
+ _ZN19QTextDocumentLayout14layoutFinishedEv @ 12117 NONAME ABSENT
+ _ZN19QTextDocumentLayout14setCursorWidthEi @ 12118 NONAME ABSENT
+ _ZN19QTextDocumentLayout15documentChangedEiii @ 12119 NONAME ABSENT
+ _ZN19QTextDocumentLayout16drawInlineObjectEP8QPainterRK6QRectF17QTextInlineObjectiRK11QTextFormat @ 12120 NONAME ABSENT
+ _ZN19QTextDocumentLayout16staticMetaObjectE @ 12121 NONAME DATA 16 ABSENT
+ _ZN19QTextDocumentLayout18resizeInlineObjectE17QTextInlineObjectiRK11QTextFormat @ 12122 NONAME ABSENT
+ _ZN19QTextDocumentLayout19getStaticMetaObjectEv @ 12123 NONAME ABSENT
+ _ZN19QTextDocumentLayout19setFixedColumnWidthEi @ 12124 NONAME ABSENT
+ _ZN19QTextDocumentLayout20positionInlineObjectE17QTextInlineObjectiRK11QTextFormat @ 12125 NONAME ABSENT
+ _ZN19QTextDocumentLayout4drawEP8QPainterRKN27QAbstractTextDocumentLayout12PaintContextE @ 12126 NONAME ABSENT
+ _ZN19QTextDocumentLayout8doLayoutEiii @ 12127 NONAME ABSENT
+ _ZN19QTextDocumentLayoutC1EP13QTextDocument @ 12128 NONAME ABSENT
+ _ZN19QTextDocumentLayoutC2EP13QTextDocument @ 12129 NONAME ABSENT
_ZNK12QTextControl13isDragEnabledEv @ 12130 NONAME
- _ZNK19QTextDocumentLayout10idealWidthEv @ 12131 NONAME
- _ZNK19QTextDocumentLayout10metaObjectEv @ 12132 NONAME
- _ZNK19QTextDocumentLayout11cursorWidthEv @ 12133 NONAME
- _ZNK19QTextDocumentLayout12documentSizeEv @ 12134 NONAME
- _ZNK19QTextDocumentLayout12layoutStatusEv @ 12135 NONAME
- _ZNK19QTextDocumentLayout16dynamicPageCountEv @ 12136 NONAME
- _ZNK19QTextDocumentLayout17blockBoundingRectERK10QTextBlock @ 12137 NONAME
- _ZNK19QTextDocumentLayout17frameBoundingRectEP10QTextFrame @ 12138 NONAME
- _ZNK19QTextDocumentLayout19contentHasAlignmentEv @ 12139 NONAME
- _ZNK19QTextDocumentLayout19dynamicDocumentSizeEv @ 12140 NONAME
- _ZNK19QTextDocumentLayout7hitTestERK7QPointFN2Qt15HitTestAccuracyE @ 12141 NONAME
- _ZNK19QTextDocumentLayout9pageCountEv @ 12142 NONAME
- _ZTI19QTextDocumentLayout @ 12143 NONAME
- _ZTV19QTextDocumentLayout @ 12144 NONAME
+ _ZNK19QTextDocumentLayout10idealWidthEv @ 12131 NONAME ABSENT
+ _ZNK19QTextDocumentLayout10metaObjectEv @ 12132 NONAME ABSENT
+ _ZNK19QTextDocumentLayout11cursorWidthEv @ 12133 NONAME ABSENT
+ _ZNK19QTextDocumentLayout12documentSizeEv @ 12134 NONAME ABSENT
+ _ZNK19QTextDocumentLayout12layoutStatusEv @ 12135 NONAME ABSENT
+ _ZNK19QTextDocumentLayout16dynamicPageCountEv @ 12136 NONAME ABSENT
+ _ZNK19QTextDocumentLayout17blockBoundingRectERK10QTextBlock @ 12137 NONAME ABSENT
+ _ZNK19QTextDocumentLayout17frameBoundingRectEP10QTextFrame @ 12138 NONAME ABSENT
+ _ZNK19QTextDocumentLayout19contentHasAlignmentEv @ 12139 NONAME ABSENT
+ _ZNK19QTextDocumentLayout19dynamicDocumentSizeEv @ 12140 NONAME ABSENT
+ _ZNK19QTextDocumentLayout7hitTestERK7QPointFN2Qt15HitTestAccuracyE @ 12141 NONAME ABSENT
+ _ZNK19QTextDocumentLayout9pageCountEv @ 12142 NONAME ABSENT
+ _ZTI19QTextDocumentLayout @ 12143 NONAME ABSENT
+ _ZTV19QTextDocumentLayout @ 12144 NONAME ABSENT
_ZN12QTextControl23setWordSelectionEnabledEb @ 12145 NONAME
_ZNK12QTextControl22isWordSelectionEnabledEv @ 12146 NONAME
_ZN12QLineControl16updateMicroFocusEv @ 12147 NONAME
@@ -12182,4 +12182,255 @@ EXPORTS
_ZNK14QVolatileImage9constBitsEv @ 12181 NONAME
_ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME
_Z32qt_s60_setPartialScreenInputModeb @ 12183 NONAME
+ _Z18qt_addBitmapToPathffPKhiiiP12QPainterPath @ 12184 NONAME
+ _Z22qt_fontdata_from_indexi @ 12185 NONAME
+ _Z32qGamma_correct_back_to_linear_csP6QImage @ 12186 NONAME
+ _ZN10QBlittable4lockEv @ 12187 NONAME
+ _ZN10QBlittable6unlockEv @ 12188 NONAME
+ _ZN10QBlittableC2ERK5QSize6QFlagsINS_10CapabilityEE @ 12189 NONAME
+ _ZN10QBlittableD0Ev @ 12190 NONAME
+ _ZN10QBlittableD1Ev @ 12191 NONAME
+ _ZN10QBlittableD2Ev @ 12192 NONAME
+ _ZN11QFontEngine16alphaMapForGlyphEj6QFixed @ 12193 NONAME
+ _ZN11QFontEngine16alphaMapForGlyphEj6QFixedRK10QTransform @ 12194 NONAME
+ _ZN11QFontEngine19alphaRGBMapForGlyphEj6QFixediRK10QTransform @ 12195 NONAME
+ _ZN12QInputDialog7getItemEP7QWidgetRK7QStringS4_RK11QStringListibPb6QFlagsIN2Qt10WindowTypeEES9_INSA_15InputMethodHintEE @ 12196 NONAME
+ _ZN12QInputDialog7getTextEP7QWidgetRK7QStringS4_N9QLineEdit8EchoModeES4_Pb6QFlagsIN2Qt10WindowTypeEES8_INS9_15InputMethodHintEE @ 12197 NONAME
+ _ZN12QScrollEvent6d_funcEv @ 12198 NONAME
+ _ZN12QScrollEventC1ERK7QPointFS2_NS_11ScrollStateE @ 12199 NONAME
+ _ZN12QScrollEventC2ERK7QPointFS2_NS_11ScrollStateE @ 12200 NONAME
+ _ZN12QScrollEventD0Ev @ 12201 NONAME
+ _ZN12QScrollEventD1Ev @ 12202 NONAME
+ _ZN12QScrollEventD2Ev @ 12203 NONAME
+ _ZN13QFlickGesture11qt_metacallEN11QMetaObject4CallEiPPv @ 12204 NONAME
+ _ZN13QFlickGesture11qt_metacastEPKc @ 12205 NONAME
+ _ZN13QFlickGesture16staticMetaObjectE @ 12206 NONAME DATA 16
+ _ZN13QFlickGesture19getStaticMetaObjectEv @ 12207 NONAME
+ _ZN13QFlickGestureC1EP7QObjectN2Qt11MouseButtonES1_ @ 12208 NONAME
+ _ZN13QFlickGestureC2EP7QObjectN2Qt11MouseButtonES1_ @ 12209 NONAME
+ _ZN13QFlickGestureD0Ev @ 12210 NONAME
+ _ZN13QFlickGestureD1Ev @ 12211 NONAME
+ _ZN13QFlickGestureD2Ev @ 12212 NONAME
+ _ZN13QFontDatabase22resolveFontFamilyAliasERK7QString @ 12213 NONAME
+ _ZN13QS60MainAppUi25ProcessCommandParametersLE11TApaCommandR4TBufILi256EERK6TDesC8 @ 12214 NONAME
+ _ZN14QFileOpenEventC1ERK5RFile @ 12215 NONAME
+ _ZN14QFileOpenEventC2ERK5RFile @ 12216 NONAME
+ _ZN14QWindowSurfaceC2EP7QWidgetb @ 12217 NONAME
+ _ZN17QInternalMimeData11canReadDataERK7QString @ 12218 NONAME
+ _ZN17QInternalMimeData11qt_metacallEN11QMetaObject4CallEiPPv @ 12219 NONAME
+ _ZN17QInternalMimeData11qt_metacastEPKc @ 12220 NONAME
+ _ZN17QInternalMimeData13formatsHelperEPK9QMimeData @ 12221 NONAME
+ _ZN17QInternalMimeData15hasFormatHelperERK7QStringPK9QMimeData @ 12222 NONAME
+ _ZN17QInternalMimeData16renderDataHelperERK7QStringPK9QMimeData @ 12223 NONAME
+ _ZN17QInternalMimeData16staticMetaObjectE @ 12224 NONAME DATA 16
+ _ZN17QInternalMimeData19getStaticMetaObjectEv @ 12225 NONAME
+ _ZN17QInternalMimeDataC2Ev @ 12226 NONAME
+ _ZN17QInternalMimeDataD0Ev @ 12227 NONAME
+ _ZN17QInternalMimeDataD1Ev @ 12228 NONAME
+ _ZN17QInternalMimeDataD2Ev @ 12229 NONAME
+ _ZN18QTextureGlyphCache19fillInPendingGlyphsEv @ 12230 NONAME
+ _ZN19QAbstractProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 12231 NONAME
+ _ZN19QAbstractProxyModel17resetInternalDataEv @ 12232 NONAME
+ _ZN19QAbstractProxyModel4sortEiN2Qt9SortOrderE @ 12233 NONAME
+ _ZN19QAbstractProxyModel9fetchMoreERK11QModelIndex @ 12234 NONAME
+ _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeEi @ 12235 NONAME
+ _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeEi @ 12236 NONAME
+ _ZN19QBlitterPaintEngine10drawPixmapERK6QRectFRK7QPixmapS2_ @ 12237 NONAME
+ _ZN19QBlitterPaintEngine10penChangedEv @ 12238 NONAME
+ _ZN19QBlitterPaintEngine11drawEllipseERK6QRectF @ 12239 NONAME
+ _ZN19QBlitterPaintEngine12brushChangedEv @ 12240 NONAME
+ _ZN19QBlitterPaintEngine12drawTextItemERK7QPointFRK9QTextItem @ 12241 NONAME
+ _ZN19QBlitterPaintEngine14opacityChangedEv @ 12242 NONAME
+ _ZN19QBlitterPaintEngine16transformChangedEv @ 12243 NONAME
+ _ZN19QBlitterPaintEngine18brushOriginChangedEv @ 12244 NONAME
+ _ZN19QBlitterPaintEngine18clipEnabledChangedEv @ 12245 NONAME
+ _ZN19QBlitterPaintEngine18drawStaticTextItemEP15QStaticTextItem @ 12246 NONAME
+ _ZN19QBlitterPaintEngine18renderHintsChangedEv @ 12247 NONAME
+ _ZN19QBlitterPaintEngine22compositionModeChangedEv @ 12248 NONAME
+ _ZN19QBlitterPaintEngine3endEv @ 12249 NONAME
+ _ZN19QBlitterPaintEngine4clipERK11QVectorPathN2Qt13ClipOperationE @ 12250 NONAME
+ _ZN19QBlitterPaintEngine4clipERK5QRectN2Qt13ClipOperationE @ 12251 NONAME
+ _ZN19QBlitterPaintEngine4clipERK7QRegionN2Qt13ClipOperationE @ 12252 NONAME
+ _ZN19QBlitterPaintEngine4fillERK11QVectorPathRK6QBrush @ 12253 NONAME
+ _ZN19QBlitterPaintEngine5beginEP12QPaintDevice @ 12254 NONAME
+ _ZN19QBlitterPaintEngine6strokeERK11QVectorPathRK4QPen @ 12255 NONAME
+ _ZN19QBlitterPaintEngine8fillRectERK6QRectFRK6QBrush @ 12256 NONAME
+ _ZN19QBlitterPaintEngine8fillRectERK6QRectFRK6QColor @ 12257 NONAME
+ _ZN19QBlitterPaintEngine8setStateEP13QPainterState @ 12258 NONAME
+ _ZN19QBlitterPaintEngine9drawImageERK6QRectFRK6QImageS2_6QFlagsIN2Qt19ImageConversionFlagEE @ 12259 NONAME
+ _ZN19QBlitterPaintEngine9drawRectsEPK5QRecti @ 12260 NONAME
+ _ZN19QBlitterPaintEngine9drawRectsEPK6QRectFi @ 12261 NONAME
+ _ZN19QBlitterPaintEngineC1EP20QBlittablePixmapData @ 12262 NONAME
+ _ZN19QBlitterPaintEngineC2EP20QBlittablePixmapData @ 12263 NONAME
+ _ZN19QBlitterPaintEngineD0Ev @ 12264 NONAME
+ _ZN19QBlitterPaintEngineD1Ev @ 12265 NONAME
+ _ZN19QBlitterPaintEngineD2Ev @ 12266 NONAME
+ _ZN19QGraphicsGridLayout10removeItemEP19QGraphicsLayoutItem @ 12267 NONAME
+ _ZN19QScrollPrepareEvent13setContentPosERK7QPointF @ 12268 NONAME
+ _ZN19QScrollPrepareEvent15setViewportSizeERK6QSizeF @ 12269 NONAME
+ _ZN19QScrollPrepareEvent18setContentPosRangeERK6QRectF @ 12270 NONAME
+ _ZN19QScrollPrepareEvent6d_funcEv @ 12271 NONAME
+ _ZN19QScrollPrepareEventC1ERK7QPointF @ 12272 NONAME
+ _ZN19QScrollPrepareEventC2ERK7QPointF @ 12273 NONAME
+ _ZN19QScrollPrepareEventD0Ev @ 12274 NONAME
+ _ZN19QScrollPrepareEventD1Ev @ 12275 NONAME
+ _ZN19QScrollPrepareEventD2Ev @ 12276 NONAME
+ _ZN19QScrollerProperties15setScrollMetricENS_12ScrollMetricERK8QVariant @ 12277 NONAME
+ _ZN19QScrollerProperties28setDefaultScrollerPropertiesERKS_ @ 12278 NONAME
+ _ZN19QScrollerProperties30unsetDefaultScrollerPropertiesEv @ 12279 NONAME
+ _ZN19QScrollerPropertiesC1ERKS_ @ 12280 NONAME
+ _ZN19QScrollerPropertiesC1Ev @ 12281 NONAME
+ _ZN19QScrollerPropertiesC2ERKS_ @ 12282 NONAME
+ _ZN19QScrollerPropertiesC2Ev @ 12283 NONAME
+ _ZN19QScrollerPropertiesD0Ev @ 12284 NONAME
+ _ZN19QScrollerPropertiesD1Ev @ 12285 NONAME
+ _ZN19QScrollerPropertiesD2Ev @ 12286 NONAME
+ _ZN19QScrollerPropertiesaSERKS_ @ 12287 NONAME
+ _ZN20QBlittablePixmapData12setBlittableEP10QBlittable @ 12288 NONAME
+ _ZN20QBlittablePixmapData4fillERK6QColor @ 12289 NONAME
+ _ZN20QBlittablePixmapData6bufferEv @ 12290 NONAME
+ _ZN20QBlittablePixmapData6resizeEii @ 12291 NONAME
+ _ZN20QBlittablePixmapData9fromImageERK6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 12292 NONAME
+ _ZN20QBlittablePixmapDataC2Ev @ 12293 NONAME
+ _ZN20QBlittablePixmapDataD0Ev @ 12294 NONAME
+ _ZN20QBlittablePixmapDataD1Ev @ 12295 NONAME
+ _ZN20QBlittablePixmapDataD2Ev @ 12296 NONAME
+ _ZN20QRasterWindowSurfaceC1EP7QWidgetb @ 12297 NONAME
+ _ZN20QRasterWindowSurfaceC2EP7QWidgetb @ 12298 NONAME
+ _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj6QFixed @ 12299 NONAME
+ _ZN26QAbstractScrollAreaPrivate19canStartScrollingAtERK6QPoint @ 12300 NONAME
+ _ZN5QFont20setHintingPreferenceENS_17HintingPreferenceE @ 12301 NONAME
+ _ZN6QImage4fillEN2Qt11GlobalColorE @ 12302 NONAME
+ _ZN6QImage4fillERK6QColor @ 12303 NONAME
+ _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12304 NONAME
+ _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12305 NONAME
+ _ZN7QGlyphs5clearEv @ 12306 NONAME
+ _ZN7QGlyphs6detachEv @ 12307 NONAME
+ _ZN7QGlyphs7setFontERK5QFont @ 12308 NONAME
+ _ZN7QGlyphsC1ERKS_ @ 12309 NONAME
+ _ZN7QGlyphsC1Ev @ 12310 NONAME
+ _ZN7QGlyphsC2ERKS_ @ 12311 NONAME
+ _ZN7QGlyphsC2Ev @ 12312 NONAME
+ _ZN7QGlyphsD1Ev @ 12313 NONAME
+ _ZN7QGlyphsD2Ev @ 12314 NONAME
+ _ZN7QGlyphsaSERKS_ @ 12315 NONAME
+ _ZN7QGlyphspLERKS_ @ 12316 NONAME
+ _ZN8QMdiArea14setTabsMovableEb @ 12317 NONAME
+ _ZN8QMdiArea15setTabsClosableEb @ 12318 NONAME
+ _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12319 NONAME
+ _ZN9QScroller11grabGestureEP7QObjectNS_19ScrollerGestureTypeE @ 12320 NONAME
+ _ZN9QScroller11handleInputENS_5InputERK7QPointFx @ 12321 NONAME
+ _ZN9QScroller11hasScrollerEP7QObject @ 12322 NONAME
+ _ZN9QScroller11qt_metacallEN11QMetaObject4CallEiPPv @ 12323 NONAME
+ _ZN9QScroller11qt_metacastEPKc @ 12324 NONAME
+ _ZN9QScroller12stateChangedENS_5StateE @ 12325 NONAME
+ _ZN9QScroller13ensureVisibleERK6QRectFff @ 12326 NONAME
+ _ZN9QScroller13ensureVisibleERK6QRectFffi @ 12327 NONAME
+ _ZN9QScroller13ungrabGestureEP7QObject @ 12328 NONAME
+ _ZN9QScroller14grabbedGestureEP7QObject @ 12329 NONAME
+ _ZN9QScroller15activeScrollersEv @ 12330 NONAME
+ _ZN9QScroller16staticMetaObjectE @ 12331 NONAME DATA 16
+ _ZN9QScroller17setSnapPositionsXERK5QListIfE @ 12332 NONAME
+ _ZN9QScroller17setSnapPositionsXEff @ 12333 NONAME
+ _ZN9QScroller17setSnapPositionsYERK5QListIfE @ 12334 NONAME
+ _ZN9QScroller17setSnapPositionsYEff @ 12335 NONAME
+ _ZN9QScroller18resendPrepareEventEv @ 12336 NONAME
+ _ZN9QScroller19getStaticMetaObjectEv @ 12337 NONAME
+ _ZN9QScroller21setScrollerPropertiesERK19QScrollerProperties @ 12338 NONAME
+ _ZN9QScroller25scrollerPropertiesChangedERK19QScrollerProperties @ 12339 NONAME
+ _ZN9QScroller4stopEv @ 12340 NONAME
+ _ZN9QScroller8scrollToERK7QPointF @ 12341 NONAME
+ _ZN9QScroller8scrollToERK7QPointFi @ 12342 NONAME
+ _ZN9QScroller8scrollerEP7QObject @ 12343 NONAME
+ _ZN9QScroller8scrollerEPK7QObject @ 12344 NONAME
+ _ZN9QScrollerC1EP7QObject @ 12345 NONAME
+ _ZN9QScrollerC2EP7QObject @ 12346 NONAME
+ _ZN9QScrollerD0Ev @ 12347 NONAME
+ _ZN9QScrollerD1Ev @ 12348 NONAME
+ _ZN9QScrollerD2Ev @ 12349 NONAME
+ _ZNK10QBlittable12capabilitiesEv @ 12350 NONAME
+ _ZNK10QBlittable4sizeEv @ 12351 NONAME
+ _ZNK10QTabWidget14heightForWidthEi @ 12352 NONAME
+ _ZNK11QFontEngine18createExplicitFontEv @ 12353 NONAME
+ _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12354 NONAME
+ _ZNK11QTextLayout6glyphsEv @ 12355 NONAME
+ _ZNK12QFontMetrics10inFontUcs4Ej @ 12356 NONAME
+ _ZNK12QRadioButton15minimumSizeHintEv @ 12357 NONAME
+ _ZNK12QScrollEvent10contentPosEv @ 12358 NONAME
+ _ZNK12QScrollEvent11scrollStateEv @ 12359 NONAME
+ _ZNK12QScrollEvent17overshootDistanceEv @ 12360 NONAME
+ _ZNK12QScrollEvent6d_funcEv @ 12361 NONAME
+ _ZNK13QFlickGesture10metaObjectEv @ 12362 NONAME
+ _ZNK13QFontMetricsF10inFontUcs4Ej @ 12363 NONAME
+ _ZNK13QTextFragment6glyphsEv @ 12364 NONAME
+ _ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12365 NONAME
+ _ZNK14QWidgetPrivate17hasHeightForWidthEv @ 12366 NONAME
+ _ZNK16QFileSystemModel5rmdirERK11QModelIndex @ 12367 NONAME
+ _ZNK17QInternalMimeData10metaObjectEv @ 12368 NONAME
+ _ZNK17QInternalMimeData12retrieveDataERK7QStringN8QVariant4TypeE @ 12369 NONAME
+ _ZNK17QInternalMimeData7formatsEv @ 12370 NONAME
+ _ZNK17QInternalMimeData9hasFormatERK7QString @ 12371 NONAME
+ _ZNK18QTextureGlyphCache18textureMapForGlyphEj6QFixed @ 12372 NONAME
+ _ZNK18QTextureGlyphCache20subPixelPositionForXE6QFixed @ 12373 NONAME
+ _ZNK18QTextureGlyphCache30calculateSubPixelPositionCountEj @ 12374 NONAME
+ _ZNK19QAbstractProxyModel11hasChildrenERK11QModelIndex @ 12375 NONAME
+ _ZNK19QAbstractProxyModel12canFetchMoreERK11QModelIndex @ 12376 NONAME
+ _ZNK19QAbstractProxyModel20supportedDropActionsEv @ 12377 NONAME
+ _ZNK19QAbstractProxyModel4spanERK11QModelIndex @ 12378 NONAME
+ _ZNK19QAbstractProxyModel5buddyERK11QModelIndex @ 12379 NONAME
+ _ZNK19QAbstractProxyModel8mimeDataERK5QListI11QModelIndexE @ 12380 NONAME
+ _ZNK19QAbstractProxyModel9mimeTypesEv @ 12381 NONAME
+ _ZNK19QBlitterPaintEngine11createStateEP13QPainterState @ 12382 NONAME
+ _ZNK19QScrollPrepareEvent10contentPosEv @ 12383 NONAME
+ _ZNK19QScrollPrepareEvent12viewportSizeEv @ 12384 NONAME
+ _ZNK19QScrollPrepareEvent15contentPosRangeEv @ 12385 NONAME
+ _ZNK19QScrollPrepareEvent6d_funcEv @ 12386 NONAME
+ _ZNK19QScrollPrepareEvent8startPosEv @ 12387 NONAME
+ _ZNK19QScrollerProperties12scrollMetricENS_12ScrollMetricE @ 12388 NONAME
+ _ZNK19QScrollerPropertieseqERKS_ @ 12389 NONAME
+ _ZNK19QScrollerPropertiesneERKS_ @ 12390 NONAME
+ _ZNK20QBlittablePixmapData11paintEngineEv @ 12391 NONAME
+ _ZNK20QBlittablePixmapData15hasAlphaChannelEv @ 12392 NONAME
+ _ZNK20QBlittablePixmapData6metricEN12QPaintDevice17PaintDeviceMetricE @ 12393 NONAME
+ _ZNK20QBlittablePixmapData7toImageEv @ 12394 NONAME
+ _ZNK20QBlittablePixmapData9blittableEv @ 12395 NONAME
+ _ZNK20QRasterWindowSurface24hasStaticContentsSupportEv @ 12396 NONAME
+ _ZNK5QFont17hintingPreferenceEv @ 12397 NONAME
+ _ZNK7QGlyphs12glyphIndexesEv @ 12398 NONAME
+ _ZNK7QGlyphs4fontEv @ 12399 NONAME
+ _ZNK7QGlyphs9positionsEv @ 12400 NONAME
+ _ZNK7QGlyphseqERKS_ @ 12401 NONAME
+ _ZNK7QGlyphsneERKS_ @ 12402 NONAME
+ _ZNK7QGlyphsplERKS_ @ 12403 NONAME
+ _ZNK8QMdiArea11tabsMovableEv @ 12404 NONAME
+ _ZNK8QMdiArea12tabsClosableEv @ 12405 NONAME
+ _ZNK8QPainter16clipBoundingRectEv @ 12406 NONAME
+ _ZNK9QCheckBox15minimumSizeHintEv @ 12407 NONAME
+ _ZNK9QScroller10metaObjectEv @ 12408 NONAME
+ _ZNK9QScroller13finalPositionEv @ 12409 NONAME
+ _ZNK9QScroller13pixelPerMeterEv @ 12410 NONAME
+ _ZNK9QScroller18scrollerPropertiesEv @ 12411 NONAME
+ _ZNK9QScroller5stateEv @ 12412 NONAME
+ _ZNK9QScroller6targetEv @ 12413 NONAME
+ _ZNK9QScroller8velocityEv @ 12414 NONAME
+ _ZNK9QTextLine6glyphsEii @ 12415 NONAME
+ _ZTI10QBlittable @ 12416 NONAME
+ _ZTI12QScrollEvent @ 12417 NONAME
+ _ZTI13QFlickGesture @ 12418 NONAME
+ _ZTI17QInternalMimeData @ 12419 NONAME
+ _ZTI19QBlitterPaintEngine @ 12420 NONAME
+ _ZTI19QScrollPrepareEvent @ 12421 NONAME
+ _ZTI19QScrollerProperties @ 12422 NONAME
+ _ZTI20QBlittablePixmapData @ 12423 NONAME
+ _ZTI9QScroller @ 12424 NONAME
+ _ZTV10QBlittable @ 12425 NONAME
+ _ZTV12QScrollEvent @ 12426 NONAME
+ _ZTV13QFlickGesture @ 12427 NONAME
+ _ZTV17QInternalMimeData @ 12428 NONAME
+ _ZTV19QBlitterPaintEngine @ 12429 NONAME
+ _ZTV19QScrollPrepareEvent @ 12430 NONAME
+ _ZTV19QScrollerProperties @ 12431 NONAME
+ _ZTV20QBlittablePixmapData @ 12432 NONAME
+ _ZTV9QScroller @ 12433 NONAME
+ _Zls6QDebugPK13QSymbianEvent @ 12434 NONAME
diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def
index f13fab3..658b82d 100644
--- a/src/s60installs/eabi/QtNetworku.def
+++ b/src/s60installs/eabi/QtNetworku.def
@@ -1085,12 +1085,12 @@ EXPORTS
_ZN35QNetworkConfigurationManagerPrivate11pollEnginesEv @ 1084 NONAME
_ZN35QNetworkConfigurationManagerPrivate11qt_metacallEN11QMetaObject4CallEiPPv @ 1085 NONAME
_ZN35QNetworkConfigurationManagerPrivate11qt_metacastEPKc @ 1086 NONAME
- _ZN35QNetworkConfigurationManagerPrivate12capabilitiesEv @ 1087 NONAME
+ _ZN35QNetworkConfigurationManagerPrivate12capabilitiesEv @ 1087 NONAME ABSENT
_ZN35QNetworkConfigurationManagerPrivate12startPollingEv @ 1088 NONAME
_ZN35QNetworkConfigurationManagerPrivate13enablePollingEv @ 1089 NONAME
_ZN35QNetworkConfigurationManagerPrivate14disablePollingEv @ 1090 NONAME
_ZN35QNetworkConfigurationManagerPrivate16staticMetaObjectE @ 1091 NONAME DATA 16
- _ZN35QNetworkConfigurationManagerPrivate17allConfigurationsE6QFlagsIN21QNetworkConfiguration9StateFlagEE @ 1092 NONAME
+ _ZN35QNetworkConfigurationManagerPrivate17allConfigurationsE6QFlagsIN21QNetworkConfiguration9StateFlagEE @ 1092 NONAME ABSENT
_ZN35QNetworkConfigurationManagerPrivate18configurationAddedE28QExplicitlySharedDataPointerI28QNetworkConfigurationPrivateE @ 1093 NONAME
_ZN35QNetworkConfigurationManagerPrivate18configurationAddedERK21QNetworkConfiguration @ 1094 NONAME
_ZN35QNetworkConfigurationManagerPrivate18onlineStateChangedEb @ 1095 NONAME
@@ -1099,14 +1099,14 @@ EXPORTS
_ZN35QNetworkConfigurationManagerPrivate20configurationChangedERK21QNetworkConfiguration @ 1098 NONAME
_ZN35QNetworkConfigurationManagerPrivate20configurationRemovedE28QExplicitlySharedDataPointerI28QNetworkConfigurationPrivateE @ 1099 NONAME
_ZN35QNetworkConfigurationManagerPrivate20configurationRemovedERK21QNetworkConfiguration @ 1100 NONAME
- _ZN35QNetworkConfigurationManagerPrivate20defaultConfigurationEv @ 1101 NONAME
+ _ZN35QNetworkConfigurationManagerPrivate20defaultConfigurationEv @ 1101 NONAME ABSENT
_ZN35QNetworkConfigurationManagerPrivate20updateConfigurationsEv @ 1102 NONAME
- _ZN35QNetworkConfigurationManagerPrivate27configurationFromIdentifierERK7QString @ 1103 NONAME
+ _ZN35QNetworkConfigurationManagerPrivate27configurationFromIdentifierERK7QString @ 1103 NONAME ABSENT
_ZN35QNetworkConfigurationManagerPrivate27configurationUpdateCompleteEv @ 1104 NONAME
_ZN35QNetworkConfigurationManagerPrivate31performAsyncConfigurationUpdateEv @ 1105 NONAME
- _ZN35QNetworkConfigurationManagerPrivate5abortEv @ 1106 NONAME
- _ZN35QNetworkConfigurationManagerPrivate7enginesEv @ 1107 NONAME
- _ZN35QNetworkConfigurationManagerPrivate8isOnlineEv @ 1108 NONAME
+ _ZN35QNetworkConfigurationManagerPrivate5abortEv @ 1106 NONAME ABSENT
+ _ZN35QNetworkConfigurationManagerPrivate7enginesEv @ 1107 NONAME ABSENT
+ _ZN35QNetworkConfigurationManagerPrivate8isOnlineEv @ 1108 NONAME ABSENT
_ZN35QNetworkConfigurationManagerPrivateC1Ev @ 1109 NONAME
_ZN35QNetworkConfigurationManagerPrivateC2Ev @ 1110 NONAME
_ZN35QNetworkConfigurationManagerPrivateD0Ev @ 1111 NONAME
@@ -1168,4 +1168,19 @@ EXPORTS
_ZTV35QNetworkConfigurationManagerPrivate @ 1167 NONAME
_ZThn8_N19QBearerEnginePluginD0Ev @ 1168 NONAME
_ZThn8_N19QBearerEnginePluginD1Ev @ 1169 NONAME
+ _ZN10QUdpSocket18joinMulticastGroupERK12QHostAddress @ 1170 NONAME
+ _ZN10QUdpSocket18joinMulticastGroupERK12QHostAddressRK17QNetworkInterface @ 1171 NONAME
+ _ZN10QUdpSocket19leaveMulticastGroupERK12QHostAddress @ 1172 NONAME
+ _ZN10QUdpSocket19leaveMulticastGroupERK12QHostAddressRK17QNetworkInterface @ 1173 NONAME
+ _ZN10QUdpSocket21setMulticastInterfaceERK17QNetworkInterface @ 1174 NONAME
+ _ZN13QNetworkReply11setFinishedEb @ 1175 NONAME
+ _ZNK10QUdpSocket18multicastInterfaceEv @ 1176 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate12capabilitiesEv @ 1177 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate17allConfigurationsE6QFlagsIN21QNetworkConfiguration9StateFlagEE @ 1178 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate20defaultConfigurationEv @ 1179 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate27configurationFromIdentifierERK7QString @ 1180 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate7enginesEv @ 1181 NONAME
+ _ZNK35QNetworkConfigurationManagerPrivate8isOnlineEv @ 1182 NONAME
+ _ZN10QSslSocket17setPeerVerifyNameERK7QString @ 1183 NONAME
+ _ZNK10QSslSocket14peerVerifyNameEv @ 1184 NONAME
diff --git a/src/s60installs/eabi/QtOpenGLu.def b/src/s60installs/eabi/QtOpenGLu.def
index 488c6cd..251521a 100644
--- a/src/s60installs/eabi/QtOpenGLu.def
+++ b/src/s60installs/eabi/QtOpenGLu.def
@@ -293,13 +293,13 @@ EXPORTS
_ZN17QGLContextPrivate14extensionFuncsEPK10QGLContext @ 292 NONAME
_ZN17QGLGraphicsSystemC1Eb @ 293 NONAME
_ZN17QGLGraphicsSystemC2Eb @ 294 NONAME
- _ZN18QGLContextResource5valueEPK10QGLContext @ 295 NONAME
- _ZN18QGLContextResource6insertEPK10QGLContextPv @ 296 NONAME
- _ZN18QGLContextResource7cleanupEPK10QGLContextPv @ 297 NONAME
- _ZN18QGLContextResourceC1EPFvPvE @ 298 NONAME
- _ZN18QGLContextResourceC2EPFvPvE @ 299 NONAME
- _ZN18QGLContextResourceD1Ev @ 300 NONAME
- _ZN18QGLContextResourceD2Ev @ 301 NONAME
+ _ZN18QGLContextResource5valueEPK10QGLContext @ 295 NONAME ABSENT
+ _ZN18QGLContextResource6insertEPK10QGLContextPv @ 296 NONAME ABSENT
+ _ZN18QGLContextResource7cleanupEPK10QGLContextPv @ 297 NONAME ABSENT
+ _ZN18QGLContextResourceC1EPFvPvE @ 298 NONAME ABSENT
+ _ZN18QGLContextResourceC2EPFvPvE @ 299 NONAME ABSENT
+ _ZN18QGLContextResourceD1Ev @ 300 NONAME ABSENT
+ _ZN18QGLContextResourceD2Ev @ 301 NONAME ABSENT
_ZN20QGLCustomShaderStage11setInactiveEv @ 302 NONAME
_ZN20QGLCustomShaderStage12setOnPainterEP8QPainter @ 303 NONAME
_ZN20QGLCustomShaderStage16setUniformsDirtyEv @ 304 NONAME
@@ -333,15 +333,15 @@ EXPORTS
_ZN20QGLFramebufferObjectD0Ev @ 332 NONAME
_ZN20QGLFramebufferObjectD1Ev @ 333 NONAME
_ZN20QGLFramebufferObjectD2Ev @ 334 NONAME
- _ZN20QGLTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 335 NONAME
- _ZN20QGLTextureGlyphCache11qt_metacallEN11QMetaObject4CallEiPPv @ 336 NONAME
- _ZN20QGLTextureGlyphCache11qt_metacastEPKc @ 337 NONAME
- _ZN20QGLTextureGlyphCache16staticMetaObjectE @ 338 NONAME DATA 16
+ _ZN20QGLTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 335 NONAME ABSENT
+ _ZN20QGLTextureGlyphCache11qt_metacallEN11QMetaObject4CallEiPPv @ 336 NONAME ABSENT
+ _ZN20QGLTextureGlyphCache11qt_metacastEPKc @ 337 NONAME ABSENT
+ _ZN20QGLTextureGlyphCache16staticMetaObjectE @ 338 NONAME DATA 16 ABSENT
_ZN20QGLTextureGlyphCache17createTextureDataEii @ 339 NONAME
_ZN20QGLTextureGlyphCache17resizeTextureDataEii @ 340 NONAME
- _ZN20QGLTextureGlyphCache19getStaticMetaObjectEv @ 341 NONAME
- _ZN20QGLTextureGlyphCacheC1EP10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 342 NONAME
- _ZN20QGLTextureGlyphCacheC2EP10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 343 NONAME
+ _ZN20QGLTextureGlyphCache19getStaticMetaObjectEv @ 341 NONAME ABSENT
+ _ZN20QGLTextureGlyphCacheC1EP10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 342 NONAME ABSENT
+ _ZN20QGLTextureGlyphCacheC2EP10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 343 NONAME ABSENT
_ZN20QGLTextureGlyphCacheD0Ev @ 344 NONAME
_ZN20QGLTextureGlyphCacheD1Ev @ 345 NONAME
_ZN20QGLTextureGlyphCacheD2Ev @ 346 NONAME
@@ -601,7 +601,7 @@ EXPORTS
_ZNK20QGLFramebufferObject7isValidEv @ 600 NONAME
_ZNK20QGLFramebufferObject7textureEv @ 601 NONAME
_ZNK20QGLFramebufferObject7toImageEv @ 602 NONAME
- _ZNK20QGLTextureGlyphCache10metaObjectEv @ 603 NONAME
+ _ZNK20QGLTextureGlyphCache10metaObjectEv @ 603 NONAME ABSENT
_ZNK20QGLTextureGlyphCache12glyphPaddingEv @ 604 NONAME
_ZNK21QGraphicsShaderEffect10metaObjectEv @ 605 NONAME
_ZNK21QGraphicsShaderEffect19pixelShaderFragmentEv @ 606 NONAME
@@ -690,14 +690,14 @@ EXPORTS
_ZThn8_N16QGLWindowSurface8endPaintERK7QRegion @ 689 NONAME
_ZThn8_N16QGLWindowSurfaceD0Ev @ 690 NONAME
_ZThn8_N16QGLWindowSurfaceD1Ev @ 691 NONAME
- _ZThn8_N20QGLTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 692 NONAME
- _ZThn8_N20QGLTextureGlyphCache17createTextureDataEii @ 693 NONAME
- _ZThn8_N20QGLTextureGlyphCache17resizeTextureDataEii @ 694 NONAME
- _ZThn8_N20QGLTextureGlyphCacheD0Ev @ 695 NONAME
- _ZThn8_N20QGLTextureGlyphCacheD1Ev @ 696 NONAME
+ _ZThn8_N20QGLTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 692 NONAME ABSENT
+ _ZThn8_N20QGLTextureGlyphCache17createTextureDataEii @ 693 NONAME ABSENT
+ _ZThn8_N20QGLTextureGlyphCache17resizeTextureDataEii @ 694 NONAME ABSENT
+ _ZThn8_N20QGLTextureGlyphCacheD0Ev @ 695 NONAME ABSENT
+ _ZThn8_N20QGLTextureGlyphCacheD1Ev @ 696 NONAME ABSENT
_ZThn8_N9QGLWidgetD0Ev @ 697 NONAME
_ZThn8_N9QGLWidgetD1Ev @ 698 NONAME
- _ZThn8_NK20QGLTextureGlyphCache12glyphPaddingEv @ 699 NONAME
+ _ZThn8_NK20QGLTextureGlyphCache12glyphPaddingEv @ 699 NONAME ABSENT
_ZThn8_NK9QGLWidget11paintEngineEv @ 700 NONAME
_ZeqRK9QGLFormatS1_ @ 701 NONAME
_Zls6QDebugRK9QGLFormat @ 702 NONAME
@@ -705,23 +705,56 @@ EXPORTS
_ZN16QGLWindowSurface26initializeOffscreenTextureERK5QSize @ 704 NONAME
_ZNK20QGLTextureGlyphCache15maxTextureWidthEv @ 705 NONAME
_ZNK20QGLTextureGlyphCache16maxTextureHeightEv @ 706 NONAME
- _ZThn8_NK20QGLTextureGlyphCache15maxTextureWidthEv @ 707 NONAME
- _ZThn8_NK20QGLTextureGlyphCache16maxTextureHeightEv @ 708 NONAME
- _ZN13QGLPixmapData12toNativeTypeEN11QPixmapData10NativeTypeE @ 709 NONAME
- _ZN13QGLPixmapData14fromNativeTypeEPvN11QPixmapData10NativeTypeE @ 710 NONAME
- _ZN13QGLPixmapData15fromImageReaderEP12QImageReader6QFlagsIN2Qt19ImageConversionFlagEE @ 711 NONAME
- _ZN13QGLPixmapData20createPixmapForImageER6QImage6QFlagsIN2Qt19ImageConversionFlagEEb @ 712 NONAME
- _ZN16QGLWindowSurface12swapBehaviorE @ 713 NONAME DATA 4
- _ZN20QGLTextureGlyphCache10setContextEP10QGLContext @ 714 NONAME
- _ZN20QGLTextureGlyphCache5clearEv @ 715 NONAME
- _ZN13QGLPixmapData12forceToImageEv @ 716 NONAME
- _ZN13QGLPixmapData14destroyTextureEv @ 717 NONAME
- _ZN13QGLPixmapData14reclaimTextureEv @ 718 NONAME
- _ZN13QGLPixmapData21detachTextureFromPoolEv @ 719 NONAME
- _ZN13QGLPixmapData9hibernateEv @ 720 NONAME
- _ZN17QGLGraphicsSystem22releaseCachedResourcesEv @ 721 NONAME
- _ZN13QGLPixmapData11idealFormatER6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 722 NONAME
- _ZN13QGLPixmapData24releaseNativeImageHandleEv @ 723 NONAME
- _ZN13QGLPixmapData25initFromNativeImageHandleEPvRK7QString @ 724 NONAME
- _ZN13QGLPixmapData35createFromNativeImageHandleProviderEv @ 725 NONAME
+ _ZThn8_NK20QGLTextureGlyphCache15maxTextureWidthEv @ 707 NONAME ABSENT
+ _ZThn8_NK20QGLTextureGlyphCache16maxTextureHeightEv @ 708 NONAME ABSENT
+ _Z28qt_resolve_buffer_extensionsP10QGLContext @ 709 NONAME
+ _ZN12QGLFunctions21initializeGLFunctionsEPK10QGLContext @ 710 NONAME
+ _ZN12QGLFunctionsC1EPK10QGLContext @ 711 NONAME
+ _ZN12QGLFunctionsC1Ev @ 712 NONAME
+ _ZN12QGLFunctionsC2EPK10QGLContext @ 713 NONAME
+ _ZN12QGLFunctionsC2Ev @ 714 NONAME
+ _ZN13QGLPixmapData12toNativeTypeEN11QPixmapData10NativeTypeE @ 715 NONAME
+ _ZN13QGLPixmapData14fromNativeTypeEPvN11QPixmapData10NativeTypeE @ 716 NONAME
+ _ZN13QGLPixmapData15fromImageReaderEP12QImageReader6QFlagsIN2Qt19ImageConversionFlagEE @ 717 NONAME
+ _ZN13QGLPixmapData20createPixmapForImageER6QImage6QFlagsIN2Qt19ImageConversionFlagEEb @ 718 NONAME
+ _ZN16QGLWindowSurface12swapBehaviorE @ 719 NONAME DATA 4
+ _ZN17QGLContextPrivate17qt_extensionFuncsE @ 720 NONAME DATA 60
+ _ZN20QGLTextureGlyphCache10setContextEPK10QGLContext @ 721 NONAME
+ _ZN20QGLTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj6QFixed @ 722 NONAME
+ _ZN20QGLTextureGlyphCacheC1EPK10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 723 NONAME
+ _ZN20QGLTextureGlyphCacheC2EPK10QGLContextN21QFontEngineGlyphCache4TypeERK10QTransform @ 724 NONAME
+ _ZN26QGLFramebufferObjectFormat9setMipmapEb @ 725 NONAME
+ _ZN27QGLContextGroupResourceBase5valueEPK10QGLContext @ 726 NONAME
+ _ZN27QGLContextGroupResourceBase6insertEPK10QGLContextPv @ 727 NONAME
+ _ZN27QGLContextGroupResourceBase7cleanupEPK10QGLContextPv @ 728 NONAME
+ _ZN27QGLContextGroupResourceBaseC2Ev @ 729 NONAME
+ _ZN27QGLContextGroupResourceBaseD0Ev @ 730 NONAME
+ _ZN27QGLContextGroupResourceBaseD1Ev @ 731 NONAME
+ _ZN27QGLContextGroupResourceBaseD2Ev @ 732 NONAME
+ _ZNK12QGLFunctions14openGLFeaturesEv @ 733 NONAME
+ _ZNK12QGLFunctions16hasOpenGLFeatureENS_13OpenGLFeatureE @ 734 NONAME
+ _ZNK14QGLPaintDevice9isFlippedEv @ 735 NONAME
+ _ZNK26QGLFramebufferObjectFormat6mipmapEv @ 736 NONAME
+ _ZTI27QGLContextGroupResourceBase @ 737 NONAME
+ _ZTV27QGLContextGroupResourceBase @ 738 NONAME
+ _ZThn104_N20QGLTextureGlyphCacheD0Ev @ 739 NONAME
+ _ZThn104_N20QGLTextureGlyphCacheD1Ev @ 740 NONAME
+ _ZN13QGLPixmapData12forceToImageEv @ 741 NONAME
+ _ZN13QGLPixmapData14destroyTextureEv @ 742 NONAME
+ _ZN13QGLPixmapData14reclaimTextureEv @ 743 NONAME
+ _ZN13QGLPixmapData21detachTextureFromPoolEv @ 744 NONAME
+ _ZN13QGLPixmapData9hibernateEv @ 745 NONAME
+ _ZN17QGLGraphicsSystem22releaseCachedResourcesEv @ 746 NONAME
+ _ZN22QGLEngineSharedShaders15qShaderSnippetsE @ 747 NONAME DATA 216
+ _ZN22QGLEngineSharedShaders16staticMetaObjectE @ 748 NONAME DATA 16
+ _ZN22QGLEngineSharedShaders17shadersForContextEPK10QGLContext @ 749 NONAME
+ _ZN22QGLEngineSharedShaders18cleanupCustomStageEP20QGLCustomShaderStage @ 750 NONAME
+ _ZN22QGLEngineSharedShaders18findProgramInCacheERK19QGLEngineShaderProg @ 751 NONAME
+ _ZN22QGLEngineSharedShaders19getStaticMetaObjectEv @ 752 NONAME
+ _ZN22QGLEngineSharedShadersC1EPK10QGLContext @ 753 NONAME
+ _ZN22QGLEngineSharedShadersC2EPK10QGLContext @ 754 NONAME
+ _ZN22QGLEngineSharedShadersD1Ev @ 755 NONAME
+ _ZN22QGLEngineSharedShadersD2Ev @ 756 NONAME
+ _ZNK16QGLWindowSurface23hasPartialUpdateSupportEv @ 757 NONAME
+ _ZThn8_NK16QGLWindowSurface23hasPartialUpdateSupportEv @ 758 NONAME
diff --git a/src/s60installs/eabi/QtOpenVGu.def b/src/s60installs/eabi/QtOpenVGu.def
index 08afd61..7e91b83 100644
--- a/src/s60installs/eabi/QtOpenVGu.def
+++ b/src/s60installs/eabi/QtOpenVGu.def
@@ -8,7 +8,7 @@ EXPORTS
_Z25qt_vg_create_paint_enginev @ 7 NONAME
_Z26qt_vg_destroy_paint_engineP14QVGPaintEngine @ 8 NONAME
_Z28qt_vg_config_to_image_formatP11QEglContext @ 9 NONAME
- _ZN13QVGPixmapData12forceToImageEv @ 10 NONAME ABSENT
+ _ZN13QVGPixmapData12forceToImageEv @ 10 NONAME
_ZN13QVGPixmapData12toNativeTypeEN11QPixmapData10NativeTypeE @ 11 NONAME
_ZN13QVGPixmapData14fromNativeTypeEPvN11QPixmapData10NativeTypeE @ 12 NONAME
_ZN13QVGPixmapData15setAlphaChannelERK7QPixmap @ 13 NONAME
@@ -206,12 +206,12 @@ EXPORTS
_ZN13QVGPixmapData8fromDataEPKhjPKc6QFlagsIN2Qt19ImageConversionFlagEE @ 205 NONAME
_ZN13QVGPixmapData8fromFileERK7QStringPKc6QFlagsIN2Qt19ImageConversionFlagEE @ 206 NONAME
_ZNK14QVGPaintEngine16canVgWritePixelsERK6QImage @ 207 NONAME
- _ZN13QVGPixmapData12updateSerialEv @ 208 NONAME
- _ZN13QVGPixmapData4copyEPK11QPixmapDataRK5QRect @ 209 NONAME
- _ZNK13QVGPixmapData11idealFormatEP6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 210 NONAME
- _ZNK13QVGPixmapData14ensureReadbackEb @ 211 NONAME
- _ZN13QVGPixmapData24releaseNativeImageHandleEv @ 212 NONAME
- _ZN13QVGPixmapData25initFromNativeImageHandleEPvRK7QString @ 213 NONAME
- _ZN13QVGPixmapData35createFromNativeImageHandleProviderEv @ 214 NONAME
- _ZN13QVGPixmapData12forceToImageEb @ 215 NONAME
+ _ZN13QVGPixmapData12updateSerialEv @ 208 NONAME ABSENT
+ _ZN13QVGPixmapData4copyEPK11QPixmapDataRK5QRect @ 209 NONAME ABSENT
+ _ZNK13QVGPixmapData11idealFormatEP6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 210 NONAME ABSENT
+ _ZN13QVGPixmapData24releaseNativeImageHandleEv @ 211 NONAME
+ _ZN13QVGPixmapData25initFromNativeImageHandleEPvRK7QString @ 212 NONAME
+ _ZN13QVGPixmapData35createFromNativeImageHandleProviderEv @ 213 NONAME
+ _ZNK13QVGPixmapData14ensureReadbackEb @ 214 NONAME
+ _ZNK16QVGWindowSurface24hasStaticContentsSupportEv @ 215 NONAME
diff --git a/src/s60installs/eabi/QtTestu.def b/src/s60installs/eabi/QtTestu.def
index 5cb95ba..370466b 100644
--- a/src/s60installs/eabi/QtTestu.def
+++ b/src/s60installs/eabi/QtTestu.def
@@ -70,4 +70,98 @@ EXPORTS
_ZTI14QTestEventLoop @ 69 NONAME
_ZTV14QTestEventLoop @ 70 NONAME
_ZN5QTest18setBenchmarkResultEfNS_16QBenchmarkMetricE @ 71 NONAME
+ _ZN10QTestTable15globalTestTableEv @ 72 NONAME
+ _ZN10QTestTable16currentTestTableEv @ 73 NONAME
+ _ZN10QTestTable20clearGlobalTestTableEv @ 74 NONAME
+ _ZN10QTestTable7newDataEPKc @ 75 NONAME
+ _ZN10QTestTable9addColumnEiPKc @ 76 NONAME
+ _ZN10QTestTableC1Ev @ 77 NONAME
+ _ZN10QTestTableC2Ev @ 78 NONAME
+ _ZN10QTestTableD1Ev @ 79 NONAME
+ _ZN10QTestTableD2Ev @ 80 NONAME
+ _ZN11QTestResult10addFailureEPKcS1_i @ 81 NONAME
+ _ZN11QTestResult10expectFailEPKcS1_N5QTest12TestFailModeES1_i @ 82 NONAME
+ _ZN11QTestResult10testFailedEv @ 83 NONAME
+ _ZN11QTestResult13allDataPassedEv @ 84 NONAME
+ _ZN11QTestResult13ignoreMessageE9QtMsgTypePKc @ 85 NONAME
+ _ZN11QTestResult14currentDataTagEv @ 86 NONAME
+ _ZN11QTestResult15currentTestDataEv @ 87 NONAME
+ _ZN11QTestResult15skipCurrentTestEv @ 88 NONAME
+ _ZN11QTestResult17currentTestFailedEv @ 89 NONAME
+ _ZN11QTestResult18setCurrentTestDataEP9QTestData @ 90 NONAME
+ _ZN11QTestResult18setSkipCurrentTestEb @ 91 NONAME
+ _ZN11QTestResult19currentTestFunctionEv @ 92 NONAME
+ _ZN11QTestResult19currentTestLocationEv @ 93 NONAME
+ _ZN11QTestResult20currentGlobalDataTagEv @ 94 NONAME
+ _ZN11QTestResult20setCurrentTestObjectEPKc @ 95 NONAME
+ _ZN11QTestResult21currentGlobalTestDataEv @ 96 NONAME
+ _ZN11QTestResult21currentTestObjectNameEv @ 97 NONAME
+ _ZN11QTestResult22setCurrentTestFunctionEPKc @ 98 NONAME
+ _ZN11QTestResult22setCurrentTestLocationENS_12TestLocationE @ 99 NONAME
+ _ZN11QTestResult24setCurrentGlobalTestDataEP9QTestData @ 100 NONAME
+ _ZN11QTestResult27finishedCurrentTestFunctionEv @ 101 NONAME
+ _ZN11QTestResult5resetEv @ 102 NONAME
+ _ZN11QTestResult6verifyEbPKcS1_S1_i @ 103 NONAME
+ _ZN11QTestResult7addSkipEPKcN5QTest8SkipModeES1_i @ 104 NONAME
+ _ZN11QTestResult7compareEbPKcPcS2_S1_S1_S1_i @ 105 NONAME
+ _ZN11QTestResult7compareEbPKcS1_i @ 106 NONAME
+ _ZN11QTestResult9failCountEv @ 107 NONAME
+ _ZN11QTestResult9passCountEv @ 108 NONAME
+ _ZN11QTestResult9skipCountEv @ 109 NONAME
+ _ZN20QBenchmarkGlobalData14createMeasurerEv @ 110 NONAME
+ _ZN20QBenchmarkGlobalData26adjustMedianIterationCountEv @ 111 NONAME
+ _ZN20QBenchmarkGlobalData7currentE @ 112 NONAME DATA 4
+ _ZN20QBenchmarkGlobalData7setModeENS_4ModeE @ 113 NONAME
+ _ZN20QBenchmarkGlobalDataC1Ev @ 114 NONAME
+ _ZN20QBenchmarkGlobalDataC2Ev @ 115 NONAME
+ _ZN20QBenchmarkGlobalDataD1Ev @ 116 NONAME
+ _ZN20QBenchmarkGlobalDataD2Ev @ 117 NONAME
+ _ZN24QBenchmarkTestMethodData10endDataRunEv @ 118 NONAME
+ _ZN24QBenchmarkTestMethodData12beginDataRunEv @ 119 NONAME
+ _ZN24QBenchmarkTestMethodData20adjustIterationCountEi @ 120 NONAME
+ _ZN24QBenchmarkTestMethodData7currentE @ 121 NONAME DATA 4
+ _ZN24QBenchmarkTestMethodData9setResultEfN5QTest16QBenchmarkMetricEb @ 122 NONAME
+ _ZN24QBenchmarkTestMethodDataC1Ev @ 123 NONAME
+ _ZN24QBenchmarkTestMethodDataC2Ev @ 124 NONAME
+ _ZN24QBenchmarkTestMethodDataD1Ev @ 125 NONAME
+ _ZN24QBenchmarkTestMethodDataD2Ev @ 126 NONAME
+ _ZN5QTest13testFunctionsE @ 127 NONAME DATA 4
+ _ZN5QTest16qtest_qParseArgsEiPPcb @ 128 NONAME
+ _ZN5QTest23printAvailableFunctionsE @ 129 NONAME DATA 1
+ _ZN5QTest8testTagsE @ 130 NONAME DATA 4
+ _ZN8QTestLog10setLogModeENS_7LogModeE @ 131 NONAME
+ _ZN8QTestLog11stopLoggingEv @ 132 NONAME
+ _ZN8QTestLog12setFlushModeENS_9FlushModeE @ 133 NONAME
+ _ZN8QTestLog12startLoggingEj @ 134 NONAME
+ _ZN8QTestLog12startLoggingEv @ 135 NONAME
+ _ZN8QTestLog12verboseLevelEv @ 136 NONAME
+ _ZN8QTestLog14outputFileNameEv @ 137 NONAME
+ _ZN8QTestLog14redirectOutputEPKc @ 138 NONAME
+ _ZN8QTestLog14setMaxWarningsEi @ 139 NONAME
+ _ZN8QTestLog15setVerboseLevelEi @ 140 NONAME
+ _ZN8QTestLog16addIgnoreMessageE9QtMsgTypePKc @ 141 NONAME
+ _ZN8QTestLog17enterTestFunctionEPKc @ 142 NONAME
+ _ZN8QTestLog17leaveTestFunctionEv @ 143 NONAME
+ _ZN8QTestLog18addBenchmarkResultERK16QBenchmarkResult @ 144 NONAME
+ _ZN8QTestLog23unhandledIgnoreMessagesEv @ 145 NONAME
+ _ZN8QTestLog28printUnhandledIgnoreMessagesEv @ 146 NONAME
+ _ZN8QTestLog4infoEPKcS1_i @ 147 NONAME
+ _ZN8QTestLog4warnEPKc @ 148 NONAME
+ _ZN8QTestLog7addFailEPKcS1_i @ 149 NONAME
+ _ZN8QTestLog7addPassEPKc @ 150 NONAME
+ _ZN8QTestLog7addSkipEPKcN5QTest8SkipModeES1_i @ 151 NONAME
+ _ZN8QTestLog7logModeEv @ 152 NONAME
+ _ZN8QTestLog8addXFailEPKcS1_i @ 153 NONAME
+ _ZN8QTestLog8addXPassEPKcS1_i @ 154 NONAME
+ _ZN8QTestLogC1Ev @ 155 NONAME
+ _ZN8QTestLogC2Ev @ 156 NONAME
+ _ZN8QTestLogD1Ev @ 157 NONAME
+ _ZN8QTestLogD2Ev @ 158 NONAME
+ _ZNK10QTestTable12elementCountEv @ 159 NONAME
+ _ZNK10QTestTable13elementTypeIdEi @ 160 NONAME
+ _ZNK10QTestTable7dataTagEi @ 161 NONAME
+ _ZNK10QTestTable7indexOfEPKc @ 162 NONAME
+ _ZNK10QTestTable7isEmptyEv @ 163 NONAME
+ _ZNK10QTestTable8testDataEi @ 164 NONAME
+ _ZNK10QTestTable9dataCountEv @ 165 NONAME
diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro
index d1bb48b..02c3da0 100644
--- a/src/s60installs/s60installs.pro
+++ b/src/s60installs/s60installs.pro
@@ -19,7 +19,7 @@ symbian: {
DESTDIR = $$QMAKE_LIBDIR_QT
- qtlibraries.sources = \
+ qtlibraries.files = \
$$QMAKE_LIBDIR_QT/QtCore$${QT_LIBINFIX}.dll \
$$QMAKE_LIBDIR_QT/QtXml$${QT_LIBINFIX}.dll \
$$QMAKE_LIBDIR_QT/QtGui$${QT_LIBINFIX}.dll \
@@ -64,7 +64,7 @@ symbian: {
qts60plugindeployment = \
" \"$$pluginLocations/qts60plugin_5_0$${QT_LIBINFIX}.dll\" - \"c:\\sys\\bin\\qts60plugin_5_0$${QT_LIBINFIX}.dll\""
- bearer_plugin.sources = $$QT_BUILD_TREE/plugins/bearer/qsymbianbearer$${QT_LIBINFIX}.dll
+ bearer_plugin.files = $$QT_BUILD_TREE/plugins/bearer/qsymbianbearer$${QT_LIBINFIX}.dll
bearer_plugin.path = c:$$QT_PLUGINS_BASE_DIR/bearer
DEPLOYMENT += bearer_plugin
}
@@ -97,25 +97,25 @@ symbian: {
}
qtlibraries.pkg_prerules += "(0x2002af5f), 0, 5, 0, {\"sqlite3\"}"
- !contains(QT_CONFIG, no-jpeg): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qjpeg$${QT_LIBINFIX}.dll
- !contains(QT_CONFIG, no-gif): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qgif$${QT_LIBINFIX}.dll
- !contains(QT_CONFIG, no-mng): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qmng$${QT_LIBINFIX}.dll
- !contains(QT_CONFIG, no-tiff): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qtiff$${QT_LIBINFIX}.dll
- !contains(QT_CONFIG, no-ico): imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qico$${QT_LIBINFIX}.dll
+ !contains(QT_CONFIG, no-jpeg): imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qjpeg$${QT_LIBINFIX}.dll
+ !contains(QT_CONFIG, no-gif): imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qgif$${QT_LIBINFIX}.dll
+ !contains(QT_CONFIG, no-mng): imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qmng$${QT_LIBINFIX}.dll
+ !contains(QT_CONFIG, no-tiff): imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qtiff$${QT_LIBINFIX}.dll
+ !contains(QT_CONFIG, no-ico): imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qico$${QT_LIBINFIX}.dll
imageformats_plugins.path = c:$$QT_PLUGINS_BASE_DIR/imageformats
- codecs_plugins.sources = $$QT_BUILD_TREE/plugins/codecs/qcncodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qjpcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qtwcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qkrcodecs$${QT_LIBINFIX}.dll
+ codecs_plugins.files = $$QT_BUILD_TREE/plugins/codecs/qcncodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qjpcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qtwcodecs$${QT_LIBINFIX}.dll $$QT_BUILD_TREE/plugins/codecs/qkrcodecs$${QT_LIBINFIX}.dll
codecs_plugins.path = c:$$QT_PLUGINS_BASE_DIR/codecs
contains(QT_CONFIG, phonon-backend) {
- phonon_backend_plugins.sources += $$QT_BUILD_TREE/plugins/phonon_backend/phonon_mmf$${QT_LIBINFIX}.dll
+ phonon_backend_plugins.files += $$QT_BUILD_TREE/plugins/phonon_backend/phonon_mmf$${QT_LIBINFIX}.dll
phonon_backend_plugins.path = c:$$QT_PLUGINS_BASE_DIR/phonon_backend
DEPLOYMENT += phonon_backend_plugins
}
# Support backup & restore for Qt libraries
- qtbackup.sources = backup_registration.xml
+ qtbackup.files = backup_registration.xml
qtbackup.path = c:/private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,)
DEPLOYMENT += qtlibraries \
@@ -125,35 +125,35 @@ symbian: {
graphicssystems_plugins
contains(QT_CONFIG, svg): {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtSvg$${QT_LIBINFIX}.dll
- imageformats_plugins.sources += $$QT_BUILD_TREE/plugins/imageformats/qsvg$${QT_LIBINFIX}.dll
- iconengines_plugins.sources = $$QT_BUILD_TREE/plugins/iconengines/qsvgicon$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtSvg$${QT_LIBINFIX}.dll
+ imageformats_plugins.files += $$QT_BUILD_TREE/plugins/imageformats/qsvg$${QT_LIBINFIX}.dll
+ iconengines_plugins.files = $$QT_BUILD_TREE/plugins/iconengines/qsvgicon$${QT_LIBINFIX}.dll
iconengines_plugins.path = c:$$QT_PLUGINS_BASE_DIR/iconengines
DEPLOYMENT += iconengines_plugins
}
contains(QT_CONFIG, phonon): {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/phonon$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/phonon$${QT_LIBINFIX}.dll
}
contains(QT_CONFIG, script): {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtScript$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtScript$${QT_LIBINFIX}.dll
}
contains(QT_CONFIG, xmlpatterns): {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtXmlPatterns$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtXmlPatterns$${QT_LIBINFIX}.dll
}
contains(QT_CONFIG, declarative): {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtDeclarative$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtDeclarative$${QT_LIBINFIX}.dll
- folderlistmodelImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/folderlistmodel/qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll
- gesturesImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/gestures/qmlgesturesplugin$${QT_LIBINFIX}.dll
- particlesImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/particles/qmlparticlesplugin$${QT_LIBINFIX}.dll
+ folderlistmodelImport.files = $$QT_BUILD_TREE/imports/Qt/labs/folderlistmodel/qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll
+ gesturesImport.files = $$QT_BUILD_TREE/imports/Qt/labs/gestures/qmlgesturesplugin$${QT_LIBINFIX}.dll
+ particlesImport.files = $$QT_BUILD_TREE/imports/Qt/labs/particles/qmlparticlesplugin$${QT_LIBINFIX}.dll
- folderlistmodelImport.sources += $$QT_SOURCE_TREE/src/imports/folderlistmodel/qmldir
- gesturesImport.sources += $$QT_SOURCE_TREE/src/imports/gestures/qmldir
- particlesImport.sources += $$QT_SOURCE_TREE/src/imports/particles/qmldir
+ folderlistmodelImport.files += $$QT_SOURCE_TREE/src/imports/folderlistmodel/qmldir
+ gesturesImport.files += $$QT_SOURCE_TREE/src/imports/gestures/qmldir
+ particlesImport.files += $$QT_SOURCE_TREE/src/imports/particles/qmldir
folderlistmodelImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/folderlistmodel
gesturesImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/gestures
@@ -164,17 +164,17 @@ symbian: {
graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems
contains(QT_CONFIG, openvg) {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtOpenVG$${QT_LIBINFIX}.dll
- graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtOpenVG$${QT_LIBINFIX}.dll
+ graphicssystems_plugins.files += $$QT_BUILD_TREE/plugins/graphicssystems/qvggraphicssystem$${QT_LIBINFIX}.dll
}
contains(QT_CONFIG, opengl) {
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtOpenGL$${QT_LIBINFIX}.dll
- graphicssystems_plugins.sources += $$QT_BUILD_TREE/plugins/graphicssystems/qglgraphicssystem$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtOpenGL$${QT_LIBINFIX}.dll
+ graphicssystems_plugins.files += $$QT_BUILD_TREE/plugins/graphicssystems/qglgraphicssystem$${QT_LIBINFIX}.dll
}
contains(QT_CONFIG, multimedia){
- qtlibraries.sources += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll
+ qtlibraries.files += $$QMAKE_LIBDIR_QT/QtMultimedia$${QT_LIBINFIX}.dll
}
BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)"
diff --git a/src/s60main/newallocator_hook.cpp b/src/s60main/newallocator_hook.cpp
index 3e259c2..9cc6afb 100644
--- a/src/s60main/newallocator_hook.cpp
+++ b/src/s60main/newallocator_hook.cpp
@@ -41,11 +41,6 @@
#include <e32std.h>
#include <qglobal.h>
-#ifdef QT_EXPORTS_NOT_FROZEN
-// If exports in Qt DLLs are not frozen in this build, then we have to pick up the
-// allocator creation function by import link. We know the function will be present
-// in the DLLs we test with, as we have to use the DLLs we have built.
-
struct SStdEpocThreadCreateInfo;
Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
@@ -56,98 +51,8 @@ Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCre
* Uses link-time symbol preemption to capture a call from the application
* startup. On return, there is some kind of heap allocator installed on the
* thread.
-*/
+*/
TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
{
return qt_symbian_SetupThreadHeap(aNotFirst, aInfo);
}
-
-#else // QT_EXPORTS_NOT_FROZEN
-// If we are using an export frozen build, it should be compatible with all 4.7.x Qt releases.
-// We want to use the allocator creation function introduced in qtcore.dll after 4.7.1. But we
-// can't import link to it, as it may not be present in whatever 4.7.x DLLs we are running with.
-// So the function is found and called dynamically, by library lookup. If it is not found, we
-// use the OS allocator creation functions instead.
-
-#if defined(QT_LIBINFIX)
-# define QT_LSTRING2(x) L##x
-# define QT_LSTRING(x) QT_LSTRING2(x)
-# define QT_LIBINFIX_UNICODE QT_LSTRING(QT_LIBINFIX)
-#else
-# define QT_LIBINFIX_UNICODE L""
-#endif
-
-_LIT(QtCoreLibName, "qtcore" QT_LIBINFIX_UNICODE L".dll");
-
-struct SThreadCreateInfo
- {
- TAny* iHandle;
- TInt iType;
- TThreadFunction iFunction;
- TAny* iPtr;
- TAny* iSupervisorStack;
- TInt iSupervisorStackSize;
- TAny* iUserStack;
- TInt iUserStackSize;
- TInt iInitialThreadPriority;
- TPtrC iName;
- TInt iTotalSize; // Size including any extras (must be a multiple of 8 bytes)
- };
-
-struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
- {
- RAllocator* iAllocator;
- TInt iHeapInitialSize;
- TInt iHeapMaxSize;
- TInt iPadding; // Make structure size a multiple of 8 bytes
- };
-
-
-/* \internal
- *
- * Uses link-time symbol preemption to capture a call from the application
- * startup. On return, there is some kind of heap allocator installed on the
- * thread.
-*/
-TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
-{
- TInt r = KErrNone;
-
-#ifndef __WINS__
- // attempt to create the fast allocator through a known export ordinal in qtcore.dll
- RLibrary qtcore;
- if (qtcore.Load(QtCoreLibName) == KErrNone)
- {
- const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713;
- TLibraryFunction libFunc = qtcore.Lookup(qt_symbian_SetupThreadHeap_eabi_ordinal);
- if (libFunc)
- {
- typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
- TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc(libFunc);
- r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
- }
- qtcore.Close();
- if (libFunc)
- return r;
- }
-#endif
-
- // no fast allocator support - use default allocator creation
- if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
- {
- // new heap required
- RHeap* pH = NULL;
- r = UserHeap::CreateThreadHeap(aInfo, pH);
- }
- else if (aInfo.iAllocator)
- {
- // sharing a heap
- RAllocator* pA = aInfo.iAllocator;
- pA->Open();
- User::SwitchAllocator(pA);
- r = KErrNone;
- }
- return r;
-}
-
-#endif // QT_EXPORTS_NOT_FROZEN
diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp
index 05089ff..c6fd39b 100644
--- a/src/s60main/qts60main.cpp
+++ b/src/s60main/qts60main.cpp
@@ -51,7 +51,8 @@ GLDEF_C TInt QtMainWrapper();
*/
GLDEF_C TInt E32Main()
{
- CTrapCleanup *cleanupStack = q_check_ptr(CTrapCleanup::New());
+ CTrapCleanup *cleanupStack = CTrapCleanup::New();
+ Q_CHECK_PTR(cleanupStack);
TInt err = 0;
TRAP(err, err = QtMainWrapper());
delete cleanupStack;
diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp
index bb78113..d397864 100644
--- a/src/s60main/qts60main_mcrt0.cpp
+++ b/src/s60main/qts60main_mcrt0.cpp
@@ -78,14 +78,14 @@ extern "C" IMPORT_C void exit(int ret);
GLDEF_C TInt QtMainWrapper()
{
int argc = 0;
- char **argv = 0;
- char **envp = 0;
+ // these variables are declared static in the expectation that this function is not reentrant
+ // and so that memory analysis tools can trace any memory allocated in __crt0() to global memory ownership.
+ static char **argv = 0;
+ static char **envp = 0;
// get args & environment
__crt0(argc, argv, envp);
//Call user(application)'s main
TRAPD(ret, QT_TRYCATCH_LEAVING(ret = CALLMAIN(argc, argv, envp);));
- delete[] argv;
- delete[] envp;
return ret;
}
diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro
index 1e3e06a..4c598e2 100644
--- a/src/s60main/s60main.pro
+++ b/src/s60main/s60main.pro
@@ -31,9 +31,6 @@ symbian {
# against GCCE apps, so remove it
MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA
symbian-armcc:QMAKE_CXXFLAGS *= --export_all_vtbl
-
- # Flag if exports are not frozen to avoid lookup of qtcore allocator creation function by ordinal
- contains(CONFIG, def_files_disabled): DEFINES += QT_EXPORTS_NOT_FROZEN
} else {
error("$$_FILE_ is intended only for Symbian!")
}
diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp
index 0f9de1d..182bc4a 100644
--- a/src/script/api/qscriptcontextinfo.cpp
+++ b/src/script/api/qscriptcontextinfo.cpp
@@ -159,12 +159,20 @@ QScriptContextInfoPrivate::QScriptContextInfoPrivate(const QScriptContext *conte
JSC::CodeBlock *codeBlock = frame->codeBlock();
if (returnPC && codeBlock && QScriptEnginePrivate::hasValidCodeBlockRegister(frame)) {
#if ENABLE(JIT)
- unsigned bytecodeOffset = codeBlock->getBytecodeIndex(frame, JSC::ReturnAddressPtr(returnPC));
+ JSC::JITCode code = codeBlock->getJITCode();
+ unsigned jitOffset = code.offsetOf(JSC::ReturnAddressPtr(returnPC).value());
+ // We can only use the JIT code offset if it's smaller than the JIT size;
+ // otherwise calling getBytecodeIndex() is meaningless.
+ if (jitOffset < code.size()) {
+ unsigned bytecodeOffset = codeBlock->getBytecodeIndex(frame, JSC::ReturnAddressPtr(returnPC));
#else
unsigned bytecodeOffset = returnPC - codeBlock->instructions().begin();
#endif
bytecodeOffset--; //because returnPC is on the next instruction. We want the current one
lineNumber = codeBlock->lineNumberForBytecodeOffset(const_cast<JSC::ExecState *>(frame), bytecodeOffset);
+#if ENABLE(JIT)
+ }
+#endif
}
}
}
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 160058e..a3a965e 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -779,6 +779,8 @@ JSC::JSValue JSC_HOST_CALL functionVersion(JSC::ExecState *exec, JSC::JSObject*,
return JSC::JSValue(exec, 1);
}
+#ifndef QT_NO_TRANSLATION
+
static JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
static JSC::JSValue JSC_HOST_CALL functionQsTranslateNoOp(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
static JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
@@ -808,7 +810,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje
JSC::UString comment;
if (args.size() > 2)
comment = args.at(2).toString(exec);
- QCoreApplication::Encoding encoding = QCoreApplication::CodecForTr;
+ QCoreApplication::Encoding encoding = QCoreApplication::UnicodeUTF8;
if (args.size() > 3) {
JSC::UString encStr = args.at(3).toString(exec);
if (encStr == "CodecForTr")
@@ -824,9 +826,9 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje
#endif
JSC::UString result;
#ifndef QT_NO_QOBJECT
- result = QCoreApplication::translate(QScript::convertToLatin1(context).constData(),
- QScript::convertToLatin1(text).constData(),
- QScript::convertToLatin1(comment).constData(),
+ result = QCoreApplication::translate(context.UTF8String().c_str(),
+ text.UTF8String().c_str(),
+ comment.UTF8String().c_str(),
encoding, n);
#else
result = text;
@@ -879,10 +881,10 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
#endif
JSC::UString result;
#ifndef QT_NO_QOBJECT
- result = QCoreApplication::translate(QScript::convertToLatin1(context).constData(),
- QScript::convertToLatin1(text).constData(),
- QScript::convertToLatin1(comment).constData(),
- QCoreApplication::CodecForTr, n);
+ result = QCoreApplication::translate(context.UTF8String().c_str(),
+ text.UTF8String().c_str(),
+ comment.UTF8String().c_str(),
+ QCoreApplication::UnicodeUTF8, n);
#else
result = text;
#endif
@@ -908,7 +910,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTrId(JSC::ExecState *exec, JSC::JSObject*,
int n = -1;
if (args.size() > 1)
n = args.at(1).toInt32(exec);
- return JSC::jsString(exec, qtTrId(QScript::convertToLatin1(id).constData(), n));
+ return JSC::jsString(exec, qtTrId(id.UTF8String().c_str(), n));
}
JSC::JSValue JSC_HOST_CALL functionQsTrIdNoOp(JSC::ExecState *, JSC::JSObject*, JSC::JSValue, const JSC::ArgList &args)
@@ -917,6 +919,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTrIdNoOp(JSC::ExecState *, JSC::JSObject*,
return JSC::jsUndefined();
return args.at(0);
}
+#endif // QT_NO_TRANSLATION
static JSC::JSValue JSC_HOST_CALL stringProtoFuncArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
@@ -1742,7 +1745,7 @@ QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue valu
return variantValue(value);
#ifndef QT_NO_QOBJECT
else if (isQObject(value))
- return qVariantFromValue(toQObject(exec, value));
+ return QVariant::fromValue(toQObject(exec, value));
#endif
else if (isDate(value))
return QVariant(toDateTime(exec, value));
@@ -1755,7 +1758,9 @@ QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue valu
else if (QScriptDeclarativeClass *dc = declarativeClass(value))
return dc->toVariant(declarativeObject(value));
return variantMapFromObject(exec, JSC::asObject(value));
- } else if (value.isNumber()) {
+ } else if (value.isInt32()) {
+ return QVariant(toInt32(exec, value));
+ } else if (value.isDouble()) {
return QVariant(toNumber(exec, value));
} else if (value.isString()) {
return QVariant(toString(exec, value));
@@ -2087,10 +2092,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;
}
@@ -2356,9 +2361,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;
}
@@ -2374,9 +2379,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;
}
@@ -2466,10 +2471,6 @@ QScriptValue QScriptEngine::newQMetaObject(
\snippet doc/src/snippets/code/src_script_qscriptengine.cpp 13
- \warning This function is not available with MSVC 6. Use
- qScriptValueFromQMetaObject() instead if you need to support that version
- of the compiler.
-
\sa QScriptEngine::newQMetaObject()
*/
@@ -2477,14 +2478,17 @@ QScriptValue QScriptEngine::newQMetaObject(
\fn QScriptValue qScriptValueFromQMetaObject(QScriptEngine *engine)
\since 4.3
\relates QScriptEngine
+ \obsolete
Uses \a engine to create a QScriptValue that represents the Qt class
\c{T}.
This function is equivalent to
- QScriptEngine::scriptValueFromQMetaObject(). It is provided as a
- work-around for MSVC 6, which doesn't support member template
- functions.
+ QScriptEngine::scriptValueFromQMetaObject().
+
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
\sa QScriptEngine::newQMetaObject()
*/
@@ -3020,14 +3024,7 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const
case QMetaType::LongLong:
return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
case QMetaType::ULongLong:
-#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804
-#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.")
- return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
-#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET)
- return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr)));
-#else
return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
-#endif
case QMetaType::Double:
return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const double*>(ptr)));
case QMetaType::QString:
@@ -3071,7 +3068,7 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const
break;
#endif
case QMetaType::QVariant:
- result = jscValueFromVariant(exec, *reinterpret_cast<const QVariant*>(ptr));
+ result = eng->newVariant(*reinterpret_cast<const QVariant*>(ptr));
break;
default:
if (type == qMetaTypeId<QScriptValue>()) {
@@ -3492,12 +3489,15 @@ void QScriptEngine::installTranslatorFunctions(const QScriptValue &object)
if (!jscObject || !jscObject.isObject())
jscObject = d->globalObject();
// unsigned attribs = JSC::DontEnum;
+
+#ifndef QT_NO_TRANSLATION
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 5, JSC::Identifier(exec, "qsTranslate"), QScript::functionQsTranslate));
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 2, JSC::Identifier(exec, "QT_TRANSLATE_NOOP"), QScript::functionQsTranslateNoOp));
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 3, JSC::Identifier(exec, "qsTr"), QScript::functionQsTr));
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "QT_TR_NOOP"), QScript::functionQsTrNoOp));
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "qsTrId"), QScript::functionQsTrId));
JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "QT_TRID_NOOP"), QScript::functionQsTrIdNoOp));
+#endif
glob->stringPrototype()->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "arg"), QScript::stringProtoFuncArg));
}
@@ -3789,10 +3789,6 @@ QStringList QScriptEngine::importedExtensions() const
to newVariant()); you can change this behavior by installing your
own type conversion functions with qScriptRegisterMetaType().
- \warning This function is not available with MSVC 6. Use
- qScriptValueFromValue() instead if you need to support that
- version of the compiler.
-
\sa fromScriptValue(), qScriptRegisterMetaType()
*/
@@ -3806,10 +3802,6 @@ QStringList QScriptEngine::importedExtensions() const
description of the built-in type conversion provided by
QtScript.
- \warning This function is not available with MSVC 6. Use
- qScriptValueToValue() or qscriptvalue_cast() instead if you need
- to support that version of the compiler.
-
\sa toScriptValue(), qScriptRegisterMetaType()
*/
@@ -3817,29 +3809,35 @@ QStringList QScriptEngine::importedExtensions() const
\fn QScriptValue qScriptValueFromValue(QScriptEngine *engine, const T &value)
\since 4.3
\relates QScriptEngine
+ \obsolete
Creates a QScriptValue using the given \a engine with the given \a
value of template type \c{T}.
This function is equivalent to QScriptEngine::toScriptValue().
- It is provided as a work-around for MSVC 6, which doesn't support
- member template functions.
- \sa qScriptValueToValue()
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
+
+ \sa QScriptEngine::toScriptValue(), qscriptvalue_cast
*/
/*!
\fn T qScriptValueToValue(const QScriptValue &value)
\since 4.3
\relates QScriptEngine
+ \obsolete
Returns the given \a value converted to the template type \c{T}.
This function is equivalent to QScriptEngine::fromScriptValue().
- It is provided as a work-around for MSVC 6, which doesn't
- support member template functions.
- \sa qScriptValueFromValue()
+ \note This function was provided as a workaround for MSVC 6
+ which did not support member template functions. It is advised
+ to use the other form in new code.
+
+ \sa QScriptEngine::fromScriptValue()
*/
/*!
@@ -3858,7 +3856,7 @@ QStringList QScriptEngine::importedExtensions() const
\l{Conversion Between QtScript and C++ Types} for more information
about the restrictions on types that can be used with QScriptValue.
- \sa qScriptValueFromValue()
+ \sa QScriptEngine::fromScriptValue()
*/
/*!
diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h
index c1b353a..6d2616f 100644
--- a/src/script/api/qscriptengine.h
+++ b/src/script/api/qscriptengine.h
@@ -65,13 +65,11 @@ inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext *, QScriptEngin
class QRegExp;
#endif
-#ifndef QT_NO_MEMBER_TEMPLATES
template <typename T>
inline QScriptValue qScriptValueFromValue(QScriptEngine *, const T &);
template <typename T>
-inline T qScriptValueToValue(const QScriptValue &);
-#endif
+inline T qscriptvalue_cast(const QScriptValue &);
class QScriptSyntaxCheckResultPrivate;
class Q_SCRIPT_EXPORT QScriptSyntaxCheckResult
@@ -196,9 +194,7 @@ public:
QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor = QScriptValue());
-# ifndef QT_NO_MEMBER_TEMPLATES
template <class T> QScriptValue scriptValueFromQMetaObject();
-# endif // QT_NO_MEMBER_TEMPLATES
#endif // QT_NO_QOBJECT
@@ -213,7 +209,6 @@ public:
-#ifndef QT_NO_MEMBER_TEMPLATES
template <typename T>
inline QScriptValue toScriptValue(const T &value)
{
@@ -222,9 +217,8 @@ public:
template <typename T>
inline T fromScriptValue(const QScriptValue &value)
{
- return qScriptValueToValue<T>(value);
+ return qscriptvalue_cast<T>(value);
}
-#endif // QT_NO_MEMBER_TEMPLATES
void installTranslatorFunctions(const QScriptValue &object = QScriptValue());
@@ -285,19 +279,6 @@ private:
};
#ifndef QT_NO_QOBJECT
-template <class T>
-inline QScriptValue qScriptValueFromQMetaObject(
- QScriptEngine *engine
-#ifndef qdoc
- , T * /* dummy */ = 0
-#endif
- )
-{
- typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *);
- ConstructPtr cptr = qscriptQMetaObjectConstructor<T>;
- return engine->newQMetaObject(&T::staticMetaObject,
- engine->newFunction(reinterpret_cast<QScriptEngine::FunctionWithArgSignature>(cptr), 0));
-}
#define Q_SCRIPT_DECLARE_QMETAOBJECT(T, _Arg1) \
template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext *ctx, QScriptEngine *eng, T *) \
@@ -311,12 +292,26 @@ template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext *
return o; \
}
-# ifndef QT_NO_MEMBER_TEMPLATES
- template <class T> QScriptValue QScriptEngine::scriptValueFromQMetaObject()
- {
- return qScriptValueFromQMetaObject<T>(this);
- }
-# endif // QT_NO_MEMBER_TEMPLATES
+template <class T> QScriptValue QScriptEngine::scriptValueFromQMetaObject()
+{
+ typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *);
+ ConstructPtr cptr = qscriptQMetaObjectConstructor<T>;
+ return newQMetaObject(&T::staticMetaObject,
+ newFunction(reinterpret_cast<FunctionWithArgSignature>(cptr), 0));
+}
+
+#ifdef QT_DEPRECATED
+template <class T>
+inline QT_DEPRECATED QScriptValue qScriptValueFromQMetaObject(
+ QScriptEngine *engine
+#ifndef qdoc
+ , T * /* dummy */ = 0
+#endif
+ )
+{
+ return engine->scriptValueFromQMetaObject<T>();
+}
+#endif
#endif // QT_NO_QOBJECT
@@ -337,10 +332,7 @@ inline QScriptValue qScriptValueFromValue(QScriptEngine *engine, const T &t)
template <>
inline QScriptValue qScriptValueFromValue<QVariant>(QScriptEngine *engine, const QVariant &v)
{
- QScriptValue result = qScriptValueFromValue_helper(engine, v.userType(), v.data());
- if (!result.isValid())
- result = engine->newVariant(v);
- return result;
+ return qScriptValueFromValue_helper(engine, v.userType(), v.data());
}
inline bool qscriptvalue_cast_helper(const QScriptValue &value, int type, void *ptr)
@@ -349,11 +341,7 @@ inline bool qscriptvalue_cast_helper(const QScriptValue &value, int type, void *
}
template<typename T>
-T qscriptvalue_cast(const QScriptValue &value
-#if !defined qdoc && defined Q_CC_MSVC && _MSC_VER < 1300
-, T * = 0
-#endif
- )
+T qscriptvalue_cast(const QScriptValue &value)
{
T t;
const int id = qMetaTypeId<T>();
@@ -366,19 +354,19 @@ T qscriptvalue_cast(const QScriptValue &value
return T();
}
-#if !defined Q_CC_MSVC || _MSC_VER >= 1300
template <>
inline QVariant qscriptvalue_cast<QVariant>(const QScriptValue &value)
{
return value.toVariant();
}
-#endif
+#ifdef QT_DEPRECATED
template <typename T>
-inline T qScriptValueToValue(const QScriptValue &value)
+inline QT_DEPRECATED T qScriptValueToValue(const QScriptValue &value)
{
return qscriptvalue_cast<T>(value);
}
+#endif
inline void qScriptRegisterMetaType_helper(QScriptEngine *eng, int type,
QScriptEngine::MarshalFunction mf,
@@ -418,7 +406,7 @@ QScriptValue qScriptValueFromSequence(QScriptEngine *eng, const Container &cont)
typename Container::const_iterator it;
quint32 i;
for (it = begin, i = 0; it != end; ++it, ++i)
- a.setProperty(i, qScriptValueFromValue(eng, *it));
+ a.setProperty(i, eng->toScriptValue(*it));
return a;
}
@@ -428,11 +416,7 @@ void qScriptValueToSequence(const QScriptValue &value, Container &cont)
quint32 len = value.property(QLatin1String("length")).toUInt32();
for (quint32 i = 0; i < len; ++i) {
QScriptValue item = value.property(i);
-#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET
- cont.push_back(qscriptvalue_cast<Container::value_type>(item));
-#else
cont.push_back(qscriptvalue_cast<typename Container::value_type>(item));
-#endif
}
}
diff --git a/src/script/api/qscriptprogram.cpp b/src/script/api/qscriptprogram.cpp
index 31af9a0..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
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index e289636..91ce9c8 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -145,11 +145,11 @@
\value PropertySetter The property is defined by a function which will be called to set the property value.
- \value QObjectMember This flag is used to indicate that an existing property is a QObject member (a property or method).
+ \omitvalue QObjectMember This flag is used to indicate that an existing property is a QObject member (a property or method).
\value KeepExistingFlags This value is used to indicate to setProperty() that the property's flags should be left unchanged. If the property doesn't exist, the default flags (0) will be used.
- \value UserRange Flags in this range are not used by Qt Script, and can be used for custom purposes.
+ \omitvalue UserRange Flags in this range are not used by Qt Script, and can be used for custom purposes.
*/
/*!
@@ -536,7 +536,12 @@ void QScriptValue::setPrototype(const QScriptValue &prototype)
Q_D(QScriptValue);
if (!d || !d->isObject())
return;
- if (prototype.isValid() && QScriptValuePrivate::getEngine(prototype)
+
+ JSC::JSValue other = d->engine->scriptValueToJSCValue(prototype);
+ if (!other || !(other.isObject() || other.isNull()))
+ return;
+
+ if (QScriptValuePrivate::getEngine(prototype)
&& (QScriptValuePrivate::getEngine(prototype) != d->engine)) {
qWarning("QScriptValue::setPrototype() failed: "
"cannot set a prototype created in "
@@ -544,7 +549,6 @@ void QScriptValue::setPrototype(const QScriptValue &prototype)
return;
}
JSC::JSObject *thisObject = JSC::asObject(d->jscValue);
- JSC::JSValue other = d->engine->scriptValueToJSCValue(prototype);
// check for cycle
JSC::JSValue nextPrototypeValue = other;
@@ -693,10 +697,6 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs)
return false;
case Number:
-#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET
- if (qIsNaN(lhs.toNumber()) || qIsNaN(rhs.toNumber()))
- return false;
-#endif
return lhs.toNumber() < rhs.toNumber();
case Boolean:
@@ -719,13 +719,7 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs)
if (lhs.isString() && rhs.isString())
return lhs.toString() < rhs.toString();
- qsreal n1 = lhs.toNumber();
- qsreal n2 = rhs.toNumber();
-#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET
- if (qIsNaN(n1) || qIsNaN(n2))
- return false;
-#endif
- return n1 < n2;
+ return lhs.toNumber() < rhs.toNumber();
}
static bool Equals(QScriptValue lhs, QScriptValue rhs)
@@ -1731,7 +1725,14 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args)
QVarLengthArray<JSC::JSValue, 8> argsVector(args.size());
for (int i = 0; i < args.size(); ++i) {
- if (!args.at(i).isValid())
+ QScriptValue arg = args.at(i);
+ if (QScriptValuePrivate::getEngine(arg) != d->engine && QScriptValuePrivate::getEngine(arg)) {
+ qWarning("QScriptValue::construct() failed: "
+ "cannot construct function with argument created in "
+ "a different engine");
+ return QScriptValue();
+ }
+ if (!arg.isValid())
argsVector[i] = JSC::jsUndefined();
else
argsVector[i] = d->engine->scriptValueToJSCValue(args.at(i));
@@ -1781,6 +1782,12 @@ QScriptValue QScriptValue::construct(const QScriptValue &arguments)
JSC::ExecState *exec = d->engine->currentFrame;
+ if (QScriptValuePrivate::getEngine(arguments) != d->engine && QScriptValuePrivate::getEngine(arguments)) {
+ qWarning("QScriptValue::construct() failed: "
+ "cannot construct function with argument created in "
+ "a different engine");
+ return QScriptValue();
+ }
JSC::JSValue array = d->engine->scriptValueToJSCValue(arguments);
// copied from runtime/FunctionPrototype.cpp, functionProtoFuncApply()
JSC::MarkedArgumentBuffer applyArgs;
diff --git a/src/script/api/qscriptvalueiterator.cpp b/src/script/api/qscriptvalueiterator.cpp
index c188945..5f53b46 100644
--- a/src/script/api/qscriptvalueiterator.cpp
+++ b/src/script/api/qscriptvalueiterator.cpp
@@ -162,7 +162,7 @@ QScriptValueIterator::~QScriptValueIterator()
bool QScriptValueIterator::hasNext() const
{
Q_D(const QScriptValueIterator);
- if (!d)
+ if (!d || !d->engine())
return false;
const_cast<QScriptValueIteratorPrivate*>(d)->ensureInitialized();
@@ -198,7 +198,7 @@ void QScriptValueIterator::next()
bool QScriptValueIterator::hasPrevious() const
{
Q_D(const QScriptValueIterator);
- if (!d)
+ if (!d || !d->engine())
return false;
const_cast<QScriptValueIteratorPrivate*>(d)->ensureInitialized();
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index 56f7920..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)
@@ -223,7 +226,7 @@ JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC::
eng_p->pushContext(exec, thisValue, args, callee);
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
- QVariant result = scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx));
+ QVariant result = scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx));
eng_p->popContext();
eng_p->currentFrame = oldFrame;
return QScriptEnginePrivate::jscValueFromVariant(exec, result);
@@ -251,7 +254,7 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue defaultObject = ctx->thisObject();
- QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)));
+ QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx)));
if (!result.isObject())
result = defaultObject;
eng_p->popContext();
@@ -268,7 +271,7 @@ bool ClassObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exe
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
QScript::SaveFrameHelper saveFrame(eng_p, exec);
args << eng_p->scriptValueFromJSCValue(object) << eng_p->scriptValueFromJSCValue(value);
- QVariant result = scriptClass()->extension(QScriptClass::HasInstance, qVariantFromValue(args));
+ QVariant result = scriptClass()->extension(QScriptClass::HasInstance, QVariant::fromValue(args));
return result.toBool();
}
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index e138193..cee8319 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -664,7 +664,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
if (actual.isNumber()) {
int ival = QScriptEnginePrivate::toInt32(exec, actual);
if (m.valueToKey(ival) != 0) {
- qVariantSetValue(v, ival);
+ v.setValue(ival);
converted = true;
matchDistance += 10;
}
@@ -672,7 +672,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
JSC::UString sval = QScriptEnginePrivate::toString(exec, actual);
int ival = m.keyToValue(convertToLatin1(sval));
if (ival != -1) {
- qVariantSetValue(v, ival);
+ v.setValue(ival);
converted = true;
matchDistance += 10;
}
@@ -1668,7 +1668,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec
QString name;
if (args.size() != 0)
name = args.at(0).toString(exec);
- QObject *child = qFindChild<QObject*>(obj, name);
+ QObject *child = obj->findChild<QObject*>(name);
QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject;
return engine->newQObject(child, QScriptEngine::QtOwnership, opt);
}
@@ -1709,10 +1709,10 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *e
}
} else {
const QString name(args.at(0).toString(exec));
- children = qFindChildren<QObject*>(obj, name);
+ children = obj->findChildren<QObject*>(name);
}
} else {
- children = qFindChildren<QObject*>(obj, QString());
+ children = obj->findChildren<QObject*>(QString());
}
// create the result array with the children
const int length = children.size();
diff --git a/src/script/script.pro b/src/script/script.pro
index 63917b1..c558ba8 100644
--- a/src/script/script.pro
+++ b/src/script/script.pro
@@ -7,7 +7,7 @@ DEFINES += QT_NO_USING_NAMESPACE
DEFINES += QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO
#win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 ### FIXME
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
@@ -39,10 +39,18 @@ wince* {
LIBS += -lmmtimer
}
-mac {
+!qpa:mac {
DEFINES += ENABLE_JSC_MULTIPLE_THREADS=0
LIBS_PRIVATE += -framework AppKit
}
+qpa:mac {
+ DEFINES += ENABLE_JSC_MULTIPLE_THREADS=0
+ contains(QT_CONFIG, coreservices) {
+ LIBS_PRIVATE += -framework CoreServices
+ } else {
+ LIBS_PRIVATE += -framework CoreFoundation
+ }
+}
include($$WEBKITDIR/JavaScriptCore/JavaScriptCore.pri)
@@ -65,7 +73,7 @@ INCLUDEPATH += $$WEBKITDIR/JavaScriptCore/generated
# This line copied from WebCore.pro
DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 WTF_CHANGES=1
-DEFINES += NDEBUG
+CONFIG(release, debug|release):DEFINES += NDEBUG
solaris-g++:isEqual(QT_ARCH,sparc) {
CONFIG -= separate_debug_info
@@ -93,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/scripttools/debugging/qscriptdebuggercommand.cpp b/src/scripttools/debugging/qscriptdebuggercommand.cpp
index 15a5969..f026c93 100644
--- a/src/scripttools/debugging/qscriptdebuggercommand.cpp
+++ b/src/scripttools/debugging/qscriptdebuggercommand.cpp
@@ -256,7 +256,7 @@ QScriptBreakpointData QScriptDebuggerCommand::breakpointData() const
void QScriptDebuggerCommand::setBreakpointData(const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerCommand);
- d->attributes[BreakpointData] = qVariantFromValue(data);
+ d->attributes[BreakpointData] = QVariant::fromValue(data);
}
QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const
@@ -268,7 +268,7 @@ QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const
void QScriptDebuggerCommand::setScriptValue(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerCommand);
- d->attributes[ScriptValue] = qVariantFromValue(value);
+ d->attributes[ScriptValue] = QVariant::fromValue(value);
}
int QScriptDebuggerCommand::contextIndex() const
@@ -316,7 +316,7 @@ QScriptDebuggerValue QScriptDebuggerCommand::subordinateScriptValue() const
void QScriptDebuggerCommand::setSubordinateScriptValue(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerCommand);
- d->attributes[SubordinateScriptValue] = qVariantFromValue(value);
+ d->attributes[SubordinateScriptValue] = QVariant::fromValue(value);
}
int QScriptDebuggerCommand::snapshotId() const
diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
index a555eba..adc5d6d 100644
--- a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
+++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
@@ -229,11 +229,11 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
case QScriptDebuggerCommand::ScriptsCheckpoint:
backend->scriptsCheckpoint();
- response.setResult(qVariantFromValue(backend->scriptsDelta()));
+ response.setResult(QVariant::fromValue(backend->scriptsDelta()));
break;
case QScriptDebuggerCommand::GetScriptsDelta:
- response.setResult(qVariantFromValue(backend->scriptsDelta()));
+ response.setResult(QVariant::fromValue(backend->scriptsDelta()));
break;
case QScriptDebuggerCommand::ResolveScript:
@@ -302,7 +302,7 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
} break;
case QScriptDebuggerCommand::ContextsCheckpoint: {
- response.setResult(qVariantFromValue(backend->contextsCheckpoint()));
+ response.setResult(QVariant::fromValue(backend->contextsCheckpoint()));
} break;
case QScriptDebuggerCommand::GetPropertyExpressionValue: {
@@ -441,7 +441,7 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
result.addedProperties.append(dest);
}
backend->setIgnoreExceptions(didIgnoreExceptions);
- response.setResult(qVariantFromValue(result));
+ response.setResult(QVariant::fromValue(result));
} break;
case QScriptDebuggerCommand::DeleteScriptObjectSnapshot: {
diff --git a/src/scripttools/debugging/qscriptdebuggerconsole.cpp b/src/scripttools/debugging/qscriptdebuggerconsole.cpp
index a2a7cf2..bab3c9f 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsole.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsole.cpp
@@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE
static QScriptValue debuggerResponseToScriptValue(QScriptEngine *eng, const QScriptDebuggerResponse &in)
{
QScriptValue out = eng->newObject();
- out.setProperty(QString::fromLatin1("result"), qScriptValueFromValue(eng, in.result()));
+ out.setProperty(QString::fromLatin1("result"), eng->toScriptValue(in.result()));
out.setProperty(QString::fromLatin1("error"), QScriptValue(eng, in.error()));
out.setProperty(QString::fromLatin1("async"), QScriptValue(eng, in.async()));
return out;
@@ -122,7 +122,7 @@ static QScriptValue breakpointMapToScriptValue(QScriptEngine *eng, const QScript
QScriptValue out = eng->newObject();
QScriptBreakpointMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
- out.setProperty(QString::number(it.key()), qScriptValueFromValue(eng, it.value()));
+ out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value()));
}
return out;
}
@@ -155,7 +155,7 @@ static QScriptValue scriptMapToScriptValue(QScriptEngine *eng, const QScriptScri
QScriptValue out = eng->newObject();
QScriptScriptMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
- out.setProperty(QString::number(it.key()), qScriptValueFromValue(eng, it.value()));
+ out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value()));
}
return out;
}
@@ -175,8 +175,8 @@ static QScriptValue consoleCommandToScriptValue(
out.setProperty(QString::fromLatin1("group"), QScriptValue(eng, in->group()));
out.setProperty(QString::fromLatin1("shortDescription"), QScriptValue(eng, in->shortDescription()));
out.setProperty(QString::fromLatin1("longDescription"), QScriptValue(eng, in->longDescription()));
- out.setProperty(QString::fromLatin1("aliases"), qScriptValueFromValue(eng, in->aliases()));
- out.setProperty(QString::fromLatin1("seeAlso"), qScriptValueFromValue(eng, in->seeAlso()));
+ out.setProperty(QString::fromLatin1("aliases"), eng->toScriptValue(in->aliases()));
+ out.setProperty(QString::fromLatin1("seeAlso"), eng->toScriptValue(in->seeAlso()));
return out;
}
@@ -207,7 +207,7 @@ static QScriptValue consoleCommandGroupMapToScriptValue(
QScriptValue out = eng->newObject();
QScriptDebuggerConsoleCommandGroupMap::const_iterator it;
for (it = in.constBegin(); it != in.constEnd(); ++it) {
- out.setProperty(it.key(), qScriptValueFromValue(eng, it.value()));
+ out.setProperty(it.key(), eng->toScriptValue(it.value()));
}
return out;
}
@@ -238,7 +238,7 @@ static QScriptValue debuggerScriptValuePropertyToScriptValue(QScriptEngine *eng,
{
QScriptValue out = eng->newObject();
out.setProperty(QString::fromLatin1("name"), QScriptValue(eng, in.name()));
- out.setProperty(QString::fromLatin1("value"), qScriptValueFromValue(eng, in.value()));
+ out.setProperty(QString::fromLatin1("value"), eng->toScriptValue(in.value()));
out.setProperty(QString::fromLatin1("valueAsString"), QScriptValue(eng, in.valueAsString()));
out.setProperty(QString::fromLatin1("flags"), QScriptValue(eng, static_cast<int>(in.flags())));
return out;
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp b/src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp
index 88dffc2..8824d48 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp
@@ -163,10 +163,10 @@ private:
InputEdit *inputEdit;
};
-class OutputEdit : public QPlainTextEdit
+class QScriptDebuggerConsoleWidgetOutputEdit : public QPlainTextEdit
{
public:
- OutputEdit(QWidget *parent = 0)
+ QScriptDebuggerConsoleWidgetOutputEdit(QWidget *parent = 0)
: QPlainTextEdit(parent)
{
setFrameShape(QFrame::NoFrame);
@@ -206,7 +206,7 @@ public:
void _q_onCompletionTaskFinished();
CommandLine *commandLine;
- OutputEdit *outputEdit;
+ QScriptDebuggerConsoleWidgetOutputEdit *outputEdit;
int historyIndex;
QString newInput;
};
@@ -320,7 +320,7 @@ QScriptDebuggerConsoleWidget::QScriptDebuggerConsoleWidget(QWidget *parent)
Q_D(QScriptDebuggerConsoleWidget);
d->commandLine = new CommandLine();
d->commandLine->setPrompt(QString::fromLatin1("qsdb>"));
- d->outputEdit = new OutputEdit();
+ d->outputEdit = new QScriptDebuggerConsoleWidgetOutputEdit();
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setSpacing(0);
vbox->setMargin(0);
diff --git a/src/scripttools/debugging/qscriptdebuggerevent.cpp b/src/scripttools/debugging/qscriptdebuggerevent.cpp
index 9d3bc99..26a1c26 100644
--- a/src/scripttools/debugging/qscriptdebuggerevent.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerevent.cpp
@@ -216,7 +216,7 @@ QScriptDebuggerValue QScriptDebuggerEvent::scriptValue() const
void QScriptDebuggerEvent::setScriptValue(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerEvent);
- d->attributes[Value] = qVariantFromValue(value);
+ d->attributes[Value] = QVariant::fromValue(value);
}
void QScriptDebuggerEvent::setNestedEvaluate(bool nested)
diff --git a/src/scripttools/debugging/qscriptdebuggerresponse.cpp b/src/scripttools/debugging/qscriptdebuggerresponse.cpp
index 46cec56..af338f2 100644
--- a/src/scripttools/debugging/qscriptdebuggerresponse.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerresponse.cpp
@@ -162,49 +162,49 @@ void QScriptDebuggerResponse::setResult(const QString &value)
void QScriptDebuggerResponse::setResult(const QScriptBreakpointData &data)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(data);
+ d->result = QVariant::fromValue(data);
}
void QScriptDebuggerResponse::setResult(const QScriptBreakpointMap &breakpoints)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(breakpoints);
+ d->result = QVariant::fromValue(breakpoints);
}
void QScriptDebuggerResponse::setResult(const QScriptScriptMap &scripts)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(scripts);
+ d->result = QVariant::fromValue(scripts);
}
void QScriptDebuggerResponse::setResult(const QScriptScriptData &data)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(data);
+ d->result = QVariant::fromValue(data);
}
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValue &value)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(value);
+ d->result = QVariant::fromValue(value);
}
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValueList &values)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(values);
+ d->result = QVariant::fromValue(values);
}
void QScriptDebuggerResponse::setResult(const QScriptDebuggerValuePropertyList &props)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(props);
+ d->result = QVariant::fromValue(props);
}
void QScriptDebuggerResponse::setResult(const QScriptContextInfo &info)
{
Q_D(QScriptDebuggerResponse);
- d->result = qVariantFromValue(info);
+ d->result = QVariant::fromValue(info);
}
int QScriptDebuggerResponse::resultAsInt() const
diff --git a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
index 348e912..37634c8 100644
--- a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp
@@ -227,7 +227,7 @@ void QScriptDebuggerScriptedConsoleCommandJob::handleResponse(
QScriptEngine *engine = d->command->globalObject.engine();
engine->setGlobalObject(d->command->globalObject);
QScriptValueList args;
- args.append(qScriptValueFromValue(engine, response));
+ args.append(engine->toScriptValue(response));
args.append(QScriptValue(engine, commandId));
QScriptDebuggerConsoleGlobalObject *global;
global = qobject_cast<QScriptDebuggerConsoleGlobalObject*>(d->command->globalObject.toQObject());
diff --git a/src/scripttools/debugging/qscriptdebugoutputwidget.cpp b/src/scripttools/debugging/qscriptdebugoutputwidget.cpp
index c2bdc22..5bd3d48 100644
--- a/src/scripttools/debugging/qscriptdebugoutputwidget.cpp
+++ b/src/scripttools/debugging/qscriptdebugoutputwidget.cpp
@@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE
namespace {
-class OutputEdit : public QPlainTextEdit
+class QScriptDebugOutputWidgetOutputEdit : public QPlainTextEdit
{
public:
- OutputEdit(QWidget *parent = 0)
+ QScriptDebugOutputWidgetOutputEdit(QWidget *parent = 0)
: QPlainTextEdit(parent)
{
setReadOnly(true);
@@ -85,7 +85,7 @@ public:
QScriptDebugOutputWidgetPrivate();
~QScriptDebugOutputWidgetPrivate();
- OutputEdit *outputEdit;
+ QScriptDebugOutputWidgetOutputEdit *outputEdit;
};
QScriptDebugOutputWidgetPrivate::QScriptDebugOutputWidgetPrivate()
@@ -100,7 +100,7 @@ QScriptDebugOutputWidget::QScriptDebugOutputWidget(QWidget *parent)
: QScriptDebugOutputWidgetInterface(*new QScriptDebugOutputWidgetPrivate, parent, 0)
{
Q_D(QScriptDebugOutputWidget);
- d->outputEdit = new OutputEdit();
+ d->outputEdit = new QScriptDebugOutputWidgetOutputEdit();
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
vbox->setSpacing(0);
diff --git a/src/scripttools/debugging/qscripterrorlogwidget.cpp b/src/scripttools/debugging/qscripterrorlogwidget.cpp
index a4851c0..904cb90 100644
--- a/src/scripttools/debugging/qscripterrorlogwidget.cpp
+++ b/src/scripttools/debugging/qscripterrorlogwidget.cpp
@@ -52,10 +52,10 @@ QT_BEGIN_NAMESPACE
namespace {
-class OutputEdit : public QTextEdit
+class QScriptErrorLogWidgetOutputEdit : public QTextEdit
{
public:
- OutputEdit(QWidget *parent = 0)
+ QScriptErrorLogWidgetOutputEdit(QWidget *parent = 0)
: QTextEdit(parent)
{
setReadOnly(true);
@@ -80,7 +80,7 @@ public:
QScriptErrorLogWidgetPrivate();
~QScriptErrorLogWidgetPrivate();
- OutputEdit *outputEdit;
+ QScriptErrorLogWidgetOutputEdit *outputEdit;
};
QScriptErrorLogWidgetPrivate::QScriptErrorLogWidgetPrivate()
@@ -95,7 +95,7 @@ QScriptErrorLogWidget::QScriptErrorLogWidget(QWidget *parent)
: QScriptErrorLogWidgetInterface(*new QScriptErrorLogWidgetPrivate, parent, 0)
{
Q_D(QScriptErrorLogWidget);
- d->outputEdit = new OutputEdit();
+ d->outputEdit = new QScriptErrorLogWidgetOutputEdit();
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
vbox->setSpacing(0);
diff --git a/src/scripttools/scripttools.pro b/src/scripttools/scripttools.pro
index b1df7aa..061dea5 100644
--- a/src/scripttools/scripttools.pro
+++ b/src/scripttools/scripttools.pro
@@ -5,7 +5,7 @@ DEFINES += QT_BUILD_SCRIPTTOOLS_LIB
DEFINES += QT_NO_USING_NAMESPACE
#win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript
include(../qbase.pri)
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 495b1a6..49e7f13 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -420,10 +420,10 @@ QVariant QMYSQLResult::handle() const
{
#if MYSQL_VERSION_ID >= 40108
if(d->preparedQuery)
- return d->meta ? qVariantFromValue(d->meta) : qVariantFromValue(d->stmt);
+ return d->meta ? QVariant::fromValue(d->meta) : qVariantFromValue(d->stmt);
else
#endif
- return qVariantFromValue(d->result);
+ return QVariant::fromValue(d->result);
}
void QMYSQLResult::cleanup()
@@ -1432,7 +1432,7 @@ QSqlRecord QMYSQLDriver::record(const QString& tablename) const
QVariant QMYSQLDriver::handle() const
{
- return qVariantFromValue(d->mysql);
+ return QVariant::fromValue(d->mysql);
}
bool QMYSQLDriver::beginTransaction()
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index 4051c6c..8500d25 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -331,9 +331,9 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in
SQLT_FLT, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
break;
case QVariant::UserType:
- if (qVariantCanConvert<QOCIRowIdPointer>(val) && !isOutValue(pos)) {
+ if (val.canConvert<QOCIRowIdPointer>() && !isOutValue(pos)) {
// use a const pointer to prevent a detach
- const QOCIRowIdPointer rptr = qVariantValue<QOCIRowIdPointer>(val);
+ const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
r = OCIBindByPos(sql, hbnd, err,
pos + 1,
// it's an IN value, so const_cast is ok
@@ -1454,8 +1454,8 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
break;
}
case QVariant::UserType:
- if (qVariantCanConvert<QOCIRowIdPointer>(val)) {
- const QOCIRowIdPointer rptr = qVariantValue<QOCIRowIdPointer>(val);
+ if (val.canConvert<QOCIRowIdPointer>()) {
+ const QOCIRowIdPointer rptr = qvariant_cast<QOCIRowIdPointer>(val);
*reinterpret_cast<OCIRowid**>(dataPtr) = rptr->id;
columns[i].lengths[row] = 0;
break;
@@ -1809,7 +1809,7 @@ QOCIResult::~QOCIResult()
QVariant QOCIResult::handle() const
{
- return qVariantFromValue(d->sql);
+ return QVariant::fromValue(d->sql);
}
bool QOCIResult::reset (const QString& query)
@@ -2037,7 +2037,7 @@ QVariant QOCIResult::lastInsertId() const
int r = OCIAttrGet(d->sql, OCI_HTYPE_STMT, ptr.constData()->id,
0, OCI_ATTR_ROWID, d->err);
if (r == OCI_SUCCESS)
- return qVariantFromValue(ptr);
+ return QVariant::fromValue(ptr);
}
return QVariant();
}
@@ -2639,7 +2639,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const
QVariant QOCIDriver::handle() const
{
- return qVariantFromValue(d->env);
+ return QVariant::fromValue(d->env);
}
QString QOCIDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 8cff61b..0b534d9 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -62,15 +62,6 @@ QT_BEGIN_NAMESPACE
// undefine this to prevent initial check of the ODBC driver
#define ODBC_CHECK_DRIVER
-// newer platform SDKs use SQLLEN instead of SQLINTEGER
-#if defined(WIN32) && (_MSC_VER < 1300) && !defined(__MINGW64_VERSION_MAJOR)
-# define QSQLLEN SQLINTEGER
-# define QSQLULEN SQLUINTEGER
-#else
-# define QSQLLEN SQLLEN
-# define QSQLULEN SQLULEN
-#endif
-
static const int COLNAMESIZE = 256;
//Map Qt parameter types to ODBC types
static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT };
@@ -360,7 +351,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
{
QString fieldVal;
SQLRETURN r = SQL_ERROR;
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
// NB! colSize must be a multiple of 2 for unicode enabled DBs
if (colSize <= 0) {
@@ -400,7 +391,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
// colSize-1: remove 0 termination when there is more data to fetch
int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR);
fieldVal += fromSQLTCHAR(buf, rSize);
- if ((unsigned)lengthIndicator < colSize*sizeof(SQLTCHAR)) {
+ if (lengthIndicator < SQLLEN(colSize*sizeof(SQLTCHAR))) {
// workaround for Drivermanagers that don't return SQL_NO_DATA
break;
}
@@ -441,7 +432,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
// colSize-1: remove 0 termination when there is more data to fetch
int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator;
fieldVal += QString::fromUtf8((const char *)buf.constData(), rSize);
- if (lengthIndicator < (unsigned int)colSize) {
+ if (lengthIndicator < SQLLEN(colSize)) {
// workaround for Drivermanagers that don't return SQL_NO_DATA
break;
}
@@ -462,10 +453,10 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
QByteArray fieldVal;
SQLSMALLINT colNameLen;
SQLSMALLINT colType;
- QSQLULEN colSize;
+ SQLULEN colSize;
SQLSMALLINT colScale;
SQLSMALLINT nullable;
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
SQLRETURN r = SQL_ERROR;
QVarLengthArray<SQLTCHAR> colName(COLNAMESIZE);
@@ -499,7 +490,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
break;
if (lengthIndicator == SQL_NULL_DATA)
return QVariant(QVariant::ByteArray);
- if (lengthIndicator > QSQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) {
+ if (lengthIndicator > SQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) {
read += colSize;
colSize = 65536;
} else {
@@ -517,7 +508,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column)
static QVariant qGetIntData(SQLHANDLE hStmt, int column, bool isSigned = true)
{
SQLINTEGER intbuf = 0;
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
SQLRETURN r = SQLGetData(hStmt,
column+1,
isSigned ? SQL_C_SLONG : SQL_C_ULONG,
@@ -537,7 +528,7 @@ static QVariant qGetIntData(SQLHANDLE hStmt, int column, bool isSigned = true)
static QVariant qGetDoubleData(SQLHANDLE hStmt, int column)
{
SQLDOUBLE dblbuf;
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
SQLRETURN r = SQLGetData(hStmt,
column+1,
SQL_C_DOUBLE,
@@ -557,7 +548,7 @@ static QVariant qGetDoubleData(SQLHANDLE hStmt, int column)
static QVariant qGetBigIntData(SQLHANDLE hStmt, int column, bool isSigned = true)
{
SQLBIGINT lngbuf = 0;
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
SQLRETURN r = SQLGetData(hStmt,
column+1,
isSigned ? SQL_C_SBIGINT : SQL_C_UBIGINT,
@@ -601,7 +592,7 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i )
{
SQLSMALLINT colNameLen;
SQLSMALLINT colType;
- QSQLULEN colSize;
+ SQLULEN colSize;
SQLSMALLINT colScale;
SQLSMALLINT nullable;
SQLRETURN r = SQL_ERROR;
@@ -621,7 +612,7 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i )
return QSqlField();
}
- QSQLLEN unsignedFlag = SQL_FALSE;
+ SQLLEN unsignedFlag = SQL_FALSE;
r = SQLColAttribute (p->hStmt,
i + 1,
SQL_DESC_UNSIGNED,
@@ -1146,7 +1137,7 @@ QVariant QODBCResult::data(int field)
return d->fieldCache.at(field);
SQLRETURN r(0);
- QSQLLEN lengthIndicator = 0;
+ SQLLEN lengthIndicator = 0;
for (int i = d->fieldCacheIdx; i <= field; ++i) {
// some servers do not support fetching column n after we already
@@ -1256,7 +1247,7 @@ int QODBCResult::size()
int QODBCResult::numRowsAffected()
{
- QSQLLEN affectedRowCount = 0;
+ SQLLEN affectedRowCount = 0;
SQLRETURN r = SQLRowCount(d->hStmt, &affectedRowCount);
if (r == SQL_SUCCESS)
return affectedRowCount;
@@ -1343,8 +1334,8 @@ bool QODBCResult::exec()
SQLCloseCursor(d->hStmt);
QList<QByteArray> tmpStorage; // holds temporary buffers
- QVarLengthArray<QSQLLEN, 32> indicators(boundValues().count());
- memset(indicators.data(), 0, indicators.size() * sizeof(QSQLLEN));
+ QVarLengthArray<SQLLEN, 32> indicators(boundValues().count());
+ memset(indicators.data(), 0, indicators.size() * sizeof(SQLLEN));
// bind parameters - only positional binding allowed
QVector<QVariant>& values = boundValues();
@@ -1354,7 +1345,7 @@ bool QODBCResult::exec()
if (bindValueType(i) & QSql::Out)
values[i].detach();
const QVariant &val = values.at(i);
- QSQLLEN *ind = &indicators[i];
+ SQLLEN *ind = &indicators[i];
if (val.isNull())
*ind = SQL_NULL_DATA;
switch (val.type()) {
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp
index a044c7f..34277b3 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/sql/drivers/psql/qsql_psql.cpp
@@ -278,7 +278,7 @@ QPSQLResult::~QPSQLResult()
QVariant QPSQLResult::handle() const
{
- return qVariantFromValue(d->result);
+ return QVariant::fromValue(d->result);
}
void QPSQLResult::cleanup()
@@ -743,7 +743,7 @@ QPSQLDriver::~QPSQLDriver()
QVariant QPSQLDriver::handle() const
{
- return qVariantFromValue(d->connection);
+ return QVariant::fromValue(d->connection);
}
bool QPSQLDriver::hasFeature(DriverFeature f) const
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 54a6e43..727c4f9 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -452,7 +452,7 @@ QSqlRecord QSQLiteResult::record() const
QVariant QSQLiteResult::handle() const
{
- return qVariantFromValue(d->stmt);
+ return QVariant::fromValue(d->stmt);
}
/////////////////////////////////////////////////////////
@@ -697,7 +697,7 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const
QVariant QSQLiteDriver::handle() const
{
- return qVariantFromValue(d->access);
+ return QVariant::fromValue(d->access);
}
QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
index f58b32f..2f3c780 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
+++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
@@ -342,7 +342,7 @@ QSqlRecord QSQLite2Result::record() const
QVariant QSQLite2Result::handle() const
{
- return qVariantFromValue(d->currentMachine);
+ return QVariant::fromValue(d->currentMachine);
}
/////////////////////////////////////////////////////////
@@ -558,7 +558,7 @@ QSqlRecord QSQLite2Driver::record(const QString &tbl) const
QVariant QSQLite2Driver::handle() const
{
- return qVariantFromValue(d->access);
+ return QVariant::fromValue(d->access);
}
QString QSQLite2Driver::escapeIdentifier(const QString &identifier, IdentifierType /*type*/) const
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index ce9aae5..b0ae8d9 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -166,7 +166,7 @@ public:
static QSqlDatabase database(const QString& name, bool open);
static void addDatabase(const QSqlDatabase &db, const QString & name);
static void removeDatabase(const QString& name);
- static void invalidateDb(const QSqlDatabase &db, const QString &name);
+ static void invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn = true);
static DriverDict &driverDict();
static void cleanConnections();
};
@@ -200,7 +200,7 @@ void QSqlDatabasePrivate::cleanConnections()
QConnectionDict::iterator it = dict->begin();
while (it != dict->end()) {
- invalidateDb(it.value(), it.key());
+ invalidateDb(it.value(), it.key(), false);
++it;
}
dict->clear();
@@ -232,9 +232,9 @@ QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null()
return &n;
}
-void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name)
+void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn)
{
- if (db.d->ref != 1) {
+ if (db.d->ref != 1 && doWarn) {
qWarning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, "
"all queries will cease to work.", name.toLocal8Bit().constData());
db.d->disable();
diff --git a/src/sql/sql.pro b/src/sql/sql.pro
index a02b0f4..81aa3c0 100644
--- a/src/sql/sql.pro
+++ b/src/sql/sql.pro
@@ -5,7 +5,7 @@ DEFINES += QT_BUILD_SQL_LIB
DEFINES += QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x62000000
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
diff --git a/src/src.pro b/src/src.pro
index 868e22f..0908911 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -5,6 +5,7 @@ unset(SRC_SUBDIRS)
win32:SRC_SUBDIRS += src_winmain
symbian:SRC_SUBDIRS += src_s60main
SRC_SUBDIRS += src_corelib src_xml src_network src_sql src_testlib
+nacl: SRC_SUBDIRS -= src_network src_testlib
!symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
!contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui
!wince*:!symbian:!vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support
@@ -112,6 +113,7 @@ src_webkit_declarative.target = sub-webkitdeclarative
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/svg/svg.pro b/src/svg/svg.pro
index 7b5251a..79f284a 100644
--- a/src/svg/svg.pro
+++ b/src/svg/svg.pro
@@ -6,7 +6,7 @@ DEFINES += QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
include(../qbase.pri)
diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h
index ea9e00e..d116a6e 100644
--- a/src/testlib/qabstracttestlogger_p.h
+++ b/src/testlib/qabstracttestlogger_p.h
@@ -95,6 +95,8 @@ public:
virtual void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0) = 0;
+ virtual void registerRandomSeed(unsigned int seed) = 0;
+
static void outputString(const char *msg);
static bool isTtyOutput();
};
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index b4b0aff..e1ae534 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -384,6 +384,7 @@ namespace QTest {
}
QPlainTestLogger::QPlainTestLogger()
+: randomSeed(9), hasRandomSeed(false)
{
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
InitializeCriticalSection(&QTest::outputCriticalSection);
@@ -415,10 +416,17 @@ void QPlainTestLogger::startLogging()
QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n",
QTestResult::currentTestObjectName());
} else {
- QTest::qt_snprintf(buf, sizeof(buf),
- "********* Start testing of %s *********\n"
- "Config: Using QTest library " QTEST_VERSION_STR
- ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
+ if (hasRandomSeed) {
+ QTest::qt_snprintf(buf, sizeof(buf),
+ "********* Start testing of %s *********\n"
+ "Config: Using QTest library " QTEST_VERSION_STR
+ ", Qt %s, Random seed %d\n", QTestResult::currentTestObjectName(), qVersion(), randomSeed);
+ } else {
+ QTest::qt_snprintf(buf, sizeof(buf),
+ "********* Start testing of %s *********\n"
+ "Config: Using QTest library " QTEST_VERSION_STR
+ ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion());
+ }
}
QTest::outputMessage(buf);
}
@@ -480,4 +488,10 @@ void QPlainTestLogger::addMessage(MessageTypes type, const char *message,
QTest::printMessage(QTest::messageType2String(type), message, file, line);
}
+void QPlainTestLogger::registerRandomSeed(unsigned int seed)
+{
+ randomSeed = seed;
+ hasRandomSeed = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h
index 3c065f0..054ec1e 100644
--- a/src/testlib/qplaintestlogger_p.h
+++ b/src/testlib/qplaintestlogger_p.h
@@ -75,6 +75,10 @@ public:
void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0);
+ void registerRandomSeed(unsigned int seed);
+private:
+ unsigned int randomSeed;
+ bool hasRandomSeed;
};
QT_END_NAMESPACE
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 93632d3..3652109 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -159,7 +159,7 @@ template<> inline char *toString(const QVariant &v)
if (!v.isNull()) {
vstring.append(',');
if (v.canConvert(QVariant::String)) {
- vstring.append(qVariantValue<QString>(v).toLatin1());
+ vstring.append(qvariant_cast<QString>(v).toLatin1());
}
else {
vstring.append("<value not representable as string>");
diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h
index c73d763..28c8617 100644
--- a/src/testlib/qtest_global.h
+++ b/src/testlib/qtest_global.h
@@ -62,7 +62,7 @@ QT_MODULE(Test)
# endif
#endif
-#if (defined (Q_CC_MSVC) && _MSC_VER < 1310) || defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3)) || defined (Q_CC_NOKIAX86)
+#if defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3)) || defined (Q_CC_NOKIAX86)
# define QTEST_NO_SPECIALIZATIONS
#endif
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 97f069e..287d8e6 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -833,25 +833,46 @@ namespace QTest
{
static QObject *currentTestObject = 0;
- static struct TestFunction {
- TestFunction():function(0), data(0) {}
- ~TestFunction() { delete [] data; }
- int function;
- char *data;
- } *testFuncs;
-
+ class TestFunction {
+ public:
+ TestFunction() : function_(-1), data_(0) {}
+ void set(int function, char *data) { function_ = function; data_ = data; }
+ char *data() const { return data_; }
+ int function() const { return function_; }
+ ~TestFunction() { delete[] data_; }
+ private:
+ int function_;
+ char *data_;
+ };
/**
- * Contains the count of test functions that was supplied
- * on the command line, if any. Hence, if lastTestFuncIdx is
- * more than zero, those functions should be run instead of
+ * Contains the list of test functions that was supplied
+ * on the command line, if any. Hence, if not empty,
+ * those functions should be run instead of
* all appearing in the test case.
*/
- static int lastTestFuncIdx = -1;
+ static TestFunction * testFuncs = 0;
+ static int testFuncCount = 0;
+
+ /** Don't leak testFuncs on exit even on error */
+ static struct TestFuncCleanup
+ {
+ void cleanup()
+ {
+ delete[] testFuncs;
+ testFuncCount = 0;
+ testFuncs = 0;
+ }
+
+ ~TestFuncCleanup() { cleanup(); }
+ } testFuncCleaner;
static int keyDelay = -1;
static int mouseDelay = -1;
static int eventDelay = -1;
+ static bool randomOrder = false;
static int keyVerbose = -1;
+ static unsigned int seed = 0;
+ static bool seedSet = false;
#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
static bool noCrashHandler = false;
#endif
@@ -937,6 +958,43 @@ int Q_TESTLIB_EXPORT defaultKeyDelay()
return keyDelay;
}
+void seedRandom()
+{
+ static bool randomSeeded = false;
+ if (!randomSeeded) {
+ if (!QTest::seedSet) {
+ QElapsedTimer timer;
+ timer.start();
+ QTest::seed = timer.msecsSinceReference();
+ }
+ qsrand(QTest::seed);
+ randomSeeded = true;
+ }
+}
+
+int qTestRandomSeed()
+{
+ Q_ASSERT(QTest::seedSet);
+ return QTest::seed;
+}
+
+template<typename T>
+void swap(T * array, int pos, int otherPos)
+{
+ T tmp = array[pos];
+ array[pos] = array[otherPos];
+ array[otherPos] = tmp;
+}
+
+template<typename T>
+static void randomizeList(T * array, int size)
+{
+ for (int i = 0; i != size; i++) {
+ int pos = qrand() % size;
+ swap(array, pos, i);
+ }
+}
+
static bool isValidSlot(const QMetaMethod &sl)
{
if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty()
@@ -982,8 +1040,6 @@ static int qToInt(char *str)
Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
{
- lastTestFuncIdx = -1;
-
const char *testOptions =
" options:\n"
" -functions : Returns a list of current testfunctions\n"
@@ -996,6 +1052,9 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" -v1 : Print enter messages for each testfunction\n"
" -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n"
" -vs : Print every signal emitted\n"
+ " -random : Run testcases within each test in random order\n"
+ " -seed n : Positive integer to be used as seed for -random. If not specified,\n"
+ " the current time will be used as seed.\n"
" -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n"
" -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n"
" -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n"
@@ -1115,6 +1174,22 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
#endif
} else if (strcmp(argv[i], "-eventcounter") == 0) {
QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter);
+ } else if (strcmp(argv[i], "-random") == 0) {
+ QTest::randomOrder = true;
+ } else if (strcmp(argv[i], "-seed") == 0) {
+ bool argumentOk = false;
+ if (i + 1 < argc) {
+ char * endpt = 0;
+ long longSeed = strtol(argv[++i], &endpt, 10);
+ argumentOk = (*endpt == '\0' && longSeed >= 0);
+ QTest::seed = longSeed;
+ }
+ if (!argumentOk) {
+ printf("-seed needs an extra positive integer parameter to specify the seed\n");
+ exit(1);
+ } else {
+ QTest::seedSet = true;
+ }
} else if (strcmp(argv[i], "-minimumvalue") == 0) {
if (i + 1 >= argc) {
printf("-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n");
@@ -1181,6 +1256,10 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QString::fromLatin1(argv[i] + colon + 1);
}
} else {
+ if (!QTest::testFuncs) {
+ QTest::testFuncs = new QTest::TestFunction[512];
+ }
+
int colon = -1;
char buf[512], *data=0;
int off;
@@ -1202,17 +1281,16 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
qPrintTestSlots();
exit(1);
}
- ++QTest::lastTestFuncIdx;
- if (!QTest::testFuncs) {
- struct Cleanup { ~Cleanup() { delete[] QTest::testFuncs; } };
- static Cleanup cleanup;
- QTest::testFuncs = new TestFunction[512];
- }
- QTest::testFuncs[QTest::lastTestFuncIdx].function = idx;
- QTest::testFuncs[QTest::lastTestFuncIdx].data = data;
- QTEST_ASSERT(QTest::lastTestFuncIdx < 512);
+ testFuncs[testFuncCount].set(idx, data);
+ testFuncCount++;
+ QTEST_ASSERT(QTest::testFuncCount < 512);
}
}
+
+ if (QTest::seedSet && !QTest::randomOrder) {
+ printf("-seed requires -random\n");
+ exit(1);
+ }
}
QBenchmarkResult qMedian(const QList<QBenchmarkResult> &container)
@@ -1507,9 +1585,11 @@ static void qInvokeTestMethods(QObject *testObject)
{
const QMetaObject *metaObject = testObject->metaObject();
QTEST_ASSERT(metaObject);
-
- QTestLog::startLogging();
-
+ if (QTest::randomOrder) {
+ QTestLog::startLogging(QTest::seed);
+ } else {
+ QTestLog::startLogging();
+ }
QTestResult::setCurrentTestFunction("initTestCase");
QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
QTestTable::globalTestTable();
@@ -1525,21 +1605,31 @@ static void qInvokeTestMethods(QObject *testObject)
if(!QTestResult::skipCurrentTest() && !previousFailed) {
- if (lastTestFuncIdx >= 0) {
- for (int i = 0; i <= lastTestFuncIdx; ++i) {
- if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
- testFuncs[i].data))
+ if (QTest::testFuncs) {
+ if (QTest::randomOrder)
+ randomizeList(QTest::testFuncs, QTest::testFuncCount);
+ for (int i = 0; i != QTest::testFuncCount; i++) {
+ if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).signature(),
+ QTest::testFuncs[i].data())) {
break;
+ }
}
+ testFuncCleaner.cleanup();
} else {
int methodCount = metaObject->methodCount();
- for (int i = 0; i < methodCount; ++i) {
- QMetaMethod slotMethod = metaObject->method(i);
- if (!isValidSlot(slotMethod))
+ QMetaMethod *testMethods = new QMetaMethod[methodCount];
+ for (int i = 0; i != methodCount; i++)
+ testMethods[i] = metaObject->method(i);
+ if (QTest::randomOrder)
+ randomizeList(testMethods, methodCount);
+ for (int i = 0; i != methodCount; i++) {
+ if (!isValidSlot(testMethods[i]))
continue;
- if (!qInvokeTestMethod(slotMethod.signature()))
+ if (!qInvokeTestMethod(testMethods[i].signature()))
break;
}
+ delete[] testMethods;
+ testMethods = 0;
}
}
@@ -1569,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()
@@ -1583,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);
@@ -1730,6 +1829,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
QTestResult::setCurrentTestObject(metaObject->className());
qtest_qParseArgs(argc, argv, false);
+ if (QTest::randomOrder) {
+ seedRandom();
+ }
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
const QStringList origAppArgs(QCoreApplication::arguments());
diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp
index feb8544..7bdd34c 100644
--- a/src/testlib/qtestlightxmlstreamer.cpp
+++ b/src/testlib/qtestlightxmlstreamer.cpp
@@ -42,6 +42,7 @@
#include "qtestlightxmlstreamer.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
+#include "qtestlogger_p.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
@@ -164,8 +165,13 @@ void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element,
void QTestLightXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
- QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ if (logger()->hasRandomSeed()) {
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n <RandomSeed>%d</RandomSeed>\n",
+ qVersion(), QTEST_VERSION_STR, logger()->randomSeed() );
+ } else {
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
+ }
outputString(buf.constData());
QTest::qt_asprintf(&buf, "</Environment>\n");
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 342e9a2..ed9a005 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -168,6 +168,29 @@ namespace QTest {
}
}
+void initLogger()
+{
+ switch (QTest::logMode) {
+ case QTestLog::Plain:
+ QTest::testLogger = new QPlainTestLogger;
+ break;
+ case QTestLog::XML:{
+ if(QTest::flushMode == QTestLog::FLushOn)
+ QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
+ else
+ QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML);
+ break;
+ }case QTestLog::LightXML:{
+ if(QTest::flushMode == QTestLog::FLushOn)
+ QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
+ else
+ QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml);
+ break;
+ }case QTestLog::XunitXML:
+ QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml);
+ }
+}
+
}
QTestLog::QTestLog()
@@ -268,32 +291,20 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result)
QTest::testLogger->addBenchmarkResult(result);
}
-void QTestLog::startLogging()
+void QTestLog::startLogging(unsigned int randomSeed)
{
QTEST_ASSERT(!QTest::testLogger);
-
- switch (QTest::logMode) {
- case QTestLog::Plain:
- QTest::testLogger = new QPlainTestLogger;
- break;
- case QTestLog::XML:{
- if(QTest::flushMode == QTestLog::FLushOn)
- QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
- else
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML);
- break;
- }case QTestLog::LightXML:{
- if(QTest::flushMode == QTestLog::FLushOn)
- QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
- else
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml);
- break;
- }case QTestLog::XunitXML:
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml);
- }
-
+ QTest::initLogger();
+ QTest::testLogger->registerRandomSeed(randomSeed);
QTest::testLogger->startLogging();
+ QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler);
+}
+void QTestLog::startLogging()
+{
+ QTEST_ASSERT(!QTest::testLogger);
+ QTest::initLogger();
+ QTest::testLogger->startLogging();
QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler);
}
diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h
index 6648beb..a892d3d 100644
--- a/src/testlib/qtestlog_p.h
+++ b/src/testlib/qtestlog_p.h
@@ -83,6 +83,7 @@ public:
static void info(const char *msg, const char *file, int line);
static void startLogging();
+ static void startLogging(unsigned int randomSeed);
static void stopLogging();
static void setLogMode(LogMode mode);
@@ -97,7 +98,6 @@ public:
static void setMaxWarnings(int max);
static void setFlushMode(FlushMode mode);
-
private:
QTestLog();
~QTestLog();
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp
index 8bb4f21..86826f8 100644
--- a/src/testlib/qtestlogger.cpp
+++ b/src/testlib/qtestlogger.cpp
@@ -62,7 +62,8 @@ QTestLogger::QTestLogger(int fm)
warningCounter(0), skipCounter(0),
systemCounter(0), qdebugCounter(0),
qwarnCounter(0), qfatalCounter(0),
- infoCounter(0)
+ infoCounter(0), randomSeed_(0),
+ hasRandomSeed_(false)
{
}
@@ -133,6 +134,14 @@ void QTestLogger::stopLogging()
property->addAttribute(QTest::AI_PropertyValue, qVersion());
properties->addLogElement(property);
+ if (hasRandomSeed()) {
+ property = new QTestElement(QTest::LET_Property);
+ property->addAttribute(QTest::AI_Name, "RandomSeed");
+ QTest::qt_snprintf(buf, sizeof(buf), "%i", randomSeed());
+ property->addAttribute(QTest::AI_PropertyValue, buf);
+ properties->addLogElement(property);
+ }
+
currentLogElement->addLogElement(properties);
currentLogElement->addLogElement(iterator);
@@ -420,5 +429,21 @@ int QTestLogger::infoCount() const
return infoCounter;
}
+void QTestLogger::registerRandomSeed(unsigned int seed)
+{
+ randomSeed_ = seed;
+ hasRandomSeed_ = true;
+}
+
+unsigned int QTestLogger::randomSeed() const
+{
+ return randomSeed_;
+}
+
+bool QTestLogger::hasRandomSeed() const
+{
+ return hasRandomSeed_;
+}
+
QT_END_NAMESPACE
diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h
index bc619ee..d8867de 100644
--- a/src/testlib/qtestlogger_p.h
+++ b/src/testlib/qtestlogger_p.h
@@ -101,6 +101,9 @@ class QTestLogger : public QAbstractTestLogger
int qwarnCount() const;
int qfatalCount() const;
int infoCount() const;
+ void registerRandomSeed(unsigned int seed);
+ unsigned int randomSeed() const;
+ bool hasRandomSeed() const;
private:
QTestElement *listOfTestcases;
@@ -121,6 +124,8 @@ class QTestLogger : public QAbstractTestLogger
int qwarnCounter;
int qfatalCounter;
int infoCounter;
+ unsigned int randomSeed_;
+ bool hasRandomSeed_;
};
QT_END_NAMESPACE
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.cpp b/src/testlib/qtestresult.cpp
index cd8786b..d5d314a 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -191,10 +191,13 @@ bool QTestResult::expectFail(const char *dataIndex, const char *comment,
QTEST_ASSERT(comment);
QTEST_ASSERT(mode > 0);
- if (!isExpectFailData(dataIndex))
+ if (!isExpectFailData(dataIndex)) {
+ delete[] comment;
return true; // we don't care
+ }
if (QTest::expectFailMode) {
+ delete[] comment;
clearExpectFail();
addFailure("Already expecting a fail", file, line);
return false;
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index a9ca836..f4cb1ed 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -42,6 +42,7 @@
#include "qtestxmlstreamer.h"
#include "qtestelement.h"
#include "qtestelementattribute.h"
+#include "qtestlogger_p.h"
#include "QtTest/private/qtestlog_p.h"
#include "QtTest/private/qtestresult_p.h"
@@ -204,8 +205,13 @@ void QTestXmlStreamer::output(QTestElement *element) const
quotedTc.constData());
outputString(buf.constData());
- QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
- qVersion(), QTEST_VERSION_STR );
+ if (logger()->hasRandomSeed()) {
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n <RandomSeed>%d</RandomSeed>\n",
+ qVersion(), QTEST_VERSION_STR, logger()->randomSeed() );
+ } else {
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ qVersion(), QTEST_VERSION_STR );
+ }
outputString(buf.constData());
QTest::qt_asprintf(&buf, "</Environment>\n");
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp
index d64d7a2..827b0ad 100644
--- a/src/testlib/qxmltestlogger.cpp
+++ b/src/testlib/qxmltestlogger.cpp
@@ -93,7 +93,7 @@ namespace QTest {
QXmlTestLogger::QXmlTestLogger(XmlMode mode )
- :xmlmode(mode)
+ :xmlmode(mode), randomSeed(0), hasRandomSeed(false)
{
}
@@ -116,11 +116,20 @@ void QXmlTestLogger::startLogging()
outputString(buf.constData());
}
- QTest::qt_asprintf(&buf,
- "<Environment>\n"
- " <QtVersion>%s</QtVersion>\n"
- " <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"
- "</Environment>\n", qVersion());
+ if (hasRandomSeed) {
+ QTest::qt_asprintf(&buf,
+ "<Environment>\n"
+ " <QtVersion>%s</QtVersion>\n"
+ " <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"
+ " <RandomSeed>%d</RandomSeed>\n"
+ "</Environment>\n", qVersion(), randomSeed);
+ } else {
+ QTest::qt_asprintf(&buf,
+ "<Environment>\n"
+ " <QtVersion>%s</QtVersion>\n"
+ " <QTestVersion>"QTEST_VERSION_STR"</QTestVersion>\n"
+ "</Environment>\n", qVersion());
+ }
outputString(buf.constData());
}
@@ -441,4 +450,10 @@ int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src)
return allocateStringFn(str, src, QXmlTestLogger::xmlCdata);
}
+void QXmlTestLogger::registerRandomSeed(unsigned int seed)
+{
+ randomSeed = seed;
+ hasRandomSeed = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h
index 567d7b3..f815103 100644
--- a/src/testlib/qxmltestlogger_p.h
+++ b/src/testlib/qxmltestlogger_p.h
@@ -79,6 +79,8 @@ public:
void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0);
+ void registerRandomSeed(unsigned int seed);
+
static int xmlCdata(QTestCharBuffer *dest, char const* src);
static int xmlQuote(QTestCharBuffer *dest, char const* src);
static int xmlCdata(QTestCharBuffer *dest, char const* src, size_t n);
@@ -86,6 +88,8 @@ public:
private:
XmlMode xmlmode;
+ unsigned int randomSeed;
+ bool hasRandomSeed;
};
QT_END_NAMESPACE
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index a8186d8..c25d23d 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -70,8 +70,16 @@ wince*::LIBS += libcmt.lib \
coredll.lib \
winsock.lib
mac:LIBS += -framework IOKit \
- -framework ApplicationServices \
-framework Security
+!qpa:mac: LIBS += -framework ApplicationServices
+qpa:mac: {
+ contains(QT_CONFIG, coreservices) {
+ LIBS_PRIVATE += -framework CoreServices
+ } else {
+ LIBS_PRIVATE += -framework CoreFoundation
+ }
+}
+
include(../qbase.pri)
QMAKE_TARGET_PRODUCT = QTestLib
QMAKE_TARGET_DESCRIPTION = Qt \
diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri
index 1aa8121..f48c8c1 100644
--- a/src/tools/bootstrap/bootstrap.pri
+++ b/src/tools/bootstrap/bootstrap.pri
@@ -22,7 +22,9 @@ DEFINES += \
QT_NO_TEXTSTREAM \
QT_NO_THREAD \
QT_NO_UNICODETABLES \
- QT_NO_USING_NAMESPACE
+ QT_NO_USING_NAMESPACE \
+ QT_NO_DEPRECATED
+
win32:DEFINES += QT_NODLL
INCLUDEPATH += $$QT_BUILD_TREE/include \
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index ba844ea..9e5845c 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -25,7 +25,9 @@ DEFINES += \
QT_NO_TEXTSTREAM \
QT_NO_THREAD \
QT_NO_UNICODETABLES \
- QT_NO_USING_NAMESPACE
+ QT_NO_USING_NAMESPACE \
+ QT_NO_DEPRECATED
+
win32:DEFINES += QT_NODLL
INCLUDEPATH += $$QT_BUILD_TREE/include \
@@ -57,6 +59,8 @@ SOURCES += \
../../corelib/io/qdiriterator.cpp \
../../corelib/io/qfile.cpp \
../../corelib/io/qfileinfo.cpp \
+ ../../corelib/io/qfilesystementry.cpp \
+ ../../corelib/io/qfilesystemengine.cpp \
../../corelib/io/qfsfileengine.cpp \
../../corelib/io/qfsfileengine_iterator.cpp \
../../corelib/io/qiodevice.cpp \
@@ -65,6 +69,7 @@ SOURCES += \
../../corelib/io/qurl.cpp \
../../corelib/kernel/qmetatype.cpp \
../../corelib/kernel/qvariant.cpp \
+ ../../corelib/kernel/qsystemerror.cpp \
../../corelib/tools/qbitarray.cpp \
../../corelib/tools/qbytearray.cpp \
../../corelib/tools/qbytearraymatcher.cpp \
@@ -79,19 +84,22 @@ SOURCES += \
../../corelib/tools/qvector.cpp \
../../corelib/tools/qvsnprintf.cpp \
../../corelib/xml/qxmlutils.cpp \
- ../../corelib/xml/qxmlstream.cpp \
+ ../../corelib/xml/qxmlstream.cpp \
../../xml/dom/qdom.cpp \
../../xml/sax/qxml.cpp
-unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \
- ../../corelib/io/qfsfileengine_iterator_unix.cpp
+unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \
+ ../../corelib/io/qfilesystemiterator_unix.cpp \
+ ../../corelib/io/qfsfileengine_unix.cpp
-win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
- ../../corelib/io/qfsfileengine_iterator_win.cpp \
+win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \
+ ../../corelib/io/qfilesystemiterator_win.cpp \
+ ../../corelib/io/qfsfileengine_win.cpp \
../../corelib/plugin/qsystemlibrary.cpp \
macx: {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
+ SOURCES += ../../corelib/io/qfilesystemengine_mac.cpp
SOURCES += ../../corelib/kernel/qcore_mac.cpp
LIBS += -framework CoreServices
}
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 2cf2412..74b1ace 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -685,10 +685,13 @@ void Moc::parse()
if (parseEnum(&enumDef))
def.enumList += enumDef;
} break;
+ case SEMIC:
+ case COLON:
+ break;
default:
FunctionDef funcDef;
funcDef.access = access;
- int rewind = index;
+ int rewind = index--;
if (parseMaybeFunction(&def, &funcDef)) {
if (funcDef.isConstructor) {
if ((access == FunctionDef::Public) && funcDef.isInvokable) {
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/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 8f63054..37d012c 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -139,13 +139,17 @@ namespace {
<< indent << "QWidgetList childWidgets;\n";
}
- static inline bool isIconFormat44(const DomResourceIcon *i) {
+ static inline bool iconHasStatePixmaps(const DomResourceIcon *i) {
return i->hasElementNormalOff() || i->hasElementNormalOn() ||
i->hasElementDisabledOff() || i->hasElementDisabledOn() ||
i->hasElementActiveOff() || i->hasElementActiveOn() ||
i->hasElementSelectedOff() || i->hasElementSelectedOn();
}
+ static inline bool isIconFormat44(const DomResourceIcon *i) {
+ return iconHasStatePixmaps(i) || !i->attributeTheme().isEmpty();
+ }
+
// Check on properties. Filter out empty legacy pixmap/icon properties
// as Designer pre 4.4 used to remove missing resource references.
// This can no longer be handled by the code as we have 'setIcon(QIcon())' as well as 'QIcon icon'
@@ -258,6 +262,9 @@ IconHandle::IconHandle(const DomResourceIcon *domIcon) :
int IconHandle::compare(const IconHandle &rhs) const
{
+ if (const int comp = m_domIcon->attributeTheme().compare(rhs.m_domIcon->attributeTheme()))
+ return comp;
+
const QString normalOff = m_domIcon->hasElementNormalOff() ? m_domIcon->elementNormalOff()->text() : QString();
const QString rhsNormalOff = rhs.m_domIcon->hasElementNormalOff() ? rhs.m_domIcon->elementNormalOff()->text() : QString();
if (const int comp = normalOff.compare(rhsNormalOff))
@@ -478,7 +485,8 @@ WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) :
m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly),
m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly),
m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly),
- m_activateScripts(activateScripts), m_layoutWidget(false)
+ m_activateScripts(activateScripts), m_layoutWidget(false),
+ m_firstThemeIcon(true)
{
}
@@ -1088,6 +1096,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1;
addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan);
+ if (!node->attributeAlignment().isEmpty())
+ addArgs += QLatin1String(", ") + node->attributeAlignment();
} else {
if (layout->attributeClass() == QLatin1String("QFormLayout")) {
methodPrefix = QLatin1String("set");
@@ -1097,6 +1107,8 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName);
} else {
addArgs = itemName;
+ if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty())
+ addArgs += QLatin1String(", 0, ") + node->attributeAlignment();
}
}
@@ -1670,6 +1682,30 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
return fontName;
}
+// Post 4.4 write resource icon
+static void writeResourceIcon(QTextStream &output,
+ const QString &iconName,
+ const QString &indent,
+ const DomResourceIcon *i)
+{
+ if (i->hasElementNormalOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::Off);\n";
+ if (i->hasElementNormalOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::On);\n";
+ if (i->hasElementDisabledOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n";
+ if (i->hasElementDisabledOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::On);\n";
+ if (i->hasElementActiveOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), indent) << "), QSize(), QIcon::Active, QIcon::Off);\n";
+ if (i->hasElementActiveOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), indent) << "), QSize(), QIcon::Active, QIcon::On);\n";
+ if (i->hasElementSelectedOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::Off);\n";
+ if (i->hasElementSelectedOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::On);\n";
+}
+
QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
{
// check cache
@@ -1683,25 +1719,41 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
const QString iconName = m_driver->unique(QLatin1String("icon"));
m_iconPropertiesNameMap.insert(IconHandle(i), iconName);
if (isIconFormat44(i)) {
- const QString pixmap = QLatin1String("QPixmap");
- m_output << m_indent << "QIcon " << iconName << ";\n";
- if (i->hasElementNormalOff())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::Off);\n";
- if (i->hasElementNormalOn())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), m_dindent) << "), QSize(), QIcon::Normal, QIcon::On);\n";
- if (i->hasElementDisabledOff())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n";
- if (i->hasElementDisabledOn())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), m_dindent) << "), QSize(), QIcon::Disabled, QIcon::On);\n";
- if (i->hasElementActiveOff())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::Off);\n";
- if (i->hasElementActiveOn())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), m_dindent) << "), QSize(), QIcon::Active, QIcon::On);\n";
- if (i->hasElementSelectedOff())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::Off);\n";
- if (i->hasElementSelectedOn())
- m_output << m_indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), m_dindent) << "), QSize(), QIcon::Selected, QIcon::On);\n";
- } else { // pre-4.4 legacy
+ if (i->attributeTheme().isEmpty()) {
+ // No theme: Write resource icon as is
+ m_output << m_indent << "QIcon " << iconName << ";\n";
+ writeResourceIcon(m_output, iconName, m_indent, i);
+ } else {
+ // Theme: Generate code to check the theme and default to resource
+ const QString themeIconName = fixString(i->attributeTheme(), QString());
+ if (iconHasStatePixmaps(i)) {
+ // Theme + default state pixmaps:
+ // Generate code to check the theme and default to state pixmaps
+ m_output << m_indent << "QIcon " << iconName << ";\n";
+ const char themeNameStringVariableC[] = "iconThemeName";
+ // Store theme name in a variable
+ m_output << m_indent;
+ if (m_firstThemeIcon) { // Declare variable string
+ m_output << "QString ";
+ m_firstThemeIcon = false;
+ }
+ m_output << themeNameStringVariableC << " = QString::fromUtf8("
+ << themeIconName << ");\n";
+ m_output << m_indent << "if (QIcon::hasThemeIcon("
+ << themeNameStringVariableC
+ << ")) {\n"
+ << m_dindent << iconName << " = QIcon::fromTheme(" << themeNameStringVariableC << ");\n"
+ << m_indent << "} else {\n";
+ writeResourceIcon(m_output, iconName, m_dindent, i);
+ m_output << m_indent << "}\n";
+ } else {
+ // Theme, but no state pixmaps: Construct from theme directly.
+ m_output << m_indent << "QIcon " << iconName
+ << "(QIcon::fromTheme(QString::fromUtf8("
+ << themeIconName << ")));\n";
+ } // Theme, but not state
+ } // >= 4.4
+ } else { // pre-4.4 legacy
m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n";
}
return iconName;
diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h
index 667ec96..302fbe4 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.h
+++ b/src/tools/uic/cpp/cppwriteinitialization.h
@@ -363,6 +363,7 @@ private:
const bool m_activateScripts;
bool m_layoutWidget;
+ bool m_firstThemeIcon;
};
} // namespace CPP
diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp
index 52bc8e3..94d931b 100644
--- a/src/tools/uic/ui4.cpp
+++ b/src/tools/uic/ui4.cpp
@@ -3673,6 +3673,7 @@ void DomLayoutItem::clear(bool clear_all)
m_attr_rowSpan = 0;
m_has_attr_colSpan = false;
m_attr_colSpan = 0;
+ m_has_attr_alignment = false;
}
m_kind = Unknown;
@@ -3694,6 +3695,7 @@ DomLayoutItem::DomLayoutItem()
m_attr_rowSpan = 0;
m_has_attr_colSpan = false;
m_attr_colSpan = 0;
+ m_has_attr_alignment = false;
m_widget = 0;
m_layout = 0;
m_spacer = 0;
@@ -3727,6 +3729,10 @@ void DomLayoutItem::read(QXmlStreamReader &reader)
setAttributeColSpan(attribute.value().toString().toInt());
continue;
}
+ if (name == QLatin1String("alignment")) {
+ setAttributeAlignment(attribute.value().toString());
+ continue;
+ }
reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
}
@@ -3779,6 +3785,8 @@ void DomLayoutItem::read(const QDomElement &node)
setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt());
if (node.hasAttribute(QLatin1String("colspan")))
setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt());
+ if (node.hasAttribute(QLatin1String("alignment")))
+ setAttributeAlignment(node.attribute(QLatin1String("alignment")));
for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
if (!n.isElement())
@@ -3828,6 +3836,9 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons
if (hasAttributeColSpan())
writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan()));
+ if (hasAttributeAlignment())
+ writer.writeAttribute(QLatin1String("alignment"), attributeAlignment());
+
switch (kind()) {
case Widget: {
DomWidget* v = elementWidget();
@@ -7745,6 +7756,7 @@ void DomResourceIcon::clear(bool clear_all)
if (clear_all) {
m_text = QLatin1String("");
+ m_has_attr_theme = false;
m_has_attr_resource = false;
}
@@ -7762,6 +7774,7 @@ void DomResourceIcon::clear(bool clear_all)
DomResourceIcon::DomResourceIcon()
{
m_children = 0;
+ m_has_attr_theme = false;
m_has_attr_resource = false;
m_text = QLatin1String("");
m_normalOff = 0;
@@ -7791,6 +7804,10 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
QStringRef name = attribute.name();
+ if (name == QLatin1String("theme")) {
+ setAttributeTheme(attribute.value().toString());
+ continue;
+ }
if (name == QLatin1String("resource")) {
setAttributeResource(attribute.value().toString());
continue;
@@ -7869,6 +7886,8 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
#ifdef QUILOADER_QDOM_READ
void DomResourceIcon::read(const QDomElement &node)
{
+ if (node.hasAttribute(QLatin1String("theme")))
+ setAttributeTheme(node.attribute(QLatin1String("theme")));
if (node.hasAttribute(QLatin1String("resource")))
setAttributeResource(node.attribute(QLatin1String("resource")));
@@ -7938,6 +7957,9 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co
{
writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower());
+ if (hasAttributeTheme())
+ writer.writeAttribute(QLatin1String("theme"), attributeTheme());
+
if (hasAttributeResource())
writer.writeAttribute(QLatin1String("resource"), attributeResource());
diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h
index 2e09c67..6caf515 100644
--- a/src/tools/uic/ui4.h
+++ b/src/tools/uic/ui4.h
@@ -1427,6 +1427,11 @@ public:
inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; }
inline void clearAttributeColSpan() { m_has_attr_colSpan = false; }
+ inline bool hasAttributeAlignment() const { return m_has_attr_alignment; }
+ inline QString attributeAlignment() const { return m_attr_alignment; }
+ inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; }
+ inline void clearAttributeAlignment() { m_has_attr_alignment = false; }
+
// child element accessors
enum Kind { Unknown = 0, Widget, Layout, Spacer };
inline Kind kind() const { return m_kind; }
@@ -1460,6 +1465,9 @@ private:
int m_attr_colSpan;
bool m_has_attr_colSpan;
+ QString m_attr_alignment;
+ bool m_has_attr_alignment;
+
// child element data
Kind m_kind;
DomWidget* m_widget;
@@ -2809,6 +2817,11 @@ public:
inline void setText(const QString &s) { m_text = s; }
// attribute accessors
+ inline bool hasAttributeTheme() const { return m_has_attr_theme; }
+ inline QString attributeTheme() const { return m_attr_theme; }
+ inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; }
+ inline void clearAttributeTheme() { m_has_attr_theme = false; }
+
inline bool hasAttributeResource() const { return m_has_attr_resource; }
inline QString attributeResource() const { return m_attr_resource; }
inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; }
@@ -2868,6 +2881,9 @@ private:
void clear(bool clear_all = true);
// attribute data
+ QString m_attr_theme;
+ bool m_has_attr_theme;
+
QString m_attr_resource;
bool m_has_attr_resource;
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
index 657198e..cc0992f 100644
--- a/src/tools/uic3/converter.cpp
+++ b/src/tools/uic3/converter.cpp
@@ -864,7 +864,7 @@ DomLayoutItem *Ui3Reader::createLayoutItem(const QDomElement &e)
Variant var;
var.createSize(0, 0);
- QVariant def = qVariantFromValue(var);
+ QVariant def = QVariant::fromValue(var);
Size size = asVariant(DomTool::readProperty(e, QLatin1String("sizeHint"), def)).size;
QString sizeType = QLatin1String("QSizePolicy::") + DomTool::readProperty(e, QLatin1String("sizeType"), QLatin1String("Expanding")).toString();
diff --git a/src/tools/uic3/domtool.cpp b/src/tools/uic3/domtool.cpp
index 920e7d4..d6fc296 100644
--- a/src/tools/uic3/domtool.cpp
+++ b/src/tools/uic3/domtool.cpp
@@ -169,7 +169,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu
n3 = n3.nextSibling().toElement();
}
var.createRect(x, y, w, h);
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("point")) {
QDomElement n3 = e.firstChild().toElement();
int x = 0, y = 0;
@@ -181,7 +181,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu
n3 = n3.nextSibling().toElement();
}
var.createPoint(x,y);
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("size")) {
QDomElement n3 = e.firstChild().toElement();
int w = 0, h = 0;
@@ -193,10 +193,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu
n3 = n3.nextSibling().toElement();
}
var.createSize(w, h);
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("color")) {
var.color = readColor(e);
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("font")) {
QDomElement n3 = e.firstChild().toElement();
Font f;
@@ -217,7 +217,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu
n3 = n3.nextSibling().toElement();
}
var.font = f;
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("string")) {
v = QVariant(e.firstChild().toText().data());
QDomElement n = e;
@@ -258,10 +258,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu
var.sizePolicy.verstretch = n3.firstChild().toText().data().toInt();
n3 = n3.nextSibling().toElement();
}
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("cursor")) {
var.createCursor(e.firstChild().toText().data().toInt());
- qVariantSetValue(v, var);
+ v.setValue(var);
} else if (e.tagName() == QLatin1String("stringlist")) {
QStringList lst;
QDomElement n;
diff --git a/src/tools/uic3/domtool.h b/src/tools/uic3/domtool.h
index a0ba54f..c724e52 100644
--- a/src/tools/uic3/domtool.h
+++ b/src/tools/uic3/domtool.h
@@ -266,7 +266,7 @@ QT_BEGIN_NAMESPACE
inline Variant asVariant(const QVariant &v)
{
Variant var;
- var = qVariantValue<Variant>(v);
+ var = qvariant_cast<Variant>(v);
return var;
}
diff --git a/src/xml/xml.pro b/src/xml/xml.pro
index 8d1bf68..019153c 100644
--- a/src/xml/xml.pro
+++ b/src/xml/xml.pro
@@ -4,7 +4,7 @@ QT = core
DEFINES += QT_BUILD_XML_LIB QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
diff --git a/src/xmlpatterns/api/quriloader.cpp b/src/xmlpatterns/api/quriloader.cpp
index 61a17e3..b8cb104 100644
--- a/src/xmlpatterns/api/quriloader.cpp
+++ b/src/xmlpatterns/api/quriloader.cpp
@@ -69,7 +69,7 @@ QNetworkReply *URILoader::createRequest(Operation op, const QNetworkRequest &req
const QVariant variant(m_variableLoader->valueFor(m_namePool->allocateQName(QString(), name, QString())));
if(!variant.isNull() && variant.userType() == qMetaTypeId<QIODevice *>())
- return new QIODeviceDelegate(qVariantValue<QIODevice *>(variant));
+ return new QIODeviceDelegate(qvariant_cast<QIODevice *>(variant));
else
{
/* If we're entering this code path, the variable URI identified a variable
diff --git a/src/xmlpatterns/api/qvariableloader.cpp b/src/xmlpatterns/api/qvariableloader.cpp
index 83e9f5e..9909508 100644
--- a/src/xmlpatterns/api/qvariableloader.cpp
+++ b/src/xmlpatterns/api/qvariableloader.cpp
@@ -131,12 +131,12 @@ SequenceType::Ptr VariableLoader::announceExternalVariable(const QXmlName name,
return CommonSequenceTypes::ExactlyOneAnyURI;
else if(variant.userType() == qMetaTypeId<QXmlQuery>())
{
- const QXmlQuery variableQuery(qVariantValue<QXmlQuery>(variant));
+ const QXmlQuery variableQuery(qvariant_cast<QXmlQuery>(variant));
return variableQuery.d->expression()->staticType();
}
else
{
- return makeGenericSequenceType(AtomicValue::qtToXDMType(qVariantValue<QXmlItem>(variant)),
+ return makeGenericSequenceType(AtomicValue::qtToXDMType(qvariant_cast<QXmlItem>(variant)),
Cardinality::exactlyOne());
}
}
@@ -154,12 +154,12 @@ Item::Iterator::Ptr VariableLoader::evaluateSequence(const QXmlName name,
return makeSingletonIterator(itemForName(name));
else if(variant.userType() == qMetaTypeId<QXmlQuery>())
{
- const QXmlQuery variableQuery(qVariantValue<QXmlQuery>(variant));
+ const QXmlQuery variableQuery(qvariant_cast<QXmlQuery>(variant));
return variableQuery.d->expression()->evaluateSequence(DynamicContext::Ptr(new TemporaryTreesRedirectingContext(variableQuery.d->dynamicContext(), context)));
}
- const QVariant v(qVariantValue<QXmlItem>(variant).toAtomicValue());
+ const QVariant v(qvariant_cast<QXmlItem>(variant).toAtomicValue());
switch(v.type())
{
@@ -179,7 +179,7 @@ Item VariableLoader::itemForName(const QXmlName &name) const
if(variant.userType() == qMetaTypeId<QIODevice *>())
return Item(AnyURI::fromValue(QLatin1String("tag:trolltech.com,2007:QtXmlPatterns:QIODeviceVariable:") + m_namePool->stringForLocalName(name.localName())));
- const QXmlItem item(qVariantValue<QXmlItem>(variant));
+ const QXmlItem item(qvariant_cast<QXmlItem>(variant));
if(item.isNode())
return Item::fromPublic(item);
@@ -210,8 +210,8 @@ bool VariableLoader::isSameType(const QVariant &v1,
return true;
/* Ok, we have two QXmlItems. */
- const QXmlItem i1(qVariantValue<QXmlItem>(v1));
- const QXmlItem i2(qVariantValue<QXmlItem>(v2));
+ const QXmlItem i1(qvariant_cast<QXmlItem>(v1));
+ const QXmlItem i2(qvariant_cast<QXmlItem>(v2));
if(i1.isNode())
{
diff --git a/src/xmlpatterns/api/qxmlquery.cpp b/src/xmlpatterns/api/qxmlquery.cpp
index 8c215f1..d74a536 100644
--- a/src/xmlpatterns/api/qxmlquery.cpp
+++ b/src/xmlpatterns/api/qxmlquery.cpp
@@ -534,7 +534,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, const QXmlItem &value)
}
const QPatternist::VariableLoader::Ptr vl(d->variableLoader());
- const QVariant variant(qVariantFromValue(value));
+ const QVariant variant(QVariant::fromValue(value));
/* If the type of the variable changed(as opposed to only the value),
* we will have to recompile. */
@@ -610,7 +610,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, QIODevice *device)
if(device)
{
- const QVariant variant(qVariantFromValue(device));
+ const QVariant variant(QVariant::fromValue(device));
if(vl->invalidationRequired(name, variant))
d->recompileRequired();
@@ -1184,7 +1184,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, const QXmlQuery &query)
Q_ASSERT_X(query.isValid(), Q_FUNC_INFO, "The query being bound must be valid.");
const QPatternist::VariableLoader::Ptr vl(d->variableLoader());
- const QVariant variant(qVariantFromValue(query));
+ const QVariant variant(QVariant::fromValue(query));
if(vl->invalidationRequired(name, variant))
d->recompileRequired();
diff --git a/src/xmlpatterns/data/qatomicvalue.cpp b/src/xmlpatterns/data/qatomicvalue.cpp
index 6726f7b..a15a6b4 100644
--- a/src/xmlpatterns/data/qatomicvalue.cpp
+++ b/src/xmlpatterns/data/qatomicvalue.cpp
@@ -121,7 +121,7 @@ QVariant AtomicValue::toQt(const AtomicValue *const value)
|| BuiltinTypes::xsHexBinary->xdtTypeMatches(t))
return QVariant(value->as<Base64Binary>()->asByteArray());
else if(BuiltinTypes::xsQName->xdtTypeMatches(t))
- return qVariantFromValue(value->as<QNameValue>()->qName());
+ return QVariant::fromValue(value->as<QNameValue>()->qName());
else
{
/* A type we don't support in Qt. Includes xs:time currently. */
diff --git a/src/xmlpatterns/utils/qautoptr_p.h b/src/xmlpatterns/utils/qautoptr_p.h
index 6a22b52..b9fe6ec 100644
--- a/src/xmlpatterns/utils/qautoptr_p.h
+++ b/src/xmlpatterns/utils/qautoptr_p.h
@@ -122,7 +122,6 @@ namespace QPatternist
return *this;
}
-#ifndef QT_NO_MEMBER_TEMPLATES
template<typename L>
operator AutoPtrRef<L>()
{
@@ -139,7 +138,6 @@ namespace QPatternist
inline AutoPtr(AutoPtr<L>& other) : m_ptr(other.release())
{
}
-#endif
inline T *release()
{
diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro
index e50d184..d22f417 100644
--- a/src/xmlpatterns/xmlpatterns.pro
+++ b/src/xmlpatterns/xmlpatterns.pro
@@ -5,7 +5,7 @@ QT = core \
DEFINES += QT_BUILD_XMLPATTERNS_LIB \
QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000
-unix:QMAKE_PKGCONFIG_REQUIRES = QtCore \
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore \
QtNetwork
include(../qbase.pri)
PRECOMPILED_HEADER = ../corelib/global/qt_pch.h