summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@digia.com>2009-06-15 15:08:43 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2009-06-15 15:08:43 (GMT)
commit7a42405649aeea3e709231464d450b5da521e5cb (patch)
treec8a0bc351478ee24a29e2a436fe498213598a5ae /src
parentba1491c5942239f9e0f3f283114f9ed91f43f02b (diff)
parent08ae7ee1fb930e7d4b4039e2294cba69f9380964 (diff)
downloadQt-7a42405649aeea3e709231464d450b5da521e5cb.zip
Qt-7a42405649aeea3e709231464d450b5da521e5cb.tar.gz
Qt-7a42405649aeea3e709231464d450b5da521e5cb.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts: src/corelib/tools/qringbuffer_p.h
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp8
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp1
-rw-r--r--src/3rdparty/phonon/ds9/videowidget.cpp2
-rw-r--r--src/3rdparty/phonon/phonon/abstractmediastream.cpp1
-rw-r--r--src/3rdparty/phonon/phonon/abstractmediastream.h2
-rw-r--r--src/3rdparty/phonon/phonon/abstractmediastream_p.h2
-rw-r--r--src/3rdparty/phonon/phonon/effectwidget.cpp3
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog140
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp27
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp19
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp13
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h3
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp1
-rw-r--r--src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp11
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog25
-rw-r--r--src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp8
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp39
-rw-r--r--src/corelib/arch/qatomic_symbian.h32
-rw-r--r--src/corelib/arch/qatomic_windows.h14
-rw-r--r--src/corelib/arch/symbian/qatomic_symbian.cpp32
-rw-r--r--src/corelib/codecs/qisciicodec.cpp1
-rw-r--r--src/corelib/codecs/qtextcodec.cpp21
-rw-r--r--src/corelib/codecs/qutfcodec.cpp2
-rw-r--r--src/corelib/concurrent/qthreadpool.cpp6
-rw-r--r--src/corelib/global/qglobal.cpp311
-rw-r--r--src/corelib/global/qglobal.h103
-rw-r--r--src/corelib/global/qlibraryinfo.cpp28
-rw-r--r--src/corelib/global/qnamespace.h26
-rw-r--r--src/corelib/io/qabstractfileengine.cpp3
-rw-r--r--src/corelib/io/qabstractfileengine.h4
-rw-r--r--src/corelib/io/qdatastream.cpp92
-rw-r--r--src/corelib/io/qdebug.h7
-rw-r--r--src/corelib/io/qdir.cpp3
-rw-r--r--src/corelib/io/qdir.h3
-rw-r--r--src/corelib/io/qdiriterator.cpp4
-rw-r--r--src/corelib/io/qfile.cpp31
-rw-r--r--src/corelib/io/qfileinfo.cpp2
-rw-r--r--src/corelib/io/qfileinfo.h3
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp40
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian_p.h32
-rw-r--r--src/corelib/io/qfsfileengine.cpp122
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp33
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp83
-rw-r--r--src/corelib/io/qiodevice.cpp11
-rw-r--r--src/corelib/io/qiodevice.h3
-rw-r--r--src/corelib/io/qprocess_symbian.cpp33
-rw-r--r--src/corelib/io/qprocess_unix.cpp23
-rw-r--r--src/corelib/io/qresource.cpp3
-rw-r--r--src/corelib/io/qresource.h2
-rw-r--r--src/corelib/io/qsettings.cpp83
-rw-r--r--src/corelib/io/qsettings.h2
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp96
-rw-r--r--src/corelib/io/qtextstream.cpp3
-rw-r--r--src/corelib/io/qtextstream.h3
-rw-r--r--src/corelib/io/qurl.cpp6
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp51
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h36
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp96
-rw-r--r--src/corelib/kernel/qcoreapplication.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp233
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h35
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp59
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h1
-rw-r--r--src/corelib/kernel/qobject.cpp79
-rw-r--r--src/corelib/kernel/qobject.h3
-rw-r--r--src/corelib/kernel/qobject_p.h1
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp4
-rw-r--r--src/corelib/kernel/qsharedmemory_symbian.cpp46
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp4
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore.h3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_symbian.cpp39
-rw-r--r--src/corelib/kernel/qtimer.cpp2
-rw-r--r--src/corelib/kernel/qtranslator.cpp7
-rw-r--r--src/corelib/kernel/qtranslator_p.h1
-rw-r--r--src/corelib/plugin/qlibrary.cpp7
-rw-r--r--src/corelib/plugin/qpluginloader.cpp19
-rw-r--r--src/corelib/thread/qthread.cpp15
-rw-r--r--src/corelib/thread/qthread_unix.cpp9
-rw-r--r--src/corelib/thread/qthread_win.cpp9
-rw-r--r--src/corelib/thread/qthreadstorage.cpp14
-rw-r--r--src/corelib/tools/qbitarray.cpp2
-rw-r--r--src/corelib/tools/qbytearray.cpp55
-rw-r--r--src/corelib/tools/qbytearraymatcher.h2
-rw-r--r--src/corelib/tools/qcryptographichash.cpp2
-rw-r--r--src/corelib/tools/qdatetime.cpp14
-rw-r--r--src/corelib/tools/qdatetime.h3
-rw-r--r--src/corelib/tools/qharfbuzz.cpp1
-rw-r--r--src/corelib/tools/qhash.cpp78
-rw-r--r--src/corelib/tools/qhash.h44
-rw-r--r--src/corelib/tools/qlinkedlist.h44
-rw-r--r--src/corelib/tools/qlist.h108
-rw-r--r--src/corelib/tools/qlistdata.cpp28
-rw-r--r--src/corelib/tools/qlocale.cpp804
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp878
-rw-r--r--src/corelib/tools/qmap.cpp41
-rw-r--r--src/corelib/tools/qmap.h35
-rw-r--r--src/corelib/tools/qpodlist_p.h192
-rw-r--r--src/corelib/tools/qrect.cpp2
-rw-r--r--src/corelib/tools/qregexp.cpp25
-rw-r--r--src/corelib/tools/qringbuffer_p.h3
-rw-r--r--src/corelib/tools/qscopedpointer.cpp177
-rw-r--r--src/corelib/tools/qscopedpointer.h199
-rw-r--r--src/corelib/tools/qshareddata.cpp2
-rw-r--r--src/corelib/tools/qsharedpointer.cpp9
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h21
-rw-r--r--src/corelib/tools/qsize.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp138
-rw-r--r--src/corelib/tools/qstringlist.cpp4
-rw-r--r--src/corelib/tools/qtextboundaryfinder.cpp10
-rw-r--r--src/corelib/tools/qvarlengtharray.h80
-rw-r--r--src/corelib/tools/qvector.cpp1
-rw-r--r--src/corelib/tools/qvector.h98
-rw-r--r--src/corelib/tools/tools.pri4
-rw-r--r--src/corelib/xml/qxmlstream.cpp5
-rw-r--r--src/corelib/xml/qxmlstream.h5
-rw-r--r--src/dbus/qdbusabstractadaptor.cpp2
-rw-r--r--src/dbus/qdbuscontext.h2
-rw-r--r--src/dbus/qdbusmessage.cpp1
-rw-r--r--src/gui/dialogs/dialogs.pri1
-rw-r--r--src/gui/dialogs/qcolordialog.cpp2
-rw-r--r--src/gui/dialogs/qdialog.cpp10
-rw-r--r--src/gui/dialogs/qfiledialog.cpp71
-rw-r--r--src/gui/dialogs/qfiledialog_p.h55
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp28
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp11
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h25
-rw-r--r--src/gui/dialogs/qfontdialog.cpp10
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm40
-rw-r--r--src/gui/dialogs/qfscompleter_p.h81
-rw-r--r--src/gui/dialogs/qinputdialog.cpp12
-rw-r--r--src/gui/dialogs/qmessagebox.cpp15
-rw-r--r--src/gui/dialogs/qpagesetupdialog.cpp6
-rw-r--r--src/gui/dialogs/qpagesetupdialog_mac.mm3
-rw-r--r--src/gui/dialogs/qpagesetupdialog_win.cpp2
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp4
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.cpp13
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.h2
-rw-r--r--src/gui/dialogs/qwizard.cpp4
-rw-r--r--src/gui/dialogs/qwizard_win.cpp5
-rw-r--r--src/gui/dialogs/qwizard_win_p.h2
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp4
-rw-r--r--src/gui/embedded/qscreen_qws.cpp2
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp36
-rw-r--r--src/gui/embedded/qwindowsystem_qws.cpp44
-rw-r--r--src/gui/embedded/qwscursor_qws.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp139
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp3
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp10
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp15
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h3
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp17
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h2
-rw-r--r--src/gui/gui.pro5
-rw-r--r--src/gui/image/qicon.cpp11
-rw-r--r--src/gui/image/qimage.cpp19
-rw-r--r--src/gui/image/qimageiohandler.cpp1
-rw-r--r--src/gui/image/qimageiohandler.h3
-rw-r--r--src/gui/image/qpicture.cpp17
-rw-r--r--src/gui/image/qpicture.h4
-rw-r--r--src/gui/image/qpicture_p.h2
-rw-r--r--src/gui/image/qpixmap.cpp97
-rw-r--r--src/gui/image/qpixmap.h9
-rw-r--r--src/gui/image/qpixmap_qws.cpp14
-rw-r--r--src/gui/image/qpixmap_s60.cpp173
-rw-r--r--src/gui/image/qpixmap_win.cpp45
-rw-r--r--src/gui/image/qpixmap_x11.cpp28
-rw-r--r--src/gui/image/qpixmapcache.cpp7
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_p.h34
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp125
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp7
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp2
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp17
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h2
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp1
-rw-r--r--src/gui/itemviews/qfileiconprovider.h5
-rw-r--r--src/gui/itemviews/qheaderview.cpp4
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp5
-rw-r--r--src/gui/itemviews/qlistwidget.cpp2
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp3
-rw-r--r--src/gui/itemviews/qstandarditemmodel.cpp2
-rw-r--r--src/gui/itemviews/qstandarditemmodel.h2
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp3
-rw-r--r--src/gui/itemviews/qtreeview.cpp8
-rw-r--r--src/gui/itemviews/qtreewidget.cpp2
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.cpp3
-rw-r--r--src/gui/itemviews/qtreewidgetitemiterator.h3
-rw-r--r--src/gui/kernel/qaction.cpp29
-rw-r--r--src/gui/kernel/qaction.h10
-rw-r--r--src/gui/kernel/qaction_p.h1
-rw-r--r--src/gui/kernel/qapplication.cpp14
-rw-r--r--src/gui/kernel/qapplication.h3
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qapplication_qws.cpp27
-rw-r--r--src/gui/kernel/qapplication_s60.cpp151
-rw-r--r--src/gui/kernel/qapplication_win.cpp29
-rw-r--r--src/gui/kernel/qapplication_x11.cpp8
-rw-r--r--src/gui/kernel/qclipboard.cpp2
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp32
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm2
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm11
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm28
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm13
-rw-r--r--src/gui/kernel/qcursor.cpp4
-rw-r--r--src/gui/kernel/qcursor_qws.cpp6
-rw-r--r--src/gui/kernel/qcursor_s60.cpp32
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp95
-rw-r--r--src/gui/kernel/qdnd_s60.cpp32
-rw-r--r--src/gui/kernel/qevent.cpp11
-rw-r--r--src/gui/kernel/qevent.h3
-rw-r--r--src/gui/kernel/qeventdispatcher_s60.cpp56
-rw-r--r--src/gui/kernel/qeventdispatcher_s60_p.h32
-rw-r--r--src/gui/kernel/qkeymapper_s60.cpp32
-rw-r--r--src/gui/kernel/qkeysequence.cpp2
-rw-r--r--src/gui/kernel/qshortcutmap.cpp5
-rw-r--r--src/gui/kernel/qshortcutmap_p.h3
-rw-r--r--src/gui/kernel/qsound_s60.cpp39
-rw-r--r--src/gui/kernel/qt_s60_p.h98
-rw-r--r--src/gui/kernel/qwidget.cpp196
-rw-r--r--src/gui/kernel/qwidget.h4
-rw-r--r--src/gui/kernel/qwidget_mac.mm10
-rw-r--r--src/gui/kernel/qwidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_qws.cpp3
-rw-r--r--src/gui/kernel/qwidget_s60.cpp94
-rw-r--r--src/gui/kernel/qwidget_x11.cpp3
-rw-r--r--src/gui/painting/painting.pri3
-rw-r--r--src/gui/painting/qbrush.cpp113
-rw-r--r--src/gui/painting/qbrush.h6
-rw-r--r--src/gui/painting/qcolor.cpp8
-rw-r--r--src/gui/painting/qcolormap_s60.cpp108
-rw-r--r--src/gui/painting/qcolormap_x11.cpp4
-rw-r--r--src/gui/painting/qdrawhelper.cpp4
-rw-r--r--src/gui/painting/qpaintdevice_s60.cpp32
-rw-r--r--src/gui/painting/qpaintengine.cpp1
-rw-r--r--src/gui/painting/qpaintengine.h3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp187
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp17
-rw-r--r--src/gui/painting/qpainter.cpp61
-rw-r--r--src/gui/painting/qpainter.h5
-rw-r--r--src/gui/painting/qpainterpath.cpp49
-rw-r--r--src/gui/painting/qpainterpath.h9
-rw-r--r--src/gui/painting/qprinter.cpp33
-rw-r--r--src/gui/painting/qprinter.h5
-rw-r--r--src/gui/painting/qprinterinfo.h3
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp32
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp33
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp30
-rw-r--r--src/gui/painting/qrasterizer.cpp7
-rw-r--r--src/gui/painting/qregion.cpp160
-rw-r--r--src/gui/painting/qregion_s60.cpp32
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp8
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp4
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h2
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp32
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h32
-rw-r--r--src/gui/styles/gtksymbols.cpp27
-rw-r--r--src/gui/styles/qcommonstyle.cpp2
-rw-r--r--src/gui/styles/qgtkstyle.cpp78
-rw-r--r--src/gui/styles/qmacstyle_mac.mm161
-rw-r--r--src/gui/styles/qmotifstyle.cpp5
-rw-r--r--src/gui/styles/qs60style.cpp1725
-rw-r--r--src/gui/styles/qs60style.h40
-rw-r--r--src/gui/styles/qs60style_p.h122
-rw-r--r--src/gui/styles/qs60style_s60.cpp (renamed from src/gui/styles/qs60style_symbian.cpp)840
-rw-r--r--src/gui/styles/qs60style_simulated.cpp221
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp9
-rw-r--r--src/gui/styles/styles.pri3
-rw-r--r--src/gui/text/qcssparser.cpp19
-rw-r--r--src/gui/text/qfont.cpp83
-rw-r--r--src/gui/text/qfont.h3
-rw-r--r--src/gui/text/qfont_s60.cpp32
-rw-r--r--src/gui/text/qfont_x11.cpp11
-rw-r--r--src/gui/text/qfontdatabase.cpp43
-rw-r--r--src/gui/text/qfontdatabase_mac.cpp9
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp81
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp76
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp2
-rw-r--r--src/gui/text/qfontengine.cpp22
-rw-r--r--src/gui/text/qfontengine_ft.cpp84
-rw-r--r--src/gui/text/qfontengine_ft_p.h1
-rw-r--r--src/gui/text/qfontengine_mac.mm4
-rw-r--r--src/gui/text/qfontengine_qpf.cpp31
-rw-r--r--src/gui/text/qfontengine_qpf_p.h1
-rw-r--r--src/gui/text/qfontengine_s60.cpp59
-rw-r--r--src/gui/text/qfontengine_s60_p.h32
-rw-r--r--src/gui/text/qfontengine_win.cpp30
-rw-r--r--src/gui/text/qfontengine_win_p.h3
-rw-r--r--src/gui/text/qfontmetrics.cpp20
-rw-r--r--src/gui/text/qfragmentmap_p.h8
-rw-r--r--src/gui/text/qtextcontrol.cpp32
-rw-r--r--src/gui/text/qtextengine.cpp50
-rw-r--r--src/gui/text/qtextformat.cpp2
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/text/qtextoption.cpp10
-rw-r--r--src/gui/text/qtexttable.cpp15
-rw-r--r--src/gui/text/qzip.cpp10
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp133
-rw-r--r--src/gui/util/qundostack.cpp2
-rw-r--r--src/gui/util/util.pri5
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp23
-rw-r--r--src/gui/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp13
-rw-r--r--src/gui/widgets/qabstractspinbox.h2
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper.cpp103
-rw-r--r--src/gui/widgets/qactiontokeyeventmapper_p.h81
-rw-r--r--src/gui/widgets/qcalendarwidget.cpp2
-rw-r--r--src/gui/widgets/qcombobox.cpp30
-rw-r--r--src/gui/widgets/qcombobox_p.h6
-rw-r--r--src/gui/widgets/qdatetimeedit.cpp1
-rw-r--r--src/gui/widgets/qlcdnumber.cpp2
-rw-r--r--src/gui/widgets/qlineedit.cpp51
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.h2
-rw-r--r--src/gui/widgets/qmainwindow.cpp5
-rw-r--r--src/gui/widgets/qmdiarea.cpp2
-rw-r--r--src/gui/widgets/qmenu.cpp14
-rw-r--r--src/gui/widgets/qmenu.h3
-rw-r--r--src/gui/widgets/qmenu_mac.mm52
-rw-r--r--src/gui/widgets/qmenu_p.h3
-rw-r--r--src/gui/widgets/qmenu_symbian.cpp151
-rw-r--r--src/gui/widgets/qmenubar.cpp2
-rw-r--r--src/gui/widgets/qmenubar.h4
-rw-r--r--src/gui/widgets/qmenubar_p.h3
-rw-r--r--src/gui/widgets/qmenudata.h2
-rw-r--r--src/gui/widgets/qplaintextedit.cpp20
-rw-r--r--src/gui/widgets/qplaintextedit_p.h6
-rw-r--r--src/gui/widgets/qprintpreviewwidget.cpp13
-rw-r--r--src/gui/widgets/qprintpreviewwidget.h2
-rw-r--r--src/gui/widgets/qprogressbar.cpp2
-rw-r--r--src/gui/widgets/qscrollarea.cpp2
-rw-r--r--src/gui/widgets/qspinbox.cpp9
-rw-r--r--src/gui/widgets/qsplitter.cpp2
-rw-r--r--src/gui/widgets/qtabbar.cpp11
-rw-r--r--src/gui/widgets/qtabwidget.cpp2
-rw-r--r--src/gui/widgets/qtextedit.cpp17
-rw-r--r--src/gui/widgets/qtextedit_p.h1
-rw-r--r--src/gui/widgets/qtoolbox.cpp2
-rw-r--r--src/gui/widgets/widgets.pri8
-rw-r--r--src/network/access/qftp.cpp12
-rw-r--r--src/network/access/qhttp.cpp7
-rw-r--r--src/network/access/qhttp.h3
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp6
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h4
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp12
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp2
-rw-r--r--src/network/access/qnetworkdiskcache.cpp48
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp3
-rw-r--r--src/network/access/qnetworkrequest.cpp3
-rw-r--r--src/network/kernel/qhostaddress.cpp5
-rw-r--r--src/network/kernel/qhostaddress.h3
-rw-r--r--src/network/kernel/qhostinfo.cpp20
-rw-r--r--src/network/kernel/qhostinfo.h3
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp2
-rw-r--r--src/network/kernel/qhostinfo_win.cpp15
-rw-r--r--src/network/kernel/qnetworkinterface.cpp7
-rw-r--r--src/network/kernel/qnetworkinterface.h3
-rw-r--r--src/network/kernel/qnetworkinterface_symbian.cpp32
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp11
-rw-r--r--src/network/kernel/qnetworkproxy.cpp4
-rw-r--r--src/network/kernel/qurlinfo.cpp4
-rw-r--r--src/network/socket/qabstractsocket.cpp30
-rw-r--r--src/network/socket/qhttpsocketengine.cpp4
-rw-r--r--src/network/socket/qlocalserver.cpp4
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp5
-rw-r--r--src/network/socket/qlocalsocket_win.cpp4
-rw-r--r--src/network/socket/qnativesocketengine_p.h37
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp61
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp40
-rw-r--r--src/network/socket/qsocks5socketengine.cpp4
-rw-r--r--src/network/socket/qtcpserver.cpp7
-rw-r--r--src/network/ssl/qsslcertificate.cpp15
-rw-r--r--src/network/ssl/qsslcertificate.h2
-rw-r--r--src/network/ssl/qsslcipher.cpp5
-rw-r--r--src/network/ssl/qsslcipher.h3
-rw-r--r--src/network/ssl/qsslerror.cpp5
-rw-r--r--src/network/ssl/qsslerror.h2
-rw-r--r--src/network/ssl/qsslkey.cpp17
-rw-r--r--src/network/ssl/qsslkey.h3
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp25
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp145
-rw-r--r--src/network/ssl/ssl.pri6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp3
-rw-r--r--src/opengl/qgl.cpp55
-rw-r--r--src/opengl/qgl.h3
-rw-r--r--src/opengl/qgl_win.cpp16
-rw-r--r--src/opengl/qgl_wince.cpp3
-rw-r--r--src/opengl/qgl_x11.cpp30
-rw-r--r--src/opengl/qglframebufferobject.cpp1
-rw-r--r--src/opengl/qglframebufferobject.h2
-rw-r--r--src/opengl/qglpaintdevice_qws.cpp2
-rw-r--r--src/opengl/qglpaintdevice_qws_p.h3
-rw-r--r--src/opengl/qglpixelbuffer.cpp1
-rw-r--r--src/opengl/qglpixelbuffer.h2
-rw-r--r--src/opengl/qpaintengine_opengl.cpp2
-rw-r--r--src/phonon/phonon.pro17
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.h2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h4
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp193
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp30
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp42
-rw-r--r--src/plugins/imageformats/mng/qmnghandler.cpp2
-rw-r--r--src/plugins/imageformats/mng/qmnghandler.h3
-rw-r--r--src/plugins/s60/src/qdesktopservices_3_1.cpp32
-rw-r--r--src/plugins/s60/src/qdesktopservices_3_2.cpp36
-rw-r--r--src/plugins/s60/src/qlocale_3_1.cpp32
-rw-r--r--src/plugins/s60/src/qlocale_3_2.cpp34
-rw-r--r--src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro4
-rw-r--r--src/qt3support/itemviews/q3table.cpp1
-rw-r--r--src/qt3support/network/q3http.cpp2
-rw-r--r--src/qt3support/network/q3urloperator.cpp2
-rw-r--r--src/qt3support/other/q3accel.cpp2
-rw-r--r--src/qt3support/painting/q3painter.h2
-rw-r--r--src/qt3support/widgets/q3action.cpp2
-rw-r--r--src/qt3support/widgets/q3groupbox.cpp4
-rw-r--r--src/qt3support/widgets/q3popupmenu.cpp2
-rw-r--r--src/qt3support/widgets/q3progressbar.cpp2
-rw-r--r--src/qt3support/widgets/q3scrollview.cpp2
-rw-r--r--src/s60installs/qt_libs.pro2
-rw-r--r--src/s60main/qts60main.cpp33
-rw-r--r--src/s60main/qts60main_mcrt0.cpp42
-rw-r--r--src/s60main/qts60mainapplication.cpp33
-rw-r--r--src/s60main/qts60mainapplication.h32
-rw-r--r--src/s60main/qts60mainappui.cpp58
-rw-r--r--src/s60main/qts60mainappui.h39
-rw-r--r--src/s60main/qts60maindocument.cpp33
-rw-r--r--src/s60main/qts60maindocument.h32
-rw-r--r--src/s60main/s60main.rss32
-rw-r--r--src/script/qscriptable.cpp2
-rw-r--r--src/script/qscriptable.h4
-rw-r--r--src/script/qscriptclass.cpp2
-rw-r--r--src/script/qscriptclass.h3
-rw-r--r--src/script/qscriptclasspropertyiterator.cpp2
-rw-r--r--src/script/qscriptclasspropertyiterator.h3
-rw-r--r--src/script/qscriptcontext.cpp2
-rw-r--r--src/script/qscriptcontext.h3
-rw-r--r--src/script/qscriptcontextinfo.cpp23
-rw-r--r--src/script/qscriptcontextinfo.h3
-rw-r--r--src/script/qscriptengine.cpp20
-rw-r--r--src/script/qscriptengine.h5
-rw-r--r--src/script/qscriptengineagent.cpp2
-rw-r--r--src/script/qscriptengineagent.h3
-rw-r--r--src/script/qscriptstring.cpp48
-rw-r--r--src/script/qscriptstring.h5
-rw-r--r--src/script/qscriptvalue.cpp76
-rw-r--r--src/script/qscriptvalue.h8
-rw-r--r--src/script/qscriptvalue_p.h2
-rw-r--r--src/script/qscriptvalueiterator.cpp18
-rw-r--r--src/script/qscriptvalueiterator.h4
-rw-r--r--src/scripttools/debugging/qscriptbreakpointdata.cpp5
-rw-r--r--src/scripttools/debugging/qscriptbreakpointdata_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerbackend_p.h2
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommand.cpp5
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommand_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h3
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsole.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsole_p.h3
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp14
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerevent.cpp5
-rw-r--r--src/scripttools/debugging/qscriptdebuggerevent_p.h3
-rw-r--r--src/scripttools/debugging/qscriptdebuggerfrontend.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerfrontend_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggerjob.cpp1
-rw-r--r--src/scripttools/debugging/qscriptdebuggerjob_p.h3
-rw-r--r--src/scripttools/debugging/qscriptdebuggerresponse.cpp5
-rw-r--r--src/scripttools/debugging/qscriptdebuggerresponse_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalue.cpp16
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalue_p.h4
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalueproperty.cpp14
-rw-r--r--src/scripttools/debugging/qscriptdebuggervalueproperty_p.h3
-rw-r--r--src/scripttools/debugging/qscriptenginedebugger.cpp13
-rw-r--r--src/scripttools/debugging/qscriptscriptdata.cpp20
-rw-r--r--src/scripttools/debugging/qscriptscriptdata_p.h4
-rw-r--r--src/scripttools/debugging/qscriptstdmessagehandler.cpp1
-rw-r--r--src/scripttools/debugging/qscriptstdmessagehandler_p.h4
-rw-r--r--src/scripttools/debugging/qscriptvalueproperty.cpp14
-rw-r--r--src/scripttools/debugging/qscriptvalueproperty_p.h3
-rw-r--r--src/scripttools/scripttools.pro2
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp7
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp11
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp12
-rw-r--r--src/sql/kernel/qsqlquery.cpp2
-rw-r--r--src/src.pro5
-rw-r--r--src/svg/qgraphicssvgitem.h6
-rw-r--r--src/svg/qsvggenerator.cpp3
-rw-r--r--src/svg/qsvggenerator.h3
-rw-r--r--src/testlib/3rdparty/cycle_p.h2
-rw-r--r--src/testlib/qtest.h7
-rw-r--r--src/testlib/qtestcase.cpp17
-rw-r--r--src/xml/dom/qdom.cpp88
-rw-r--r--src/xml/sax/qxml.cpp83
-rw-r--r--src/xml/sax/qxml.h5
-rw-r--r--src/xmlpatterns/api/qabstractxmlnodemodel.cpp1
-rw-r--r--src/xmlpatterns/api/qabstractxmlnodemodel.h3
-rw-r--r--src/xmlpatterns/api/qabstractxmlreceiver.cpp1
-rw-r--r--src/xmlpatterns/api/qabstractxmlreceiver.h3
-rw-r--r--src/xmlpatterns/api/qxmlresultitems.cpp1
-rw-r--r--src/xmlpatterns/api/qxmlresultitems.h3
-rw-r--r--src/xmlpatterns/expr/qpath.cpp2
519 files changed, 10450 insertions, 5655 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index 36b9282..2e3ef38 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -935,7 +935,13 @@ static HB_Stream getTableStream(void *font, HB_GetFontTableFunc tableFunc, HB_Ta
if (error)
return 0;
stream = (HB_Stream)malloc(sizeof(HB_StreamRec));
+ if (!stream)
+ return 0;
stream->base = (HB_Byte*)malloc(length);
+ if (!stream->base) {
+ free(stream);
+ return 0;
+ }
error = tableFunc(font, tag, stream->base, &length);
if (error) {
_hb_close_stream(stream);
@@ -950,6 +956,8 @@ static HB_Stream getTableStream(void *font, HB_GetFontTableFunc tableFunc, HB_Ta
HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc)
{
HB_Face face = (HB_Face )malloc(sizeof(HB_FaceRec));
+ if (!face)
+ return 0;
face->isSymbolFont = false;
face->gdef = 0;
diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
index 298e9fa..81ebb8b 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
+++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
@@ -169,6 +169,7 @@ namespace Phonon
Q_ASSERT(SUCCEEDED(hr));
ComPointer<IVMRWindowlessControl9> windowlessControl(m_filter, IID_IVMRWindowlessControl9);
windowlessControl->SetVideoClippingWindow(reinterpret_cast<HWND>(target->winId()));
+ windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size
}
QImage VideoRendererVMR9::snapshot() const
diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp
index de7ce5f..0ef653f 100644
--- a/src/3rdparty/phonon/ds9/videowidget.cpp
+++ b/src/3rdparty/phonon/ds9/videowidget.cpp
@@ -261,6 +261,7 @@ namespace Phonon
{
m_aspectRatio = aspectRatio;
updateVideoSize();
+ m_widget->update();
}
Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const
@@ -279,6 +280,7 @@ namespace Phonon
{
m_scaleMode = scaleMode;
updateVideoSize();
+ m_widget->update();
}
void VideoWidget::setBrightness(qreal b)
diff --git a/src/3rdparty/phonon/phonon/abstractmediastream.cpp b/src/3rdparty/phonon/phonon/abstractmediastream.cpp
index a661702..5b860f3 100644
--- a/src/3rdparty/phonon/phonon/abstractmediastream.cpp
+++ b/src/3rdparty/phonon/phonon/abstractmediastream.cpp
@@ -49,7 +49,6 @@ AbstractMediaStream::AbstractMediaStream(AbstractMediaStreamPrivate &dd, QObject
AbstractMediaStream::~AbstractMediaStream()
{
- delete d_ptr;
}
qint64 AbstractMediaStream::streamSize() const
diff --git a/src/3rdparty/phonon/phonon/abstractmediastream.h b/src/3rdparty/phonon/phonon/abstractmediastream.h
index 0daa92a..c4cde85 100644
--- a/src/3rdparty/phonon/phonon/abstractmediastream.h
+++ b/src/3rdparty/phonon/phonon/abstractmediastream.h
@@ -214,7 +214,7 @@ class PHONON_EXPORT AbstractMediaStream : public QObject
virtual void seekStream(qint64 offset);
AbstractMediaStream(AbstractMediaStreamPrivate &dd, QObject *parent);
- AbstractMediaStreamPrivate *d_ptr;
+ QScopedPointer<AbstractMediaStreamPrivate> d_ptr;
};
} // namespace Phonon
diff --git a/src/3rdparty/phonon/phonon/abstractmediastream_p.h b/src/3rdparty/phonon/phonon/abstractmediastream_p.h
index a9d6489..0e87c4d 100644
--- a/src/3rdparty/phonon/phonon/abstractmediastream_p.h
+++ b/src/3rdparty/phonon/phonon/abstractmediastream_p.h
@@ -45,6 +45,7 @@ class PHONON_EXPORT AbstractMediaStreamPrivate : private MediaNodeDestructionHan
public:
void setStreamInterface(StreamInterface *);
void setMediaObjectPrivate(MediaObjectPrivate *);
+ ~AbstractMediaStreamPrivate();
protected:
AbstractMediaStreamPrivate()
@@ -56,7 +57,6 @@ class PHONON_EXPORT AbstractMediaStreamPrivate : private MediaNodeDestructionHan
errorType(NoError)
{
}
- ~AbstractMediaStreamPrivate();
virtual void setStreamSize(qint64 newSize);
virtual void setStreamSeekable(bool s);
diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp
index da5a51a..d5c6c81 100644
--- a/src/3rdparty/phonon/phonon/effectwidget.cpp
+++ b/src/3rdparty/phonon/phonon/effectwidget.cpp
@@ -165,6 +165,7 @@ void EffectWidgetPrivate::autogenerateUi()
if (minValue == -1. && maxValue == 1.) {
//Special case values between -1 and 1.0 to use a slider for improved usability
QSlider *slider = new QSlider(Qt::Horizontal, q);
+ control = slider;
slider->setRange(-SLIDER_RANGE, +SLIDER_RANGE);
slider->setValue(int(SLIDER_RANGE * value.toDouble()));
slider->setTickPosition(QSlider::TicksBelow);
@@ -188,10 +189,10 @@ void EffectWidgetPrivate::autogenerateUi()
break;
}
+ if (control) {
#ifndef QT_NO_TOOLTIP
control->setToolTip(para.description());
#endif
- if (control) {
#ifndef QT_NO_SHORTCUT
label->setBuddy(control);
#endif
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index 26ce489..7d5d1c5 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- a6ebe3865025e2bb4d767a79435af4daf5a9b4db
+ 4ee8af9348b3f57d3c0f3575ae0a58336cf07a92
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index 00bd427..072beee 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,143 @@
+2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Do not call the parent implementation (Widget::) in show() and hide()
+ of the PluginViewQt, as it always changes the visible state of the
+ platformWidget (equal to the platformPluginWidget in the Qt port),
+ thus ignoring the isParentVisible() test.
+
+ * plugins/qt/PluginViewQt.cpp:
+ (WebCore::PluginView::show):
+ (WebCore::PluginView::hide):
+
+2009-04-22 Tamas Szirbucz <szirbucz.tamas@stud.u-szeged.hu>
+
+ Reviewed by Ariya Hidayat.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25023
+ Delete reply in QNetworkReplyHandler::abort() to avoid leak.
+
+ * platform/network/qt/QNetworkReplyHandler.cpp:
+ (WebCore::QNetworkReplyHandler::abort):
+
+2009-05-20 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Anders Carlsson.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24510
+
+ Fix a bug where the browserfuncs were not properly assigned,
+ make hasproperty use _NP_HasProperty and hasmethod _NP_HasMethod.
+
+ Test: plugins/netscape-invoke-browserfuncs.html
+
+ * plugins/gtk/PluginPackageGtk.cpp:
+ (WebCore::PluginPackage::load): Fix assignment
+ * plugins/qt/PluginPackageQt.cpp:
+ (WebCore::PluginPackage::load): Fix assignment
+
+2009-05-11 Yael Aharon <yael.aharon@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ Change Qt port to match the mac and windows ports, and unregister plugins when plugins are stopped.
+ Not doing that can cause assersion failure.
+ https://bugs.webkit.org/show_bug.cgi?id=25702
+
+ * plugins/qt/PluginViewQt.cpp:
+ (WebCore::PluginView::stop):
+
+2009-05-18 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Done together with Balazs Kelemen <kelemen.balazs@stud.u-szeged.hu>.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24551
+
+ [Qt] Reuse FontPlatformData for the same FontDescription.
+ This effectively prevents growing heap usage for loading every web page.
+
+ * platform/graphics/qt/FontCacheQt.cpp:
+ (WebCore::qHash): Necessary for FontPlatformDataCache.
+ (WebCore::FontCache::getCachedFontPlatformData): Reuse the instance if
+ it exists, otherwise create a new one and insert it in the cache.
+
+2009-05-18 Balazs Kelemen <kelemen.balazs@stud.u-szeged.hu>
+
+ Reviewed by Ariya Hidayat.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24551
+
+ [Qt] Fix the leak in FontFallbackList::fontDataAt() function.
+ When creating a new instance of SimpleFontData, put it in the font list
+ so that it can deleted later on.
+
+ * platform/graphics/qt/FontFallbackListQt.cpp:
+ (WebCore::FontFallbackList::invalidate):
+ (WebCore::FontFallbackList::releaseFontData):
+ (WebCore::FontFallbackList::fontDataAt):
+
+2009-05-15 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ [Qt] In the image decoder, remove the raw image data represented as QImage
+ once the image is converted to QPixmap and inserted in the pixmap cache.
+ This effectively reduces the heap usage when running on graphics system
+ other than raster (i.e the case where QImage != QPixmap).
+
+ * platform/graphics/qt/ImageDecoderQt.cpp:
+ (WebCore::ImageDecoderQt::imageAtIndex): Nullified the image on purpose.
+ * platform/graphics/qt/ImageDecoderQt.h: Made m_imageList mutable.
+
+2009-05-15 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Holger Freyther.
+
+ [Qt] Refactor alpha channel detection the image decoder.
+ Sets the boolean flag as soon as the image is being read.
+
+ * platform/graphics/qt/ImageDecoderQt.cpp:
+ (WebCore::ImageDecoderQt::ImageDecoderQt): Initialized m_hasAlphaChannel.
+ (WebCore::ImageDecoderQt::setData): Set the flag when appropriate.
+ (WebCore::ImageDecoderQt::supportsAlpha): Simplified.
+ (WebCore::ImageDecoderQt::reset): Resetted the flag.
+ * platform/graphics/qt/ImageDecoderQt.h: Added m_hasAlphaChannel.
+
+2009-05-13 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Sam Weinig.
+
+ [Qt] Fix "lighther" composition mode.
+ QPainter::CompositionMode_Plus is the right match.
+
+ * platform/graphics/qt/GraphicsContextQt.cpp:
+ (WebCore::toQtCompositionMode):
+
+2009-04-29 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Simon Fraser.
+
+ [Qt] Initialize GraphicsContext's and ImageBuffer's QPainter to match
+ the default values of canvas attributes.
+
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::ImageBufferData::ImageBufferData):
+
+2009-04-27 Ariya Hidayat <ariya.hidayat@nokia.com>
+
+ Reviewed by Tor Arne Vestbø.
+
+ https://bugs.webkit.org/show_bug.cgi?id=18475
+
+ [Qt] Widget painting should follow the layout direction (LTR, RTL)
+ of the element style, not the application layout direction.
+
+ * platform/qt/RenderThemeQt.cpp:
+ (WebCore::RenderThemeQt::applyTheme):
+
2009-03-13 Adam Bergkvist <adam.bergkvist@ericsson.com>
Reviewed by Alexey Proskuryakov.
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp
index 8a31861..5d1f147 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontCacheQt.cpp
@@ -26,6 +26,9 @@
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "Font.h"
+#include "StringHash.h"
+
+#include <QHash>
namespace WebCore {
@@ -33,9 +36,31 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne
{
}
+typedef QHash<FontDescription, FontPlatformData*> FontPlatformDataCache;
+
+// using Q_GLOBAL_STATIC leads to crash. TODO investigate the way to fix this.
+static FontPlatformDataCache* gFontPlatformDataCache;
+
+uint qHash(const FontDescription& key)
+{
+ uint value = CaseFoldingHash::hash(key.family().family());
+ value ^= key.computedPixelSize();
+ value ^= static_cast<int>(key.weight());
+ return value;
+}
+
FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& description, const AtomicString& family, bool checkingAlternateName)
{
- return new FontPlatformData(description);
+ if (!gFontPlatformDataCache)
+ gFontPlatformDataCache = new FontPlatformDataCache;
+
+ FontPlatformData* fontData = gFontPlatformDataCache->value(description, 0);
+ if (!fontData) {
+ fontData = new FontPlatformData(description);
+ gFontPlatformDataCache->insert(description, fontData);
+ }
+
+ return fontData;
}
SimpleFontData* FontCache::getCachedFontData(const FontPlatformData*)
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp
index 22ae205..50627b7 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontFallbackListQt.cpp
@@ -42,8 +42,6 @@ FontFallbackList::FontFallbackList()
void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSelector)
{
- releaseFontData();
- m_fontList.clear();
m_familyIndex = 0;
m_pitch = UnknownPitch;
m_loadingCustomFonts = false;
@@ -53,6 +51,9 @@ void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSel
void FontFallbackList::releaseFontData()
{
+ if (m_fontList.size())
+ delete m_fontList[0].first;
+ m_fontList.clear();
}
void FontFallbackList::determinePitch(const WebCore::Font* font) const
@@ -90,7 +91,12 @@ const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigne
family = family->next();
}
- return new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing());
+ if (m_fontList.size())
+ return m_fontList[0].first;
+
+ const FontData* result = new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing());
+ m_fontList.append(pair<const FontData*, bool>(result, result->isCustomFont()));
+ return result;
}
const FontData* FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 6c90ea3..490b54b 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -98,7 +98,7 @@ static inline QPainter::CompositionMode toQtCompositionMode(CompositeOperator op
case CompositeHighlight:
return QPainter::CompositionMode_SourceOver;
case CompositePlusLighter:
- return QPainter::CompositionMode_SourceOver;
+ return QPainter::CompositionMode_Plus;
}
return QPainter::CompositionMode_SourceOver;
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index 29a02d4..333269e 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -47,7 +47,24 @@ ImageBufferData::ImageBufferData(const IntSize& size)
: m_pixmap(size)
{
m_pixmap.fill(QColor(Qt::transparent));
- m_painter.set(new QPainter(&m_pixmap));
+
+ QPainter* painter = new QPainter(&m_pixmap);
+ m_painter.set(painter);
+
+ // Since ImageBuffer is used mainly for Canvas, explicitly initialize
+ // its painter's pen and brush with the corresponding canvas defaults
+ // NOTE: keep in sync with CanvasRenderingContext2D::State
+ QPen pen = painter->pen();
+ pen.setColor(Qt::black);
+ pen.setWidth(1);
+ pen.setCapStyle(Qt::FlatCap);
+ pen.setJoinStyle(Qt::MiterJoin);
+ pen.setMiterLimit(10);
+ painter->setPen(pen);
+ QBrush brush = painter->brush();
+ brush.setColor(Qt::black);
+ painter->setBrush(brush);
+ painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
}
ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index 394c7a7..cd32428 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -197,7 +197,8 @@ ImageDecoderQt* ImageDecoderQt::create(const SharedBuffer& data)
}
ImageDecoderQt::ImageDecoderQt(const QString &imageFormat)
- : m_imageFormat(imageFormat)
+ : m_hasAlphaChannel(false)
+ , m_imageFormat(imageFormat)
{
}
@@ -212,6 +213,7 @@ bool ImageDecoderQt::hasFirstImageHeader() const
void ImageDecoderQt::reset()
{
+ m_hasAlphaChannel = false;
m_failed = false;
m_imageList.clear();
m_pixmapCache.clear();
@@ -230,6 +232,9 @@ void ImageDecoderQt::setData(const IncomingData &data, bool allDataReceived)
const ReadContext::ReadResult readResult = readContext.read(allDataReceived);
+ if (hasFirstImageHeader())
+ m_hasAlphaChannel = m_imageList[0].m_image.hasAlphaChannel();
+
if (debugImageDecoderQt)
qDebug() << " read returns " << readResult;
@@ -280,7 +285,7 @@ int ImageDecoderQt::repetitionCount() const
bool ImageDecoderQt::supportsAlpha() const
{
- return hasFirstImageHeader() && m_imageList[0].m_image.hasAlphaChannel();
+ return m_hasAlphaChannel;
}
int ImageDecoderQt::duration(size_t index) const
@@ -314,6 +319,10 @@ QPixmap* ImageDecoderQt::imageAtIndex(size_t index) const
if (!m_pixmapCache.contains(index)) {
m_pixmapCache.insert(index,
QPixmap::fromImage(m_imageList[index].m_image));
+
+ // store null image since the converted pixmap is already in pixmap cache
+ Q_ASSERT(m_imageList[index].m_imageState == ImageComplete);
+ m_imageList[index].m_image = QImage();
}
return &m_pixmapCache[index];
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h
index a2eb6aa..b8c3edd 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -81,8 +81,9 @@ private:
int m_duration;
};
+ bool m_hasAlphaChannel;
typedef QList<ImageData> ImageList;
- ImageList m_imageList;
+ mutable ImageList m_imageList;
mutable QHash<int, QPixmap> m_pixmapCache;
int m_loopCount;
QString m_imageFormat;
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
index 2c730a6..3e9b239 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
@@ -174,6 +174,7 @@ void QNetworkReplyHandler::abort()
if (m_reply) {
QNetworkReply* reply = release();
reply->abort();
+ reply->deleteLater();
deleteLater();
}
}
diff --git a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
index a9da76b..02d17ed 100644
--- a/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/qt/RenderThemeQt.cpp
@@ -737,6 +737,10 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con
if (isHovered(o))
option.state |= QStyle::State_MouseOver;
+ option.direction = Qt::LeftToRight;
+ if (o->style() && o->style()->direction() == WebCore::RTL)
+ option.direction = Qt::RightToLeft;
+
ControlPart result = o->style()->appearance();
switch (result) {
diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
index 4387813..13f5394 100644
--- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
@@ -151,8 +151,8 @@ bool PluginPackage::load()
m_browserFuncs.getproperty = _NPN_GetProperty;
m_browserFuncs.setproperty = _NPN_SetProperty;
m_browserFuncs.removeproperty = _NPN_RemoveProperty;
- m_browserFuncs.hasproperty = _NPN_HasMethod;
- m_browserFuncs.hasmethod = _NPN_HasProperty;
+ m_browserFuncs.hasproperty = _NPN_HasProperty;
+ m_browserFuncs.hasmethod = _NPN_HasMethod;
m_browserFuncs.setexception = _NPN_SetException;
m_browserFuncs.enumerate = _NPN_Enumerate;
m_browserFuncs.construct = _NPN_Construct;
diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
index c8dd0e5..e856f92 100644
--- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
@@ -58,6 +58,7 @@
#include "MouseEvent.h"
#include "Page.h"
#include "PlatformMouseEvent.h"
+#include "PluginMainThreadScheduler.h"
#include "RenderLayer.h"
#include "Settings.h"
@@ -112,7 +113,9 @@ void PluginView::show()
if (isParentVisible() && platformPluginWidget())
platformPluginWidget()->setVisible(true);
- Widget::show();
+ // do not call parent impl. here as it will set the platformWidget
+ // (same as platformPluginWidget in the Qt port) to visible, even
+ // when parent isn't visible.
}
void PluginView::hide()
@@ -122,7 +125,9 @@ void PluginView::hide()
if (isParentVisible() && platformPluginWidget())
platformPluginWidget()->setVisible(false);
- Widget::hide();
+ // do not call parent impl. here as it will set the platformWidget
+ // (same as platformPluginWidget in the Qt port) to invisible, even
+ // when parent isn't visible.
}
void PluginView::paint(GraphicsContext* context, const IntRect& rect)
@@ -225,6 +230,8 @@ void PluginView::stop()
JSC::JSLock::DropAllLocks dropAllLocks(false);
+ PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance);
+
// Clear the window
m_npWindow.window = 0;
if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
index 5dc6363..e565476 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp
@@ -268,7 +268,7 @@ void QWebFrame::addToJavaScriptWindowObject(const QString &name, QObject *object
}
/*!
- Returns the frame's content, converted to HTML.
+ Returns the frame's content as HTML, enclosed in HTML and BODY tags.
\sa setHtml(), toPlainText()
*/
@@ -280,7 +280,8 @@ QString QWebFrame::toHtml() const
}
/*!
- Returns the content of this frame converted to plain text.
+ Returns the content of this frame converted to plain text, completely
+ stripped of all HTML formatting.
\sa toHtml()
*/
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index c3bd633..d9f925a 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,28 @@
+2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fix a plugin bug in the WebKit code, similar to the one in WebCore.
+
+ The problem is when a non visible QtPluginWidget would show it self
+ in a sibling frame. The problem was due to our clipping. In Qt,
+ if setMask is set with an empty QRegion, no clipping will
+ be performed, so in that case we hide the PluginContainer
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
+2009-03-27 Erik L. Bunce <elbunce@xendom.com>
+
+ Reviewed by Simon Hausmann.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24746
+
+ Improved selection tests.
+
+ * tests/qwebpage/tst_qwebpage.cpp:
+ (tst_QWebPage::textSelection):
+
2009-04-24 Simon Hausmann <simon.hausmann@nokia.com>
Rubber-stamped by Ariya Hidayat.
diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index c421d42..a2b33c0 100644
--- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -1058,7 +1058,13 @@ public:
IntRect clipRect(static_cast<FrameView*>(parentScrollView)->windowClipRect());
clipRect.move(-windowRect.x(), -windowRect.y());
clipRect.intersect(platformWidget()->rect());
- platformWidget()->setMask(QRegion(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()));
+
+ QRegion clipRegion = QRegion(clipRect);
+ platformWidget()->setMask(clipRegion);
+
+ // if setMask is set with an empty QRegion, no clipping will
+ // be performed, so in that case we hide the platformWidget
+ platformWidget()->setVisible(!clipRegion.isEmpty());
}
};
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index fe74fac..620aa31 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -872,14 +872,6 @@ void tst_QWebPage::textSelection()
"<p>May the source<br/>be with you!</p></body></html>");
page->mainFrame()->setHtml(content);
- // this will select the first paragraph
- QString script = "var range = document.createRange(); " \
- "var node = document.getElementById(\"one\"); " \
- "range.selectNode(node); " \
- "getSelection().addRange(range);";
- page->mainFrame()->evaluateJavaScript(script);
- QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
-
// these actions must exist
QVERIFY(page->action(QWebPage::SelectAll) != 0);
QVERIFY(page->action(QWebPage::SelectNextChar) != 0);
@@ -895,7 +887,8 @@ void tst_QWebPage::textSelection()
QVERIFY(page->action(QWebPage::SelectStartOfDocument) != 0);
QVERIFY(page->action(QWebPage::SelectEndOfDocument) != 0);
- // right now they are disabled because contentEditable is false
+ // right now they are disabled because contentEditable is false and
+ // there isn't an existing selection to modify
QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), false);
QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), false);
@@ -912,11 +905,37 @@ void tst_QWebPage::textSelection()
// ..but SelectAll is awalys enabled
QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
+ // this will select the first paragraph
+ QString selectScript = "var range = document.createRange(); " \
+ "var node = document.getElementById(\"one\"); " \
+ "range.selectNode(node); " \
+ "getSelection().addRange(range);";
+ page->mainFrame()->evaluateJavaScript(selectScript);
+ QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
+
+ // here the actions are enabled after a selection has been created
+ QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousWord)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectNextLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectPreviousLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfLine)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfBlock)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfBlock)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectStartOfDocument)->isEnabled(), true);
+ QCOMPARE(page->action(QWebPage::SelectEndOfDocument)->isEnabled(), true);
+
// make it editable before navigating the cursor
page->setContentEditable(true);
+ // cursor will be before the word "The", this makes sure there is a charet
+ page->triggerAction(QWebPage::MoveToStartOfDocument);
+ QVERIFY(page->isSelectionCollapsed());
+ QCOMPARE(page->selectionStartOffset(), 0);
+
// here the actions are enabled after contentEditable is true
- QCOMPARE(page->action(QWebPage::SelectAll)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectNextChar)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectPreviousChar)->isEnabled(), true);
QCOMPARE(page->action(QWebPage::SelectNextWord)->isEnabled(), true);
diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h
index 902b320..9b8b341 100644
--- a/src/corelib/arch/qatomic_symbian.h
+++ b/src/corelib/arch/qatomic_symbian.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h
index c795ea6..a1a5a7d 100644
--- a/src/corelib/arch/qatomic_windows.h
+++ b/src/corelib/arch/qatomic_windows.h
@@ -220,6 +220,9 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
#if !defined(Q_OS_WINCE) && !defined(Q_CC_MWERKS)
// use compiler intrinsics for all atomic functions
+//those functions need to be define in the global namespace
+QT_END_NAMESPACE
+
extern "C" {
long __cdecl _InterlockedIncrement(volatile long *);
long __cdecl _InterlockedDecrement(volatile long *);
@@ -252,6 +255,9 @@ extern "C" {
# define _InterlockedExchangeAddPointer(a,b) \
_InterlockedExchangeAdd(reinterpret_cast<volatile long *>(a), long(b))
# endif
+
+QT_BEGIN_NAMESPACE
+
inline bool QBasicAtomicInt::ref()
{
return _InterlockedIncrement(reinterpret_cast<volatile long *>(&_q_value)) != 0;
@@ -334,6 +340,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
#define Q_ARGUMENT_TYPE
#endif
+QT_END_NAMESPACE
+
extern "C" {
long __cdecl InterlockedIncrement(long Q_ARGUMENT_TYPE * lpAddend);
long __cdecl InterlockedDecrement(long Q_ARGUMENT_TYPE * lpAddend);
@@ -350,6 +358,8 @@ long __cdecl InterlockedExchangeAdd(long Q_ARGUMENT_TYPE * Addend, long Value);
# pragma intrinsic (_InterlockedExchangeAdd)
#endif
+QT_BEGIN_NAMESPACE
+
#endif
@@ -408,6 +418,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
// MinGW's definition, such that we pick up variations in the headers.
#ifndef __INTERLOCKED_DECLARED
#define __INTERLOCKED_DECLARED
+QT_END_NAMESPACE
+
extern "C" {
__declspec(dllimport) long __stdcall InterlockedCompareExchange(long *, long, long);
__declspec(dllimport) long __stdcall InterlockedIncrement(long *);
@@ -415,6 +427,8 @@ extern "C" {
__declspec(dllimport) long __stdcall InterlockedExchange(long *, long);
__declspec(dllimport) long __stdcall InterlockedExchangeAdd(long *, long);
}
+
+QT_BEGIN_NAMESPACE
#endif
inline bool QBasicAtomicInt::ref()
diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp
index bcb0bd4..170b737 100644
--- a/src/corelib/arch/symbian/qatomic_symbian.cpp
+++ b/src/corelib/arch/symbian/qatomic_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp
index dd2bc8d..5619580 100644
--- a/src/corelib/codecs/qisciicodec.cpp
+++ b/src/corelib/codecs/qisciicodec.cpp
@@ -38,7 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "qisciicodec_p.h"
#include "qlist.h"
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 6e8ffa1..cfb62c7 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -92,6 +92,11 @@
# define QT_NO_SETLOCALE
#endif
+#if 0 // ### TODO - remove me!
+// enabling this is not exception safe!
+#define Q_DEBUG_TEXTCODEC
+#endif
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTCODECPLUGIN
@@ -165,7 +170,9 @@ static QTextCodec *createForMib(int mib)
}
static QList<QTextCodec*> *all = 0;
+#ifdef Q_DEBUG_TEXTCODEC
static bool destroying_is_ok = false;
+#endif
static QTextCodec *localeMapper = 0;
QTextCodec *QTextCodec::cftr = 0;
@@ -187,15 +194,21 @@ QTextCodecCleanup::~QTextCodecCleanup()
if (!all)
return;
+#ifdef Q_DEBUG_TEXTCODEC
destroying_is_ok = true;
+#endif
- while (all->size())
- delete all->takeFirst();
+ for (QList<QTextCodec *>::const_iterator it = all->constBegin()
+ ; it != all->constEnd(); ++it) {
+ delete *it;
+ }
delete all;
all = 0;
localeMapper = 0;
+#ifdef Q_DEBUG_TEXTCODEC
destroying_is_ok = false;
+#endif
}
Q_GLOBAL_STATIC(QTextCodecCleanup, createQTextCodecCleanup)
@@ -659,8 +672,10 @@ static void setup()
if (all)
return;
+#ifdef Q_DEBUG_TEXTCODEC
if (destroying_is_ok)
qWarning("QTextCodec: Creating new codec during codec cleanup");
+#endif
all = new QList<QTextCodec*>;
// create the cleanup object to cleanup all codecs on exit
(void) createQTextCodecCleanup();
@@ -915,8 +930,10 @@ QTextCodec::QTextCodec()
*/
QTextCodec::~QTextCodec()
{
+#ifdef Q_DEBUG_TEXTCODEC
if (!destroying_is_ok)
qWarning("QTextCodec::~QTextCodec: Called by application");
+#endif
if (all)
all->removeAll(this);
}
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 1ac592e..d9defe1 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -478,7 +478,7 @@ QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterSt
data[2] = 0;
data[3] = 0;
}
- data += 2;
+ data += 4;
}
if (endian == BE) {
for (int i = 0; i < len; ++i) {
diff --git a/src/corelib/concurrent/qthreadpool.cpp b/src/corelib/concurrent/qthreadpool.cpp
index 30edfd4..8913b56 100644
--- a/src/corelib/concurrent/qthreadpool.cpp
+++ b/src/corelib/concurrent/qthreadpool.cpp
@@ -246,14 +246,14 @@ bool QThreadPoolPrivate::tooManyThreadsActive() const
*/
void QThreadPoolPrivate::startThread(QRunnable *runnable)
{
- QThreadPoolThread *thread = new QThreadPoolThread(this);
- allThreads.insert(thread);
+ QScopedPointer <QThreadPoolThread> thread(new QThreadPoolThread(this));
+ allThreads.insert(thread.data());
++activeThreads;
if (runnable->autoDelete())
++runnable->ref;
thread->runnable = runnable;
- thread->start();
+ thread.take()->start();
}
/*! \internal
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index dd1dbd2..e53fd2d 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -69,6 +69,7 @@
#endif
#if defined(Q_OS_SYMBIAN)
+#include <e32def.h>
#include <e32debug.h>
#endif
@@ -131,7 +132,8 @@ QT_BEGIN_NAMESPACE
If you want to use QFlags for your own enum types, use
the Q_DECLARE_FLAGS() and Q_DECLARE_OPERATORS_FOR_FLAGS().
- For example:
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 1
@@ -448,14 +450,18 @@ QT_BEGIN_NAMESPACE
function. You can retrieve the minimum and maximum of two given
objects using qMin() and qMax() respectively. All these functions
return a corresponding template type; the template types can be
- replaced by any other type. For example:
+ replaced by any other type.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 3
<QtGlobal> also contains functions that generate messages from the
given string argument: qCritical(), qDebug(), qFatal() and
qWarning(). These functions call the message handler with the
- given message. For example:
+ given message.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 4
@@ -700,7 +706,9 @@ QT_BEGIN_NAMESPACE
\relates <QtGlobal>
Wraps the signed 64-bit integer \a literal in a
- platform-independent way. For example:
+ platform-independent way.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 8
@@ -711,7 +719,9 @@ QT_BEGIN_NAMESPACE
\relates <QtGlobal>
Wraps the unsigned 64-bit integer \a literal in a
- platform-independent way. For example:
+ platform-independent way.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 9
@@ -740,7 +750,11 @@ QT_BEGIN_NAMESPACE
/*! \fn const T &qAbs(const T &value)
\relates <QtGlobal>
- Returns the absolute value of \a value. For example:
+ Compares \a value to the 0 of type T and returns the absolute
+ value. Thus if T is \e {double}, then \a value is compared to
+ \e{(double) 0}.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 10
*/
@@ -748,7 +762,9 @@ QT_BEGIN_NAMESPACE
/*! \fn int qRound(qreal value)
\relates <QtGlobal>
- Rounds \a value to the nearest integer. For example:
+ Rounds \a value to the nearest integer.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 11
*/
@@ -756,7 +772,9 @@ QT_BEGIN_NAMESPACE
/*! \fn qint64 qRound64(qreal value)
\relates <QtGlobal>
- Rounds \a value to the nearest 64-bit integer. For example:
+ Rounds \a value to the nearest 64-bit integer.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 12
*/
@@ -764,7 +782,9 @@ QT_BEGIN_NAMESPACE
/*! \fn const T &qMin(const T &value1, const T &value2)
\relates <QtGlobal>
- Returns the minimum of \a value1 and \a value2. For example:
+ Returns the minimum of \a value1 and \a value2.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 13
@@ -774,7 +794,9 @@ QT_BEGIN_NAMESPACE
/*! \fn const T &qMax(const T &value1, const T &value2)
\relates <QtGlobal>
- Returns the maximum of \a value1 and \a value2. For example:
+ Returns the maximum of \a value1 and \a value2.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 14
@@ -785,7 +807,9 @@ QT_BEGIN_NAMESPACE
\relates <QtGlobal>
Returns \a value bounded by \a min and \a max. This is equivalent
- to qMax(\a min, qMin(\a value, \a max)). For example:
+ to qMax(\a min, qMin(\a value, \a max)).
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 15
@@ -931,7 +955,9 @@ QT_BEGIN_NAMESPACE
4.1.2, the QT_VERSION macro will expand to 0x040102.
You can use QT_VERSION to use the latest Qt features where
- available. For example:
+ available.
+
+ Example:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 16
@@ -1903,6 +1929,15 @@ void qt_check_pointer(const char *n, int l)
qWarning("In file %s, line %d: Out of memory", n, l);
}
+/* \internal
+ Allows you to throw an exception without including <new>
+ Called internally from Q_CHECK_PTR on certain OS combinations
+*/
+void qBadAlloc()
+{
+ QT_THROW(std::bad_alloc());
+}
+
/*
The Q_ASSERT macro calls this function when the test fails.
*/
@@ -2150,7 +2185,12 @@ void qt_message_output(QtMsgType msgType, const char *buf)
#endif
#if defined(Q_OS_SYMBIAN)
- User::Invariant(); // Panic the current thread
+ __DEBUGGER(); // on the emulator, get the debugger to kick in if there's one around
+ TBuf<256> tmp;
+ TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
+ TInt len = Min(tmp.MaxLength(), ptr.Length());
+ tmp.Copy(ptr.Left(len));
+ User::Panic(tmp, 0); // Panic the current thread
#elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
abort(); // trap; generates core dump
#else
@@ -2159,6 +2199,48 @@ void qt_message_output(QtMsgType msgType, const char *buf)
}
}
+#if !defined(QT_NO_EXCEPTIONS)
+/*!
+ \internal
+ Uses a local buffer to output the message. Not locale safe + cuts off
+ everything after character 1023, but will work in out of memory situations.
+*/
+static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap)
+{
+ char emergency_buf[256] = { '\0' };
+ emergency_buf[255] = '\0';
+ if (msg)
+ qvsnprintf(emergency_buf, 255, msg, ap);
+ qt_message_output(msgType, emergency_buf);
+}
+#endif
+
+/*!
+ \internal
+*/
+static void qt_message(QtMsgType msgType, const char *msg, va_list ap)
+{
+#if !defined(QT_NO_EXCEPTIONS)
+ if (std::uncaught_exception()) {
+ qEmergencyOut(msgType, msg, ap);
+ return;
+ }
+#endif
+ QByteArray buf;
+ if (msg) {
+ QT_TRY {
+ buf = QString().vsprintf(msg, ap).toLocal8Bit();
+ } QT_CATCH(const std::bad_alloc &) {
+#if !defined(QT_NO_EXCEPTIONS)
+ qEmergencyOut(msgType, msg, ap);
+ // don't rethrow - we use qWarning and friends in destructors.
+ return;
+#endif
+ }
+ }
+ qt_message_output(msgType, buf.constData());
+}
+
#undef qDebug
/*!
\relates <QtGlobal>
@@ -2196,14 +2278,10 @@ void qt_message_output(QtMsgType msgType, const char *buf)
*/
void qDebug(const char *msg, ...)
{
- QString buf;
va_list ap;
- va_start(ap, msg); // use variable arg list
- if (msg)
- buf.vsprintf(msg, ap);
+ va_start(ap, msg); // use variable arg list
+ qt_message(QtDebugMsg, msg, ap);
va_end(ap);
-
- qt_message_output(QtDebugMsg, buf.toLocal8Bit().constData());
}
#undef qWarning
@@ -2240,14 +2318,10 @@ void qDebug(const char *msg, ...)
*/
void qWarning(const char *msg, ...)
{
- QString buf;
va_list ap;
va_start(ap, msg); // use variable arg list
- if (msg)
- buf.vsprintf(msg, ap);
+ qt_message(QtWarningMsg, msg, ap);
va_end(ap);
-
- qt_message_output(QtWarningMsg, buf.toLocal8Bit().constData());
}
/*!
@@ -2280,15 +2354,12 @@ void qWarning(const char *msg, ...)
*/
void qCritical(const char *msg, ...)
{
- QString buf;
va_list ap;
va_start(ap, msg); // use variable arg list
- if (msg)
- buf.vsprintf(msg, ap);
+ qt_message(QtCriticalMsg, msg, ap);
va_end(ap);
-
- qt_message_output(QtCriticalMsg, buf.toLocal8Bit().constData());
}
+
#ifdef QT3_SUPPORT
void qSystemWarning(const char *msg, int code)
{ qCritical("%s (%s)", msg, qt_error_string(code).toLocal8Bit().constData()); }
@@ -2296,6 +2367,8 @@ void qSystemWarning(const char *msg, int code)
void qErrnoWarning(const char *msg, ...)
{
+ // qt_error_string() will allocate anyway, so we don't have
+ // to be careful here (like we do in plain qWarning())
QString buf;
va_list ap;
va_start(ap, msg);
@@ -2308,6 +2381,8 @@ void qErrnoWarning(const char *msg, ...)
void qErrnoWarning(int code, const char *msg, ...)
{
+ // qt_error_string() will allocate anyway, so we don't have
+ // to be careful here (like we do in plain qWarning())
QString buf;
va_list ap;
va_start(ap, msg);
@@ -2344,14 +2419,10 @@ void qErrnoWarning(int code, const char *msg, ...)
*/
void qFatal(const char *msg, ...)
{
- QString buf;
va_list ap;
va_start(ap, msg); // use variable arg list
- if (msg)
- buf.vsprintf(msg, ap);
+ qt_message(QtFatalMsg, msg, ap);
va_end(ap);
-
- qt_message_output(QtFatalMsg, buf.toLocal8Bit().constData());
}
// getenv is declared as deprecated in VS2005. This function
@@ -3139,4 +3210,176 @@ bool QInternal::callFunction(InternalFunction func, void **args)
\sa Q_DECL_EXPORT
*/
+#if defined(Q_OS_SYMBIAN)
+
+#include <typeinfo>
+
+/*! \macro QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(function)
+ \relates <QtGlobal>
+ \ingroup qts60
+
+ TRAP leaves from Symbian \a function and throws an appropriate
+ standard C++ exception instead.
+ This must be used when calling Symbian OS leaving functions
+ from inside Qt or standard C++ code, so that the code can respond
+ correctly to the exception.
+
+ \warning This macro is only available on Symbian.
+
+ Example:
+
+ \code
+ // A Symbian leaving function is being called within a Qt function.
+ // Any leave must be converted to an exception
+ CAknTitlePane* titlePane = S60->titlePane();
+ if (titlePane) {
+ TPtrC captionPtr(qt_QString2TPtrC(caption));
+ QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(titlePane->SetTextL(captionPtr));
+ }
+ \endcode
+
+ \sa QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(), QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE()
+*/
+
+/*! \macro QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(error, function)
+ \relates <QtGlobal>
+ \ingroup qts60
+
+ Catch standard C++ exceptions from a \a function and convert them to a Symbian OS
+ \a error code, or \c KErrNone if there is no exception.
+ This must be used inside Qt or standard C++ code when using exception throwing
+ code (practically anything) and returning an error code to Symbian OS.
+
+ \warning This macro is only available on Symbian.
+
+ Example:
+
+ \code
+ // An exception might be thrown in this Symbian TInt error returning function.
+ // It is caught and translated to an error code
+ TInt QServerApp::Connect(const QString &serverName)
+ {
+ TPtrC name;
+ TInt err;
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(err, name.Set(qt_QString2TPtrC(serverName)));
+ if (err != KErrNone)
+ return err;
+ return iServer.Connect(name);
+ }
+ \endcode
+}
+
+ \sa QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(), QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION()
+*/
+
+/*! \macro QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(function)
+ \relates <QtGlobal>
+ \ingroup qts60
+
+ Catch standard C++ exceptions from \a function and convert them to Symbian OS
+ leaves. This must be used inside Qt or standard C++ code when using exception
+ throwing code (practically anything) and returning to Symbian OS from a leaving function.
+ For example inside a Symbian active object's \c RunL function implemented with Qt code.
+
+ \warning This macro is only available on Symbian.
+
+ Example:
+
+ \code
+ // This active object signals Qt code
+ // Exceptions from the Qt code must be converted to Symbian OS leaves for the active scheduler
+ void QWakeUpActiveObject::RunL()
+ {
+ iStatus = KRequestPending;
+ SetActive();
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->wakeUpWasCalled());
+ }
+ \endcode
+
+ \sa QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(), QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR()
+*/
+
+#include <stdexcept>
+
+class QSymbianLeaveException : public std::exception
+{
+public:
+ inline QSymbianLeaveException(int err) : error(err) {}
+ inline const char* what() const throw() { return "Symbian leave exception"; }
+
+public:
+ int error;
+};
+
+/*! \relates <QtGlobal>
+ \ingroup qts60
+
+ Throws an exception if the \a error parameter is a symbian error code.
+ This is the exception throwing equivalent of Symbian's User::LeaveIfError.
+
+ \warning This function is only available on Symbian.
+
+ \sa qt_translateExceptionToSymbianErrorL(), qt_translateExceptionToSymbianError()
+*/
+void qt_translateSymbianErrorToException(int error)
+{
+ if (error >= KErrNone)
+ return; // do nothing - not an exception
+ switch (error) {
+ case KErrNoMemory:
+ throw std::bad_alloc();
+ default:
+ throw QSymbianLeaveException(error);
+ }
+}
+
+/*! \relates <QtGlobal>
+ \ingroup qts60
+
+ Convert a caught standard C++ exception \a aThrow to a Symbian leave
+
+ \warning This function is only available on Symbian.
+
+ \sa qt_translateSymbianErrorToException(), qt_translateExceptionToSymbianError()
+*/
+void qt_translateExceptionToSymbianErrorL(const std::exception& aThrow)
+{
+ User::Leave(qt_translateExceptionToSymbianError(aThrow));
+}
+
+/*! \relates <QtGlobal>
+ \ingroup qts60
+
+ Convert a caught standard C++ exception \a aThrow to a Symbian error code
+
+ \warning This function is only available on Symbian.
+
+ \sa qt_translateSymbianErrorToException(), qt_translateExceptionToSymbianErrorL()
+*/
+int qt_translateExceptionToSymbianError(const std::exception& aThrow)
+{
+ const std::type_info& atype = typeid(aThrow);
+ int err = KErrGeneral;
+
+ if(atype == typeid (std::bad_alloc))
+ err = KErrNoMemory;
+ else if(atype == typeid(QSymbianLeaveException))
+ err = static_cast<const QSymbianLeaveException&>(aThrow).error;
+ else if(atype == typeid(std::invalid_argument))
+ err = KErrArgument;
+ else if(atype == typeid(std::out_of_range))
+ // std::out_of_range is of type logic_error which by definition means that it is
+ // "presumably detectable before the program executes".
+ // std::out_of_range is used to report an argument is not within the expected range.
+ // The description of KErrArgument says an argument is out of range. Hence the mapping.
+ err = KErrArgument;
+ else if(atype == typeid(std::overflow_error))
+ err = KErrOverflow;
+ else if(atype == typeid(std::underflow_error))
+ err = KErrUnderflow;
+
+ return err;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 15b2d53..825b7e8 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1055,8 +1055,13 @@ 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); }
+#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 - qint64(d-1) + 0.5) + qint64(d-1); }
+#else
inline qint64 qRound64(qreal d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); }
+#endif
template <typename T>
inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; }
@@ -1118,7 +1123,7 @@ class QDataStream;
#ifndef Q_DECL_EXPORT
# ifdef Q_OS_WIN
# define Q_DECL_EXPORT __declspec(dllexport)
-# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
+# elif defined(Q_CC_NOKIAX86)
# define Q_DECL_EXPORT __declspec(dllexport)
# elif defined(QT_VISIBILITY_AVAILABLE)
# define Q_DECL_EXPORT __attribute__((visibility("default")))
@@ -1130,7 +1135,7 @@ class QDataStream;
#ifndef Q_DECL_IMPORT
# if defined(Q_OS_WIN)
# define Q_DECL_IMPORT __declspec(dllimport)
-# elif defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT)
+# elif defined(Q_CC_NOKIAX86)
# define Q_DECL_IMPORT __declspec(dllimport)
# else
# define Q_DECL_IMPORT
@@ -1296,6 +1301,32 @@ class QDataStream;
# define Q_AUTOTEST_EXPORT
#endif
+inline void qt_noop() {}
+
+/* These wrap try/catch so we can switch off exceptions later.
+
+ Beware - do not use more than one QT_CATCH per QT_TRY, and do not use
+ the exception instance in the catch block.
+ If you can't live with those constraints, don't use these macros.
+ Use the QT_NO_EXCEPTIONS macro to protect your code instead.
+*/
+
+#ifdef QT_BOOTSTRAPPED
+# define QT_NO_EXCEPTIONS
+#endif
+
+#ifdef QT_NO_EXCEPTIONS
+# define QT_TRY if (true)
+# define QT_CATCH(A) else
+# define QT_THROW(A) qt_noop()
+# define QT_RETHROW qt_noop()
+#else
+# define QT_TRY try
+# define QT_CATCH(A) catch (A)
+# define QT_THROW(A) throw A
+# define QT_RETHROW throw
+#endif
+
/*
System information
*/
@@ -1549,8 +1580,6 @@ inline QNoDebug qDebug();
#endif
-inline void qt_noop() {}
-
Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
#if !defined(Q_ASSERT)
@@ -1576,11 +1605,16 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *
#endif
Q_CORE_EXPORT void qt_check_pointer(const char *, int);
+Q_CORE_EXPORT void qBadAlloc();
-#ifndef QT_NO_DEBUG
-# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
+#ifdef QT_NO_EXCEPTIONS
+# if defined(QT_NO_DEBUG)
+# define Q_CHECK_PTR(p) qt_noop();
+# else
+# define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0)
+# endif
#else
-# define Q_CHECK_PTR(p)
+# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
#endif
#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC)
@@ -1729,12 +1763,12 @@ public:
static TYPE *NAME() \
{ \
if (!this_##NAME.pointer && !this_##NAME.destroyed) { \
- TYPE *x = new TYPE; \
+ QScopedPointer<TYPE > x(new TYPE); \
INITIALIZER; \
- if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \
- delete x; \
- else \
+ if (this_##NAME.pointer.testAndSetOrdered(0, x.data())) { \
static QGlobalStaticDeleter<TYPE > cleanup(this_##NAME); \
+ x.take(); \
+ } \
} \
return this_##NAME.pointer; \
}
@@ -2188,8 +2222,8 @@ inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase
#endif
#define Q_DECLARE_PRIVATE(Class) \
- inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(d_ptr); } \
- inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr); } \
+ inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
+ inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.data()); } \
friend class Class##Private;
#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
@@ -2237,7 +2271,9 @@ inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase
Class(const Class &); \
Class &operator=(const Class &);
#else
-# define Q_DISABLE_COPY(Class)
+# define Q_DISABLE_COPY(Class) \
+ Class(const Class &); \
+ Class &operator=(const Class &);
#endif
class QByteArray;
@@ -2274,6 +2310,42 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();
QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#endif
+#if defined(Q_OS_SYMBIAN)
+
+// forward declare std::exception
+namespace std { class exception; }
+
+Q_CORE_EXPORT void qt_translateSymbianErrorToException(int error);
+Q_CORE_EXPORT void qt_translateExceptionToSymbianErrorL(const std::exception& ex);
+Q_CORE_EXPORT int qt_translateExceptionToSymbianError(const std::exception& ex);
+
+#define QT_TRANSLATE_SYMBIAN_LEAVE_TO_EXCEPTION(f) \
+ { \
+ TInt error; \
+ TRAP(error, f); \
+ if (error) \
+ qt_translateSymbianErrorToException(error); \
+ }
+
+#define QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(err, f) \
+ { \
+ err = KErrNone; \
+ try { \
+ f; \
+ } catch (const std::exception &ex) { \
+ err = qt_translateExceptionToSymbianError(ex); \
+ } \
+ }
+
+#define QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(f) \
+ { \
+ TInt err; \
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(err, f) \
+ User::LeaveIfError(err); \
+ }
+#endif
+
+
/*
This gives us the possibility to check which modules the user can
use. These are purely compile time checks and will generate no code.
@@ -2347,6 +2419,9 @@ QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
#define QT_LICENSED_MODULE(x) \
enum QtValidLicenseFor##x##Module { Licensed##x = true };
+/* qdoc is really unhappy with the following block of preprocessor checks,
+ making it difficult to document classes properly after this point. */
+
#if (QT_EDITION & QT_MODULE_CORE)
QT_LICENSED_MODULE(Core)
#endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 29e356e..5e4b9bd 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include "qdir.h"
-#include "qfile.h"
+#include "qfile.h"
#include "qconfig.h"
#include "qsettings.h"
#include "qlibraryinfo.h"
-#include "qpointer.h"
+#include "qscopedpointer.h"
#ifdef QT_BUILD_QMAKE
QT_BEGIN_NAMESPACE
@@ -67,8 +67,7 @@ QT_BEGIN_NAMESPACE
struct QLibrarySettings
{
QLibrarySettings();
- ~QLibrarySettings() { delete static_cast<QSettings *>(settings); }
- QSettings *settings;
+ QScopedPointer<QSettings> settings;
};
Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings)
@@ -79,32 +78,19 @@ public:
static void cleanup()
{
QLibrarySettings *ls = qt_library_settings();
- if (ls) {
- delete static_cast<QSettings *>(ls->settings);
- ls->settings = 0;
- }
+ if (ls)
+ ls->settings.reset(0);
}
static QSettings *configuration()
{
-#ifdef QT_NO_THREAD
- // This recursion guard should be a temporary solution; the recursive
- // dependency should be found and removed.
- static bool initializing = false;
- if (initializing)
- return 0;
- initializing = true;
-#endif
QLibrarySettings *ls = qt_library_settings();
-#ifdef QT_NO_THREAD
- initializing = false;
-#endif
- return ls ? static_cast<QSettings *>(qt_library_settings()->settings) : (QSettings*)0;
+ return ls ? ls->settings.data() : 0;
}
};
QLibrarySettings::QLibrarySettings()
+ : settings(QLibraryInfoPrivate::findConfiguration())
{
- settings = QLibraryInfoPrivate::findConfiguration();
#ifndef QT_BUILD_QMAKE
qAddPostRoutine(QLibraryInfoPrivate::cleanup);
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index e0ca27c..43740ed 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1395,22 +1395,26 @@ public:
ImCursorPosition,
ImSurroundingText,
ImCurrentSelection,
- ImMaximumTextLength
+ ImMaximumTextLength,
+ ImAnchorPosition
};
enum InputMethodHint {
ImhNone = 0x0,
ImhHiddenText = 0x1,
- ImhDigitsOnly = 0x2,
- ImhFormattedNumbersOnly = 0x4,
- ImhUppercaseOnly = 0x8,
- ImhLowercaseOnly = 0x10,
- ImhNoAutoUppercase = 0x20,
- ImhPreferNumbers = 0x40,
- ImhPreferUppercase = 0x80,
- ImhPreferLowercase = 0x100,
- ImhNoPredictiveText = 0x200,
- ImhDialableCharactersOnly = 0x400
+ ImhNoAutoUppercase = 0x2,
+ ImhPreferNumbers = 0x4,
+ ImhPreferUppercase = 0x8,
+ ImhPreferLowercase = 0x10,
+ ImhNoPredictiveText = 0x20,
+
+ ImhDigitsOnly = 0x10000,
+ ImhFormattedNumbersOnly = 0x20000,
+ ImhUppercaseOnly = 0x40000,
+ ImhLowercaseOnly = 0x80000,
+ ImhDialableCharactersOnly = 0x100000,
+
+ ImhExclusiveInputMask = 0xffff0000
};
Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index bedc121..63d4944 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -352,8 +352,6 @@ QAbstractFileEngine::QAbstractFileEngine(QAbstractFileEnginePrivate &dd) : d_ptr
*/
QAbstractFileEngine::~QAbstractFileEngine()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
@@ -881,7 +879,6 @@ QAbstractFileEngineIterator::QAbstractFileEngineIterator(QDir::Filters filters,
*/
QAbstractFileEngineIterator::~QAbstractFileEngineIterator()
{
- delete d;
}
/*!
diff --git a/src/corelib/io/qabstractfileengine.h b/src/corelib/io/qabstractfileengine.h
index d742467..5b75343 100644
--- a/src/corelib/io/qabstractfileengine.h
+++ b/src/corelib/io/qabstractfileengine.h
@@ -193,7 +193,7 @@ protected:
QAbstractFileEngine();
QAbstractFileEngine(QAbstractFileEnginePrivate &);
- QAbstractFileEnginePrivate *d_ptr;
+ QScopedPointer<QAbstractFileEnginePrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QAbstractFileEngine)
Q_DISABLE_COPY(QAbstractFileEngine)
@@ -237,7 +237,7 @@ private:
friend class QDirIterator;
friend class QDirIteratorPrivate;
void setPath(const QString &path);
- QAbstractFileEngineIteratorPrivate *d;
+ QScopedPointer<QAbstractFileEngineIteratorPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index b203899..e324ffe 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -622,11 +622,16 @@ QDataStream &QDataStream::operator>>(qint16 &i)
setStatus(ReadPastEnd);
}
} else {
- register uchar *p = (uchar *)(&i);
+ union {
+ qint16 val1;
+ char val2[2];
+ } x;
+ char *p = x.val2;
char b[2];
if (dev->read(b, 2) == 2) {
*p++ = b[1];
*p = b[0];
+ i = x.val1;
} else {
setStatus(ReadPastEnd);
}
@@ -660,13 +665,18 @@ QDataStream &QDataStream::operator>>(qint32 &i)
setStatus(ReadPastEnd);
}
} else { // swap bytes
- uchar *p = (uchar *)(&i);
+ union {
+ qint32 val1;
+ char val2[4];
+ } x;
+ char *p = x.val2;
char b[4];
if (dev->read(b, 4) == 4) {
*p++ = b[3];
*p++ = b[2];
*p++ = b[1];
*p = b[0];
+ i = x.val1;
} else {
setStatus(ReadPastEnd);
}
@@ -703,7 +713,12 @@ QDataStream &QDataStream::operator>>(qint64 &i)
setStatus(ReadPastEnd);
}
} else { // swap bytes
- uchar *p = (uchar *)(&i);
+ union {
+ qint64 val1;
+ char val2[8];
+ } x;
+
+ char *p = x.val2;
char b[8];
if (dev->read(b, 8) == 8) {
*p++ = b[7];
@@ -714,6 +729,7 @@ QDataStream &QDataStream::operator>>(qint64 &i)
*p++ = b[2];
*p++ = b[1];
*p = b[0];
+ i = x.val1;
} else {
setStatus(ReadPastEnd);
}
@@ -751,13 +767,19 @@ QDataStream &QDataStream::operator>>(float &f)
setStatus(ReadPastEnd);
}
} else { // swap bytes
- uchar *p = (uchar *)(&f);
+ union {
+ float val1;
+ char val2[4];
+ } x;
+
+ char *p = x.val2;
char b[4];
if (dev->read(b, 4) == 4) {
*p++ = b[3];
*p++ = b[2];
*p++ = b[1];
*p = b[0];
+ f = x.val1;
} else {
setStatus(ReadPastEnd);
}
@@ -788,7 +810,11 @@ QDataStream &QDataStream::operator>>(double &f)
setStatus(ReadPastEnd);
}
} else { // swap bytes
- register uchar *p = (uchar *)(&f);
+ union {
+ double val1;
+ char val2[8];
+ } x;
+ char *p = x.val2;
char b[8];
if (dev->read(b, 8) == 8) {
*p++ = b[7];
@@ -799,13 +825,18 @@ QDataStream &QDataStream::operator>>(double &f)
*p++ = b[2];
*p++ = b[1];
*p = b[0];
+ f = x.val1;
} else {
setStatus(ReadPastEnd);
}
}
#else
//non-standard floating point format
- register uchar *p = (uchar *)(&f);
+ union {
+ double val1;
+ char val2[8];
+ } x;
+ char *p = x.val2;
char b[8];
if (dev->read(b, 8) == 8) {
if (noswap) {
@@ -827,6 +858,7 @@ QDataStream &QDataStream::operator>>(double &f)
*p++ = b[Q_DF(1)];
*p = b[Q_DF(0)];
}
+ f = x.val1;
} else {
setStatus(ReadPastEnd);
}
@@ -970,7 +1002,12 @@ QDataStream &QDataStream::operator<<(qint16 i)
if (noswap) {
dev->write((char *)&i, sizeof(qint16));
} else { // swap bytes
- register uchar *p = (uchar *)(&i);
+ union {
+ qint16 val1;
+ char val2[2];
+ } x;
+ x.val1 = i;
+ char *p = x.val2;
char b[2];
b[1] = *p++;
b[0] = *p;
@@ -992,7 +1029,12 @@ QDataStream &QDataStream::operator<<(qint32 i)
if (noswap) {
dev->write((char *)&i, sizeof(qint32));
} else { // swap bytes
- register uchar *p = (uchar *)(&i);
+ union {
+ qint32 val1;
+ char val2[4];
+ } x;
+ x.val1 = i;
+ char *p = x.val2;
char b[4];
b[3] = *p++;
b[2] = *p++;
@@ -1022,13 +1064,18 @@ QDataStream &QDataStream::operator<<(qint64 i)
{
CHECK_STREAM_PRECOND(*this)
if (version() < 6) {
- quint32 i1 = i & 0xffffffff;
- quint32 i2 = i >> 32;
- *this << i2 << i1;
+ quint32 i1 = i & 0xffffffff;
+ quint32 i2 = i >> 32;
+ *this << i2 << i1;
} else if (noswap) { // no conversion needed
dev->write((char *)&i, sizeof(qint64));
} else { // swap bytes
- register uchar *p = (uchar *)(&i);
+ union {
+ qint64 val1;
+ char val2[8];
+ } x;
+ x.val1 = i;
+ char *p = x.val2;
char b[8];
b[7] = *p++;
b[6] = *p++;
@@ -1077,7 +1124,12 @@ QDataStream &QDataStream::operator<<(float f)
if (noswap) { // no conversion needed
dev->write((char *)&g, sizeof(float));
} else { // swap bytes
- register uchar *p = (uchar *)(&g);
+ union {
+ float val1;
+ char val2[4];
+ } x;
+ x.val1 = f;
+ char *p = x.val2;
char b[4];
b[3] = *p++;
b[2] = *p++;
@@ -1103,7 +1155,12 @@ QDataStream &QDataStream::operator<<(double f)
if (noswap) {
dev->write((char *)&f, sizeof(double));
} else {
- register uchar *p = (uchar *)(&f);
+ union {
+ double val1;
+ char val2[8];
+ } x;
+ x.val1 = f;
+ char *p = x.val2;
char b[8];
b[7] = *p++;
b[6] = *p++;
@@ -1116,7 +1173,12 @@ QDataStream &QDataStream::operator<<(double f)
dev->write(b, 8);
}
#else
- register uchar *p = (uchar *)(&f);
+ union {
+ double val1;
+ char val2[8];
+ } x;
+ x.val1 = f;
+ char *p = x.val2;
char b[8];
if (noswap) {
b[Q_DF(0)] = *p++;
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 8334146..60dc688 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -79,8 +79,11 @@ public:
inline QDebug &operator=(const QDebug &other);
inline ~QDebug() {
if (!--stream->ref) {
- if(stream->message_output)
- qt_message_output(stream->type, stream->buffer.toLocal8Bit().data());
+ if(stream->message_output) {
+ QT_TRY {
+ qt_message_output(stream->type, stream->buffer.toLocal8Bit().data());
+ } QT_CATCH(std::bad_alloc) { /* We're out of memory - give up. */ }
+ }
delete stream;
}
}
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 901641c..e1cc7ac 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -83,6 +83,7 @@ class QDirPrivate
QDir *q_ptr;
Q_DECLARE_PUBLIC(QDir)
+ friend class QScopedPointer<QDirPrivate>;
protected:
QDirPrivate(QDir*, const QDir *copy=0);
~QDirPrivate();
@@ -573,8 +574,6 @@ QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(this, &dir))
QDir::~QDir()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index c4f6b1a..ac80094 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -45,6 +45,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qstringlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -57,7 +58,7 @@ class QDirPrivate;
class Q_CORE_EXPORT QDir
{
protected:
- QDirPrivate *d_ptr;
+ QScopedPointer<QDirPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QDir)
public:
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index b14f436..81bfb27 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -201,8 +201,8 @@ void QDirIteratorPrivate::advance()
QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
- if (currentFileInfo.isSymLink())
- subDir = currentFileInfo.canonicalFilePath();
+ if (nextFileInfo.isSymLink())
+ subDir = nextFileInfo.canonicalFilePath();
#endif
pushSubDirectory(subDir, it->nameFilters(), it->filters());
}
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 4a20c97..1e3d5a3 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -109,6 +109,7 @@ QFilePrivate::openExternalFile(int flags, int fd)
return false;
#else
delete fileEngine;
+ fileEngine = 0;
QFSFileEngine *fe = new QFSFileEngine;
fe->setFileName(fileName);
fileEngine = fe;
@@ -125,6 +126,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh)
return false;
#else
delete fileEngine;
+ fileEngine = 0;
QFSFileEngine *fe = new QFSFileEngine;
fe->setFileName(fileName);
fileEngine = fe;
@@ -410,9 +412,6 @@ QFile::QFile(QFilePrivate &dd, QObject *parent)
QFile::~QFile()
{
close();
-#ifdef QT_NO_QOBJECT
- delete d_ptr;
-#endif
}
/*!
@@ -718,26 +717,29 @@ QFile::rename(const QString &newName)
return true;
}
- QFile in(fileName());
+ if (isSequential()) {
+ d->setError(QFile::RenameError, tr("Will not rename sequential file using block copy"));
+ return false;
+ }
+
QFile out(newName);
- if (in.open(QIODevice::ReadOnly)) {
+ if (open(QIODevice::ReadOnly)) {
if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
bool error = false;
char block[4096];
- qint64 read;
- while ((read = in.read(block, sizeof(block))) > 0) {
- if (read != out.write(block, read)) {
+ qint64 bytes;
+ while ((bytes = read(block, sizeof(block))) > 0) {
+ if (bytes != out.write(block, bytes)) {
d->setError(QFile::RenameError, out.errorString());
error = true;
break;
}
}
- if (read == -1) {
- d->setError(QFile::RenameError, in.errorString());
+ if (bytes == -1) {
+ d->setError(QFile::RenameError, errorString());
error = true;
}
if(!error) {
- in.close();
if (!remove()) {
d->setError(QFile::RenameError, tr("Cannot remove source file"));
error = true;
@@ -747,12 +749,16 @@ QFile::rename(const QString &newName)
out.remove();
} else {
fileEngine()->setFileName(newName);
+ setPermissions(permissions());
+ unsetError();
setFileName(newName);
}
+ close();
return !error;
}
+ close();
}
- d->setError(QFile::RenameError, out.isOpen() ? in.errorString() : out.errorString());
+ d->setError(QFile::RenameError, out.isOpen() ? errorString() : out.errorString());
}
return false;
}
@@ -914,6 +920,7 @@ QFile::copy(const QString &newName)
out.setAutoRemove(false);
#endif
}
+ close();
}
if(!error) {
QFile::setPermissions(newName, permissions());
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 96e0f82..b36fb69 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -439,8 +439,6 @@ QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fi
QFileInfo::~QFileInfo()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 97997a3..6c01f63 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -44,6 +44,7 @@
#include <QtCore/qfile.h>
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -165,7 +166,7 @@ public:
#endif
protected:
- QFileInfoPrivate *d_ptr;
+ QScopedPointer<QFileInfoPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QFileInfo)
};
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index 883b70f..aeb19db 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -50,7 +80,7 @@ void CNotifyChangeEvent::RunL()
if (iStatus.Int() == KErrNone){
fsSession.NotifyChange(ENotifyAll, iStatus, watchedPath);
SetActive();
- engine->emitPathChanged(this);
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(engine->emitPathChanged(this));
} else {
qWarning("CNotifyChangeEvent::RunL() - Failed to order change notifications: %d", iStatus.Int());
}
@@ -232,9 +262,9 @@ void QSymbianFileSystemWatcherEngine::run()
void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directoryPath)
{
QMutexLocker locker(&mutex);
- HBufC* buffer = qt_QString2HBufCNewL(QDir::toNativeSeparators(directoryPath));
- currentEvent = CNotifyChangeEvent::New(fsSession, *buffer, this);
- delete buffer;
+ QString nativeDir(QDir::toNativeSeparators(directoryPath));
+ TPtrC ptr(qt_QString2TPtrC(nativeDir));
+ currentEvent = CNotifyChangeEvent::New(fsSession, ptr, this);
syncCondition.wakeOne();
}
diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h
index b34418a..9919114 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian_p.h
+++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 61ea7cc..07f3c9c 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -312,6 +312,10 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
if (ret == -1) {
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
qt_error_string(int(errno)));
+
+ this->openMode = QIODevice::NotOpen;
+ this->fh = 0;
+
return false;
}
}
@@ -335,6 +339,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
openMode |= QFile::Truncate;
+ d->openMode = openMode;
d->lastFlushFailed = false;
d->closeFileHandle = false;
d->nativeFilePath.clear();
@@ -367,6 +372,10 @@ bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd)
if (ret == -1) {
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
qt_error_string(int(errno)));
+
+ this->openMode = QIODevice::NotOpen;
+ this->fd = -1;
+
return false;
}
}
@@ -868,6 +877,119 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
return false;
}
+/*! \fn bool QFSFileEngine::caseSensitive() const
+ Returns true for Windows, false for Unix.
+*/
+
+/*! \fn bool QFSFileEngine::copy(const QString &copyName)
+
+ For windows, copy the file to file \a copyName.
+
+ Not implemented for Unix.
+*/
+
+/*! \fn QString QFSFileEngine::currentPath(const QString &fileName)
+ For Unix, returns the current working directory for the file
+ engine.
+
+ For Windows, returns the canonicalized form of the current path used
+ by the file engine for the drive specified by \a fileName. On
+ Windows, each drive has its own current directory, so a different
+ path is returned for file names that include different drive names
+ (e.g. A: or C:).
+
+ \sa setCurrentPath()
+*/
+
+/*! \fn QFileInfoList QFSFileEngine::drives()
+ For Windows, returns the list of drives in the file system as a list
+ of QFileInfo objects. On unix, Mac OS X and Windows CE, only the
+ root path is returned. On Windows, this function returns all drives
+ (A:\, C:\, D:\, etc.).
+
+ For Unix, the list contains just the root path "/".
+*/
+
+/*! \fn QString QFSFileEngine::fileName(FileName file) const
+ \reimp
+*/
+
+/*! \fn QDateTime QFSFileEngine::fileTime(FileTime time) const
+ \reimp
+*/
+
+/*! \fn QString QFSFileEngine::homePath()
+ Returns the home path of the current user.
+
+ \sa rootPath()
+*/
+
+/*! \fn bool QFSFileEngine::isRelativePath() const
+ \reimp
+*/
+
+/*! \fn bool QFSFileEngine::link(const QString &newName)
+
+ Creates a link from the file currently specified by fileName() to
+ \a newName. What a link is depends on the underlying filesystem
+ (be it a shortcut on Windows or a symbolic link on Unix). Returns
+ true if successful; otherwise returns false.
+*/
+
+/*! \fn bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
+ \reimp
+*/
+
+/*! \fn uint QFSFileEngine::ownerId(FileOwner own) const
+ In Unix, if stat() is successful, the \c uid is returned if
+ \a own is the owner. Otherwise the \c gid is returned. If stat()
+ is unsuccessful, -2 is reuturned.
+
+ For Windows, -2 is always returned.
+*/
+
+/*! \fn QString QFSFileEngine::owner(FileOwner own) const
+ \reimp
+*/
+
+/*! \fn bool QFSFileEngine::remove()
+ \reimp
+*/
+
+/*! \fn bool QFSFileEngine::rename(const QString &newName)
+ \reimp
+*/
+
+/*! \fn bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const
+ \reimp
+*/
+
+/*! \fn QString QFSFileEngine::rootPath()
+ Returns the root path.
+
+ \sa homePath()
+*/
+
+/*! \fn bool QFSFileEngine::setCurrentPath(const QString &path)
+ Sets the current path (e.g., for QDir), to \a path. Returns true if the
+ new path exists; otherwise this function does nothing, and returns false.
+
+ \sa currentPath()
+*/
+
+/*! \fn bool QFSFileEngine::setPermissions(uint perms)
+ \reimp
+*/
+
+/*! \fn bool QFSFileEngine::setSize(qint64 size)
+ \reimp
+*/
+
+/*! \fn QString QFSFileEngine::tempPath()
+ Returns the temporary path (i.e., a path in which it is safe
+ to store temporary files).
+*/
+
QT_END_NAMESPACE
#endif // QT_NO_FSFILEENGINE
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 72ea065..45e547f 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -293,9 +293,8 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len)
int oldFlags = fcntl(QT_FILENO(fh), F_GETFL);
for (int i = 0; i < 2; ++i) {
// Unix: Make the underlying file descriptor non-blocking
- int v = 1;
if ((oldFlags & O_NONBLOCK) == 0)
- fcntl(QT_FILENO(fh), F_SETFL, oldFlags | O_NONBLOCK, &v, sizeof(v));
+ fcntl(QT_FILENO(fh), F_SETFL, oldFlags | O_NONBLOCK);
// Cross platform stdlib read
size_t read = 0;
@@ -313,8 +312,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len)
// Unix: Restore the blocking state of the underlying socket
if ((oldFlags & O_NONBLOCK) == 0) {
- int v = 1;
- fcntl(QT_FILENO(fh), F_SETFL, oldFlags, &v, sizeof(v));
+ fcntl(QT_FILENO(fh), F_SETFL, oldFlags);
if (readBytes == 0) {
int readByte = 0;
do {
@@ -331,8 +329,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len)
}
// Unix: Restore the blocking state of the underlying socket
if ((oldFlags & O_NONBLOCK) == 0) {
- int v = 1;
- fcntl(QT_FILENO(fh), F_SETFL, oldFlags, &v, sizeof(v));
+ fcntl(QT_FILENO(fh), F_SETFL, oldFlags);
}
if (readBytes == 0 && !feof(fh)) {
// if we didn't read anything and we're not at EOF, it must be an error
@@ -407,23 +404,21 @@ bool QFSFileEngine::copy(const QString &newName)
TInt err = rfs.Connect();
if (err == KErrNone) {
CFileMan* fm = NULL;
- HBufC* oldBuf = NULL;
- HBufC* newBuf = NULL;
+ QString oldNative(QDir::toNativeSeparators(d->filePath));
+ TPtrC oldPtr(qt_QString2TPtrC(oldNative));
+ QFileInfo fi(newName);
+ QString absoluteNewName = fi.absolutePath() + QDir::separator() + fi.fileName();
+ QString newNative(QDir::toNativeSeparators(absoluteNewName));
+ TPtrC newPtr(qt_QString2TPtrC(newNative));
TRAP (err,
fm = CFileMan::NewL(rfs);
- oldBuf = qt_QString2HBufCNewL(QDir::toNativeSeparators(d->filePath));
RFile rfile;
- err = rfile.Open(rfs, *oldBuf, EFileShareReadersOrWriters);
+ err = rfile.Open(rfs, oldPtr, EFileShareReadersOrWriters);
if (err == KErrNone) {
- QFileInfo fi(newName);
- QString absoluteNewName = fi.absolutePath() + QDir::separator() + fi.fileName();
- newBuf = qt_QString2HBufCNewL(QDir::toNativeSeparators(absoluteNewName));
- err = fm->Copy(rfile, *newBuf);
+ err = fm->Copy(rfile, newPtr);
rfile.Close();
}
) // End TRAP
- delete oldBuf;
- delete newBuf;
delete fm;
rfs.Close();
}
@@ -678,10 +673,10 @@ static bool _q_isSymbianHidden(const QString &path, bool isDir)
if (isDir && absPath.at(absPath.size()-1) != QChar('/')) {
absPath += QChar('/');
}
- HBufC* buffer = qt_QString2HBufCNewL(QDir::toNativeSeparators(absPath));
+ QString native(QDir::toNativeSeparators(absPath));
+ TPtrC ptr(qt_QString2TPtrC(native));
TUint attributes;
- err = rfs.Att(*buffer, attributes);
- delete buffer;
+ err = rfs.Att(ptr, attributes);
rfs.Close();
if (err == KErrNone && (attributes & KEntryAttHidden)) {
retval = true;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 2df13f0..6ae13e9 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -946,9 +946,6 @@ bool QFSFileEnginePrivate::nativeIsSequential() const
return false;
}
-/*!
- \reimp
-*/
bool QFSFileEngine::remove()
{
Q_D(QFSFileEngine);
@@ -959,9 +956,6 @@ bool QFSFileEngine::remove()
});
}
-/*!
- \reimp
-*/
bool QFSFileEngine::copy(const QString &copyName)
{
Q_D(QFSFileEngine);
@@ -974,9 +968,6 @@ bool QFSFileEngine::copy(const QString &copyName)
});
}
-/*!
- \reimp
-*/
bool QFSFileEngine::rename(const QString &newName)
{
Q_D(QFSFileEngine);
@@ -1017,9 +1008,6 @@ static inline bool mkDir(const QString &path)
});
}
-/*!
- \reimp
-*/
static inline bool rmDir(const QString &path)
{
QT_WA({
@@ -1029,9 +1017,6 @@ static inline bool rmDir(const QString &path)
});
}
-/*!
- \reimp
-*/
static inline bool isDirPath(const QString &dirPath, bool *existed)
{
QString path = dirPath;
@@ -1054,9 +1039,6 @@ static inline bool isDirPath(const QString &dirPath, bool *existed)
return fileAttrib & FILE_ATTRIBUTE_DIRECTORY;
}
-/*!
- \reimp
-*/
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
QString dirName = name;
@@ -1097,9 +1079,6 @@ bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) con
return mkDir(name);
}
-/*!
- \reimp
-*/
bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const
{
QString dirName = name;
@@ -1120,20 +1099,11 @@ bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) co
return rmDir(name);
}
-/*!
- \reimp
-*/
bool QFSFileEngine::caseSensitive() const
{
return false;
}
-/*!
- Sets the current path (e.g., for QDir), to \a path. Returns true if the
- new path exists; otherwise this function does nothing, and returns false.
-
- \sa currentPath()
-*/
bool QFSFileEngine::setCurrentPath(const QString &path)
{
if (!QDir(path).exists())
@@ -1153,16 +1123,6 @@ bool QFSFileEngine::setCurrentPath(const QString &path)
#endif
}
-/*!
- Returns the canonicalized form of the current path used by the file
- engine for the drive specified by \a fileName.
-
- On Windows, each drive has its own current directory, so a different
- path is returned for file names that include different drive names
- (e.g. A: or C:).
-
- \sa setCurrentPath()
-*/
QString QFSFileEngine::currentPath(const QString &fileName)
{
#if !defined(Q_OS_WINCE)
@@ -1219,11 +1179,6 @@ QString QFSFileEngine::currentPath(const QString &fileName)
#endif
}
-/*!
- Returns the home path of the current user.
-
- \sa rootPath()
-*/
QString QFSFileEngine::homePath()
{
QString ret;
@@ -1277,11 +1232,6 @@ QString QFSFileEngine::homePath()
return QDir::fromNativeSeparators(ret);
}
-/*!
- Returns the root path.
-
- \sa homePath()
-*/
QString QFSFileEngine::rootPath()
{
#if defined(Q_OS_WINCE)
@@ -1299,10 +1249,6 @@ QString QFSFileEngine::rootPath()
return ret;
}
-/*!
- Returns the temporary path (i.e., a path in which it is safe to store
- temporary files).
-*/
QString QFSFileEngine::tempPath()
{
QString ret;
@@ -1330,11 +1276,6 @@ QString QFSFileEngine::tempPath()
return ret;
}
-/*!
- Returns the list of drives in the file system as a list of QFileInfo
- objects. On unix, Mac OS X and Windows CE, only the root path is returned.
- On Windows, this function returns all drives (A:\, C:\, D:\, etc.).
-*/
QFileInfoList QFSFileEngine::drives()
{
QFileInfoList ret;
@@ -1556,9 +1497,6 @@ QString QFSFileEnginePrivate::getLink() const
return readLink(filePath);
}
-/*!
- \reimp
-*/
bool QFSFileEngine::link(const QString &newName)
{
#if !defined(Q_OS_WINCE)
@@ -1816,9 +1754,6 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil
return ret;
}
-/*!
- \reimp
-*/
QString QFSFileEngine::fileName(FileName file) const
{
Q_D(const QFSFileEngine);
@@ -1912,9 +1847,6 @@ QString QFSFileEngine::fileName(FileName file) const
return d->filePath;
}
-/*!
- \reimp
-*/
bool QFSFileEngine::isRelativePath() const
{
Q_D(const QFSFileEngine);
@@ -1924,18 +1856,12 @@ bool QFSFileEngine::isRelativePath() const
|| (d->filePath.at(0) == QLatin1Char('/') && d->filePath.at(1) == QLatin1Char('/'))))); // drive, e.g. a:
}
-/*!
- \reimp
-*/
uint QFSFileEngine::ownerId(FileOwner /*own*/) const
{
static const uint nobodyID = (uint) -2;
return nobodyID;
}
-/*!
- \reimp
-*/
QString QFSFileEngine::owner(FileOwner own) const
{
#if !defined(QT_NO_LIBRARY)
@@ -1974,9 +1900,6 @@ QString QFSFileEngine::owner(FileOwner own) const
return QString(QLatin1String(""));
}
-/*!
- \reimp
-*/
bool QFSFileEngine::setPermissions(uint perms)
{
Q_D(QFSFileEngine);
@@ -2003,9 +1926,6 @@ bool QFSFileEngine::setPermissions(uint perms)
return ret;
}
-/*!
- \reimp
-*/
bool QFSFileEngine::setSize(qint64 size)
{
Q_D(QFSFileEngine);
@@ -2075,9 +1995,6 @@ static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
return ret;
}
-/*!
- \reimp
-*/
QDateTime QFSFileEngine::fileTime(FileTime time) const
{
Q_D(const QFSFileEngine);
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index fe3ceff..765bf40 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -362,7 +362,7 @@ QIODevice::QIODevice()
{
#if defined QIODEVICE_DEBUG
QFile *file = qobject_cast<QFile *>(this);
- printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, className(),
+ printf("%p QIODevice::QIODevice(\"%s\") %s\n", this, metaObject()->className(),
qPrintable(file ? file->fileName() : QString()));
#endif
}
@@ -375,7 +375,7 @@ QIODevice::QIODevice(QObject *parent)
: QObject(*new QIODevicePrivate, parent)
{
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, className());
+ printf("%p QIODevice::QIODevice(%p \"%s\")\n", this, parent, metaObject()->className());
#endif
}
@@ -945,9 +945,9 @@ QByteArray QIODevice::readAll()
QByteArray tmp;
if (d->isSequential() || size() == 0) {
- // Read it in chunks, bytesAvailable() is unreliable for sequential
- // devices.
- const int chunkSize = 4096;
+ // Read it in chunks. Use bytesAvailable() as an unreliable hint for
+ // sequential devices, but try to read 4K as a minimum.
+ int chunkSize = qMax(qint64(4096), bytesAvailable());
qint64 totalRead = 0;
forever {
tmp.resize(tmp.size() + chunkSize);
@@ -956,6 +956,7 @@ QByteArray QIODevice::readAll()
if (readBytes <= 0)
return tmp;
totalRead += readBytes;
+ chunkSize = qMax(qint64(4096), bytesAvailable());
}
} else {
// Read it all in one go.
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index 76d47ca..ad87125 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -46,6 +46,7 @@
#include <QtCore/qobject.h>
#else
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
#endif
#include <QtCore/qstring.h>
@@ -160,7 +161,7 @@ protected:
void setErrorString(const QString &errorString);
#ifdef QT_NO_QOBJECT
- QIODevicePrivate *d_ptr;
+ QScopedPointer<QIODevicePrivate> d_ptr;
#endif
private:
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
index ae7f51a..26e7cdc 100644
--- a/src/corelib/io/qprocess_symbian.cpp
+++ b/src/corelib/io/qprocess_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -26,6 +56,7 @@
User::Panic(KQProcessPanic, panicReason); \
}
+#include <exception>
#include <e32base.h>
#include <e32std.h>
#include <stdio.h>
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 33d4a47..1fedd55 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -140,15 +140,6 @@ static void qt_native_close(int fd)
} while (ret == -1 && errno == EINTR);
}
-static void qt_native_sigaction(int signum, const struct sigaction *act,
- struct sigaction *oldact)
-{
- int ret;
- do {
- ret = ::sigaction(signum, act, oldact);
- } while (ret == -1 && errno == EINTR);
-}
-
static void qt_native_dup2(int oldfd, int newfd)
{
int ret;
@@ -255,7 +246,7 @@ QProcessManager::QProcessManager()
memset(&action, 0, sizeof(action));
action.sa_handler = qt_sa_sigchld_handler;
action.sa_flags = SA_NOCLDSTOP;
- qt_native_sigaction(SIGCHLD, &action, &oldAction);
+ ::sigaction(SIGCHLD, &action, &oldAction);
if (oldAction.sa_handler != qt_sa_sigchld_handler)
qt_sa_old_sigchld_handler = oldAction.sa_handler;
}
@@ -282,9 +273,9 @@ QProcessManager::~QProcessManager()
memset(&action, 0, sizeof(action));
action.sa_handler = qt_sa_old_sigchld_handler;
action.sa_flags = SA_NOCLDSTOP;
- qt_native_sigaction(SIGCHLD, &action, &oldAction);
+ ::sigaction(SIGCHLD, &action, &oldAction);
if (oldAction.sa_handler != qt_sa_sigchld_handler) {
- qt_native_sigaction(SIGCHLD, &oldAction, 0);
+ ::sigaction(SIGCHLD, &oldAction, 0);
}
}
@@ -900,7 +891,7 @@ static void qt_ignore_sigpipe()
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
}
}
@@ -1270,7 +1261,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
::setsid();
@@ -1316,7 +1307,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
// '\1' means execv failed
char c = '\1';
@@ -1327,7 +1318,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
// '\2' means internal error
char c = '\2';
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index a1f921e..0cbcc41 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -334,7 +334,6 @@ QResource::QResource(const QString &file, const QLocale &locale) : d_ptr(new QRe
*/
QResource::~QResource()
{
- delete d_ptr;
}
/*!
@@ -406,7 +405,7 @@ QString QResource::absoluteFilePath() const
}
/*!
- Returns true if the resource really exists in the resource heirarchy,
+ Returns true if the resource really exists in the resource hierarchy,
false otherwise.
*/
diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h
index 1e9b2d5..f260b68 100644
--- a/src/corelib/io/qresource.h
+++ b/src/corelib/io/qresource.h
@@ -91,7 +91,7 @@ protected:
QStringList children() const;
protected:
- QResourcePrivate *d_ptr;
+ QScopedPointer<QResourcePrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QResource)
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 484e79a..afaaf28 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1106,10 +1106,10 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope)
QString homePath = QDir::homePath();
QString systemPath;
- globalMutex()->lock();
+ QMutexLocker locker(globalMutex());
PathHash *pathHash = pathHashFunc();
bool loadSystemPath = pathHash->isEmpty();
- globalMutex()->unlock();
+ locker.unlock();
if (loadSystemPath) {
/*
@@ -1121,7 +1121,7 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope)
systemPath += QLatin1Char('/');
}
- QMutexLocker locker(globalMutex());
+ locker.relock();
if (pathHash->isEmpty()) {
/*
Lazy initialization of pathHash. We initialize the
@@ -1181,9 +1181,6 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
int i;
initFormat();
- for (i = 0; i < NumConfFiles; ++i)
- confFiles[i] = 0;
-
QString org = organization;
if (org.isEmpty()) {
setStatus(QSettings::AccessError);
@@ -1196,14 +1193,14 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
if (scope == QSettings::UserScope) {
QString userPath = getPath(format, QSettings::UserScope);
if (!application.isEmpty())
- confFiles[F_User | F_Application] = QConfFile::fromName(userPath + appFile, true);
- confFiles[F_User | F_Organization] = QConfFile::fromName(userPath + orgFile, true);
+ confFiles[F_User | F_Application].reset(QConfFile::fromName(userPath + appFile, true));
+ confFiles[F_User | F_Organization].reset(QConfFile::fromName(userPath + orgFile, true));
}
QString systemPath = getPath(format, QSettings::SystemScope);
if (!application.isEmpty())
- confFiles[F_System | F_Application] = QConfFile::fromName(systemPath + appFile, false);
- confFiles[F_System | F_Organization] = QConfFile::fromName(systemPath + orgFile, false);
+ confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
+ confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
for (i = 0; i < NumConfFiles; ++i) {
if (confFiles[i]) {
@@ -1222,9 +1219,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName,
{
initFormat();
- confFiles[0] = QConfFile::fromName(fileName, true);
- for (int i = 1; i < NumConfFiles; ++i)
- confFiles[i] = 0;
+ confFiles[0].reset(QConfFile::fromName(fileName, true));
initAccess();
}
@@ -1241,19 +1236,27 @@ QConfFileSettingsPrivate::~QConfFileSettingsPrivate()
usedHash->remove(confFiles[i]->name);
if (confFiles[i]->size == 0) {
- delete confFiles[i];
+ delete confFiles[i].take();
} else if (unusedCache) {
- // compute a better size?
- unusedCache->insert(confFiles[i]->name, confFiles[i],
+ QT_TRY {
+ // compute a better size?
+ unusedCache->insert(confFiles[i]->name, confFiles[i].data(),
10 + (confFiles[i]->originalKeys.size() / 4));
+ confFiles[i].take();
+ } QT_CATCH(...) {
+ // out of memory. Do not cache the file.
+ delete confFiles[i].take();
+ }
}
}
+ // prevent the ScopedPointer to deref it again.
+ confFiles[i].take();
}
}
void QConfFileSettingsPrivate::remove(const QString &key)
{
- QConfFile *confFile = confFiles[spec];
+ QConfFile *confFile = confFiles[spec].data();
if (!confFile)
return;
@@ -1280,7 +1283,7 @@ void QConfFileSettingsPrivate::remove(const QString &key)
void QConfFileSettingsPrivate::set(const QString &key, const QVariant &value)
{
- QConfFile *confFile = confFiles[spec];
+ QConfFile *confFile = confFiles[spec].data();
if (!confFile)
return;
@@ -1297,7 +1300,7 @@ bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const
bool found = false;
for (int i = 0; i < NumConfFiles; ++i) {
- if (QConfFile *confFile = confFiles[i]) {
+ if (QConfFile *confFile = confFiles[i].data()) {
QMutexLocker locker(&confFile->mutex);
if (!confFile->addedKeys.isEmpty()) {
@@ -1332,7 +1335,7 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
int startPos = prefix.size();
for (int i = 0; i < NumConfFiles; ++i) {
- if (QConfFile *confFile = confFiles[i]) {
+ if (QConfFile *confFile = confFiles[i].data()) {
QMutexLocker locker(&confFile->mutex);
if (thePrefix.isEmpty()) {
@@ -1365,7 +1368,7 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
void QConfFileSettingsPrivate::clear()
{
- QConfFile *confFile = confFiles[spec];
+ QConfFile *confFile = confFiles[spec].data();
if (!confFile)
return;
@@ -1381,7 +1384,7 @@ void QConfFileSettingsPrivate::sync()
// error we just try to go on and make the best of it
for (int i = 0; i < NumConfFiles; ++i) {
- QConfFile *confFile = confFiles[i];
+ QConfFile *confFile = confFiles[i].data();
if (confFile) {
QMutexLocker locker(&confFile->mutex);
syncConfFile(i);
@@ -1396,7 +1399,7 @@ void QConfFileSettingsPrivate::flush()
QString QConfFileSettingsPrivate::fileName() const
{
- QConfFile *confFile = confFiles[spec];
+ QConfFile *confFile = confFiles[spec].data();
if (!confFile)
return QString();
return confFile->name;
@@ -1407,7 +1410,7 @@ bool QConfFileSettingsPrivate::isWritable() const
if (format > QSettings::IniFormat && !writeFunc)
return false;
- QConfFile *confFile = confFiles[spec];
+ QConfFile *confFile = confFiles[spec].data();
if (!confFile)
return false;
@@ -1416,7 +1419,7 @@ bool QConfFileSettingsPrivate::isWritable() const
void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
{
- QConfFile *confFile = confFiles[confFileNo];
+ QConfFile *confFile = confFiles[confFileNo].data();
bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
bool ok;
@@ -2295,7 +2298,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
As mentioned in the \l{Fallback Mechanism} section, QSettings
stores settings for an application in up to four locations,
depending on whether the settings are user-specific or
- system-wide and whether the the settings are application-specific
+ system-wide and whether the settings are application-specific
or organization-wide. For simplicity, we're assuming the
organization is called MySoft and the application is called Star
Runner.
@@ -2759,11 +2762,13 @@ QSettings::QSettings(const QString &fileName, Format format)
QSettings::~QSettings()
{
Q_D(QSettings);
- if (d->pendingChanges)
- d->flush();
-#ifdef QT_NO_QOBJECT
- delete d;
-#endif
+ if (d->pendingChanges) {
+ QT_TRY {
+ d->flush();
+ } QT_CATCH(...) {
+ ; // ok. then don't flush but at least don't throw in the destructor
+ }
+ }
}
/*!
@@ -3468,7 +3473,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
\typedef QSettings::SettingsMap
Typedef for QMap<QString, QVariant>.
-
+
\sa registerFormat()
*/
@@ -3479,6 +3484,11 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
\snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 27
+ \c ReadFunc is used in \c registerFormat() as a pointer to a function
+ that reads a set of key/value pairs. \c ReadFunc should read all the
+ options in one pass, and return all the settings in the \c SettingsMap
+ container, which is initially empty.
+
\sa WriteFunc, registerFormat()
*/
@@ -3489,6 +3499,10 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
\snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 28
+ \c WriteFunc is used in \c registerFormat() as a pointer to a function
+ that writes a set of key/value pairs. \c WriteFunc is only called once,
+ so you need to output the settings in one go.
+
\sa ReadFunc, registerFormat()
*/
@@ -3504,7 +3518,7 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
extension associated to the format (without the '.').
The \a readFunc and \a writeFunc parameters are pointers to
- functions that read and write a set of (key, value) pairs. The
+ functions that read and write a set of key/value pairs. The
QIODevice parameter to the read and write functions is always
opened in binary mode (i.e., without the QIODevice::Text flag).
@@ -3557,8 +3571,7 @@ void QSettings::setPath_helper(Scope scope, const QString &organization, const Q
QSettingsPrivate *oldPriv = d;
QSettingsPrivate *newPriv = QSettingsPrivate::create(oldPriv->format, scope, organization, application);
static_cast<QObjectPrivate &>(*newPriv) = static_cast<QObjectPrivate &>(*oldPriv); // copy the QObject stuff over (hack)
- delete oldPriv;
- d_ptr = newPriv;
+ d_ptr.reset(newPriv);
}
/*! \fn bool QSettings::writeEntry(const QString &key, bool value)
diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h
index cbb24ba..41bce89 100644
--- a/src/corelib/io/qsettings.h
+++ b/src/corelib/io/qsettings.h
@@ -78,7 +78,7 @@ class Q_CORE_EXPORT QSettings
#ifndef QT_NO_QOBJECT
Q_OBJECT
#else
- QSettingsPrivate *d_ptr;
+ QScopedPointer<QSettingsPrivate> d_ptr;
#endif
Q_DECLARE_PRIVATE(QSettings)
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index dd72fd9..1bdbf2c 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -300,7 +300,7 @@ private:
void ensureAllSectionsParsed(QConfFile *confFile) const;
void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const;
- QConfFile *confFiles[NumConfFiles];
+ QScopedSharedPointer<QConfFile> confFiles[NumConfFiles];
QSettings::ReadFunc readFunc;
QSettings::WriteFunc writeFunc;
QString extension;
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index e120f28..45a03e3 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -291,14 +291,22 @@ class QTemporaryFileEngine : public QFSFileEngine
{
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
- QTemporaryFileEngine(const QString &file) : QFSFileEngine(file) { }
+ QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true)
+ : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate)
+ {
+ }
+
~QTemporaryFileEngine();
+ bool isReallyOpen();
void setFileName(const QString &file);
bool open(QIODevice::OpenMode flags);
bool remove();
+ bool rename(const QString &newName);
bool close();
+
+ bool filePathIsTemplate;
};
QTemporaryFileEngine::~QTemporaryFileEngine()
@@ -306,6 +314,21 @@ QTemporaryFileEngine::~QTemporaryFileEngine()
QFSFileEngine::close();
}
+bool QTemporaryFileEngine::isReallyOpen()
+{
+ Q_D(QFSFileEngine);
+
+ if (!((0 == d->fh) && (-1 == d->fd)
+#if defined Q_OS_WIN
+ && (INVALID_HANDLE_VALUE == d->fileHandle)
+#endif
+ ))
+ return true;
+
+ return false;
+
+}
+
void QTemporaryFileEngine::setFileName(const QString &file)
{
// Really close the file, so we don't leak
@@ -316,13 +339,16 @@ void QTemporaryFileEngine::setFileName(const QString &file)
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
+ Q_ASSERT(!isReallyOpen());
+
+ if (!filePathIsTemplate)
+ return QFSFileEngine::open(openMode);
QString qfilename = d->filePath;
if(!qfilename.contains(QLatin1String("XXXXXX")))
qfilename += QLatin1String(".XXXXXX");
int suffixLength = qfilename.length() - (qfilename.lastIndexOf(QLatin1String("XXXXXX"), -1, Qt::CaseSensitive) + 6);
- d->closeFileHandle = true;
char *filename = qstrdup(qfilename.toLocal8Bit());
#ifndef Q_WS_WIN
@@ -330,16 +356,20 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
if (fd != -1) {
// First open the fd as an external file descriptor to
// initialize the engine properly.
- QFSFileEngine::open(openMode, fd);
+ if (QFSFileEngine::open(openMode, fd)) {
- // Allow the engine to close the handle even if it's "external".
- d->closeFileHandle = true;
+ // Allow the engine to close the handle even if it's "external".
+ d->closeFileHandle = true;
- // Restore the file names (open() resets them).
- d->filePath = QString::fromLocal8Bit(filename); //changed now!
- d->nativeInitFileName();
- delete [] filename;
- return true;
+ // Restore the file names (open() resets them).
+ d->filePath = QString::fromLocal8Bit(filename); //changed now!
+ filePathIsTemplate = false;
+ d->nativeInitFileName();
+ delete [] filename;
+ return true;
+ }
+
+ QT_CLOSE(fd);
}
delete [] filename;
setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(errno));
@@ -351,6 +381,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
}
d->filePath = QString::fromLocal8Bit(filename);
+ filePathIsTemplate = false;
d->nativeInitFileName();
d->closeFileHandle = true;
delete [] filename;
@@ -364,9 +395,17 @@ bool QTemporaryFileEngine::remove()
// Since the QTemporaryFileEngine::close() does not really close the file,
// we must explicitly call QFSFileEngine::close() before we remove it.
QFSFileEngine::close();
- bool removed = QFSFileEngine::remove();
- d->filePath.clear();
- return removed;
+ if (QFSFileEngine::remove()) {
+ d->filePath.clear();
+ return true;
+ }
+ return false;
+}
+
+bool QTemporaryFileEngine::rename(const QString &newName)
+{
+ QFSFileEngine::close();
+ return QFSFileEngine::rename(newName);
}
bool QTemporaryFileEngine::close()
@@ -388,17 +427,14 @@ protected:
bool autoRemove;
QString templateName;
- mutable QTemporaryFileEngine *fileEngine;
};
-QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true), fileEngine(0)
+QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true)
{
}
QTemporaryFilePrivate::~QTemporaryFilePrivate()
{
- delete fileEngine;
- fileEngine = 0;
}
//************* QTemporaryFile
@@ -430,8 +466,8 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate()
file will exist and be kept open internally by QTemporaryFile.
The file name of the temporary file can be found by calling fileName().
- Note that this is only defined while the file is open; the function returns
- an empty string before the file is opened and after it is closed.
+ Note that this is only defined after the file is first opened; the function
+ returns an empty string before this.
A temporary file will have some static part of the name and some
part that is calculated to be unique. The default filename \c
@@ -605,7 +641,8 @@ void QTemporaryFile::setAutoRemove(bool b)
QString QTemporaryFile::fileName() const
{
- if(!isOpen())
+ Q_D(const QTemporaryFile);
+ if(d->fileName.isEmpty())
return QString();
return fileEngine()->fileName(QAbstractFileEngine::DefaultName);
}
@@ -699,8 +736,12 @@ QTemporaryFile *QTemporaryFile::createLocalFile(QFile &file)
QAbstractFileEngine *QTemporaryFile::fileEngine() const
{
Q_D(const QTemporaryFile);
- if(!d->fileEngine)
- d->fileEngine = new QTemporaryFileEngine(d->templateName);
+ if(!d->fileEngine) {
+ if (d->fileName.isEmpty())
+ d->fileEngine = new QTemporaryFileEngine(d->templateName);
+ else
+ d->fileEngine = new QTemporaryFileEngine(d->fileName, false);
+ }
return d->fileEngine;
}
@@ -715,10 +756,13 @@ bool QTemporaryFile::open(OpenMode flags)
{
Q_D(QTemporaryFile);
if (!d->fileName.isEmpty()) {
- setOpenMode(flags);
- return true;
+ if (static_cast<QTemporaryFileEngine*>(fileEngine())->isReallyOpen()) {
+ setOpenMode(flags);
+ return true;
+ }
}
+ flags |= QIODevice::ReadWrite;
if (QFile::open(flags)) {
d->fileName = d->fileEngine->fileName(QAbstractFileEngine::DefaultName);
return true;
@@ -726,6 +770,8 @@ bool QTemporaryFile::open(OpenMode flags)
return false;
}
+QT_END_NAMESPACE
+
#endif // QT_NO_TEMPORARYFILE
-QT_END_NAMESPACE
+
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 1167671..9382fae 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1112,9 +1112,6 @@ QTextStream::~QTextStream()
#endif
if (!d->writeBuffer.isEmpty())
d->flushWriteBuffer();
-
- delete d;
- d_ptr = 0;
}
/*!
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index 6302d34..cfacec6 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -46,6 +46,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qchar.h>
#include <QtCore/qlocale.h>
+#include <QtCore/qscopedpointer.h>
#ifndef QT_NO_TEXTCODEC
# ifdef QT3_SUPPORT
@@ -256,7 +257,7 @@ private:
Q_DISABLE_COPY(QTextStream)
- QTextStreamPrivate *d_ptr;
+ QScopedPointer<QTextStreamPrivate> d_ptr;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextStream::NumberFlags)
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 9ce9a2e..d1a5cdd 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4759,6 +4759,12 @@ void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &que
Inserts the pair \a key = \a value into the query string of the
URL.
+ The key/value pair is encoded before it is added to the query. The
+ pair is converted into separate strings internally. The \a key and
+ \a value is first encoded into UTF-8 and then delimited by the
+ character returned by valueDelimiter(). Each key/value pair is
+ delimited by the character returned by pairDelimiter().
+
\sa addEncodedQueryItem()
*/
void QUrl::addQueryItem(const QString &key, const QString &value)
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
index 19c1510..101ed44 100644
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ b/src/corelib/kernel/qcore_symbian_p.cpp
@@ -5,13 +5,45 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
+#include <exception>
#include <e32base.h>
#include <e32uid.h>
#include "qcore_symbian_p.h"
+#include <string>
QT_BEGIN_NAMESPACE
@@ -21,18 +53,17 @@ QT_BEGIN_NAMESPACE
must be deleted by the caller.
*/
-Q_CORE_EXPORT HBufC* qt_QString2HBufCNewL(const QString& aString)
+Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
{
HBufC *buffer;
#ifdef QT_NO_UNICODE
TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData()));
- buffer = HBufC8::NewL(ptr.Length());
- buffer->Des().Copy(ptr);
#else
- TPtrC16 ptr(reinterpret_cast<const TUint16*>(aString.utf16()));
- buffer = HBufC16::NewL(ptr.Length());
- buffer->Des().Copy(ptr);
+ TPtrC16 ptr(qt_QString2TPtrC(aString));
#endif
+ buffer = HBufC::New(ptr.Length());
+ Q_CHECK_PTR(buffer);
+ buffer->Des().Copy(ptr);
return buffer;
}
@@ -52,7 +83,8 @@ QHBufC::QHBufC()
QHBufC::QHBufC(const QHBufC &src)
{
- m_hBufC = src.m_hBufC->AllocL();
+ m_hBufC = src.m_hBufC->Alloc();
+ Q_CHECK_PTR(m_hBufC);
}
/*!
@@ -67,7 +99,7 @@ QHBufC::QHBufC(HBufC *src)
QHBufC::QHBufC(const QString &src)
{
- m_hBufC = qt_QString2HBufCNewL(src);
+ m_hBufC = qt_QString2HBufC(src);
}
QHBufC::~QHBufC()
@@ -142,4 +174,5 @@ Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal)
return qt_s60_plugin_resolver()->resolve(ordinal);
}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
index a7d2ce4..bd8f304 100644
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ b/src/corelib/kernel/qcore_symbian_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -33,7 +63,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-Q_CORE_EXPORT HBufC* qt_QString2HBufCNewL(const QString& aString);
+Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString);
Q_CORE_EXPORT QString qt_TDesC2QStringL(const TDesC& aDescriptor);
inline QString qt_TDes2QStringL(const TDes& aDescriptor) { return qt_TDesC2QStringL(aDescriptor); }
@@ -61,7 +91,7 @@ static inline TRect qt_QRect2TRect(const QRect& qr)
// Returned TPtrC is valid as long as the given parameter is valid and unmodified
static inline TPtrC qt_QString2TPtrC( const QString& string )
{
- return reinterpret_cast<const TUint16*>(string.utf16());
+ return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length());
}
class Q_CORE_EXPORT QHBufC
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 7d8a77a..5c3fd76 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -63,8 +63,10 @@
#include <private/qfactoryloader_p.h>
#ifdef Q_OS_SYMBIAN
+# include <exception>
# include <f32file.h>
# include "qeventdispatcher_symbian_p.h"
+# include "private/qcore_symbian_p.h"
#elif defined(Q_OS_UNIX)
# if !defined(QT_NO_GLIB)
# include "qeventdispatcher_glib_p.h"
@@ -88,6 +90,21 @@
QT_BEGIN_NAMESPACE
+class QLockedMutexUnlocker
+{
+public:
+ inline explicit QLockedMutexUnlocker(QMutex *m)
+ : mtx(m)
+ { }
+ inline ~QLockedMutexUnlocker() { unlock(); }
+ inline void unlock() { if (mtx) mtx->unlock(); mtx = 0; }
+
+private:
+ Q_DISABLE_COPY(QLockedMutexUnlocker)
+
+ QMutex *mtx;
+};
+
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
extern QString qAppFileName();
#endif
@@ -159,7 +176,14 @@ void qRemovePostRoutine(QtCleanUpFunction p)
void Q_CORE_EXPORT qt_call_post_routines()
{
- QVFuncList *list = postRList();
+ QVFuncList *list = 0;
+ QT_TRY {
+ list = postRList();
+ } QT_CATCH(const std::bad_alloc &) {
+ // ignore - if we can't allocate a post routine list,
+ // there's a high probability that there's no post
+ // routine to be executed :)
+ }
if (!list)
return;
while (!list->isEmpty())
@@ -248,24 +272,26 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv)
QCoreApplicationPrivate::~QCoreApplicationPrivate()
{
+ if (threadData) {
#ifndef QT_NO_THREAD
- void *data = &threadData->tls;
- QThreadStorageData::finish((void **)data);
+ void *data = &threadData->tls;
+ QThreadStorageData::finish((void **)data);
#endif
- // need to clear the state of the mainData, just in case a new QCoreApplication comes along.
- QMutexLocker locker(&threadData->postEventList.mutex);
- for (int i = 0; i < threadData->postEventList.size(); ++i) {
- const QPostEvent &pe = threadData->postEventList.at(i);
- if (pe.event) {
- --pe.receiver->d_func()->postedEvents;
- pe.event->posted = false;
- delete pe.event;
+ // need to clear the state of the mainData, just in case a new QCoreApplication comes along.
+ QMutexLocker locker(&threadData->postEventList.mutex);
+ for (int i = 0; i < threadData->postEventList.size(); ++i) {
+ const QPostEvent &pe = threadData->postEventList.at(i);
+ if (pe.event) {
+ --pe.receiver->d_func()->postedEvents;
+ pe.event->posted = false;
+ delete pe.event;
+ }
}
+ threadData->postEventList.clear();
+ threadData->postEventList.recursion = 0;
+ threadData->quitNow = false;
}
- threadData->postEventList.clear();
- threadData->postEventList.recursion = 0;
- threadData->quitNow = false;
}
void QCoreApplicationPrivate::createEventDispatcher()
@@ -311,6 +337,11 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver)
Q_UNUSED(currentThread);
Q_UNUSED(thr);
}
+#elif defined(Q_OS_SYMBIAN) && defined (QT_NO_DEBUG)
+// no implementation in release builds, but keep the symbol present
+void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver)
+{
+}
#endif
void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths()
@@ -539,7 +570,14 @@ QCoreApplication::~QCoreApplication()
#if !defined(QT_NO_THREAD)
#if !defined(QT_NO_CONCURRENT)
// Synchronize and stop the global thread pool threads.
- QThreadPool::globalInstance()->waitForDone();
+ QThreadPool *globalThreadPool = 0;
+ QT_TRY {
+ globalThreadPool = QThreadPool::globalInstance();
+ } QT_CATCH (...) {
+ // swallow the exception, since destructors shouldn't throw
+ }
+ if (globalThreadPool)
+ globalThreadPool->waitForDone();
#endif
QThread::cleanup();
#endif
@@ -621,26 +659,13 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
d->inEventHandler = true;
#endif
-#if defined(Q_OS_SYMBIAN)
-// __UHEAP_MARK;
- TInt error;
- bool returnValue = false;
- TRAP(error, returnValue = notify(receiver, event));
- if (error != KErrNone) {
- qWarning(QString("Symbian OS error: %1").arg(error).toAscii().constData());
- }
-// __UHEAP_MARKEND;
-#elif defined(QT_NO_EXCEPTIONS)
- bool returnValue = notify(receiver, event);
-#else
bool returnValue;
- try {
+ QT_TRY {
returnValue = notify(receiver, event);
- } catch(...) {
+ } QT_CATCH (...) {
--threadData->loopLevel;
- throw;
+ QT_RETHROW;
}
-#endif
#ifdef QT_JAMBI_BUILD
// Restore the previous state if the object was not deleted..
@@ -1061,15 +1086,14 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
data->postEventList.mutex.lock();
}
+ QLockedMutexUnlocker locker(&data->postEventList.mutex);
+
// if this is one of the compressible events, do compression
if (receiver->d_func()->postedEvents
&& self && self->compressEvent(event, receiver, &data->postEventList)) {
- data->postEventList.mutex.unlock();
return;
}
- event->posted = true;
- ++receiver->d_func()->postedEvents;
if (event->type() == QEvent::DeferredDelete && data == QThreadData::current()) {
// remember the current running eventloop for DeferredDelete
// events posted in the receiver's thread
@@ -1090,8 +1114,10 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
QPostEventList::iterator at = qUpperBound(begin, end, priority);
data->postEventList.insert(at, QPostEvent(receiver, event, priority));
}
+ event->posted = true;
+ ++receiver->d_func()->postedEvents;
data->canWait = false;
- data->postEventList.mutex.unlock();
+ locker.unlock();
if (data->eventDispatcher)
data->eventDispatcher->wakeUp();
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 65733ac..095d501 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -195,6 +195,8 @@ private:
void init();
static QCoreApplication *self;
+
+ Q_DISABLE_COPY(QCoreApplication)
friend class QEventDispatcherUNIXPrivate;
friend class QApplication;
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 9490ad7..c1118d1 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -92,7 +92,7 @@ public:
static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data);
static void removePostedEvents_unlocked(QObject *receiver, int type, QThreadData *data);
-#if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD)
+#if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD) || defined (Q_OS_SYMBIAN)
void checkReceiverThread(QObject *receiver);
#endif
int &argc;
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index d745406..423fbaa 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -163,7 +193,7 @@ void QWakeUpActiveObject::RunL()
{
iStatus = KRequestPending;
SetActive();
- m_dispatcher->wakeUpWasCalled();
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->wakeUpWasCalled());
}
QTimerActiveObject::QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo)
@@ -192,9 +222,15 @@ void QTimerActiveObject::DoCancel()
void QTimerActiveObject::RunL()
{
- if (!okToRun())
- return;
+ int error;
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_ERROR(error, Run());
+ if (error < 0) {
+ CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit
+ }
+}
+void QTimerActiveObject::Run()
+{
if (m_timerInfo->interval > 0) {
// Start a new timer immediately so that we don't lose time.
iStatus = KRequestPending;
@@ -210,7 +246,7 @@ void QTimerActiveObject::RunL()
SymbianTimerInfoPtr timerInfoPtr(m_timerInfo);
m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId);
-
+
iStatus = KRequestPending;
SetActive();
TRequestStatus *status = &iStatus;
@@ -274,7 +310,7 @@ void QCompleteDeferredAOs::RunL()
iStatus = KRequestPending;
SetActive();
- m_dispatcher->reactivateDeferredActiveObjects();
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->reactivateDeferredActiveObjects());
}
QSelectThread::QSelectThread()
@@ -424,8 +460,8 @@ void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestSta
}
QSelectMutexGrabber lock(m_pipeEnds[1], &m_mutex);
-
- Q_ASSERT(!m_AOStatuses.contains(notifier));
+
+ Q_ASSERT(!m_AOStatuses.contains(notifier));
m_AOStatuses.insert(notifier, status);
@@ -547,7 +583,7 @@ void QSocketActiveObject::RunL()
if (!okToRun())
return;
- m_dispatcher->socketFired(this);
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(m_dispatcher->socketFired(this));
}
void QSocketActiveObject::deleteLater()
@@ -603,101 +639,108 @@ void QEventDispatcherSymbian::closingDown()
bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags flags )
{
- Q_D(QAbstractEventDispatcher);
+ bool handledAnyEvent = false;
+ QT_TRY {
+ Q_D(QAbstractEventDispatcher);
+
// It is safe if this counter overflows. The main importance is that each
// iteration count is different from the last.
m_iterationCount++;
- RThread &thread = d->threadData->symbian_thread_handle;
-
- bool block;
- if (flags & QEventLoop::WaitForMoreEvents) {
- block = true;
- emit aboutToBlock();
- } else {
- block = false;
- }
-
- bool handledAnyEvent = false;
-
- bool oldNoSocketEventsValue = m_noSocketEvents;
- if (flags & QEventLoop::ExcludeSocketNotifiers) {
- m_noSocketEvents = true;
- } else {
- m_noSocketEvents = false;
- handledAnyEvent = sendDeferredSocketEvents();
- }
-
- bool handledSymbianEvent = false;
- m_interrupt = false;
-
- /*
- * This QTime variable is used to measure the time it takes to finish
- * the event loop. If we take too long in the loop, other processes
- * may be starved and killed. After the first event has completed, we
- * take the current time, and if the remaining events take longer than
- * a preset time, we temporarily lower the priority to force a context
- * switch. For applications that do not take unecessarily long in the
- * event loop, the priority will not be altered.
- */
- QTime time;
- enum {
- FirstRun,
- SubsequentRun,
- TimeStarted
- } timeState = FirstRun;
-
- TProcessPriority priority;
-
- while (1) {
- if (block) {
- // This is where Qt will spend most of its time.
- CActiveScheduler::Current()->WaitForAnyRequest();
+ RThread &thread = d->threadData->symbian_thread_handle;
+
+ bool block;
+ if (flags & QEventLoop::WaitForMoreEvents) {
+ block = true;
+ emit aboutToBlock();
} else {
- if (thread.RequestCount() == 0) {
- break;
- }
- // This one should return without delay.
- CActiveScheduler::Current()->WaitForAnyRequest();
- }
-
- if (timeState == SubsequentRun) {
- time.start();
- timeState = TimeStarted;
+ block = false;
}
-
- TInt error;
- handledSymbianEvent = CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle);
- if (error) {
- qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error);
- CActiveScheduler::Current()->Error(error);
- }
- if (!handledSymbianEvent) {
- qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal");
- }
- handledAnyEvent = true;
- if (m_interrupt) {
- break;
+
+ bool oldNoSocketEventsValue = m_noSocketEvents;
+ if (flags & QEventLoop::ExcludeSocketNotifiers) {
+ m_noSocketEvents = true;
+ } else {
+ m_noSocketEvents = false;
+ handledAnyEvent = sendDeferredSocketEvents();
}
- block = false;
- if (timeState == TimeStarted && time.elapsed() > 500) {
- priority = m_processHandle.Priority();
- m_processHandle.SetPriority(EPriorityLow);
- time.start();
- // Slight chance of race condition in the next lines, but nothing fatal
- // will happen, just wrong priority.
- if (m_processHandle.Priority() == EPriorityLow) {
- m_processHandle.SetPriority(priority);
+
+ bool handledSymbianEvent = false;
+ m_interrupt = false;
+
+ /*
+ * This QTime variable is used to measure the time it takes to finish
+ * the event loop. If we take too long in the loop, other processes
+ * may be starved and killed. After the first event has completed, we
+ * take the current time, and if the remaining events take longer than
+ * a preset time, we temporarily lower the priority to force a context
+ * switch. For applications that do not take unecessarily long in the
+ * event loop, the priority will not be altered.
+ */
+ QTime time;
+ enum {
+ FirstRun,
+ SubsequentRun,
+ TimeStarted
+ } timeState = FirstRun;
+
+ TProcessPriority priority;
+
+ while (1) {
+ if (block) {
+ // This is where Qt will spend most of its time.
+ CActiveScheduler::Current()->WaitForAnyRequest();
+ } else {
+ if (thread.RequestCount() == 0) {
+ break;
+ }
+ // This one should return without delay.
+ CActiveScheduler::Current()->WaitForAnyRequest();
}
- }
- if (timeState == FirstRun)
- timeState = SubsequentRun;
- };
-
- emit awake();
-
- m_noSocketEvents = oldNoSocketEventsValue;
+
+ if (timeState == SubsequentRun) {
+ time.start();
+ timeState = TimeStarted;
+ }
+
+ TInt error;
+ handledSymbianEvent = CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle);
+ if (error) {
+ qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error);
+ CActiveScheduler::Current()->Error(error);
+ }
+
+ if (!handledSymbianEvent) {
+ qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal");
+ }
+ handledAnyEvent = true;
+ if (m_interrupt) {
+ break;
+ }
+ block = false;
+ if (timeState == TimeStarted && time.elapsed() > 100) {
+ priority = m_processHandle.Priority();
+ m_processHandle.SetPriority(EPriorityLow);
+ time.start();
+ // Slight chance of race condition in the next lines, but nothing fatal
+ // will happen, just wrong priority.
+ if (m_processHandle.Priority() == EPriorityLow) {
+ m_processHandle.SetPriority(priority);
+ }
+ }
+ if (timeState == FirstRun)
+ timeState = SubsequentRun;
+ };
+
+ emit awake();
+
+ m_noSocketEvents = oldNoSocketEventsValue;
+ } QT_CATCH (const std::exception& ex) {
+#ifndef QT_NO_EXCEPTIONS
+ CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex));
+#endif
+ }
return handledAnyEvent;
}
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index 393749f..3593055 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -106,6 +136,9 @@ public:
protected:
void DoCancel();
void RunL();
+
+private:
+ void Run();
private:
SymbianTimerInfo *m_timerInfo;
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index ce38b73..ea8299c 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -54,7 +54,7 @@
#include <stdio.h>
#include <stdlib.h>
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)
# include <sys/times.h>
#endif
@@ -65,7 +65,7 @@ Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false;
/*****************************************************************************
UNIX signal handling
*****************************************************************************/
-#if !defined(Q_OS_SYMBIAN)
+
static sig_atomic_t signal_received;
static sig_atomic_t signals_fired[NSIG];
@@ -74,7 +74,7 @@ static void signalHandler(int sig)
signals_fired[sig] = 1;
signal_received = 1;
}
-#endif
+
static void initThreadPipeFD(int fd)
{
@@ -134,7 +134,6 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
int nsel;
do {
-#if !defined(Q_OS_SYMBIAN)
if (mainThread) {
while (signal_received) {
signal_received = 0;
@@ -146,7 +145,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
}
}
}
-#endif
+
// Process timers and socket notifiers - the common UNIX stuff
int highest = 0;
if (! (flags & QEventLoop::ExcludeSocketNotifiers) && (sn_highest >= 0)) {
@@ -185,7 +184,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
continue;
for (int i = 0; i < list.size(); ++i) {
- QSockNot *sn = list.at(i);
+ QSockNot *sn = list[i];
FD_ZERO(&fdset);
FD_SET(sn->fd, &fdset);
@@ -242,7 +241,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
for (int i=0; i<3; i++) {
QSockNotType::List &list = sn_vec[i].list;
for (int j = 0; j < list.size(); ++j) {
- QSockNot *sn = list.at(j);
+ QSockNot *sn = list[j];
if (FD_ISSET(sn->fd, &sn_vec[i].select_fds))
q->setSocketNotifierPending(sn->obj);
}
@@ -258,7 +257,7 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
QTimerInfoList::QTimerInfoList()
{
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0)
useMonotonicTimers = false;
# if (_POSIX_MONOTONIC_CLOCK == 0)
@@ -299,7 +298,7 @@ timeval QTimerInfoList::updateCurrentTime()
return currentTime;
}
-#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)) && !defined(Q_OS_SYMBIAN)
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED)
/*
Returns true if the real time clock has changed by more than 10%
@@ -375,11 +374,7 @@ void QTimerInfoList::repairTimersIfNeeded()
void QTimerInfoList::getTime(timeval &t)
{
timespec ts;
-#if !defined(Q_OS_SYMBIAN)
clock_gettime(CLOCK_MONOTONIC, &ts);
-#else
- clock_gettime(CLOCK_REALTIME, &ts);
-#endif
t.tv_sec = ts.tv_sec;
t.tv_usec = ts.tv_nsec / 1000;
}
@@ -425,10 +420,18 @@ bool QTimerInfoList::timerWait(timeval &tm)
timeval currentTime = updateCurrentTime();
repairTimersIfNeeded();
- if (isEmpty())
- return false;
+ // Find first waiting timer not already active
+ QTimerInfo *t = 0;
+ for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
+ if (!(*it)->inTimerEvent) {
+ t = *it;
+ break;
+ }
+ }
+
+ if (!t)
+ return false;
- QTimerInfo *t = first(); // first waiting timer
if (currentTime < t->timeout) {
// time to wait
tm = t->timeout - currentTime;
@@ -596,7 +599,10 @@ QEventDispatcherUNIX::QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObj
{ }
QEventDispatcherUNIX::~QEventDispatcherUNIX()
-{ }
+{
+ Q_D(QEventDispatcherUNIX);
+ d->threadData->eventDispatcher = 0;
+}
int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
timeval *timeout)
@@ -703,8 +709,8 @@ QSockNotType::QSockNotType()
QSockNotType::~QSockNotType()
{
- while (!list.isEmpty())
- delete list.takeFirst();
+ for (int i = 0; i < list.size(); ++i)
+ delete list[i];
}
/*****************************************************************************
@@ -740,7 +746,7 @@ void QEventDispatcherUNIX::registerSocketNotifier(QSocketNotifier *notifier)
int i;
for (i = 0; i < list.size(); ++i) {
- QSockNot *p = list.at(i);
+ QSockNot *p = list[i];
if (p->fd < sockfd)
break;
if (p->fd == sockfd) {
@@ -778,7 +784,7 @@ void QEventDispatcherUNIX::unregisterSocketNotifier(QSocketNotifier *notifier)
QSockNot *sn = 0;
int i;
for (i = 0; i < list.size(); ++i) {
- sn = list.at(i);
+ sn = list[i];
if(sn->obj == notifier && sn->fd == sockfd)
break;
}
@@ -796,7 +802,7 @@ void QEventDispatcherUNIX::unregisterSocketNotifier(QSocketNotifier *notifier)
for (int i=0; i<3; i++) {
if (!d->sn_vec[i].list.isEmpty())
d->sn_highest = qMax(d->sn_highest, // list is fd-sorted
- d->sn_vec[i].list.first()->fd);
+ d->sn_vec[i].list[0]->fd);
}
}
}
@@ -820,7 +826,7 @@ void QEventDispatcherUNIX::setSocketNotifierPending(QSocketNotifier *notifier)
QSockNot *sn = 0;
int i;
for (i = 0; i < list.size(); ++i) {
- sn = list.at(i);
+ sn = list[i];
if(sn->obj == notifier && sn->fd == sockfd)
break;
}
@@ -944,7 +950,7 @@ void QEventDispatcherUNIX::flush()
-#if !defined(Q_OS_SYMBIAN)
+
void QCoreApplication::watchUnixSignal(int sig, bool watch)
{
if (sig < NSIG) {
@@ -958,10 +964,5 @@ void QCoreApplication::watchUnixSignal(int sig, bool watch)
sigaction(sig, &sa, 0);
}
}
-#else
-void QCoreApplication::watchUnixSignal(int, bool)
-{
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index 41329cf..816add5 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -57,6 +57,7 @@
#include "QtCore/qlist.h"
#include "private/qabstracteventdispatcher_p.h"
#include "private/qpodlist_p.h"
+#include "QtCore/qvarlengtharray.h"
#include <sys/types.h>
#include <sys/time.h>
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index f5d3f78..ac505e1 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -345,18 +345,6 @@ void QObjectPrivate::derefSender(QObject *sender, int signal)
// Q_ASSERT_X(false, "QObjectPrivate::derefSender", "sender not found");
}
-void QObjectPrivate::removeSender(QObject *sender, int signal)
-{
- for (int i = 0; i < senders.count(); ++i) {
- Sender &s = senders[i];
- if (s.sender == sender && s.signal == signal) {
- senders.removeAt(i);
- return;
- }
- }
- // Q_ASSERT_X(false, "QObjectPrivate::removeSender", "sender not found");
-}
-
QObjectPrivate::Sender *QObjectPrivate::setCurrentSender(QObject *receiver,
Sender *sender)
{
@@ -404,7 +392,9 @@ void QMetaObject::removeGuard(QObject **ptr)
if (!*ptr)
return;
GuardHash *hash = guardHash();
- if (!hash)
+ /* check that the hash is empty - otherwise we might detach
+ the shared_null hash, which will alloc, which is not nice */
+ if (!hash || hash->isEmpty())
return;
QMutexLocker locker(guardHashLock());
GuardHash::iterator it = hash->find(*ptr);
@@ -446,9 +436,19 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o)
*/
void QObjectPrivate::clearGuards(QObject *object)
{
- GuardHash *hash = guardHash();
- if (hash) {
- QMutexLocker locker(guardHashLock());
+ GuardHash *hash = 0;
+ QMutex *mutex = 0;
+ QT_TRY {
+ hash = guardHash();
+ mutex = guardHashLock();
+ } QT_CATCH(const std::bad_alloc &) {
+ // do nothing in case of OOM - code below is safe
+ }
+
+ /* check that the hash is empty - otherwise we might detach
+ the shared_null hash, which will alloc, which is not nice */
+ if (hash && !hash->isEmpty()) {
+ QMutexLocker locker(mutex);
GuardHash::iterator it = hash->find(object);
const GuardHash::iterator end = hash->end();
while (it.key() == object && it != end) {
@@ -766,7 +766,14 @@ QObject::~QObject()
QObjectPrivate::clearGuards(this);
}
- emit destroyed(this);
+ 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;
+ }
{
QMutexLocker locker(&d->threadData->mutex);
@@ -790,7 +797,7 @@ QObject::~QObject()
bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
c = &connectionList[i];
if (c->receiver)
- c->receiver->d_func()->removeSender(this, signal);
+ c->receiver->d_func()->derefSender(this, signal);
if (needToUnlock)
m->unlock();
@@ -811,18 +818,22 @@ QObject::~QObject()
}
// disconnect all senders
- for (int i = 0; i < d->senders.count(); ++i) {
+ for (int i = 0; i < d->senders.count(); ) {
QObjectPrivate::Sender *s = &d->senders[i];
- if (!s->sender)
- continue;
QMutex *m = &s->sender->d_func()->threadData->mutex;
bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m);
- s = &d->senders[i];
- if (s->sender)
- s->sender->d_func()->removeReceiver(s->signal, this);
+ if (m < locker.mutex()) {
+ if (i >= d->senders.count() || s != &d->senders[i]) {
+ if (needToUnlock)
+ m->unlock();
+ continue;
+ }
+ }
+ s->sender->d_func()->removeReceiver(s->signal, this);
if (needToUnlock)
m->unlock();
+ ++i;
}
d->senders.clear();
@@ -861,9 +872,6 @@ QObject::~QObject()
objectName().isNull() ? "unnamed" : qPrintable(objectName()));
}
#endif
-
- delete d;
- d_ptr = 0;
}
@@ -920,7 +928,8 @@ QObject::~QObject()
\relates QObject
Returns the given \a object cast to type T if the object is of type
- T (or of a subclass); otherwise returns 0.
+ T (or of a subclass); otherwise returns 0. If \a object is 0 then
+ it will also return 0.
The class T must inherit (directly or indirectly) QObject and be
declared with the \l Q_OBJECT macro.
@@ -1105,11 +1114,11 @@ bool QObject::event(QEvent *e)
#if defined(QT_NO_EXCEPTIONS)
mce->placeMetaCall(this);
#else
- try {
+ QT_TRY {
mce->placeMetaCall(this);
- } catch (...) {
+ } QT_CATCH(...) {
QObjectPrivate::resetCurrentSender(this, &currentSender, previousSender);
- throw;
+ QT_RETHROW;
}
#endif
QObjectPrivate::resetCurrentSender(this, &currentSender, previousSender);
@@ -2076,7 +2085,7 @@ void QObject::deleteLater()
or
- \tt{/*: ... \starslash}
+ \tt{\begincomment: ... \endcomment}
Examples:
@@ -3109,9 +3118,9 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
#if defined(QT_NO_EXCEPTIONS)
receiver->qt_metacall(QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
#else
- try {
+ QT_TRY {
receiver->qt_metacall(QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
- } catch (...) {
+ } QT_CATCH(...) {
locker.relock();
QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
@@ -3120,7 +3129,7 @@ void QMetaObject::activate(QObject *sender, int from_signal_index, int to_signal
Q_ASSERT(connectionLists->inUse >= 0);
if (connectionLists->orphaned && !connectionLists->inUse)
delete connectionLists;
- throw;
+ QT_RETHROW;
}
#endif
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index dbec0a6..8d5c4e3 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -51,6 +51,7 @@
#ifdef QT_INCLUDE_COMPAT
#include <QtCore/qcoreevent.h>
#endif
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -286,7 +287,7 @@ protected:
QObject(QObjectPrivate &dd, QObject *parent = 0);
protected:
- QObjectData *d_ptr;
+ QScopedPointer<QObjectData> d_ptr;
static const QMetaObject staticQtMetaObject;
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index b324334..0eed938 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -163,7 +163,6 @@ public:
QList<Sender> senders;
void refSender(QObject *sender, int signal);
void derefSender(QObject *sender, int signal);
- void removeSender(QObject *sender, int signal);
static Sender *setCurrentSender(QObject *receiver,
Sender *sender);
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 2b0e0af..dc9cabf 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -142,6 +142,10 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
detached from the segment, and no references to the segment
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.
*/
/*!
diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp
index afb161c..d05f9f3 100644
--- a/src/corelib/kernel/qsharedmemory_symbian.cpp
+++ b/src/corelib/kernel/qsharedmemory_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -86,11 +116,9 @@ bool QSharedMemoryPrivate::create(int size)
return false;
}
- HBufC* buffer = qt_QString2HBufCNewL(safeKey);
+ TPtrC ptr(qt_QString2TPtrC(safeKey));
- TInt err = chunk.CreateGlobal(*buffer, size, size);
-
- delete buffer;
+ TInt err = chunk.CreateGlobal(ptr, size, size);
setErrorString(function, err);
@@ -117,15 +145,11 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
return false;
}
- HBufC* buffer = qt_QString2HBufCNewL(safeKey);
+ TPtrC ptr(qt_QString2TPtrC(safeKey));
TInt err = KErrNoMemory;
- if (buffer) {
- err = chunk.OpenGlobal(*buffer, false);
- }
-
- delete buffer;
+ err = chunk.OpenGlobal(ptr, false);
if (err != KErrNone) {
setErrorString(function, err);
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index c4395d9..b664093 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -56,10 +56,10 @@
#include <fcntl.h>
#include <unistd.h>
-QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_SHAREDMEMORY
+QT_BEGIN_NAMESPACE
+
QSharedMemoryPrivate::QSharedMemoryPrivate()
: QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError),
#ifndef QT_NO_SYSTEMSEMAPHORE
diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp
index 7e09a6e..fb9385a 100644
--- a/src/corelib/kernel/qsystemsemaphore.cpp
+++ b/src/corelib/kernel/qsystemsemaphore.cpp
@@ -170,8 +170,8 @@ QT_BEGIN_NAMESPACE
\sa acquire(), key()
*/
QSystemSemaphore::QSystemSemaphore(const QString &key, int initialValue, AccessMode mode)
+ : d(new QSystemSemaphorePrivate)
{
- d = new QSystemSemaphorePrivate;
setKey(key, initialValue, mode);
}
@@ -193,7 +193,6 @@ QSystemSemaphore::QSystemSemaphore(const QString &key, int initialValue, AccessM
QSystemSemaphore::~QSystemSemaphore()
{
d->cleanHandle();
- delete d;
}
/*!
diff --git a/src/corelib/kernel/qsystemsemaphore.h b/src/corelib/kernel/qsystemsemaphore.h
index 5a02072..3cafebf 100644
--- a/src/corelib/kernel/qsystemsemaphore.h
+++ b/src/corelib/kernel/qsystemsemaphore.h
@@ -43,6 +43,7 @@
#define QSYSTEMSEMAPHORE_H
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -89,7 +90,7 @@ public:
private:
Q_DISABLE_COPY(QSystemSemaphore)
- QSystemSemaphorePrivate *d;
+ QScopedPointer<QSystemSemaphorePrivate> d;
};
#endif // QT_NO_SYSTEMSEMAPHORE
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index 05a9347..0e6def3 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -110,9 +110,9 @@ public:
QSystemSemaphore::SystemSemaphoreError error;
};
-#endif // QT_NO_SYSTEMSEMAPHORE
+QT_END_NAMESPACE
+#endif // QT_NO_SYSTEMSEMAPHORE
-QT_END_NAMESPACE
#endif // QSYSTEMSEMAPHORE_P_H
diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
index 0c138c4..8179046 100644
--- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -60,13 +90,12 @@ int QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
if (key.isEmpty())
return 0;
QString safeName = makeKeyFileName();
- HBufC* name = qt_QString2HBufCNewL(safeName);
+ TPtrC name(qt_QString2TPtrC(safeName));
int err;
- err = semaphore.OpenGlobal(*name,EOwnerProcess);
+ err = semaphore.OpenGlobal(name,EOwnerProcess);
if (err == KErrNotFound){
- err = semaphore.CreateGlobal(*name,initialValue, EOwnerProcess);
+ err = semaphore.CreateGlobal(name,initialValue, EOwnerProcess);
}
- delete name;
if (err){
setErrorString(QLatin1String("QSystemSemaphore::handle"),err);
return 0;
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 01e81ab..4b3feb0 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE
In multithreaded applications, you can use QTimer in any thread
that has an event loop. To start an event loop from a non-GUI
- thread, use QThread::exec(). Qt uses the the timer's
+ thread, use QThread::exec(). Qt uses the timer's
\l{QObject::thread()}{thread affinity} to determine which thread
will emit the \l{QTimer::}{timeout()} signal. Because of this, you
must start and stop the timer in its thread; it is not possible to
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 77d6599..df904a6 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -149,6 +149,9 @@ static int numerusHelper(int n, const uchar *rules, int rulesSize)
leftOperand %= 10;
} else if (opcode & Q_MOD_100) {
leftOperand %= 100;
+ } else if (opcode & Q_LEAD_1000) {
+ while (leftOperand >= 1000)
+ leftOperand /= 1000;
}
int op = opcode & Q_OP_MASK;
@@ -819,6 +822,6 @@ bool QTranslator::isEmpty() const
Use translate(\a context, \a sourceText, \a comment) instead.
*/
-#endif // QT_NO_TRANSLATION
-
QT_END_NAMESPACE
+
+#endif // QT_NO_TRANSLATION
diff --git a/src/corelib/kernel/qtranslator_p.h b/src/corelib/kernel/qtranslator_p.h
index 77ec8f5..a7d58c5 100644
--- a/src/corelib/kernel/qtranslator_p.h
+++ b/src/corelib/kernel/qtranslator_p.h
@@ -62,6 +62,7 @@ enum {
Q_NOT = 0x08,
Q_MOD_10 = 0x10,
Q_MOD_100 = 0x20,
+ Q_LEAD_1000 = 0x40,
Q_AND = 0xFD,
Q_OR = 0xFE,
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 420dd1d..0ca0169 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -611,10 +611,10 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
.arg(fileName);
QStringList reg;
#ifndef QT_NO_SETTINGS
- bool madeSettings = false;
+ QScopedPointer<QSettings> madeSettings;
if (!settings) {
settings = new QSettings(QSettings::UserScope, QLatin1String("Trolltech"));
- madeSettings = true;
+ madeSettings.reset(settings);
}
reg = settings->value(regkey).toStringList();
#endif
@@ -708,8 +708,7 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
#endif
}
#ifndef QT_NO_SETTINGS
- if (madeSettings)
- delete settings;
+ madeSettings.reset();
#endif
if (!success) {
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index a911f1d..8d1c0f7 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -46,6 +46,7 @@
#include <qfileinfo.h>
#include "qlibrary_p.h"
#include "qdebug.h"
+#include "qdir.h"
#ifndef QT_NO_LIBRARY
@@ -301,6 +302,24 @@ void QPluginLoader::setFileName(const QString &fileName)
}
QString fn = fi.canonicalFilePath();
+ // If not found directly, check also all the available drives
+ if (!fn.length()) {
+ QString stubPath(fi.fileName().length() ? fi.absoluteFilePath() : QString());
+ if (stubPath.length() > 1) {
+ if (stubPath.at(1).toAscii() == ':')
+ stubPath.remove(0,2);
+ QFileInfoList driveList(QDir::drives());
+ foreach(const QFileInfo& drive, driveList) {
+ QString testFilePath(drive.absolutePath() + stubPath);
+ testFilePath = QDir::cleanPath(testFilePath);
+ if (QFile::exists(testFilePath)) {
+ fn = testFilePath;
+ break;
+ }
+ }
+ }
+ }
+
#else
QString fn = QFileInfo(fileName).canonicalFilePath();
#endif
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index cb44a25..f1bdc64 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -163,9 +163,9 @@ QAdoptedThread::~QAdoptedThread()
QThread *QAdoptedThread::createThreadForAdoption()
{
- QThread *t = new QAdoptedThread(0);
- t->moveToThread(t);
- return t;
+ QScopedPointer<QThread> t(new QAdoptedThread(0));
+ t->moveToThread(t.data());
+ return t.take();
}
void QAdoptedThread::run()
@@ -483,10 +483,10 @@ uint QThread::stackSize() const
int QThread::exec()
{
Q_D(QThread);
- d->mutex.lock();
+ QMutexLocker locker(&d->mutex);
d->data->quitNow = false;
QEventLoop eventLoop;
- d->mutex.unlock();
+ locker.unlock();
int returnCode = eventLoop.exec();
return returnCode;
}
@@ -734,8 +734,9 @@ QThreadData* QThreadData::current()
{
static QThreadData *data = 0; // reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
if (!data) {
- data = new QThreadData;
- data->thread = new QAdoptedThread(data);
+ QScopedPointer<QThreadData> newdata(new QThreadData);
+ newdata->thread = new QAdoptedThread(newdata.data());
+ data = newdata.take();
data->deref();
}
return data;
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 567c936..d2a824a 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -124,7 +124,14 @@ QThreadData *QThreadData::current()
} else {
data = new QThreadData;
pthread_setspecific(current_thread_data_key, data);
- data->thread = new QAdoptedThread(data);
+ QT_TRY {
+ data->thread = new QAdoptedThread(data);
+ } QT_CATCH(...) {
+ pthread_setspecific(current_thread_data_key, 0);
+ data->deref();
+ data = 0;
+ QT_RETHROW;
+ }
data->deref();
}
if (!QCoreApplicationPrivate::theMainThread)
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 7094e3d..76e551e 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -112,7 +112,14 @@ QThreadData *QThreadData::current()
// This needs to be called prior to new AdoptedThread() to
// avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData);
- threadData->thread = new QAdoptedThread(threadData);
+ QT_TRY {
+ threadData->thread = new QAdoptedThread(threadData);
+ } QT_CATCH(...) {
+ TlsSetValue(qt_current_thread_data_tls_index, 0);
+ threadData->deref();
+ threadData = 0;
+ QT_RETHROW;
+ }
threadData->deref();
}
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 35c55c1..4657009 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -101,12 +101,14 @@ void **QThreadStorageData::get() const
qWarning("QThreadStorage::get: QThreadStorage can only be used with threads started with QThread");
return 0;
}
- QMap<int, void *>::iterator it = data->tls.find(id);
+ QMap<int, void *>::const_iterator it = data->tls.constFind(id);
DEBUG_MSG("QThreadStorageData: Returning storage %d, data %p, for thread %p",
id,
it != data->tls.end() ? it.value() : 0,
data->thread);
- return it != data->tls.end() && it.value() != 0 ? &it.value() : 0;
+ // const_cast below is a bit evil - but we have to make sure not to detach here
+ // otherwise we'll go bonkers in oom situations
+ return it != data->tls.constEnd() && it.value() != 0 ? const_cast<void **>(&it.value()) : 0;
}
void **QThreadStorageData::set(void *p)
@@ -129,9 +131,9 @@ void **QThreadStorageData::set(void *p)
void *q = it.value();
it.value() = 0;
- mutex()->lock();
+ QMutexLocker locker(mutex());
void (*destructor)(void *) = destructors()->value(id);
- mutex()->unlock();
+ locker.unlock();
destructor(q);
}
@@ -167,9 +169,9 @@ void QThreadStorageData::finish(void **p)
continue;
}
- mutex()->lock();
+ QMutexLocker locker(mutex());
void (*destructor)(void *) = destructors()->value(id);
- mutex()->unlock();
+ locker.unlock();
if (!destructor) {
if (QThread::currentThread())
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index a947ab5..7168a9a 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -209,6 +209,8 @@ void QBitArray::resize(int size)
uchar* c = reinterpret_cast<uchar*>(d.data());
if (size > (s << 3))
memset(c + s, 0, d.size() - s);
+ else if ( size % 8)
+ *(c+1+size/8) &= (1 << (size%8)) - 1;
*c = d.size()*8 - size;
}
}
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 6aa35f3..ae6561f 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1233,14 +1233,11 @@ QByteArray::QByteArray(const char *str)
} else {
int len = qstrlen(str);
d = static_cast<Data *>(qMalloc(sizeof(Data)+len));
- if (!d) {
- d = &shared_null;
- } else {
- d->ref = 0;;
- d->alloc = d->size = len;
- d->data = d->array;
- memcpy(d->array, str, len+1); // include null terminator
- }
+ Q_CHECK_PTR(d);
+ d->ref = 0;;
+ d->alloc = d->size = len;
+ d->data = d->array;
+ memcpy(d->array, str, len+1); // include null terminator
}
d->ref.ref();
}
@@ -1264,15 +1261,12 @@ QByteArray::QByteArray(const char *data, int size)
d = &shared_empty;
} else {
d = static_cast<Data *>(qMalloc(sizeof(Data) + size));
- if (!d) {
- d = &shared_null;
- } else {
- d->ref = 0;
- d->alloc = d->size = size;
- d->data = d->array;
- memcpy(d->array, data, size);
- d->array[size] = '\0';
- }
+ Q_CHECK_PTR(d);
+ d->ref = 0;
+ d->alloc = d->size = size;
+ d->data = d->array;
+ memcpy(d->array, data, size);
+ d->array[size] = '\0';
}
d->ref.ref();
}
@@ -1290,15 +1284,12 @@ QByteArray::QByteArray(int size, char ch)
d = &shared_null;
} else {
d = static_cast<Data *>(qMalloc(sizeof(Data)+size));
- if (!d) {
- d = &shared_null;
- } else {
- d->ref = 0;
- d->alloc = d->size = size;
- d->data = d->array;
- d->array[size] = '\0';
- memset(d->array, ch, size);
- }
+ Q_CHECK_PTR(d);
+ d->ref = 0;
+ d->alloc = d->size = size;
+ d->data = d->array;
+ d->array[size] = '\0';
+ memset(d->array, ch, size);
}
d->ref.ref();
}
@@ -1334,8 +1325,7 @@ void QByteArray::resize(int size)
// QByteArray a(sz);
//
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)+size));
- if (!x)
- return;
+ Q_CHECK_PTR(x);
x->ref = 1;
x->alloc = x->size = size;
x->data = x->array;
@@ -1377,8 +1367,7 @@ void QByteArray::realloc(int alloc)
{
if (d->ref != 1 || d->data != d->array) {
Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc));
- if (!x)
- return;
+ Q_CHECK_PTR(x);
x->size = qMin(alloc, d->size);
::memcpy(x->array, d->data, x->size);
x->array[x->size] = '\0';
@@ -1390,8 +1379,7 @@ void QByteArray::realloc(int alloc)
d = x;
} else {
Data *x = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc));
- if (!x)
- return;
+ Q_CHECK_PTR(x);
x->alloc = alloc;
x->data = x->array;
d = x;
@@ -1812,11 +1800,13 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after
const char *b = before;
if (after >= d->data && after < d->data + d->size) {
char *copy = (char *)malloc(asize);
+ Q_CHECK_PTR(copy);
memcpy(copy, after, asize);
a = copy;
}
if (before >= d->data && before < d->data + d->size) {
char *copy = (char *)malloc(bsize);
+ Q_CHECK_PTR(copy);
memcpy(copy, before, bsize);
b = copy;
}
@@ -3738,6 +3728,7 @@ QByteArray QByteArray::number(double n, char f, int prec)
QByteArray QByteArray::fromRawData(const char *data, int size)
{
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)));
+ Q_CHECK_PTR(x);
if (data) {
x->data = const_cast<char *>(data);
} else {
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index 633e92c..970cbcc 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -70,7 +70,7 @@ public:
inline QByteArray pattern() const
{
if (q_pattern.isNull())
- return QByteArray((const char*)p.p, p.l);
+ return QByteArray(reinterpret_cast<const char*>(p.p), p.l);
return q_pattern;
}
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 9063ae4..917679c 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -78,7 +78,7 @@ public:
QCryptographicHash can be used to generate cryptographic hashes of binary or text data.
- Currently MD4, MD5, and SHA1 are supported.
+ Currently MD4, MD5, and SHA-1 are supported.
*/
/*!
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 781514c..b43891c 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2200,8 +2200,8 @@ int QTime::elapsed() const
\sa isValid()
*/
QDateTime::QDateTime()
+ : d(new QDateTimePrivate)
{
- d = new QDateTimePrivate;
}
@@ -2211,8 +2211,8 @@ QDateTime::QDateTime()
*/
QDateTime::QDateTime(const QDate &date)
+ : d(new QDateTimePrivate)
{
- d = new QDateTimePrivate;
d->date = date;
d->time = QTime(0, 0, 0);
}
@@ -2225,8 +2225,8 @@ QDateTime::QDateTime(const QDate &date)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
+ : d(new QDateTimePrivate)
{
- d = new QDateTimePrivate;
d->date = date;
d->time = date.isValid() && !time.isValid() ? QTime(0, 0, 0) : time;
d->spec = (spec == Qt::UTC) ? QDateTimePrivate::UTC : QDateTimePrivate::LocalUnknown;
@@ -2237,8 +2237,8 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
*/
QDateTime::QDateTime(const QDateTime &other)
+ : d(other.d.data())
{
- d = other.d;
d->ref.ref();
}
@@ -2247,8 +2247,6 @@ QDateTime::QDateTime(const QDateTime &other)
*/
QDateTime::~QDateTime()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -2258,7 +2256,7 @@ QDateTime::~QDateTime()
QDateTime &QDateTime::operator=(const QDateTime &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -3298,7 +3296,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format)
*/
void QDateTime::detach()
{
- qAtomicDetach(d);
+ d.detach();
}
/*****************************************************************************
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 3278297..cf4246d 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -44,6 +44,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -284,7 +285,7 @@ public:
private:
friend class QDateTimePrivate;
void detach();
- QDateTimePrivate *d;
+ QScopedSharedPointer<QDateTimePrivate> d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp
index 1940209..923eda4 100644
--- a/src/corelib/tools/qharfbuzz.cpp
+++ b/src/corelib/tools/qharfbuzz.cpp
@@ -126,6 +126,7 @@ char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb
QByteArray data = reinterpret_cast<QTextCodec *>(codec)->fromUnicode((const QChar *)unicode, length);
// ### suboptimal
char *output = (char *)malloc(data.length() + 1);
+ Q_CHECK_PTR(output);
memcpy(output, data.constData(), data.length() + 1);
if (outputLength)
*outputLength = data.length();
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 2313e0e..a703621 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -171,7 +171,9 @@ QHashData QHashData::shared_null = {
void *QHashData::allocateNode()
{
- return qMalloc(nodeSize);
+ void *ptr = qMalloc(nodeSize);
+ Q_CHECK_PTR(ptr);
+ return ptr;
}
void QHashData::freeNode(void *node)
@@ -181,6 +183,13 @@ void QHashData::freeNode(void *node)
QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize)
{
+ return detach_helper( node_duplicate, 0, nodeSize );
+}
+
+QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
+ void (*node_delete)(Node *),
+ int nodeSize)
+{
union {
QHashData *d;
Node *e;
@@ -197,18 +206,43 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int
d->sharable = true;
if (numBuckets) {
- d->buckets = new Node *[numBuckets];
+ QT_TRY {
+ d->buckets = new Node *[numBuckets];
+ } QT_CATCH(...) {
+ // restore a consistent state for d
+ d->numBuckets = 0;
+ // roll back
+ d->free_helper(node_delete);
+ QT_RETHROW;
+ }
+
Node *this_e = reinterpret_cast<Node *>(this);
for (int i = 0; i < numBuckets; ++i) {
Node **nextNode = &d->buckets[i];
Node *oldNode = buckets[i];
while (oldNode != this_e) {
- Node *dup = static_cast<Node *>(allocateNode());
- node_duplicate(oldNode, dup);
- dup->h = oldNode->h;
- *nextNode = dup;
- nextNode = &dup->next;
- oldNode = oldNode->next;
+ QT_TRY {
+ Node *dup = static_cast<Node *>(allocateNode());
+
+ QT_TRY {
+ node_duplicate(oldNode, dup);
+ } QT_CATCH(...) {
+ freeNode( dup );
+ QT_RETHROW;
+ }
+
+ dup->h = oldNode->h;
+ *nextNode = dup;
+ nextNode = &dup->next;
+ oldNode = oldNode->next;
+ } QT_CATCH(...) {
+ // restore a consistent state for d
+ *nextNode = e;
+ d->numBuckets = i+1;
+ // roll back
+ d->free_helper(node_delete);
+ QT_RETHROW;
+ }
}
*nextNode = e;
}
@@ -216,6 +250,26 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int
return d;
}
+void QHashData::free_helper(void (*node_delete)(Node *))
+{
+ if (node_delete) {
+ Node *this_e = reinterpret_cast<Node *>(this);
+ Node **bucket = reinterpret_cast<Node **>(this->buckets);
+
+ int n = numBuckets;
+ while (n--) {
+ Node *cur = *bucket++;
+ while (cur != this_e) {
+ Node *next = cur->next;
+ node_delete(cur);
+ cur = next;
+ }
+ }
+ }
+ delete [] buckets;
+ delete this;
+}
+
QHashData::Node *QHashData::nextNode(Node *node)
{
union {
@@ -298,9 +352,10 @@ void QHashData::rehash(int hint)
Node **oldBuckets = buckets;
int oldNumBuckets = numBuckets;
+ int nb = primeForNumBits(hint);
+ buckets = new Node *[nb];
numBits = hint;
- numBuckets = primeForNumBits(hint);
- buckets = new Node *[numBuckets];
+ numBuckets = nb;
for (int i = 0; i < numBuckets; ++i)
buckets[i] = e;
@@ -327,8 +382,7 @@ void QHashData::rehash(int hint)
void QHashData::destroyAndFree()
{
- delete [] buckets;
- delete this;
+ free_helper(0);
}
#ifdef QT_QHASH_DEBUG
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 3328716..b3f82e9 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -97,10 +97,7 @@ Q_CORE_EXPORT uint qHash(const QBitArray &key);
#endif
template <class T> inline uint qHash(const T *key)
{
- if (sizeof(const T *) > sizeof(uint))
- return qHash(reinterpret_cast<quint64>(key));
- else
- return uint(reinterpret_cast<ulong>(key));
+ return qHash(reinterpret_cast<quintptr>(key));
}
#if defined(Q_CC_MSVC)
#pragma warning( pop )
@@ -132,12 +129,15 @@ struct Q_CORE_EXPORT QHashData
void *allocateNode();
void freeNode(void *node);
- QHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize);
+ QHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize); // ### Qt5 remove me
+ QHashData *detach_helper(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
+ int nodeSize);
void mightGrow();
bool willGrow();
void hasShrunk();
void rehash(int hint);
- void destroyAndFree();
+ void free_helper(void (*node_delete)(Node *));
+ void destroyAndFree(); // ### Qt5 remove me
Node *firstNode();
#ifdef QT_QHASH_DEBUG
void dump();
@@ -479,21 +479,30 @@ private:
Node **findNode(const Key &key, uint *hp = 0) const;
Node *createNode(uint h, const Key &key, const T &value, Node **nextNode);
void deleteNode(Node *node);
+ static void deleteNode(QHashData::Node *node);
static void duplicateNode(QHashData::Node *originalNode, void *newNode);
};
+
template <class Key, class T>
Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode(Node *node)
{
+ deleteNode(reinterpret_cast<QHashData::Node*>(node));
+}
+
+
+template <class Key, class T>
+Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode(QHashData::Node *node)
+{
#ifdef Q_CC_BOR
- node->~QHashNode<Key, T>();
+ concrete(node)->~QHashNode<Key, T>();
#elif defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION)
- node->~QHashNode();
+ concrete(node)->~QHashNode();
#else
- node->~Node();
+ concrete(node)->~Node();
#endif
- d->freeNode(node);
+ qFree(node);
}
template <class Key, class T>
@@ -541,18 +550,7 @@ Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash<Key, T> &other
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::freeData(QHashData *x)
{
- Node *e_for_x = reinterpret_cast<Node *>(x);
- Node **bucket = reinterpret_cast<Node **>(x->buckets);
- int n = x->numBuckets;
- while (n--) {
- Node *cur = *bucket++;
- while (cur != e_for_x) {
- Node *next = cur->next;
- deleteNode(cur);
- cur = next;
- }
- }
- x->destroyAndFree();
+ x->free_helper(deleteNode);
}
template <class Key, class T>
@@ -564,7 +562,7 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::clear()
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::detach_helper()
{
- QHashData *x = d->detach_helper(duplicateNode,
+ QHashData *x = d->detach_helper(duplicateNode, deleteNode,
QTypeInfo<T>::isDummy ? sizeof(DummyNode) : sizeof(Node));
if (!d->ref.deref())
freeData(d);
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 6a85386..79311bc 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -265,15 +265,22 @@ void QLinkedList<T>::detach_helper()
x.d->ref = 1;
x.d->size = d->size;
x.d->sharable = true;
- Node *i = e->n, *j = x.e;
- while (i != e) {
- j->n = new Node(i->t);
- j->n->p = j;
- i = i->n;
- j = j->n;
+ Node *original = e->n;
+ Node *copy = x.e;
+ while (original != e) {
+ QT_TRY {
+ copy->n = new Node(original->t);
+ copy->n->p = copy;
+ original = original->n;
+ copy = copy->n;
+ } QT_CATCH(...) {
+ copy->n = x.e;
+ free(x.d);
+ QT_RETHROW;
+ }
}
- j->n = x.e;
- x.e->p = j;
+ copy->n = x.e;
+ x.e->p = copy;
if (!d->ref.deref())
free(d);
d = x.d;
@@ -474,14 +481,21 @@ QLinkedList<T> &QLinkedList<T>::operator+=(const QLinkedList<T> &l)
detach();
int n = l.d->size;
d->size += n;
- Node *o = l.e->n;
+ Node *original = l.e->n;
while (n--) {
- Node *i = new Node(o->t);
- o = o->n;
- i->n = e;
- i->p = e->p;
- i->p->n = i;
- e->p = i;
+ QT_TRY {
+ Node *copy = new Node(original->t);
+ original = original->n;
+ copy->n = e;
+ copy->p = e->p;
+ copy->p->n = copy;
+ e->p = copy;
+ } QT_CATCH(...) {
+ // restore the original list
+ while (n++<d->size)
+ removeLast();
+ QT_RETHROW;
+ }
}
return *this;
}
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 3c21ec1..7540035 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -117,6 +117,14 @@ public:
inline int size() const { return p.size(); }
inline void detach() { if (d->ref != 1) detach_helper(); }
+
+ inline void detachShared()
+ {
+ // The "this->" qualification is needed for GCCE.
+ if (d->ref != 1 && this->d != &QListData::shared_null)
+ detach_helper();
+ }
+
inline bool isDetached() const { return d->ref == 1; }
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
@@ -352,12 +360,27 @@ Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *n)
template <typename T>
Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src)
{
- if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
- while(from != to)
- (from++)->v = new T(*reinterpret_cast<T*>((src++)->v));
- else if (QTypeInfo<T>::isComplex)
- while(from != to)
- new (from++) T(*reinterpret_cast<T*>(src++));
+ Node *current = from;
+ if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
+ QT_TRY {
+ while(current != to)
+ (current++)->v = new T(*reinterpret_cast<T*>((src++)->v));
+ } QT_CATCH(...) {
+ while (current != from)
+ delete reinterpret_cast<T*>(current--);
+ QT_RETHROW;
+ }
+ }
+ else if (QTypeInfo<T>::isComplex) {
+ QT_TRY {
+ while(current != to)
+ new (current++) T(*reinterpret_cast<T*>(src++));
+ } QT_CATCH(...) {
+ while (current != from)
+ (reinterpret_cast<T*>(current--))->~T();
+ QT_RETHROW;
+ }
+ }
}
template <typename T>
@@ -384,8 +407,16 @@ Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
}
template <typename T>
inline typename QList<T>::iterator QList<T>::insert(iterator before, const T &t)
-{ Node *n = reinterpret_cast<Node *>(p.insert(before.i-reinterpret_cast<Node *>(p.begin())));
- node_construct(n,t); return n; }
+{
+ Node *n = reinterpret_cast<Node *>(p.insert(before.i - reinterpret_cast<Node *>(p.begin())));
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ p.remove(before.i - reinterpret_cast<Node *>(p.begin()));
+ QT_RETHROW;
+ }
+ return n;
+}
template <typename T>
inline typename QList<T>::iterator QList<T>::erase(iterator it)
{ node_destruct(it.i);
@@ -423,10 +454,22 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::append(const T &t)
{
detach();
if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- node_construct(reinterpret_cast<Node *>(p.append()), t);
+ Node *n = reinterpret_cast<Node *>(p.append());
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ --d->end;
+ QT_RETHROW;
+ }
} else {
const T cpy(t);
- node_construct(reinterpret_cast<Node *>(p.append()), cpy);
+ Node *n = reinterpret_cast<Node *>(p.append());
+ QT_TRY {
+ node_construct(n, cpy);
+ } QT_CATCH(...) {
+ --d->end;
+ QT_RETHROW;
+ }
}
}
@@ -435,10 +478,22 @@ inline void QList<T>::prepend(const T &t)
{
detach();
if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- node_construct(reinterpret_cast<Node *>(p.prepend()), t);
+ Node *n = reinterpret_cast<Node *>(p.prepend());
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ ++d->begin;
+ QT_RETHROW;
+ }
} else {
const T cpy(t);
- node_construct(reinterpret_cast<Node *>(p.prepend()), cpy);
+ Node *n = reinterpret_cast<Node *>(p.prepend());
+ QT_TRY {
+ node_construct(n, cpy);
+ } QT_CATCH(...) {
+ ++d->begin;
+ QT_RETHROW;
+ }
}
}
@@ -447,10 +502,22 @@ inline void QList<T>::insert(int i, const T &t)
{
detach();
if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) {
- node_construct(reinterpret_cast<Node *>(p.insert(i)), t);
+ Node *n = reinterpret_cast<Node *>(p.insert(i));
+ QT_TRY {
+ node_construct(n, t);
+ } QT_CATCH(...) {
+ p.remove(i);
+ QT_RETHROW;
+ }
} else {
const T cpy(t);
- node_construct(reinterpret_cast<Node *>(p.insert(i)), cpy);
+ Node *n = reinterpret_cast<Node *>(p.insert(i));
+ QT_TRY {
+ node_construct(n, cpy);
+ } QT_CATCH(...) {
+ p.remove(i);
+ QT_RETHROW;
+ }
}
}
@@ -522,7 +589,14 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::detach_helper()
{
Node *n = reinterpret_cast<Node *>(p.begin());
QListData::Data *x = p.detach2();
- node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n);
+ QT_TRY {
+ node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n);
+ } QT_CATCH(...) {
+ qFree(d);
+ d = x;
+ QT_RETHROW;
+ }
+
if (!x->ref.deref())
free(x);
}
@@ -572,7 +646,7 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::clear()
template <typename T>
Q_OUTOFLINE_TEMPLATE int QList<T>::removeAll(const T &_t)
{
- detach();
+ detachShared();
const T t = _t;
int removedCount=0, i=0;
Node *n;
@@ -590,7 +664,7 @@ Q_OUTOFLINE_TEMPLATE int QList<T>::removeAll(const T &_t)
template <typename T>
Q_OUTOFLINE_TEMPLATE bool QList<T>::removeOne(const T &_t)
{
- detach();
+ detachShared();
int index = indexOf(_t);
if (index != -1) {
removeAt(index);
diff --git a/src/corelib/tools/qlistdata.cpp b/src/corelib/tools/qlistdata.cpp
index d40b6b6..efdde64 100644
--- a/src/corelib/tools/qlistdata.cpp
+++ b/src/corelib/tools/qlistdata.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <new>
#include "qlist.h"
#include "qtools_p.h"
#include <string.h>
@@ -71,8 +72,7 @@ static int grow(int size)
QListData::Data *QListData::detach()
{
Data *x = static_cast<Data *>(qMalloc(DataHeaderSize + d->alloc * sizeof(void *)));
- if (!x)
- qFatal("QList: Out of memory");
+ Q_CHECK_PTR(x);
::memcpy(x, d, DataHeaderSize + d->alloc * sizeof(void *));
x->alloc = d->alloc;
@@ -91,10 +91,10 @@ QListData::Data *QListData::detach()
QListData::Data *QListData::detach2()
{
Data *x = d;
- d = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *)));
- if (!d)
- qFatal("QList: Out of memory");
+ Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + x->alloc * sizeof(void *)));
+ Q_CHECK_PTR(t);
+ d = t;
::memcpy(d, x, DataHeaderSize + x->alloc * sizeof(void *));
d->alloc = x->alloc;
d->ref = 1;
@@ -109,8 +109,7 @@ void QListData::realloc(int alloc)
{
Q_ASSERT(d->ref == 1);
Data *x = static_cast<Data *>(qRealloc(d, DataHeaderSize + alloc * sizeof(void *)));
- if (!x)
- qFatal("QList: Out of memory");
+ Q_CHECK_PTR(x);
d = x;
d->alloc = alloc;
@@ -514,6 +513,15 @@ void **QListData::erase(void **xi)
\internal
*/
+/*! \fn void QList::detachShared()
+
+ \internal
+
+ like detach(), but does nothing if we're shared_null.
+ This prevents needless mallocs, and makes QList more exception safe
+ in case of cleanup work done in destructors on empty lists.
+*/
+
/*! \fn bool QList::isDetached() const
\internal
@@ -1173,7 +1181,8 @@ void **QListData::erase(void **xi)
/*! \typedef QList::iterator::iterator_category
- \internal
+ A synonym for \e {std::random_access_iterator_tag} indicating
+ this iterator is a random access iterator.
*/
/*! \typedef QList::iterator::difference_type
@@ -1432,7 +1441,8 @@ void **QListData::erase(void **xi)
/*! \typedef QList::const_iterator::iterator_category
- \internal
+ A synonym for \e {std::random_access_iterator_tag} indicating
+ this iterator is a random access iterator.
*/
/*! \typedef QList::const_iterator::difference_type
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 4267562..4317933 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -78,11 +78,6 @@ QT_END_NAMESPACE
#include <qdebug.h>
#include <time.h>
-#if defined(Q_OS_SYMBIAN)
-#include <e32std.h>
-#include "private/qcore_symbian_p.h"
-#endif
-
#if defined(Q_OS_LINUX) && !defined(__UCLIBC__)
# include <fenv.h>
#endif
@@ -303,7 +298,7 @@ static bool splitLocaleName(const QString &name, QChar *lang_begin, QChar *cntry
return lang_len == 2 || lang_len == 3;
}
-static void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry)
+void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry)
{
lang = QLocale::C;
cntry = QLocale::AnyCountry;
@@ -1282,794 +1277,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
}
return QVariant();
}
-#elif defined(Q_OS_SYMBIAN)
-
-static TExtendedLocale _s60Locale;
-
-// Type definitions for runtime resolved function pointers
-typedef void (*FormatFunc)(TTime&, TDes&, const TDesC&, const TLocale&);
-typedef TPtrC (*FormatSpecFunc)(TExtendedLocale&);
-
-// Runtime resolved functions
-static FormatFunc ptrTimeFormatL = NULL;
-static FormatSpecFunc ptrGetTimeFormatSpec = NULL;
-static FormatSpecFunc ptrGetLongDateFormatSpec = NULL;
-static FormatSpecFunc ptrGetShortDateFormatSpec = NULL;
-
-// Default functions if functions cannot be resolved
-static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&)
-{
- des.Zero();
-}
-
-static TPtrC defaultFormatSpec(TExtendedLocale&)
-{
- return TPtrC(KNullDesC);
-}
-
-/*!
- Definition of struct for mapping Symbian to ISO locale
-*/
-struct symbianToISO {
- int symbian_language;
- char iso_name[8];
-};
-
-/*!
- Mapping from Symbian to ISO locale
-*/
-static const symbianToISO symbian_to_iso_list[] = {
- { ELangEnglish, "en_GB" },
- { ELangFrench, "fr_FR" },
- { ELangGerman, "de_DE" },
- { ELangSpanish, "es_ES" },
- { ELangItalian, "it_IT" },
- { ELangSwedish, "sv_SE" },
- { ELangDanish, "da_DK" },
- { ELangNorwegian, "no_NO" },
- { ELangFinnish, "fi_FI" },
- { ELangAmerican, "en_US" },
- { ELangPortuguese, "pt_PT" },
- { ELangTurkish, "tr_TR" },
- { ELangIcelandic, "is_IS" },
- { ELangRussian, "ru_RU" },
- { ELangHungarian, "hu_HU" },
- { ELangDutch, "nl_NL" },
- { ELangBelgianFlemish, "nl_BE" },
- { ELangCzech, "cs_CZ" },
- { ELangSlovak, "sk_SK" },
- { ELangPolish, "pl_PL" },
- { ELangSlovenian, "sl_SI" },
- { ELangTaiwanChinese, "zh_TW" },
- { ELangHongKongChinese, "zh_HK" },
- { ELangPrcChinese, "zh_CN" },
- { ELangJapanese, "ja_JP" },
- { ELangThai, "th_TH" },
- { ELangArabic, "ar_AE" },
- { ELangTagalog, "tl_PH" },
- { ELangBulgarian, "bg_BG" },
- { ELangCatalan, "ca_ES" },
- { ELangCroatian, "hr_HR" },
- { ELangEstonian, "et_EE" },
- { ELangFarsi, "fa_IR" },
- { ELangCanadianFrench, "fr_CA" },
- { ELangGreek, "el_GR" },
- { ELangHebrew, "he_IL" },
- { ELangHindi, "hi_IN" },
- { ELangIndonesian, "id_ID" },
- { ELangLatvian, "lv_LV" },
- { ELangLithuanian, "lt_LT" },
- { ELangMalay, "ms_MY" },
- { ELangBrazilianPortuguese, "pt_BR" },
- { ELangRomanian, "ro_RO" },
- { ELangSerbian, "sr_YU" },
- { ELangLatinAmericanSpanish, "es" },
- { ELangUkrainian, "uk_UA" },
- { ELangUrdu, "ur_PK" }, // India/Pakistan
- { ELangVietnamese, "vi_VN" },
-#ifdef __E32LANG_H__
-// 5.0
- { ELangBasque, "eu_ES" },
- { ELangGalician, "gl_ES" },
-#endif
-#if !defined(__SERIES60_31__)
- { ELangEnglish_Apac, "en" },
- { ELangEnglish_Taiwan, "en_TW" },
- { ELangEnglish_HongKong, "en_HK" },
- { ELangEnglish_Prc, "en_CN" },
- { ELangEnglish_Japan, "en_JP"},
- { ELangEnglish_Thailand, "en_TH" },
- { ELangMalay_Apac, "ms" }
-#endif
-};
-
-/*!
- Returns ISO name corresponding to the Symbian locale code \a sys_fmt.
-*/
-static QByteArray symbianLocaleName(int code)
-{
- //Number of Symbian to ISO locale mappings
- static const int symbian_to_iso_count
- = sizeof(symbian_to_iso_list)/sizeof(symbianToISO);
-
- int cmp = code - symbian_to_iso_list[0].symbian_language;
- if (cmp < 0)
- return 0;
-
- if (cmp == 0)
- return symbian_to_iso_list[0].iso_name;
-
- int begin = 0;
- int end = symbian_to_iso_count;
-
- while (end - begin > 1) {
- uint mid = (begin + end)/2;
-
- const symbianToISO *elt = symbian_to_iso_list + mid;
- int cmp = code - elt->symbian_language;
- if (cmp < 0)
- end = mid;
- else if (cmp > 0)
- begin = mid;
- else
- return elt->iso_name;
- }
-
- return 0;
-}
-
-
-// order is: normal, abbr, nmode, nmode+abbr
-static const char *us_locale_dep[] = {
- "MM", "dd", "yyyy", "MM", "dd",
- "M", "d", "yy", "M", "d",
- "MMMM", "dd", "yyyy", "MMMM", "dd",
- "MMM", "d", "yy", "MMM", "d" };
-
-static const char *eu_locale_dep[] = {
- "dd", "MM", "yyyy", "dd", "MM",
- "d", "M", "yy", "d", "M",
- "dd", "MMMM", "yyyy", "dd", "MMMM",
- "d", "MMM", "yy", "d", "MMM" };
-
-static const char *jp_locale_dep[] = {
- "yyyy", "MM", "dd", "MM", "dd",
- "yy", "M", "d", "M", "d",
- "yyyy", "MMMM", "dd", "MMMM", "dd",
- "yy", "MMM", "d", "MMM", "d" };
-
-/*!
- Returns a Qt version of the given \a sys_fmt Symbian locale format string.
-*/
-static QString s60ToQtFormat(const QString &sys_fmt)
-{
- TLocale *locale = _s60Locale.GetLocale();
-
- QString result;
- QString other;
- QString qtformatchars = QString::fromLatin1("adhmsyzAHM");
-
- QChar c;
- int i = 0;
- bool open_escape = false;
- bool abbrev_next = false;
- bool locale_indep_ordering = false;
- bool minus_mode = false;
- bool plus_mode = false;
- bool n_mode = false;
- TTimeFormat tf = locale->TimeFormat();
-
- while (i < sys_fmt.size()) {
-
- c = sys_fmt.at(i);
-
- // let formatting thru
- if (c.unicode() == '%') {
- // if we have gathered string, concat it
- if (!other.isEmpty()) {
- result += other;
- other.clear();
- }
- // if we have open escape, end it
- if (open_escape) {
- result += QLatin1Char('\'');
- open_escape = false;
- }
-
- ++i;
- if (i >= sys_fmt.size())
- break;
-
- c = sys_fmt.at(i);
-
- // process specials
- abbrev_next = c.unicode() == '*';
- plus_mode = c.unicode() == '+';
- minus_mode = c.unicode() == '-';
-
- if (abbrev_next || plus_mode || minus_mode) {
- ++i;
- if (i >= sys_fmt.size())
- break;
-
- c = sys_fmt.at(i);
-
- if (plus_mode || minus_mode) {
- // break on undefined plus/minus mode
- if (c.unicode() != 'A' && c.unicode() != 'B')
- break;
- }
- }
-
- switch (c.unicode()) {
- case 'F':
- // locale indep mode on
- locale_indep_ordering = true;
- break;
-
- case '/':
- // date sep 0-3
- ++i;
- if (i >= sys_fmt.size())
- break;
-
- c = sys_fmt.at(i);
- if (c.isDigit() && c.digitValue() <= 3) {
- TChar s = locale->DateSeparator(c.digitValue());
- TUint val = s;
- // some indexes return zero for empty
- if (val > 0)
- result += QChar(val);
- }
- break;
-
- case 'D':
- if (!locale_indep_ordering)
- break;
-
- if (!abbrev_next)
- result += QLatin1String("dd");
- else
- result += QLatin1Char('d');
-
- break;
-
- case 'M':
- if (!locale_indep_ordering)
- break;
-
- if (!n_mode) {
- if (!abbrev_next)
- result += QLatin1String("MM");
- else
- result += QLatin1String("M");
- } else {
- if (!abbrev_next)
- result += QLatin1String("MMMM");
- else
- result += QLatin1String("MMM");
- }
-
- break;
-
- case 'N':
- n_mode = true;
-
- if (!locale_indep_ordering)
- break;
-
- if (!abbrev_next)
- result += QLatin1String("MMMM");
- else
- result += QLatin1String("MMM");
-
- break;
-
- case 'Y':
- if (!locale_indep_ordering)
- break;
-
- if (!abbrev_next)
- result += QLatin1String("yyyy");
- else
- result += QLatin1String("yy");
-
- break;
-
- case 'E':
- if (!abbrev_next)
- result += QLatin1String("dddd");
- else
- result += QLatin1String("ddd");
-
- break;
-
- case ':':
- // timesep 0-3
- ++i;
- if (i >= sys_fmt.size())
- break;
-
- c = sys_fmt.at(i);
- if (c.isDigit() && c.digitValue() <= 3) {
- TChar s = locale->TimeSeparator(c.digitValue());
- TUint val = s;
- // some indexes return zero for empty
- if (val > 0)
- result += QChar(val);
- }
-
- break;
-
- case 'J':
- if (tf == ETime24 && !abbrev_next)
- result += QLatin1String("hh");
- else
- result += QLatin1Char('h');
-
- break;
-
- case 'H':
- if (!abbrev_next)
- result += QLatin1String("hh");
- else
- result += QLatin1Char('h');
-
- break;
-
- case 'I':
- result += QLatin1Char('h');
- break;
-
- case 'T':
- if (!abbrev_next)
- result += QLatin1String("mm");
- else
- result += QLatin1Char('m');
-
- break;
-
- case 'S':
- if (!abbrev_next)
- result += QLatin1String("ss");
- else
- result += QLatin1Char('s');
-
- break;
-
- case 'B':
- // only done for 12h clock
- if (tf == ETime24)
- break;
-
- // fallthru to A
- case 'A': {
- // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic
- TAmPmName ampm = TAmPmName();
- TChar first(ampm[0]);
- QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap");
-
- int pos = locale->AmPmSymbolPosition();
-
- if ((minus_mode && pos != ELocaleBefore) ||
- (plus_mode && pos != ELocaleAfter))
- break;
-
- if (!abbrev_next && locale->AmPmSpaceBetween()) {
- if (pos == ELocaleBefore)
- qtampm.append(QLatin1Char(' '));
- else
- qtampm.prepend(QLatin1Char(' '));
- }
-
- result += qtampm;
- }
- break;
-
- case '.': {
- // decimal sep
- TChar s = locale->DecimalSeparator();
- TUint val = s;
- if (val > 0)
- result += QChar(val);
- }
- break;
-
- case 'C':
- // six digits in s60, three digits in qt
- if (!abbrev_next) {
- result += QLatin1String("zzz");
- } else {
- // next char is number from 0-6, how many digits to display
- ++i;
- if (i >= sys_fmt.size())
- break;
-
- c = sys_fmt.at(i);
-
- if (c.isDigit()) {
- // try to match wanted digits
- QChar val(c.digitValue());
-
- if (val >= 3) {
- result += QLatin1String("zzz");
- } else if (val > 0) {
- result += QLatin1Char('z');
- }
- }
- }
- break;
-
- // these cases fallthru
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
-
- // shouldn't parse these with %F
- if (locale_indep_ordering)
- break;
-
- TDateFormat df = locale->DateFormat();
-
- const char **locale_dep;
- switch (df) {
- default: // fallthru to american
- case EDateAmerican:
- locale_dep = us_locale_dep;
- break;
- case EDateEuropean:
- locale_dep = eu_locale_dep;
- break;
- case EDateJapanese:
- locale_dep = jp_locale_dep;
- break;
- }
- int offset = 0;
- if (abbrev_next)
- offset += 5;
- if (n_mode)
- offset += 10;
-
- result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]);
- break;
-
- case '%': // fallthru percent
- // any junk gets copied as is
- default:
- result += c;
- break;
-
- case 'Z': // Qt doesn't support these :(
- case 'X':
- case 'W':
- break;
- }
- } else {
- // double any single quotes, don't begin escape
- if (c.unicode() == '\'') {
- // end open escape
- if (open_escape) {
- result += other;
- other.clear();
- result += QLatin1Char('\'');
- open_escape = false;
- }
-
- other += c;
- }
-
- // gather chars and escape them in one go if any format chars are found
- if (!open_escape && qtformatchars.indexOf(c) != -1) {
- result += QLatin1Char('\'');
- open_escape = true;
- }
- other += c;
- }
-
- ++i;
- }
-
- if (!other.isEmpty())
- result += other;
- if (open_escape)
- result += QLatin1Char('\'');
-
- return result;
-}
-
-/*!
- Retrieves Symbian locale decimal separator.
-*/
-static QString symbianDecimalPoint()
-{
- TLocale *locale = _s60Locale.GetLocale();
-
- TChar decPoint = locale->DecimalSeparator();
- int val = decPoint;
- return QChar(val);
-}
-
-/*!
- Retrieves Symbian locale group separator.
-*/
-static QString symbianGroupSeparator()
-{
- TLocale *locale = _s60Locale.GetLocale();
-
- TChar grpSep = locale->ThousandsSeparator();
- int val = grpSep;
- return QChar(val);
-}
-
-/*!
- Retrieves Symbian locale zero digit.
-*/
-static QString symbianZeroDigit()
-{
- TLocale *locale = _s60Locale.GetLocale();
-
- // TDigitType enumeration value returned by TLocale
- // will always correspond to zero digit unicode value.
- TDigitType digit = locale->DigitType();
- return QChar(digit);
-}
-
-/*!
- Retrieves a day name from Symbian locale. The \a day is an integer
- from 1 to 7. When \a short_format is true the method returns
- the day in short format. Otherwise it returns the day in a long format.
-*/
-static QString symbianDayName(int day, bool short_format)
-{
- day -= 1;
-
- if (day < 0 || day > 6)
- return QString();
-
- if (short_format) {
- return qt_TDes2QStringL(TDayNameAbb(TDay(day)));
- } else {
- return qt_TDes2QStringL(TDayName(TDay(day)));
- }
-}
-
-/*!
- Retrieves a month name from Symbian locale. The \a month is an integer
- from 1 to 12. When \a short_format is true the method returns
- the month in short format. Otherwise it returns the month in a long format.
-*/
-static QString symbianMonthName(int month, bool short_format)
-{
- month -= 1;
- if (month < 0 || month > 11)
- return QString();
-
- if (short_format) {
- return qt_TDes2QStringL(TMonthNameAbb(TMonth(month)));
- } else {
- return qt_TDes2QStringL(TMonthName(TMonth(month)));
- }
-}
-
-/*!
- Retrieves date format from Symbian locale and
- transforms it to Qt format.
-
- When \a short_format is true the method returns
- short date format. Otherwise it returns the long format.
-*/
-static QString symbianDateFormat(bool short_format)
-{
- TPtrC dateFormat;
-
- if (short_format) {
- dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale));
- } else {
- dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale));
- }
-
- return s60ToQtFormat(qt_TDesC2QStringL(dateFormat));
-}
-
-/*!
- Retrieves time format from Symbian locale and
- transforms it to Qt format.
-*/
-static QString symbianTimeFormat()
-{
- return s60ToQtFormat(qt_TDesC2QStringL(ptrGetTimeFormatSpec(_s60Locale)));
-}
-
-/*!
- Returns localized string representation of given \a date
- formatted with Symbian locale date format.
-
- If \a short_format is true the format will be a short version.
- Otherwise it uses a longer version.
-*/
-static QString symbianDateToString(const QDate &date, bool short_format)
-{
- int month = date.month() - 1;
- int day = date.day() - 1;
- int year = date.year();
-
- TDateTime dateTime;
- dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0);
-
- TTime timeStr(dateTime);
- TBuf<KMaxLongDateFormatSpec*2> buffer;
-
- TPtrC dateFormat;
- if (short_format) {
- dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale));
- } else {
- dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale));
- }
-
- TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());)
-
- if (err == KErrNone)
- return qt_TDes2QStringL(buffer);
- else
- return QString();
-}
-
-/*!
- Returns localized string representation of given \a time
- formatted with Symbian locale time format.
-*/
-static QString symbianTimeToString(const QTime &time)
-{
- int hour = time.hour();
- int minute = time.minute();
- int second = time.second();
- int milliseconds = 0;
-
- TDateTime dateTime;
- dateTime.Set(0, TMonth(0), 0, hour, minute, second, milliseconds);
-
- TTime timeStr(dateTime);
- TBuf<KMaxTimeFormatSpec*2> buffer;
-
- TRAPD(err, ptrTimeFormatL(
- timeStr,
- buffer,
- ptrGetTimeFormatSpec(_s60Locale),
- *_s60Locale.GetLocale());
- )
-
- if (err == KErrNone)
- return qt_TDes2QStringL(buffer);
- else
- return QString();
-}
-
-/*!
- Returns the measurement system stored in Symbian locale
-
- \sa QLocale::MeasurementSystem
-*/
-static QLocale::MeasurementSystem symbianMeasurementSystem()
-{
- TLocale *locale = _s60Locale.GetLocale();
-
- TUnitsFormat unitFormat = locale->UnitsGeneral();
- if (unitFormat == EUnitsImperial)
- return QLocale::ImperialSystem;
- else
- return QLocale::MetricSystem;
-}
-
-QLocale QSystemLocale::fallbackLocale() const
-{
- // load system data before query calls
- static bool initDone = false;
- if (!initDone) {
- _s60Locale.LoadSystemSettings();
-
- // Initialize platform version dependent function pointers
- ptrTimeFormatL = reinterpret_cast<FormatFunc>
- (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL));
- ptrGetTimeFormatSpec = reinterpret_cast<FormatSpecFunc>
- (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec));
- ptrGetLongDateFormatSpec = reinterpret_cast<FormatSpecFunc>
- (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec));
- ptrGetShortDateFormatSpec = reinterpret_cast<FormatSpecFunc>
- (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec));
- if (!ptrTimeFormatL)
- ptrTimeFormatL = &defaultTimeFormatL;
- if (!ptrGetTimeFormatSpec)
- ptrGetTimeFormatSpec = &defaultFormatSpec;
- if (!ptrGetLongDateFormatSpec)
- ptrGetLongDateFormatSpec = &defaultFormatSpec;
- if (!ptrGetShortDateFormatSpec)
- ptrGetShortDateFormatSpec = &defaultFormatSpec;
- }
-
- TLanguage lang = User::Language();
- QString locale = symbianLocaleName(lang);
- return QLocale(locale);
-}
-
-/*!
- Generic query method for locale data. Provides indirection.
- Denotes the \a type of the query
- with \a in as input data depending on the query.
-
- \sa QSystemLocale::QueryType
-*/
-QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
-{
- switch(type) {
- case DecimalPoint:
- return symbianDecimalPoint();
- case GroupSeparator:
- return symbianGroupSeparator();
-
- case ZeroDigit:
- return symbianZeroDigit();
-
- case DayNameLong:
- case DayNameShort:
- return symbianDayName(in.toInt(), (type == DayNameShort) );
-
- case MonthNameLong:
- case MonthNameShort:
- return symbianMonthName(in.toInt(), (type == MonthNameShort) );
-
- case DateFormatLong:
- case DateFormatShort:
- return symbianDateFormat( (type == DateFormatShort) );
- case TimeFormatLong:
- case TimeFormatShort:
- return symbianTimeFormat();
- case DateTimeFormatLong:
- case DateTimeFormatShort:
- return symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat();
- case DateToStringShort:
- case DateToStringLong:
- return symbianDateToString(in.toDate(), (type == DateToStringShort) );
- case TimeToStringShort:
- case TimeToStringLong:
- return symbianTimeToString(in.toTime());
- case DateTimeToStringShort:
- case DateTimeToStringLong: {
- const QDateTime dt = in.toDateTime();
- return symbianDateToString(dt.date(), (type == DateTimeToStringShort) )
- + QLatin1Char(' ') + symbianTimeToString(dt.time());
- }
- case MeasurementSystem:
- return static_cast<int>(symbianMeasurementSystem());
- case LanguageId:
- case CountryId: {
- TLanguage language = User::Language();
- QString locale = symbianLocaleName(language);
- QLocale::Language lang;
- QLocale::Country cntry;
- getLangAndCountry(locale, lang, cntry);
- if (type == LanguageId)
- return lang;
- // few iso codes have no country and will use this
- if (cntry == QLocale::AnyCountry)
- return fallbackLocale().country();
-
- return cntry;
- }
- case NegativeSign:
- case PositiveSign:
- case AMText:
- case PMText:
- break;
- default:
- break;
- }
- return QVariant();
-}
-
-#elif defined(Q_OS_UNIX)
+#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
static uint unixGetSystemMeasurementSystem()
{
@@ -2113,7 +1322,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant /* in */) const
}
}
-#else
+#elif !defined(Q_OS_SYMBIAN)
/*!
Returns a fallback locale, that will get used for everything that
@@ -2387,7 +1596,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
defaults to the default locale (see setDefault()).
\endlist
- The "C" locale is identical to \l{English}/\l{UnitedStates}.
+ The "C" locale is identical in behavior to \l{English}/\l{UnitedStates}.
Use language() and country() to determine the actual language and
country values used.
@@ -2430,7 +1639,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
This enumerated type is used to specify a language.
- \value C The "C" locale is English/UnitedStates.
+ \value C The "C" locale is identical in behavior to English/UnitedStates.
\value Abkhazian
\value Afan
\value Afar
@@ -5915,6 +5124,7 @@ static Bigint *Balloc(int k)
x = 1 << k;
rv = static_cast<Bigint *>(MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)));
+ Q_CHECK_PTR(rv);
rv->k = k;
rv->maxwds = x;
rv->sign = rv->wds = 0;
@@ -7579,6 +6789,7 @@ static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt,
i = 1;
}
*resultp = static_cast<char *>(malloc(i + 1));
+ Q_CHECK_PTR(resultp);
s = s0 = *resultp;
if (ilim >= 0 && ilim <= Quick_max && try_quick) {
@@ -8000,6 +7211,7 @@ Q_CORE_EXPORT char *qdtoa( double d, int mode, int ndigits, int *decpt, int *sig
n = i + 1;
}
*resultp = static_cast<char*>(malloc(n + 1));
+ Q_CHECK_PTR(resultp);
qstrncpy(*resultp, res, n + 1);
return *resultp;
}
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
new file mode 100644
index 0000000..c11a7b9
--- /dev/null
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -0,0 +1,878 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDate>
+#include <QLocale>
+#include <QTime>
+#include <QVariant>
+
+#include <e32std.h>
+#include "private/qcore_symbian_p.h"
+
+// Located in qlocale.cpp
+extern void getLangAndCountry(const QString &name, QLocale::Language &lang, QLocale::Country &cntry);
+
+QT_BEGIN_NAMESPACE
+
+static TExtendedLocale _s60Locale;
+
+// Type definitions for runtime resolved function pointers
+typedef void (*FormatFunc)(TTime&, TDes&, const TDesC&, const TLocale&);
+typedef TPtrC (*FormatSpecFunc)(TExtendedLocale&);
+
+// Runtime resolved functions
+static FormatFunc ptrTimeFormatL = NULL;
+static FormatSpecFunc ptrGetTimeFormatSpec = NULL;
+static FormatSpecFunc ptrGetLongDateFormatSpec = NULL;
+static FormatSpecFunc ptrGetShortDateFormatSpec = NULL;
+
+// Default functions if functions cannot be resolved
+static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&)
+{
+ des.Zero();
+}
+
+static TPtrC defaultFormatSpec(TExtendedLocale&)
+{
+ return TPtrC(KNullDesC);
+}
+
+/*!
+ Definition of struct for mapping Symbian to ISO locale
+*/
+struct symbianToISO {
+ int symbian_language;
+ char iso_name[8];
+};
+
+
+/*!
+ Mapping from Symbian to ISO locale
+*/
+static const symbianToISO symbian_to_iso_list[] = {
+ { ELangEnglish, "en_GB" },
+ { ELangFrench, "fr_FR" },
+ { ELangGerman, "de_DE" },
+ { ELangSpanish, "es_ES" },
+ { ELangItalian, "it_IT" },
+ { ELangSwedish, "sv_SE" },
+ { ELangDanish, "da_DK" },
+ { ELangNorwegian, "no_NO" },
+ { ELangFinnish, "fi_FI" },
+ { ELangAmerican, "en_US" },
+ { ELangPortuguese, "pt_PT" },
+ { ELangTurkish, "tr_TR" },
+ { ELangIcelandic, "is_IS" },
+ { ELangRussian, "ru_RU" },
+ { ELangHungarian, "hu_HU" },
+ { ELangDutch, "nl_NL" },
+ { ELangBelgianFlemish, "nl_BE" },
+ { ELangCzech, "cs_CZ" },
+ { ELangSlovak, "sk_SK" },
+ { ELangPolish, "pl_PL" },
+ { ELangSlovenian, "sl_SI" },
+ { ELangTaiwanChinese, "zh_TW" },
+ { ELangHongKongChinese, "zh_HK" },
+ { ELangPrcChinese, "zh_CN" },
+ { ELangJapanese, "ja_JP" },
+ { ELangThai, "th_TH" },
+ { ELangArabic, "ar_AE" },
+ { ELangTagalog, "tl_PH" },
+ { ELangBulgarian, "bg_BG" },
+ { ELangCatalan, "ca_ES" },
+ { ELangCroatian, "hr_HR" },
+ { ELangEstonian, "et_EE" },
+ { ELangFarsi, "fa_IR" },
+ { ELangCanadianFrench, "fr_CA" },
+ { ELangGreek, "el_GR" },
+ { ELangHebrew, "he_IL" },
+ { ELangHindi, "hi_IN" },
+ { ELangIndonesian, "id_ID" },
+ { ELangLatvian, "lv_LV" },
+ { ELangLithuanian, "lt_LT" },
+ { ELangMalay, "ms_MY" },
+ { ELangBrazilianPortuguese, "pt_BR" },
+ { ELangRomanian, "ro_RO" },
+ { ELangSerbian, "sr_YU" },
+ { ELangLatinAmericanSpanish, "es" },
+ { ELangUkrainian, "uk_UA" },
+ { ELangUrdu, "ur_PK" }, // India/Pakistan
+ { ELangVietnamese, "vi_VN" },
+#ifdef __E32LANG_H__
+// 5.0
+ { ELangBasque, "eu_ES" },
+ { ELangGalician, "gl_ES" },
+#endif
+#if !defined(__SERIES60_31__)
+ { ELangEnglish_Apac, "en" },
+ { ELangEnglish_Taiwan, "en_TW" },
+ { ELangEnglish_HongKong, "en_HK" },
+ { ELangEnglish_Prc, "en_CN" },
+ { ELangEnglish_Japan, "en_JP"},
+ { ELangEnglish_Thailand, "en_TH" },
+ { ELangMalay_Apac, "ms" }
+#endif
+};
+
+/*!
+ Returns ISO name corresponding to the Symbian locale code \a sys_fmt.
+*/
+static QByteArray symbianLocaleName(int code)
+{
+ //Number of Symbian to ISO locale mappings
+ static const int symbian_to_iso_count
+ = sizeof(symbian_to_iso_list)/sizeof(symbianToISO);
+
+ int cmp = code - symbian_to_iso_list[0].symbian_language;
+ if (cmp < 0)
+ return 0;
+
+ if (cmp == 0)
+ return symbian_to_iso_list[0].iso_name;
+
+ int begin = 0;
+ int end = symbian_to_iso_count;
+
+ while (end - begin > 1) {
+ uint mid = (begin + end)/2;
+
+ const symbianToISO *elt = symbian_to_iso_list + mid;
+ int cmp = code - elt->symbian_language;
+ if (cmp < 0)
+ end = mid;
+ else if (cmp > 0)
+ begin = mid;
+ else
+ return elt->iso_name;
+ }
+
+ return 0;
+}
+
+
+// order is: normal, abbr, nmode, nmode+abbr
+static const char *us_locale_dep[] = {
+ "MM", "dd", "yyyy", "MM", "dd",
+ "M", "d", "yy", "M", "d",
+ "MMMM", "dd", "yyyy", "MMMM", "dd",
+ "MMM", "d", "yy", "MMM", "d" };
+
+static const char *eu_locale_dep[] = {
+ "dd", "MM", "yyyy", "dd", "MM",
+ "d", "M", "yy", "d", "M",
+ "dd", "MMMM", "yyyy", "dd", "MMMM",
+ "d", "MMM", "yy", "d", "MMM" };
+
+static const char *jp_locale_dep[] = {
+ "yyyy", "MM", "dd", "MM", "dd",
+ "yy", "M", "d", "M", "d",
+ "yyyy", "MMMM", "dd", "MMMM", "dd",
+ "yy", "MMM", "d", "MMM", "d" };
+
+/*!
+ Returns a Qt version of the given \a sys_fmt Symbian locale format string.
+*/
+static QString s60ToQtFormat(const QString &sys_fmt)
+{
+ TLocale *locale = _s60Locale.GetLocale();
+
+ QString result;
+ QString other;
+ QString qtformatchars = QString::fromLatin1("adhmsyzAHM");
+
+ QChar c;
+ int i = 0;
+ bool open_escape = false;
+ bool abbrev_next = false;
+ bool locale_indep_ordering = false;
+ bool minus_mode = false;
+ bool plus_mode = false;
+ bool n_mode = false;
+ TTimeFormat tf = locale->TimeFormat();
+
+ while (i < sys_fmt.size()) {
+
+ c = sys_fmt.at(i);
+
+ // let formatting thru
+ if (c.unicode() == '%') {
+ // if we have gathered string, concat it
+ if (!other.isEmpty()) {
+ result += other;
+ other.clear();
+ }
+ // if we have open escape, end it
+ if (open_escape) {
+ result += QLatin1Char('\'');
+ open_escape = false;
+ }
+
+ ++i;
+ if (i >= sys_fmt.size())
+ break;
+
+ c = sys_fmt.at(i);
+
+ // process specials
+ abbrev_next = c.unicode() == '*';
+ plus_mode = c.unicode() == '+';
+ minus_mode = c.unicode() == '-';
+
+ if (abbrev_next || plus_mode || minus_mode) {
+ ++i;
+ if (i >= sys_fmt.size())
+ break;
+
+ c = sys_fmt.at(i);
+
+ if (plus_mode || minus_mode) {
+ // break on undefined plus/minus mode
+ if (c.unicode() != 'A' && c.unicode() != 'B')
+ break;
+ }
+ }
+
+ switch (c.unicode()) {
+ case 'F':
+ {
+ // locale indep mode on
+ locale_indep_ordering = true;
+ break;
+ }
+
+ case '/':
+ {
+ // date sep 0-3
+ ++i;
+ if (i >= sys_fmt.size())
+ break;
+
+ c = sys_fmt.at(i);
+ if (c.isDigit() && c.digitValue() <= 3) {
+ TChar s = locale->DateSeparator(c.digitValue());
+ TUint val = s;
+ // some indexes return zero for empty
+ if (val > 0)
+ result += QChar(val);
+ }
+ break;
+ }
+
+ case 'D':
+ {
+ if (!locale_indep_ordering)
+ break;
+
+ if (!abbrev_next)
+ result += QLatin1String("dd");
+ else
+ result += QLatin1Char('d');
+
+ break;
+ }
+
+ case 'M':
+ {
+ if (!locale_indep_ordering)
+ break;
+
+ if (!n_mode) {
+ if (!abbrev_next)
+ result += QLatin1String("MM");
+ else
+ result += QLatin1String("M");
+ } else {
+ if (!abbrev_next)
+ result += QLatin1String("MMMM");
+ else
+ result += QLatin1String("MMM");
+ }
+
+ break;
+ }
+
+ case 'N':
+ {
+ n_mode = true;
+
+ if (!locale_indep_ordering)
+ break;
+
+ if (!abbrev_next)
+ result += QLatin1String("MMMM");
+ else
+ result += QLatin1String("MMM");
+
+ break;
+ }
+
+ case 'Y':
+ {
+ if (!locale_indep_ordering)
+ break;
+
+ if (!abbrev_next)
+ result += QLatin1String("yyyy");
+ else
+ result += QLatin1String("yy");
+
+ break;
+ }
+
+ case 'E':
+ {
+ if (!abbrev_next)
+ result += QLatin1String("dddd");
+ else
+ result += QLatin1String("ddd");
+
+ break;
+ }
+
+ case ':':
+ {
+ // timesep 0-3
+ ++i;
+ if (i >= sys_fmt.size())
+ break;
+
+ c = sys_fmt.at(i);
+ if (c.isDigit() && c.digitValue() <= 3) {
+ TChar s = locale->TimeSeparator(c.digitValue());
+ TUint val = s;
+ // some indexes return zero for empty
+ if (val > 0)
+ result += QChar(val);
+ }
+
+ break;
+ }
+
+ case 'J':
+ {
+ if (tf == ETime24 && !abbrev_next)
+ result += QLatin1String("hh");
+ else
+ result += QLatin1Char('h');
+
+ break;
+ }
+
+ case 'H':
+ {
+ if (!abbrev_next)
+ result += QLatin1String("hh");
+ else
+ result += QLatin1Char('h');
+
+ break;
+ }
+
+ case 'I':
+ {
+ result += QLatin1Char('h');
+ break;
+ }
+
+ case 'T':
+ {
+ if (!abbrev_next)
+ result += QLatin1String("mm");
+ else
+ result += QLatin1Char('m');
+
+ break;
+ }
+
+ case 'S':
+ {
+ if (!abbrev_next)
+ result += QLatin1String("ss");
+ else
+ result += QLatin1Char('s');
+
+ break;
+ }
+
+ case 'B':
+ {
+ // only done for 12h clock
+ if (tf == ETime24)
+ break;
+ }
+
+ // fallthru to A
+ case 'A': {
+ // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic
+ TAmPmName ampm = TAmPmName();
+ TChar first(ampm[0]);
+ QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap");
+
+ int pos = locale->AmPmSymbolPosition();
+
+ if ((minus_mode && pos != ELocaleBefore) ||
+ (plus_mode && pos != ELocaleAfter))
+ break;
+
+ if (!abbrev_next && locale->AmPmSpaceBetween()) {
+ if (pos == ELocaleBefore)
+ qtampm.append(QLatin1Char(' '));
+ else
+ qtampm.prepend(QLatin1Char(' '));
+ }
+
+ result += qtampm;
+ }
+ break;
+
+ case '.': {
+ // decimal sep
+ TChar s = locale->DecimalSeparator();
+ TUint val = s;
+ if (val > 0)
+ result += QChar(val);
+ }
+ break;
+
+ case 'C':
+ {
+ // six digits in s60, three digits in qt
+ if (!abbrev_next) {
+ result += QLatin1String("zzz");
+ } else {
+ // next char is number from 0-6, how many digits to display
+ ++i;
+ if (i >= sys_fmt.size())
+ break;
+
+ c = sys_fmt.at(i);
+
+ if (c.isDigit()) {
+ // try to match wanted digits
+ QChar val(c.digitValue());
+
+ if (val >= 3) {
+ result += QLatin1String("zzz");
+ } else if (val > 0) {
+ result += QLatin1Char('z');
+ }
+ }
+ }
+ break;
+ }
+
+ // these cases fallthru
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ {
+
+ // shouldn't parse these with %F
+ if (locale_indep_ordering)
+ break;
+
+ TDateFormat df = locale->DateFormat();
+
+ const char **locale_dep;
+ switch (df) {
+ default: // fallthru to american
+ case EDateAmerican:
+ locale_dep = us_locale_dep;
+ break;
+ case EDateEuropean:
+ locale_dep = eu_locale_dep;
+ break;
+ case EDateJapanese:
+ locale_dep = jp_locale_dep;
+ break;
+ }
+ int offset = 0;
+ if (abbrev_next)
+ offset += 5;
+ if (n_mode)
+ offset += 10;
+
+ result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]);
+ break;
+ }
+
+ case '%': // fallthru percent
+ {
+ // any junk gets copied as is
+ }
+ default:
+ {
+ result += c;
+ break;
+ }
+
+ case 'Z': // Qt doesn't support these :(
+ case 'X':
+ case 'W':
+ {
+ break;
+ }
+ }
+ } else {
+ // double any single quotes, don't begin escape
+ if (c.unicode() == '\'') {
+ // end open escape
+ if (open_escape) {
+ result += other;
+ other.clear();
+ result += QLatin1Char('\'');
+ open_escape = false;
+ }
+
+ other += c;
+ }
+
+ // gather chars and escape them in one go if any format chars are found
+ if (!open_escape && qtformatchars.indexOf(c) != -1) {
+ result += QLatin1Char('\'');
+ open_escape = true;
+ }
+ other += c;
+ }
+
+ ++i;
+ }
+
+ if (!other.isEmpty())
+ result += other;
+ if (open_escape)
+ result += QLatin1Char('\'');
+
+ return result;
+}
+
+/*!
+ Retrieves Symbian locale decimal separator.
+*/
+static QString symbianDecimalPoint()
+{
+ TLocale *locale = _s60Locale.GetLocale();
+
+ TChar decPoint = locale->DecimalSeparator();
+ int val = decPoint;
+ return QChar(val);
+}
+
+/*!
+ Retrieves Symbian locale group separator.
+*/
+static QString symbianGroupSeparator()
+{
+ TLocale *locale = _s60Locale.GetLocale();
+
+ TChar grpSep = locale->ThousandsSeparator();
+ int val = grpSep;
+ return QChar(val);
+}
+
+/*!
+ Retrieves Symbian locale zero digit.
+*/
+static QString symbianZeroDigit()
+{
+ TLocale *locale = _s60Locale.GetLocale();
+
+ // TDigitType enumeration value returned by TLocale
+ // will always correspond to zero digit unicode value.
+ TDigitType digit = locale->DigitType();
+ return QChar(digit);
+}
+
+/*!
+ Retrieves a day name from Symbian locale. The \a day is an integer
+ from 1 to 7. When \a short_format is true the method returns
+ the day in short format. Otherwise it returns the day in a long format.
+*/
+static QString symbianDayName(int day, bool short_format)
+{
+ day -= 1;
+
+ if (day < 0 || day > 6)
+ return QString();
+
+ if (short_format) {
+ return qt_TDes2QStringL(TDayNameAbb(TDay(day)));
+ } else {
+ return qt_TDes2QStringL(TDayName(TDay(day)));
+ }
+}
+
+/*!
+ Retrieves a month name from Symbian locale. The \a month is an integer
+ from 1 to 12. When \a short_format is true the method returns
+ the month in short format. Otherwise it returns the month in a long format.
+*/
+static QString symbianMonthName(int month, bool short_format)
+{
+ month -= 1;
+ if (month < 0 || month > 11)
+ return QString();
+
+ if (short_format) {
+ return qt_TDes2QStringL(TMonthNameAbb(TMonth(month)));
+ } else {
+ return qt_TDes2QStringL(TMonthName(TMonth(month)));
+ }
+}
+
+/*!
+ Retrieves date format from Symbian locale and
+ transforms it to Qt format.
+
+ When \a short_format is true the method returns
+ short date format. Otherwise it returns the long format.
+*/
+static QString symbianDateFormat(bool short_format)
+{
+ TPtrC dateFormat;
+
+ if (short_format) {
+ dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale));
+ } else {
+ dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale));
+ }
+
+ return s60ToQtFormat(qt_TDesC2QStringL(dateFormat));
+}
+
+/*!
+ Retrieves time format from Symbian locale and
+ transforms it to Qt format.
+*/
+static QString symbianTimeFormat()
+{
+ return s60ToQtFormat(qt_TDesC2QStringL(ptrGetTimeFormatSpec(_s60Locale)));
+}
+
+/*!
+ Returns localized string representation of given \a date
+ formatted with Symbian locale date format.
+
+ If \a short_format is true the format will be a short version.
+ Otherwise it uses a longer version.
+*/
+static QString symbianDateToString(const QDate &date, bool short_format)
+{
+ int month = date.month() - 1;
+ int day = date.day() - 1;
+ int year = date.year();
+
+ TDateTime dateTime;
+ dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0);
+
+ TTime timeStr(dateTime);
+ TBuf<KMaxLongDateFormatSpec*2> buffer;
+
+ TPtrC dateFormat;
+ if (short_format) {
+ dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale));
+ } else {
+ dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale));
+ }
+
+ TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());)
+
+ if (err == KErrNone)
+ return qt_TDes2QStringL(buffer);
+ else
+ return QString();
+}
+
+/*!
+ Returns localized string representation of given \a time
+ formatted with Symbian locale time format.
+*/
+static QString symbianTimeToString(const QTime &time)
+{
+ int hour = time.hour();
+ int minute = time.minute();
+ int second = time.second();
+ int milliseconds = 0;
+
+ TDateTime dateTime;
+ dateTime.Set(0, TMonth(0), 0, hour, minute, second, milliseconds);
+
+ TTime timeStr(dateTime);
+ TBuf<KMaxTimeFormatSpec*2> buffer;
+
+ TRAPD(err, ptrTimeFormatL(
+ timeStr,
+ buffer,
+ ptrGetTimeFormatSpec(_s60Locale),
+ *_s60Locale.GetLocale());
+ )
+
+ if (err == KErrNone)
+ return qt_TDes2QStringL(buffer);
+ else
+ return QString();
+}
+
+/*!
+ Returns the measurement system stored in Symbian locale
+
+ \sa QLocale::MeasurementSystem
+*/
+static QLocale::MeasurementSystem symbianMeasurementSystem()
+{
+ TLocale *locale = _s60Locale.GetLocale();
+
+ TUnitsFormat unitFormat = locale->UnitsGeneral();
+ if (unitFormat == EUnitsImperial)
+ return QLocale::ImperialSystem;
+ else
+ return QLocale::MetricSystem;
+}
+
+QLocale QSystemLocale::fallbackLocale() const
+{
+ // load system data before query calls
+ static bool initDone = false;
+ if (!initDone) {
+ _s60Locale.LoadSystemSettings();
+
+ // Initialize platform version dependent function pointers
+ ptrTimeFormatL = reinterpret_cast<FormatFunc>
+ (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL));
+ ptrGetTimeFormatSpec = reinterpret_cast<FormatSpecFunc>
+ (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec));
+ ptrGetLongDateFormatSpec = reinterpret_cast<FormatSpecFunc>
+ (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec));
+ ptrGetShortDateFormatSpec = reinterpret_cast<FormatSpecFunc>
+ (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec));
+ if (!ptrTimeFormatL)
+ ptrTimeFormatL = &defaultTimeFormatL;
+ if (!ptrGetTimeFormatSpec)
+ ptrGetTimeFormatSpec = &defaultFormatSpec;
+ if (!ptrGetLongDateFormatSpec)
+ ptrGetLongDateFormatSpec = &defaultFormatSpec;
+ if (!ptrGetShortDateFormatSpec)
+ ptrGetShortDateFormatSpec = &defaultFormatSpec;
+ }
+
+ TLanguage lang = User::Language();
+ QString locale = symbianLocaleName(lang);
+ return QLocale(locale);
+}
+
+/*!
+ Generic query method for locale data. Provides indirection.
+ Denotes the \a type of the query
+ with \a in as input data depending on the query.
+
+ \sa QSystemLocale::QueryType
+*/
+QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
+{
+ switch(type) {
+ case DecimalPoint:
+ return symbianDecimalPoint();
+ case GroupSeparator:
+ return symbianGroupSeparator();
+
+ case ZeroDigit:
+ return symbianZeroDigit();
+
+ case DayNameLong:
+ case DayNameShort:
+ return symbianDayName(in.toInt(), (type == DayNameShort) );
+
+ case MonthNameLong:
+ case MonthNameShort:
+ return symbianMonthName(in.toInt(), (type == MonthNameShort) );
+
+ case DateFormatLong:
+ case DateFormatShort:
+ return symbianDateFormat( (type == DateFormatShort) );
+ case TimeFormatLong:
+ case TimeFormatShort:
+ return symbianTimeFormat();
+ case DateTimeFormatLong:
+ case DateTimeFormatShort:
+ return symbianDateFormat( (type == DateTimeFormatShort) ) + QLatin1Char(' ') + symbianTimeFormat();
+ case DateToStringShort:
+ case DateToStringLong:
+ return symbianDateToString(in.toDate(), (type == DateToStringShort) );
+ case TimeToStringShort:
+ case TimeToStringLong:
+ return symbianTimeToString(in.toTime());
+ case DateTimeToStringShort:
+ case DateTimeToStringLong: {
+ const QDateTime dt = in.toDateTime();
+ return symbianDateToString(dt.date(), (type == DateTimeToStringShort) )
+ + QLatin1Char(' ') + symbianTimeToString(dt.time());
+ }
+ case MeasurementSystem:
+ return static_cast<int>(symbianMeasurementSystem());
+ case LanguageId:
+ case CountryId: {
+ TLanguage language = User::Language();
+ QString locale = symbianLocaleName(language);
+ QLocale::Language lang;
+ QLocale::Country cntry;
+ getLangAndCountry(locale, lang, cntry);
+ if (type == LanguageId)
+ return lang;
+ // few iso codes have no country and will use this
+ if (cntry == QLocale::AnyCountry)
+ return fallbackLocale().country();
+
+ return cntry;
+ }
+ case NegativeSign:
+ case PositiveSign:
+ case AMText:
+ case PMText:
+ break;
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 0699400..ceaf370 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -59,6 +59,7 @@ QMapData QMapData::shared_null = {
QMapData *QMapData::createData()
{
QMapData *d = new QMapData;
+ Q_CHECK_PTR(d);
Node *e = reinterpret_cast<Node *>(d);
e->backward = e;
e->forward[0] = e;
@@ -84,6 +85,15 @@ void QMapData::continueFreeData(int offset)
delete this;
}
+/*!
+ Creates a new node inside the data structure.
+
+ \a update is an array with pointers to the node after which the new node
+ should be inserted. Because of the strange skip list data structure there
+ could be several pointers to this node on different levels.
+ \a offset is an amount of bytes that needs to reserved just before the
+ QMapData::Node structure.
+*/
QMapData::Node *QMapData::node_create(Node *update[], int offset)
{
int level = 0;
@@ -94,10 +104,6 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset)
mask <<= Sparseness;
}
- ++randomBits;
- if (level == 3 && !insertInOrder)
- randomBits = qrand();
-
if (level > topLevel) {
Node *e = reinterpret_cast<Node *>(this);
level = ++topLevel;
@@ -105,7 +111,13 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset)
update[level] = e;
}
+ ++randomBits;
+ if (level == 3 && !insertInOrder)
+ randomBits = qrand();
+
void *concreteNode = qMalloc(offset + sizeof(Node) + level * sizeof(Node *));
+ Q_CHECK_PTR(concreteNode);
+
Node *abstractNode = reinterpret_cast<Node *>(reinterpret_cast<char *>(concreteNode) + offset);
abstractNode->backward = update[0];
@@ -116,6 +128,7 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset)
update[i]->forward[i] = abstractNode;
update[i] = abstractNode;
}
+ // update[level+1]=reinterpret_cast<Node *>(this);
++size;
return abstractNode;
}
@@ -146,7 +159,7 @@ uint QMapData::adjust_ptr(Node *node)
void QMapData::dump()
{
- qDebug("Map data (ref = %d, size = %d, randomBits = %#.8x)", ref.atomic, size, randomBits);
+ qDebug("Map data (ref = %d, size = %d, randomBits = %#.8x)", int(ref), size, randomBits);
QString preOutput;
QVector<QString> output(topLevel + 1);
@@ -158,12 +171,12 @@ void QMapData::dump()
Node *update[LastLevel + 1];
for (int i = 0; i <= topLevel; ++i) {
- str.sprintf("%d: [%.8x] -", i, adjust_ptr(forward[i]));
+ str.sprintf("%d: [%.8x] -", i, adjust_ptr(reinterpret_cast<Node *>(forward[i])));
output[i] += str;
- update[i] = forward[i];
+ update[i] = reinterpret_cast<Node *>(forward[i]);
}
- Node *node = forward[0];
+ Node *node = reinterpret_cast<Node *>(forward[0]);
while (node != e) {
int level = 0;
while (level < topLevel && update[level + 1] == node)
@@ -178,13 +191,13 @@ void QMapData::dump()
update[i] = node->forward[i];
}
for (int j = level + 1; j <= topLevel; ++j)
- output[j] += "---------------";
+ output[j] += QString("---------------");
node = node->forward[0];
}
- qDebug(preOutput.ascii());
+ qDebug("%s", preOutput.ascii());
for (int i = 0; i <= topLevel; ++i)
- qDebug(output[i].ascii());
+ qDebug("%s", output[i].ascii());
}
#endif
@@ -902,7 +915,8 @@ void QMapData::dump()
/*! \typedef QMap::iterator::iterator_category
- \internal
+ A synonym for \e {std::bidirectional_iterator_tag} indicating
+ this iterator is a bidirectional iterator.
*/
/*! \typedef QMap::iterator::pointer
@@ -1123,7 +1137,8 @@ void QMapData::dump()
/*! \typedef QMap::const_iterator::iterator_category
- \internal
+ A synonym for \e {std::bidirectional_iterator_tag} indicating
+ this iterator is a bidirectional iterator.
*/
/*! \typedef QMap::const_iterator::pointer
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 0215a78..bd9ba74 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -416,9 +416,29 @@ Q_INLINE_TEMPLATE typename QMapData::Node *
QMap<Key, T>::node_create(QMapData *adt, QMapData::Node *aupdate[], const Key &akey, const T &avalue)
{
QMapData::Node *abstractNode = adt->node_create(aupdate, payload());
- Node *concreteNode = concrete(abstractNode);
- new (&concreteNode->key) Key(akey);
- new (&concreteNode->value) T(avalue);
+ QT_TRY {
+ Node *concreteNode = concrete(abstractNode);
+ new (&concreteNode->key) Key(akey);
+ QT_TRY {
+ new (&concreteNode->value) T(avalue);
+ } QT_CATCH(...) {
+ concreteNode->key.~Key();
+ QT_RETHROW;
+ }
+ } QT_CATCH(...) {
+ adt->node_delete(aupdate, payload(), abstractNode);
+ QT_RETHROW;
+ }
+
+ // clean up the update array for further insertions
+ /*
+ for (int i = 0; i <= d->topLevel; ++i) {
+ if ( aupdate[i]==reinterpret_cast<QMapData::Node *>(adt) || aupdate[i]->forward[i] != abstractNode)
+ break;
+ aupdate[i] = abstractNode;
+ }
+*/
+
return abstractNode;
}
@@ -704,8 +724,13 @@ Q_OUTOFLINE_TEMPLATE void QMap<Key, T>::detach_helper()
QMapData::Node *cur = e->forward[0];
update[0] = x.e;
while (cur != e) {
- Node *concreteNode = concrete(cur);
- node_create(x.d, update, concreteNode->key, concreteNode->value);
+ QT_TRY {
+ Node *concreteNode = concrete(cur);
+ node_create(x.d, update, concreteNode->key, concreteNode->value);
+ } QT_CATCH(...) {
+ freeData(x.d);
+ QT_RETHROW;
+ }
cur = cur->forward[0];
}
x.d->insertInOrder = false;
diff --git a/src/corelib/tools/qpodlist_p.h b/src/corelib/tools/qpodlist_p.h
index 9708f8d..9e6d19b 100644
--- a/src/corelib/tools/qpodlist_p.h
+++ b/src/corelib/tools/qpodlist_p.h
@@ -53,9 +53,7 @@
// We mean it.
//
-#include <QtCore/qcontainerfwd.h>
-#include <QtCore/qglobal.h>
-#include <new>
+#include <QtCore/qvarlengtharray.h>
QT_BEGIN_HEADER
@@ -63,87 +61,29 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
-template<class T, int Prealloc>
-class QPodList
+template <typename T, int Prealloc>
+class QPodList : public QVarLengthArray<T, Prealloc>
{
+ using QVarLengthArray<T, Prealloc>::s;
+ using QVarLengthArray<T, Prealloc>::a;
+ using QVarLengthArray<T, Prealloc>::ptr;
+ using QVarLengthArray<T, Prealloc>::realloc;
public:
- inline explicit QPodList(int size = 0);
+ inline explicit QPodList(int size = 0)
+ : QVarLengthArray<T, Prealloc>(size)
+ {}
- inline QPodList(const QPodList<T, Prealloc> &other)
- : a(Prealloc), s(0), ptr(reinterpret_cast<T *>(array))
+ inline void insert(int idx, const T &t)
{
- append(other.constData(), other.size());
- }
-
- inline ~QPodList() {
- if (ptr != reinterpret_cast<T *>(array))
- qFree(ptr);
- }
- inline QPodList<T, Prealloc> &operator=(const QPodList<T, Prealloc> &other)
- {
- if (this != &other) {
- clear();
- append(other.constData(), other.size());
- }
- return *this;
- }
-
- inline int size() const { return s; }
- inline int count() const { return s; }
- inline bool isEmpty() const { return (s == 0); }
- inline void resize(int size);
- inline void clear() { resize(0); }
-
- inline int capacity() const { return a; }
- inline void reserve(int size);
-
- inline T &operator[](int idx) {
- Q_ASSERT(idx >= 0 && idx < s);
- return ptr[idx];
- }
- inline const T &operator[](int idx) const {
- Q_ASSERT(idx >= 0 && idx < s);
- return ptr[idx];
- }
-
- inline const T &at(int idx) const {
- Q_ASSERT(idx >= 0 && idx < s);
- return ptr[idx];
- }
-
- inline const T &first() const {
- return at(0);
- }
-
- inline T& append() {
- const int idx = s++;
- if (s == a)
- realloc(s, s<<1);
- return ptr[idx];
- }
- inline void append(const T &t) {
- append() = t;
- }
-
- inline T& insert(int idx) {
- Q_ASSERT(idx >= 0 && idx <= s);
const int sz = s++;
if (s == a)
- realloc(s, s<<1);
+ realloc(s, s << 1);
::memmove(ptr + idx + 1, ptr + idx, (sz - idx) * sizeof(T));
- return ptr[idx];
- }
- inline void insert(int idx, const T &t) {
- insert(idx) = t;
+ ptr[idx] = t;
}
- inline void removeAt(int idx) {
- Q_ASSERT(idx >= 0 && idx < s);
- ::memmove(ptr + idx, ptr + idx + 1, (s - idx - 1) * sizeof(T));
- --s;
- }
-
- inline void removeAll(const T &t) {
+ inline void removeAll(const T &t)
+ {
int i = 0;
for (int j = 0; j < s; ++j) {
if (ptr[j] != t)
@@ -152,110 +92,22 @@ public:
s = i;
}
- inline int indexOf(const T &t, int from = 0) const {
- if (from < 0)
- from = qMax(from + s, 0);
- if (from < s) {
- const T *n = ptr + from - 1;
- const T *e = ptr + s;
- while (++n != e)
- if (*n == t)
- return n - ptr;
- }
- return -1;
- }
-
- inline bool contains(const T &t) const {
- return indexOf(t) >= 0;
+ inline void removeAt(int idx)
+ {
+ Q_ASSERT(idx >= 0 && idx < s);
+ ::memmove(ptr + idx, ptr + idx + 1, (s - idx - 1) * sizeof(T));
+ --s;
}
- inline T takeFirst() {
+ inline T takeFirst()
+ {
Q_ASSERT(s > 0);
T tmp = ptr[0];
removeAt(0);
return tmp;
}
-
- inline T *data() { return ptr; }
- inline const T *data() const { return ptr; }
- inline const T * constData() const { return ptr; }
-
-private:
- void append(const T *buf, int size);
- void realloc(int size, int alloc);
-
- int a;
- int s;
- T *ptr;
- union {
- // ### Qt 5: Use 'Prealloc * sizeof(T)' as array size
- char array[sizeof(qint64) * (((Prealloc * sizeof(T)) / sizeof(qint64)) + 1)];
- qint64 q_for_alignment_1;
- double q_for_alignment_2;
- };
};
-template <class T, int Prealloc>
-Q_INLINE_TEMPLATE QPodList<T, Prealloc>::QPodList(int asize)
- : s(asize) {
- if (s > Prealloc) {
- ptr = reinterpret_cast<T *>(qMalloc(s * sizeof(T)));
- a = s;
- } else {
- ptr = reinterpret_cast<T *>(array);
- a = Prealloc;
- }
-}
-
-template <class T, int Prealloc>
-Q_INLINE_TEMPLATE void QPodList<T, Prealloc>::resize(int asize)
-{ realloc(asize, qMax(asize, a)); }
-
-template <class T, int Prealloc>
-Q_INLINE_TEMPLATE void QPodList<T, Prealloc>::reserve(int asize)
-{ if (asize > a) realloc(s, asize); }
-
-template <class T, int Prealloc>
-Q_OUTOFLINE_TEMPLATE void QPodList<T, Prealloc>::append(const T *abuf, int asize)
-{
- Q_ASSERT(abuf);
- if (asize <= 0)
- return;
-
- const int idx = s;
- const int news = s + asize;
- if (news >= a)
- realloc(news, news<<1);
- else
- s = news;
-
- qMemCopy(&ptr[idx], abuf, asize * sizeof(T));
-}
-
-template <class T, int Prealloc>
-Q_OUTOFLINE_TEMPLATE void QPodList<T, Prealloc>::realloc(int asize, int aalloc)
-{
- Q_ASSERT(aalloc >= asize);
- T *oldPtr = ptr;
- int osize = s;
- s = asize;
-
- if (aalloc != a) {
- ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T)));
- if (ptr) {
- a = aalloc;
- qMemCopy(ptr, oldPtr, osize * sizeof(T));
- } else {
- ptr = oldPtr;
- s = 0;
- asize = 0;
- }
- }
-
- if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
- qFree(oldPtr);
-}
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 3930a0d..5602170 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -901,7 +901,7 @@ void QRect::moveCenter(const QPoint &p)
/*!
\fn bool QRect::contains(const QPoint &point, bool proper) const
- Returns true if the the given \a point is inside or on the edge of
+ Returns true if the given \a point is inside or on the edge of
the rectangle, otherwise returns false. If \a proper is true, this
function only returns true if the given \a point is \e inside the
rectangle (i.e., not on the edge).
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index e1c3921..f357956 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1297,14 +1297,20 @@ void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng)
int ns = eng->s.size(); // number of states
int ncap = eng->ncap;
#ifndef QT_NO_REGEXP_OPTIM
- slideTabSize = qMax(eng->minl + 1, 16);
+ int newSlideTabSize = qMax(eng->minl + 1, 16);
#else
- slideTabSize = 0;
+ int newSlideTabSize = 0;
#endif
int numCaptures = eng->numCaptures();
- capturedSize = 2 + 2 * numCaptures;
- bigArray = (int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + slideTabSize + capturedSize)*sizeof(int));
+ int newCapturedSize = 2 + 2 * numCaptures;
+ bigArray = (int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int));
+ Q_CHECK_PTR(bigArray);
+ // set all internal variables only _after_ bigArray is realloc'ed
+ // to prevent a broken regexp in oom case
+
+ slideTabSize = newSlideTabSize;
+ capturedSize = newCapturedSize;
inNextStack = bigArray;
memset(inNextStack, -1, ns * sizeof(int));
curStack = inNextStack + ns;
@@ -3281,10 +3287,15 @@ static void derefEngine(QRegExpEngine *eng, const QRegExpEngineKey &key)
#if !defined(QT_NO_REGEXP_OPTIM)
if (globalEngineCache()) {
QMutexLocker locker(mutex());
- globalEngineCache()->insert(key, eng, 4 + key.pattern.length() / 4);
- }
- else
+ QT_TRY {
+ globalEngineCache()->insert(key, eng, 4 + key.pattern.length() / 4);
+ } QT_CATCH(const std::bad_alloc &) {
+ // in case of an exception (e.g. oom), just delete the engine
+ delete eng;
+ }
+ } else {
delete eng;
+ }
#else
Q_UNUSED(key);
delete eng;
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 99c89f8..d4d0af7 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -208,6 +208,9 @@ public:
QByteArray tmp = buffers[0];
buffers.clear();
buffers << tmp;
+ //TODO merge this optimization ?
+ //buffers.erase(buffers.begin() + 1, buffers.end());
+ //>>>>>>> 08ae7ee1fb930e7d4b4039e2294cba69f9380964:src/corelib/tools/qringbuffer_p.h
if (buffers.at(0).size() != basicBlockSize)
buffers[0].resize(basicBlockSize);
}
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
new file mode 100644
index 0000000..6a1ffb6
--- /dev/null
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QScopedPointer
+ \brief The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon destruction.
+ \since 4.6
+ \reentrant
+ \ingroup misc
+
+ Managing heap allocated objects manually is hard and error prone, with the
+ common result that code leaks memory and is hard to maintain.
+ QScopedPointer is a small utility class that heavily simplifies this by
+ assigning stack-based memory ownership to heap allocations, more generally
+ called resource acquisition is initialization(RAII).
+
+ QScopedPointer guarantees that the object pointed to will get deleted when
+ the current scope dissapears, and it also has no way of releasing
+ ownership, hence clearly communicating the lifetime and ownership of the
+ object. These guarantees are convenient when reading the code.
+
+ Consider this function which does heap allocations, and have various exit points:
+
+ \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 0
+
+ It's encumbered by the manual delete calls. With QScopedPointer, the code
+ can be simplified to:
+
+ \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 1
+
+ The code the compiler generates for QScopedPointer is the same as when
+ writing it manually. Code that makes use of \a delete are candidates for
+ QScopedPointer usage(and if not, possibly another type of smart pointer
+ such as QSharedPointer). QScopedPointer intentionally has no copy
+ constructor or assignment operator, such that ownership and lifetime is
+ clearly communicated.
+
+ The const qualification on a regular C++ pointer can also be expressed with
+ a QScopedPointer:
+
+ \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 2
+
+ \note QScopedPointer does not work with arrays.
+
+ \sa QSharedPointer
+*/
+
+/*!
+ \fn QScopedPointer::QScopedPointer(T *p = 0)
+
+ Constructs this QScopedPointer instance and sets its pointer to \a p.
+*/
+
+/*!
+ \fn QScopedPointer::~QScopedPointer()
+
+ Destroys this QScopedPointer object. Delete the object its pointer points
+ to.
+*/
+
+/*!
+ \fn T *QScopedPointer::data() const
+
+ Returns the value of the pointer referenced by this object. QScopedPointer
+ still owns the object pointed to.
+*/
+
+/*!
+ \fn T &QScopedPointer::operator*() const
+
+ Provides access to the scoped pointer's object.
+
+ If the contained pointer is \c null, behavior is undefined.
+ \sa isNull()
+*/
+
+/*!
+ \fn T *QScopedPointer::operator->() const
+
+ Provides access to the scoped pointer's object.
+
+ If the contained pointer is \c null, behavior is undefined.
+
+ \sa isNull()
+*/
+
+/*!
+ \fn QScopedPointer::operator bool() const
+
+ Returns \c true if this object is not \c null. This function is suitable
+ for use in \tt if-constructs, like:
+
+ \snippet doc/src/snippets/code/src_corelib_tools_qscopedpointer.cpp 3
+
+ \sa isNull()
+*/
+
+/*!
+ \fn bool QScopedPointer::operator==(const QScopedPointer<T> &other) const
+
+ Equality operator. Returns true if the scoped pointer \a other
+ is pointing to the same object as this pointer, otherwise returns false.
+*/
+
+
+/*!
+ \fn bool QScopedPointer::operator!=(const QScopedPointer<T> *other) const
+
+ Inequality operator. Returns true if the scoped pointer \a other
+ is not pointing to the same object as this pointer, otherwise returns false.
+*/
+
+/*!
+ \fn bool QScopedPointer::isNull() const
+
+ Returns \c true if this object is holding a pointer that is \c null.
+*/
+
+/*!
+ \fn void QScopedPointer::reset(T *other = 0)
+
+ Deletes the existing object it is pointing to if any, and sets its pointer to
+ \a other. QScopedPointer now owns \a other and will delete it in its
+ destructor.
+
+ If \a other is equal to the value returned by data(), behavior is
+ undefined.
+*/
+
+/*!
+ \fn T *QScopedPointer::take()
+
+ Returns the value of the pointer referenced by this object. The pointer of this
+ QScopedPointer object will be reset to \c null.
+*/
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
new file mode 100644
index 0000000..fc8f9e2
--- /dev/null
+++ b/src/corelib/tools/qscopedpointer.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCOPEDPOINTER_H
+#define QSCOPEDPOINTER_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+QT_MODULE(Core)
+
+template <typename T>
+class QScopedPointer
+{
+public:
+ explicit inline QScopedPointer(T *p = 0) : d(p)
+ {
+ }
+
+ inline ~QScopedPointer()
+ {
+ delete d;
+ }
+
+ inline T &operator*() const
+ {
+ return *d;
+ }
+
+ inline T *operator->() const
+ {
+ return d;
+ }
+
+ inline bool operator==(const QScopedPointer<T> &other) const
+ {
+ return d == other.d;
+ }
+
+ inline bool operator!=(const QScopedPointer<T> &other) const
+ {
+ return d != other.d;
+ }
+
+ inline operator bool() const
+ {
+ return d;
+ }
+
+ inline T *data() const
+ {
+ return d;
+ }
+
+ inline bool isNull() const
+ {
+ return !d;
+ }
+
+ inline void reset(T *other = 0)
+ {
+ T *oldD = d;
+ d = other;
+ delete oldD;
+ }
+
+ inline T *take()
+ {
+ T *oldD = d;
+ d = 0;
+ return oldD;
+ }
+
+protected:
+ T *d;
+
+private:
+ Q_DISABLE_COPY(QScopedPointer)
+};
+
+/* internal class - allows special handling for resetting and cleaning the pointer */
+template <typename T, typename CustomHandler>
+class QScopedCustomPointer : public QScopedPointer<T>
+{
+public:
+ inline QScopedCustomPointer(T *p = 0)
+ : QScopedPointer<T>(p)
+ {
+ }
+
+ inline ~QScopedCustomPointer()
+ {
+ T *oldD = this->d;
+ this->d = 0;
+ CustomHandler::cleanup(oldD);
+ }
+
+ inline void reset(T *other = 0)
+ {
+ CustomHandler::reset(this->d, other);
+ }
+
+ inline T *&data_ptr()
+ {
+ return this->d;
+ }
+};
+
+/* Internal helper class - a handler for QShared* classes, to be used in QScopedCustomPointer */
+template <typename T>
+class QScopedSharedPointerHandler
+{
+public:
+ static inline void cleanup(T *d)
+ {
+ if (d && !d->ref.deref())
+ delete d;
+ }
+
+ static inline void reset(T *&d, T *other)
+ {
+ T *oldD = d;
+ d = other;
+ cleanup(oldD);
+ }
+};
+
+/* Internal. This should really have been a typedef, but you can't have a templated typedef :)
+ This class is basically a scoped pointer pointing to a ref-counted object
+ */
+template <typename T>
+class QScopedSharedPointer : public QScopedCustomPointer<T, QScopedSharedPointerHandler<T> >
+{
+public:
+ inline QScopedSharedPointer(T *p = 0)
+ : QScopedCustomPointer<T, QScopedSharedPointerHandler<T> >(p)
+ {
+ }
+
+ inline void detach()
+ {
+ qAtomicDetach(this->d);
+ }
+
+ inline void assign(T *other)
+ {
+ if (this->d == other)
+ return;
+ if (other)
+ other->ref.ref();
+ T *oldD = this->d;
+ this->d = other;
+ QScopedSharedPointerHandler<T>::cleanup(oldD);
+ }
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QSCOPEDPOINTER_H
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index 2b879ea..03bc964 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -231,7 +231,7 @@ QT_BEGIN_NAMESPACE
In the member function documentation, \e{d pointer} always refers
to the internal pointer to the shared data object.
- \sa QSharedData, QExplicitlySharedDataPointer
+ \sa QSharedData, QExplicitlySharedDataPointer, QScopedPointer, QSharedPointer
*/
/*! \fn T& QSharedDataPointer::operator*()
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index c3a989e..dee06f0 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -102,13 +102,18 @@
except that it only detaches if
QExplicitlySharedDataPointer::detach() is explicitly called.
+ QScopedPointer simply holds a pointer to a heap allocated object and
+ deletes it in its destructor. This class is useful when an object needs to
+ be heap allocated and deleted, but no more. QScopedPointer is lightweight,
+ it makes no use of additional structure or reference counting.
+
Finally, QPointer holds a pointer to a QObject-derived object, but
it does so weakly. QPointer is similar, in that behaviour, to
QWeakPointer: it does not allow you to prevent the object from
being destroyed. All you can do is query whether it has been
destroyed or not.
- \sa QSharedDataPointer, QWeakPointer
+ \sa QSharedDataPointer, QWeakPointer, QScopedPointer
*/
/*!
@@ -130,7 +135,7 @@
must first create a QSharedPointer object and verify if the pointer
is null or not.
- \sa QSharedPointer
+ \sa QSharedPointer, QScopedPointer
*/
/*!
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index b8c3f3d..88b8b8c 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -244,6 +244,7 @@ namespace QtSharedPointer {
template <class X> friend class ExternalRefCount;
template <class X> friend class QWeakPointer;
template <class X, class Y> friend QSharedPointer<X> qSharedPointerCastHelper(const QSharedPointer<Y> &src, X *);
+ template <class X, class Y> friend QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<Y> &src, X *);
template <class X, class Y> friend QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<Y> &src, X *);
template <class X, class Y> friend QSharedPointer<X> QtSharedPointer::qStrongRefFromWeakHelper(const QWeakPointer<Y> &src, X *);
#endif
@@ -521,6 +522,14 @@ namespace QtSharedPointer {
return result;
}
template <class X, class T>
+ Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCastHelper(const QSharedPointer<T> &src, X *)
+ {
+ QSharedPointer<X> result;
+ register T *ptr = src.data();
+ result.internalSet(src.d, dynamic_cast<X *>(ptr));
+ return result;
+ }
+ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCastHelper(const QSharedPointer<T> &src, X *)
{
QSharedPointer<X> result;
@@ -556,9 +565,7 @@ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyDynamicCast(src.data(), x))
- return QtSharedPointer::qSharedPointerCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerDynamicCastHelper(src, x);
}
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src)
@@ -570,17 +577,13 @@ template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyConstCast(src.data(), x))
- return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
}
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src)
{
X *x = 0;
- if (QtSharedPointer::qVerifyConstCast(src.data(), x))
- return QtSharedPointer::qSharedPointerCastHelper(src, x);
- return QSharedPointer<X>();
+ return QtSharedPointer::qSharedPointerConstCastHelper(src, x);
}
template <class X, class T>
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index 76a5484..bbf6c2a 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -781,7 +781,7 @@ void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode)
\fn QDataStream &operator<<(QDataStream &stream, const QSizeF &size)
\relates QSizeF
- Writes the the given \a size to the given \a stream and returns a
+ Writes the given \a size to the given \a stream and returns a
reference to the stream.
\sa {Format of the QDataStream Operators}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index c3649e3..e61a568 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -846,6 +846,7 @@ QString::QString(const QChar *unicode, int size)
d->ref.ref();
} else {
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
+ Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
@@ -869,6 +870,7 @@ QString::QString(int size, QChar ch)
d->ref.ref();
} else {
d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
+ Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
@@ -894,7 +896,9 @@ QString::QString(int size, QChar ch)
*/
QString::QString(QChar ch)
{
- d = (Data *)qMalloc(sizeof(Data) + sizeof(QChar));
+ void *buf = qMalloc(sizeof(Data) + sizeof(QChar));
+ Q_CHECK_PTR(buf);
+ d = reinterpret_cast<Data *>(buf);
d->ref = 1;
d->alloc = d->size = 1;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
@@ -1064,8 +1068,7 @@ void QString::realloc(int alloc)
{
if (d->ref != 1 || d->data != d->array) {
Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc * sizeof(QChar)));
- if (!x)
- return;
+ Q_CHECK_PTR(x);
x->size = qMin(alloc, d->size);
::memcpy(x->array, d->data, x->size * sizeof(QChar));
x->array[x->size] = 0;
@@ -1088,8 +1091,7 @@ void QString::realloc(int alloc)
}
#endif
Data *x = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
- if (!x)
- return;
+ Q_CHECK_PTR(x);
x->alloc = alloc;
x->data = x->array;
d = x;
@@ -1246,6 +1248,7 @@ QString& QString::insert(int i, const QChar *unicode, int size)
if (s >= d->data && s < d->data + d->alloc) {
// Part of me - take a copy
ushort *tmp = static_cast<ushort *>(qMalloc(size * sizeof(QChar)));
+ Q_CHECK_PTR(tmp);
memcpy(tmp, s, size * sizeof(QChar));
insert(i, reinterpret_cast<const QChar *>(tmp), size);
qFree(tmp);
@@ -1600,51 +1603,69 @@ QString &QString::replace(const QString &before, const QString &after, Qt::CaseS
*/
void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen)
{
- if (blen == alen) {
- detach();
- for (int i = 0; i < nIndices; ++i)
- memcpy(d->data + indices[i], after, alen * sizeof(QChar));
- } else if (alen < blen) {
+ // copy *after in case it lies inside our own d->data area
+ // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.)
+ QChar *afterBuffer = const_cast<QChar *>(after);
+ if (after >= reinterpret_cast<QChar *>(d->data) && after < reinterpret_cast<QChar *>(d->data) + d->size) {
+ afterBuffer = static_cast<QChar *>(qMalloc(alen*sizeof(QChar)));
+ Q_CHECK_PTR(afterBuffer);
+ ::memcpy(afterBuffer, after, alen*sizeof(QChar));
+ }
+
+ QT_TRY {
detach();
- uint to = indices[0];
- if (alen)
- memcpy(d->data+to, after, alen*sizeof(QChar));
- to += alen;
- uint movestart = indices[0] + blen;
- for (int i = 1; i < nIndices; ++i) {
- int msize = indices[i] - movestart;
- if (msize > 0) {
- memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
- to += msize;
+ if (blen == alen) {
+ // replace in place
+ for (int i = 0; i < nIndices; ++i)
+ memcpy(d->data + indices[i], afterBuffer, alen * sizeof(QChar));
+ } else if (alen < blen) {
+ // replace from front
+ uint to = indices[0];
+ if (alen)
+ memcpy(d->data+to, after, alen*sizeof(QChar));
+ to += alen;
+ uint movestart = indices[0] + blen;
+ for (int i = 1; i < nIndices; ++i) {
+ int msize = indices[i] - movestart;
+ if (msize > 0) {
+ memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
+ to += msize;
+ }
+ if (alen) {
+ memcpy(d->data + to, afterBuffer, alen*sizeof(QChar));
+ to += alen;
+ }
+ movestart = indices[i] + blen;
}
- if (alen) {
- memcpy(d->data + to, after, alen*sizeof(QChar));
- to += alen;
+ int msize = d->size - movestart;
+ if (msize > 0)
+ memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
+ resize(d->size - nIndices*(blen-alen));
+ } else {
+ // replace from back
+ int adjust = nIndices*(alen-blen);
+ int newLen = d->size + adjust;
+ int moveend = d->size;
+ resize(newLen);
+
+ while (nIndices) {
+ --nIndices;
+ int movestart = indices[nIndices] + blen;
+ int insertstart = indices[nIndices] + nIndices*(alen-blen);
+ int moveto = insertstart + alen;
+ memmove(d->data + moveto, d->data + movestart,
+ (moveend - movestart)*sizeof(QChar));
+ memcpy(d->data + insertstart, afterBuffer, alen*sizeof(QChar));
+ moveend = movestart-blen;
}
- movestart = indices[i] + blen;
- }
- int msize = d->size - movestart;
- if (msize > 0)
- memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
- resize(d->size - nIndices*(blen-alen));
- } else {
- // we have a table of replacement positions, use them for fast replacing
- int adjust = nIndices*(alen-blen);
- int newLen = d->size + adjust;
- int moveend = d->size;
- resize(newLen);
-
- while (nIndices) {
- --nIndices;
- int movestart = indices[nIndices] + blen;
- int insertstart = indices[nIndices] + nIndices*(alen-blen);
- int moveto = insertstart + alen;
- memmove(d->data + moveto, d->data + movestart,
- (moveend - movestart)*sizeof(QChar));
- memcpy(d->data + insertstart, after, alen*sizeof(QChar));
- moveend = movestart-blen;
}
+ } QT_CATCH(const std::bad_alloc &) {
+ if (afterBuffer != after)
+ qFree(afterBuffer);
+ QT_RETHROW;
}
+ if (afterBuffer != after)
+ qFree(afterBuffer);
}
/*!
@@ -1672,21 +1693,7 @@ QString &QString::replace(const QChar *before, int blen,
if (alen == 0 && blen == 0)
return *this;
- // protect against before or after being part of this
- const QChar *a = after;
- const QChar *b = before;
- if (after >= (const QChar *)d->data && after < (const QChar *)d->data + d->size) {
- QChar *copy = (QChar *)malloc(alen*sizeof(QChar));
- memcpy(copy, after, alen*sizeof(QChar));
- a = copy;
- }
- if (before >= (const QChar *)d->data && before < (const QChar *)d->data + d->size) {
- QChar *copy = (QChar *)malloc(blen*sizeof(QChar));
- memcpy(copy, before, blen*sizeof(QChar));
- b = copy;
- }
-
- QStringMatcher matcher(b, blen, cs);
+ QStringMatcher matcher(before, blen, cs);
int index = 0;
while (1) {
@@ -1705,7 +1712,7 @@ QString &QString::replace(const QChar *before, int blen,
if (!pos)
break;
- replace_helper(indices, pos, blen, a, alen);
+ replace_helper(indices, pos, blen, after, alen);
if (index == -1)
break;
@@ -1713,11 +1720,6 @@ QString &QString::replace(const QChar *before, int blen,
index += pos*(alen-blen);
}
- if (a != after)
- ::free((QChar *)a);
- if (b != before)
- ::free((QChar *)b);
-
return *this;
}
@@ -3450,6 +3452,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
if (size < 0)
size = qstrlen(str);
d = static_cast<Data *>(qMalloc(sizeof(Data) + size * sizeof(QChar)));
+ Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
@@ -3457,7 +3460,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
ushort *i = d->data;
d->array[size] = '\0';
while (size--)
- *i++ = (uchar)*str++;
+ *i++ = (uchar)*str++;
}
return d;
}
@@ -6867,6 +6870,7 @@ void QString::updateProperties() const
QString QString::fromRawData(const QChar *unicode, int size)
{
Data *x = static_cast<Data *>(qMalloc(sizeof(Data)));
+ Q_CHECK_PTR(x);
if (unicode) {
x->data = (ushort *)unicode;
} else {
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index 386321f1..cf1bff8 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -397,7 +397,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r
\fn QString QStringList::join(const QString &separator) const
Joins all the string list's strings into a single string with each
- element separated by the the given \a separator (which can be an
+ element separated by the given \a separator (which can be an
empty string).
\sa QString::split()
@@ -621,8 +621,6 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int
the list, searching forward from index position \a from. Returns
-1 if no item matched.
- By default, this function is case sensitive.
-
\sa lastIndexOf(), contains(), QList::indexOf()
*/
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp
index 8a8e95b..5ca6a11 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/tools/qtextboundaryfinder.cpp
@@ -176,6 +176,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)
, freePrivate(true)
{
d = (QTextBoundaryFinderPrivate *) malloc(length*sizeof(HB_CharAttributes));
+ Q_CHECK_PTR(d);
memcpy(d, other.d, length*sizeof(HB_CharAttributes));
}
@@ -193,8 +194,11 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o
length = other.length;
pos = other.pos;
freePrivate = true;
-
- d = (QTextBoundaryFinderPrivate *) realloc(d, length*sizeof(HB_CharAttributes));
+
+ QTextBoundaryFinderPrivate *newD = (QTextBoundaryFinderPrivate *)
+ realloc(d, length*sizeof(HB_CharAttributes));
+ Q_CHECK_PTR(newD);
+ d = newD;
memcpy(d, other.d, length*sizeof(HB_CharAttributes));
return *this;
@@ -221,6 +225,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QString &strin
, freePrivate(true)
{
d = (QTextBoundaryFinderPrivate *) malloc(length*sizeof(HB_CharAttributes));
+ Q_CHECK_PTR(d);
init(t, chars, length, d->attributes);
}
@@ -248,6 +253,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QChar *chars,
freePrivate = false;
} else {
d = (QTextBoundaryFinderPrivate *) malloc(length*sizeof(HB_CharAttributes));
+ Q_CHECK_PTR(d);
freePrivate = true;
}
init(t, chars, length, d->attributes);
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index e2f60ed..b41240e 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -52,6 +52,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
+template<class T, int Prealloc>
+class QPodList;
+
// Prealloc = 256 by default, specified in qcontainerfwd.h
template<class T, int Prealloc>
class QVarLengthArray
@@ -122,6 +125,7 @@ public:
inline const T * constData() const { return ptr; }
private:
+ friend class QPodList<T, Prealloc>;
void realloc(int size, int alloc);
int a;
@@ -140,6 +144,7 @@ Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(int asize)
: s(asize) {
if (s > Prealloc) {
ptr = reinterpret_cast<T *>(qMalloc(s * sizeof(T)));
+ Q_CHECK_PTR(ptr);
a = s;
} else {
ptr = reinterpret_cast<T *>(array);
@@ -161,25 +166,24 @@ Q_INLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reserve(int asize)
{ if (asize > a) realloc(s, asize); }
template <class T, int Prealloc>
-Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::append(const T *abuf, int asize)
+Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::append(const T *abuf, int increment)
{
Q_ASSERT(abuf);
- if (asize <= 0)
+ if (increment <= 0)
return;
- const int idx = s;
- const int news = s + asize;
- if (news >= a)
- realloc(s, qMax(s<<1, news));
- s = news;
+ const int asize = s + increment;
+
+ if (asize >= a)
+ realloc(s, qMax(s*2, asize));
if (QTypeInfo<T>::isComplex) {
- T *i = ptr + idx;
- T *j = i + asize;
- while (i < j)
- new (i++) T(*abuf++);
+ // call constructor for new objects (which can throw)
+ while (s < asize)
+ new (ptr+(s++)) T(*abuf++);
} else {
- qMemCopy(&ptr[idx], abuf, asize * sizeof(T));
+ qMemCopy(&ptr[s], abuf, increment * sizeof(T));
+ s = asize;
}
}
@@ -189,46 +193,58 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
Q_ASSERT(aalloc >= asize);
T *oldPtr = ptr;
int osize = s;
- s = asize;
+ // s = asize;
if (aalloc != a) {
ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T)));
+ Q_CHECK_PTR(ptr);
if (ptr) {
+ s = 0;
a = aalloc;
if (QTypeInfo<T>::isStatic) {
- T *i = ptr + osize;
- T *j = oldPtr + osize;
- while (i != ptr) {
- new (--i) T(*--j);
- j->~T();
+ QT_TRY {
+ while (s < asize) {
+ new (ptr+s) T(*(oldPtr+s));
+ (oldPtr+s)->~T();
+ s++;
+ }
+ } QT_CATCH(...) {
+ // clean up all the old objects and then free the old ptr
+ int sClean = s;
+ while (sClean < osize)
+ (oldPtr+(sClean++))->~T();
+ if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
+ qFree(oldPtr);
+ QT_RETHROW;
}
} else {
- qMemCopy(ptr, oldPtr, osize * sizeof(T));
+ qMemCopy(ptr, oldPtr, qMin(asize, osize) * sizeof(T));
+ s = asize;
}
} else {
ptr = oldPtr;
- s = 0;
- asize = 0;
+ return;
}
}
if (QTypeInfo<T>::isComplex) {
- if (asize < osize) {
- T *i = oldPtr + osize;
- T *j = oldPtr + asize;
- while (i-- != j)
- i->~T();
- } else {
- T *i = ptr + asize;
- T *j = ptr + osize;
- while (i != j)
- new (--i) T;
- }
+ while (osize > asize)
+ (oldPtr+(--osize))->~T();
+ if( oldPtr == ptr )
+ s = osize;
}
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
qFree(oldPtr);
+
+ if (QTypeInfo<T>::isComplex) {
+ // call default constructor for new objects (which can throw)
+ while (s < asize)
+ new (ptr+(s++)) T;
+ } else {
+ s = asize;
+ }
}
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 6b26b2e..04e9ace 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -50,6 +50,7 @@ QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, tr
QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init)
{
QVectorData* p = (QVectorData *)qMalloc(sizeofTypedData + (size - 1) * sizeofT);
+ Q_CHECK_PTR(p);
::memcpy(p, init, sizeofTypedData + (qMin(size, init->alloc) - 1) * sizeofT);
return p;
}
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 1f047b8..610b8e7 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -77,6 +77,7 @@ struct Q_CORE_EXPORT QVectorData
static QVectorData shared_null;
// ### Qt 5: rename to 'allocate()'. The current name causes problems for
// some debugges when the QVector is member of a class within an unnamed namespace.
+ // ### Qt 5: can be removed completely. (Ralf)
static QVectorData *malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init);
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive);
};
@@ -379,7 +380,9 @@ QVector<T> &QVector<T>::operator=(const QVector<T> &v)
template <typename T>
inline QVectorData *QVector<T>::malloc(int aalloc)
{
- return static_cast<QVectorData *>(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ QVectorData *data = static_cast<QVectorData *>(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ Q_CHECK_PTR(data);
+ return data;
}
template <typename T>
@@ -428,74 +431,79 @@ void QVector<T>::free(Data *x)
template <typename T>
void QVector<T>::realloc(int asize, int aalloc)
{
- T *j, *i, *b;
+ T *pOld;
+ T *pNew;
union { QVectorData *p; Data *d; } x;
x.d = d;
- if (QTypeInfo<T>::isComplex && aalloc == d->alloc && d->ref == 1) {
- // pure resize
- i = d->array + d->size;
- j = d->array + asize;
- if (i > j) {
- while (i-- != j)
- i->~T();
- } else {
- while (j-- != i)
- new (j) T;
+ if (QTypeInfo<T>::isComplex && asize < d->size && d->ref == 1 ) {
+ // call the destructor on all objects that need to be
+ // destroyed when shrinking
+ pOld = d->array + d->size;
+ pNew = d->array + asize;
+ while (asize < d->size) {
+ (--pOld)->~T();
+ d->size--;
}
- d->size = asize;
- return;
}
if (aalloc != d->alloc || d->ref != 1) {
// (re)allocate memory
if (QTypeInfo<T>::isStatic) {
x.p = malloc(aalloc);
+ Q_CHECK_PTR(x.p);
+ x.d->size = 0;
} else if (d->ref != 1) {
- x.p = QVectorData::malloc(sizeOfTypedData(), aalloc, sizeof(T), p);
- } else {
+ x.p = malloc(aalloc);
+ Q_CHECK_PTR(x.p);
if (QTypeInfo<T>::isComplex) {
- // call the destructor on all objects that need to be
- // destroyed when shrinking
- if (asize < d->size) {
- j = d->array + asize;
- i = d->array + d->size;
- while (i-- != j)
- i->~T();
- i = d->array + asize;
- }
+ x.d->size = 0;
+ } else {
+ ::memcpy(x.p, p, sizeOfTypedData() + (qMin(aalloc, p->alloc) - 1) * sizeof(T));
+ x.d->size = d->size;
+ }
+ } else {
+ QT_TRY {
+ QVectorData *mem = static_cast<QVectorData *>(qRealloc(p, sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ Q_CHECK_PTR(mem);
+ x.p = p = mem;
+ x.d->size = d->size;
+ } QT_CATCH (const std::bad_alloc &) {
+ if (aalloc > d->alloc) // ignore the error in case we are just shrinking.
+ QT_RETHROW;
}
- x.p = p = static_cast<QVectorData *>(qRealloc(p, sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
}
x.d->ref = 1;
+ x.d->alloc = aalloc;
x.d->sharable = true;
x.d->capacity = d->capacity;
-
}
+
if (QTypeInfo<T>::isComplex) {
- if (asize < d->size) {
- j = d->array + asize;
- i = x.d->array + asize;
- } else {
- // construct all new objects when growing
- i = x.d->array + asize;
- j = x.d->array + d->size;
- while (i != j)
- new (--i) T;
- j = d->array + d->size;
- }
- if (i != j) {
+ QT_TRY {
+ pOld = d->array + x.d->size;
+ pNew = x.d->array + x.d->size;
// copy objects from the old array into the new array
- b = x.d->array;
- while (i != b)
- new (--i) T(*--j);
+ while (x.d->size < qMin(asize, d->size)) {
+ new (pNew++) T(*pOld++);
+ x.d->size++;
+ }
+ // construct all new objects when growing
+ while (x.d->size < asize) {
+ new (pNew++) T;
+ x.d->size++;
+ }
+ } QT_CATCH (...) {
+ free(x.d);
+ QT_RETHROW;
}
- } else if (asize > d->size) {
+
+ } else if (asize > x.d->size) {
// initialize newly allocated memory to 0
- qMemSet(x.d->array + d->size, 0, (asize - d->size) * sizeof(T));
+ qMemSet(x.d->array + x.d->size, 0, (asize - x.d->size) * sizeof(T));
}
x.d->size = asize;
- x.d->alloc = aalloc;
+
if (d != x.d) {
if (!d->ref.deref())
free(d);
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 45e92bf..8d27100 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -36,7 +36,8 @@ HEADERS += \
tools/qtimeline.h \
tools/qunicodetables_p.h \
tools/qvarlengtharray.h \
- tools/qvector.h
+ tools/qvector.h \
+ tools/qscopedpointer.h
SOURCES += \
@@ -65,6 +66,7 @@ SOURCES += \
tools/qvector.cpp \
tools/qvsnprintf.cpp
+symbian:SOURCES+=tools/qlocale_symbian.cpp
#zlib support
contains(QT_CONFIG, zlib) {
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index ff1a01f..6fe6ebf 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -429,7 +429,6 @@ QXmlStreamReader::~QXmlStreamReader()
Q_D(QXmlStreamReader);
if (d->deleteDevice)
delete d->device;
- delete d;
}
/*! \fn bool QXmlStreamReader::hasError() const
@@ -819,7 +818,9 @@ inline void QXmlStreamReaderPrivate::reallocateStack()
{
stack_size <<= 1;
sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
+ Q_CHECK_PTR(sym_stack);
state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
+ Q_CHECK_PTR(sym_stack);
}
@@ -3131,8 +3132,6 @@ QXmlStreamWriter::QXmlStreamWriter(QString *string)
*/
QXmlStreamWriter::~QXmlStreamWriter()
{
- Q_D(QXmlStreamWriter);
- delete d;
}
diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h
index 2ba7972..6903d56 100644
--- a/src/corelib/xml/qxmlstream.h
+++ b/src/corelib/xml/qxmlstream.h
@@ -48,6 +48,7 @@
#include <QtCore/QString>
#include <QtCore/QVector>
+#include <QtCore/QScopedPointer>
QT_BEGIN_HEADER
@@ -392,7 +393,7 @@ public:
private:
Q_DISABLE_COPY(QXmlStreamReader)
Q_DECLARE_PRIVATE(QXmlStreamReader)
- QXmlStreamReaderPrivate *d_ptr;
+ QScopedPointer<QXmlStreamReaderPrivate> d_ptr;
};
#endif // QT_NO_XMLSTREAMREADER
@@ -465,7 +466,7 @@ public:
private:
Q_DISABLE_COPY(QXmlStreamWriter)
Q_DECLARE_PRIVATE(QXmlStreamWriter)
- QXmlStreamWriterPrivate *d_ptr;
+ QScopedPointer<QXmlStreamWriterPrivate> d_ptr;
};
#endif // QT_NO_XMLSTREAMWRITER
diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp
index 883aabf..350f1aa 100644
--- a/src/dbus/qdbusabstractadaptor.cpp
+++ b/src/dbus/qdbusabstractadaptor.cpp
@@ -264,7 +264,7 @@ void QDBusAdaptorConnector::polish()
void QDBusAdaptorConnector::relaySlot(void **argv)
{
- QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr);
+ QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data());
relay(d->currentSender->sender, d->currentSender->signal, argv);
}
diff --git a/src/dbus/qdbuscontext.h b/src/dbus/qdbuscontext.h
index 3d043cf..6ece5b6 100644
--- a/src/dbus/qdbuscontext.h
+++ b/src/dbus/qdbuscontext.h
@@ -74,7 +74,7 @@ public:
private:
QDBusContextPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QDBusContext)
+ friend class QDBusContextPrivate;
};
QT_END_NAMESPACE
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index 19f0b04..96dcd3b 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -161,7 +161,6 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message)
// not ok;
q_dbus_message_unref(msg);
- Q_ASSERT(false);
return 0;
}
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
index 92347a7..b9fad41 100644
--- a/src/gui/dialogs/dialogs.pri
+++ b/src/gui/dialogs/dialogs.pri
@@ -7,6 +7,7 @@ HEADERS += \
dialogs/qabstractpagesetupdialog_p.h \
dialogs/qcolordialog.h \
dialogs/qcolordialog_p.h \
+ dialogs/qfscompleter_p.h \
dialogs/qdialog.h \
dialogs/qdialog_p.h \
dialogs/qerrormessage.h \
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index 3aa04f6..4702d14 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1749,7 +1749,7 @@ void QColorDialog::setVisible(bool visible)
\overload
\since 4.5
- Opens the dialog and connects its accepted() signal to the slot specified
+ Opens the dialog and connects its colorSelected() signal to the slot specified
by \a receiver and \a member.
The signal will be disconnected from the slot when the dialog is closed.
diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp
index ef562f4..cecbb87 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/gui/dialogs/qdialog.cpp
@@ -296,9 +296,13 @@ QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f)
QDialog::~QDialog()
{
- // Need to hide() here, as our (to-be) overridden hide()
- // will not be called in ~QWidget.
- hide();
+ QT_TRY {
+ // Need to hide() here, as our (to-be) overridden hide()
+ // will not be called in ~QWidget.
+ hide();
+ } QT_CATCH(...) {
+ // we're in the destructor - just swallow the exception
+ }
}
/*!
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 789b364..9768162 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -356,7 +356,6 @@ QFileDialog::~QFileDialog()
settings.beginGroup(QLatin1String("Qt"));
settings.setValue(QLatin1String("filedialog"), saveState());
#endif
- delete d->qFileDialogUi;
d->deleteNativeDialog_sys();
}
@@ -488,6 +487,38 @@ void QFileDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
+QFileDialogPrivate::QFileDialogPrivate()
+ :
+#ifndef QT_NO_PROXYMODEL
+ proxyModel(0),
+#endif
+ model(0),
+ fileMode(QFileDialog::AnyFile),
+ acceptMode(QFileDialog::AcceptOpen),
+ currentHistoryLocation(-1),
+ renameAction(0),
+ deleteAction(0),
+ showHiddenAction(0),
+ useDefaultCaption(true),
+ defaultFileTypes(true),
+ fileNameLabelExplicitlySat(false),
+ nativeDialogInUse(false),
+#ifdef Q_WS_MAC
+ mDelegate(0),
+#ifndef QT_MAC_USE_COCOA
+ mDialog(0),
+ mDialogStarted(false),
+ mDialogClosed(true),
+#endif
+#endif
+ qFileDialogUi(0)
+{
+}
+
+QFileDialogPrivate::~QFileDialogPrivate()
+{
+}
+
void QFileDialogPrivate::retranslateWindowTitle()
{
Q_Q(QFileDialog);
@@ -568,8 +599,9 @@ bool QFileDialogPrivate::canBeNativeDialog()
}
/*!
- Sets the given \a option to be enabled if \a on is true;
- otherwise, clears the given \a option.
+ \since 4.5
+ Sets the given \a option to be enabled if \a on is true; otherwise,
+ clears the given \a option.
\sa options, testOption()
*/
@@ -640,8 +672,9 @@ QFileDialog::Options QFileDialog::options() const
\since 4.5
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
+ This function connects one of its signals to the slot specified by \a receiver
+ and \a member. The specific signal depends is filesSelected() if fileMode is
+ ExistingFiles and fileSelected() if fileMode is anything else.
The signal will be disconnected from the slot when the dialog is closed.
*/
@@ -779,6 +812,7 @@ void QFileDialog::selectFile(const QString &filename)
}
QModelIndex index = d->model->index(filename);
+ QString file;
if (!index.isValid()) {
// save as dialog where we want to input a default value
QString text = filename;
@@ -793,13 +827,13 @@ void QFileDialog::selectFile(const QString &filename)
)
text = text.remove(0,1);
}
- if (!isVisible() || !d->lineEdit()->hasFocus())
- d->lineEdit()->setText(text);
+ file = text;
} else {
- d->qFileDialogUi->listView->selectionModel()->clear();
- if (!isVisible() || !d->lineEdit()->hasFocus())
- d->lineEdit()->setText(index.data().toString());
+ file = index.data().toString();
}
+ d->qFileDialogUi->listView->selectionModel()->clear();
+ if (!isVisible() || !d->lineEdit()->hasFocus())
+ d->lineEdit()->setText(file);
}
/**
@@ -2110,6 +2144,7 @@ void QFileDialogPrivate::createWidgets()
#else
model->setNameFilterDisables(false);
#endif
+ model->d_func()->disableRecursiveSort = true;
QFileDialog::connect(model, SIGNAL(fileRenamed(const QString &, const QString &, const QString &)), q, SLOT(_q_fileRenamed(const QString &, const QString &, const QString &)));
QFileDialog::connect(model, SIGNAL(rootPathChanged(const QString &)),
q, SLOT(_q_pathChanged(const QString &)));
@@ -2117,7 +2152,7 @@ void QFileDialogPrivate::createWidgets()
q, SLOT(_q_rowsInserted(const QModelIndex &)));
model->setReadOnly(false);
- qFileDialogUi = new Ui_QFileDialog();
+ qFileDialogUi.reset(new Ui_QFileDialog());
qFileDialogUi->setupUi(q);
QList<QUrl> initialBookmarks;
@@ -2143,7 +2178,7 @@ void QFileDialogPrivate::createWidgets()
qFileDialogUi->fileNameLabel->setBuddy(qFileDialogUi->fileNameEdit);
#endif
#ifndef QT_NO_COMPLETER
- completer = new QFSCompletor(model, q);
+ completer = new QFSCompleter(model, q);
qFileDialogUi->fileNameEdit->setCompleter(completer);
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_autoCompleteFileName(QString)));
@@ -2201,9 +2236,9 @@ void QFileDialogPrivate::createWidgets()
treeHeader->addAction(showHeader);
}
- QItemSelectionModel *selModel = qFileDialogUi->treeView->selectionModel();
+ QScopedPointer<QItemSelectionModel> selModel(qFileDialogUi->treeView->selectionModel());
qFileDialogUi->treeView->setSelectionModel(qFileDialogUi->listView->selectionModel());
- delete selModel;
+
QObject::connect(qFileDialogUi->treeView, SIGNAL(activated(QModelIndex)),
q, SLOT(_q_enterDirectory(QModelIndex)));
QObject::connect(qFileDialogUi->treeView, SIGNAL(customContextMenuRequested(QPoint)),
@@ -2285,9 +2320,9 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
}
- QItemSelectionModel *selModel = d->qFileDialogUi->treeView->selectionModel();
+ QScopedPointer<QItemSelectionModel> selModel(d->qFileDialogUi->treeView->selectionModel());
d->qFileDialogUi->treeView->setSelectionModel(d->qFileDialogUi->listView->selectionModel());
- delete selModel;
+
d->setRootIndex(idx);
// reconnect selection
@@ -3168,7 +3203,7 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_COMPLETER
-QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
+QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
{
const QFileSystemModel *dirModel;
if (proxyModel)
@@ -3183,7 +3218,7 @@ QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
return index.data(QFileSystemModel::FilePathRole).toString();
}
-QStringList QFSCompletor::splitPath(const QString &path) const
+QStringList QFSCompleter::splitPath(const QString &path) const
{
if (path.isEmpty())
return QStringList(completionPrefix());
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h
index de7e332..3195583 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/gui/dialogs/qfiledialog_p.h
@@ -76,6 +76,7 @@
#include <qtimeline.h>
#include <qdebug.h>
#include "qsidebar_p.h"
+#include "qfscompleter_p.h"
#if defined (Q_OS_UNIX)
#include <unistd.h>
@@ -91,25 +92,6 @@ class QCompleter;
class QHBoxLayout;
class Ui_QFileDialog;
-#ifndef QT_NO_COMPLETER
-/*!
- QCompleter that can deal with QFileSystemModel
- */
-class QFSCompletor : public QCompleter {
-public:
- QFSCompletor(QFileSystemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(model)
- {
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#endif
- }
- QString pathFromIndex(const QModelIndex &index) const;
- QStringList splitPath(const QString& path) const;
-
- QAbstractProxyModel *proxyModel;
- QFileSystemModel *sourceModel;
-};
-#endif // QT_NO_COMPLETER
struct QFileDialogArgs
{
@@ -131,31 +113,7 @@ class Q_AUTOTEST_EXPORT QFileDialogPrivate : public QDialogPrivate
Q_DECLARE_PUBLIC(QFileDialog)
public:
- QFileDialogPrivate() :
-#ifndef QT_NO_PROXYMODEL
- proxyModel(0),
-#endif
- model(0),
- fileMode(QFileDialog::AnyFile),
- acceptMode(QFileDialog::AcceptOpen),
- currentHistoryLocation(-1),
- renameAction(0),
- deleteAction(0),
- showHiddenAction(0),
- useDefaultCaption(true),
- defaultFileTypes(true),
- fileNameLabelExplicitlySat(false),
- nativeDialogInUse(false),
-#ifdef Q_WS_MAC
- mDelegate(0),
-#ifndef QT_MAC_USE_COCOA
- mDialog(0),
- mDialogStarted(false),
- mDialogClosed(true),
-#endif
-#endif
- qFileDialogUi(0)
- {}
+ QFileDialogPrivate();
void createToolButtons();
void createMenuActions();
@@ -275,7 +233,7 @@ public:
// data
QStringList watching;
QFileSystemModel *model;
- QFSCompletor *completer;
+ QFSCompleter *completer;
QFileDialog::FileMode fileMode;
QFileDialog::AcceptMode acceptMode;
@@ -357,7 +315,7 @@ public:
void mac_nativeDialogModalHelp();
#endif
- Ui_QFileDialog *qFileDialogUi;
+ QScopedPointer<Ui_QFileDialog> qFileDialogUi;
QString acceptLabel;
@@ -366,6 +324,11 @@ public:
QByteArray signalToDisconnectOnClose;
QFileDialog::Options opts;
+
+ ~QFileDialogPrivate();
+
+private:
+ Q_DISABLE_COPY(QFileDialogPrivate)
};
class QFileDialogLineEdit : public QLineEdit
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index a2abe54..119164d 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -83,10 +83,10 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
*/
QFileInfoGatherer::~QFileInfoGatherer()
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
abort = true;
condition.wakeOne();
- mutex.unlock();
+ locker.unlock();
wait();
}
@@ -94,9 +94,8 @@ void QFileInfoGatherer::setResolveSymlinks(bool enable)
{
Q_UNUSED(enable);
#ifdef Q_OS_WIN
- mutex.lock();
+ QMutexLocker locker(&mutex);
m_resolveSymlinks = enable;
- mutex.unlock();
#endif
}
@@ -107,9 +106,8 @@ bool QFileInfoGatherer::resolveSymlinks() const
void QFileInfoGatherer::setIconProvider(QFileIconProvider *provider)
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
m_iconProvider = provider;
- mutex.unlock();
}
QFileIconProvider *QFileInfoGatherer::iconProvider() const
@@ -124,12 +122,11 @@ QFileIconProvider *QFileInfoGatherer::iconProvider() const
*/
void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStringList &files)
{
- mutex.lock();
+ QMutexLocker locker(&mutex);
// See if we already have this dir/file in our que
int loc = this->path.lastIndexOf(path);
while (loc > 0) {
if (this->files.at(loc) == files) {
- mutex.unlock();
return;
}
loc = this->path.lastIndexOf(path, loc - 1);
@@ -137,7 +134,6 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
this->path.push(path);
this->files.push(files);
condition.wakeAll();
- mutex.unlock();
}
/*!
@@ -160,10 +156,9 @@ void QFileInfoGatherer::updateFile(const QString &filePath)
void QFileInfoGatherer::clear()
{
#ifndef QT_NO_FILESYSTEMWATCHER
- mutex.lock();
+ QMutexLocker locker(&mutex);
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
- mutex.unlock();
#endif
}
@@ -175,9 +170,8 @@ void QFileInfoGatherer::clear()
void QFileInfoGatherer::removePath(const QString &path)
{
#ifndef QT_NO_FILESYSTEMWATCHER
- mutex.lock();
+ QMutexLocker locker(&mutex);
watcher->removePath(path);
- mutex.unlock();
#endif
}
@@ -198,9 +192,8 @@ void QFileInfoGatherer::run()
{
forever {
bool updateFiles = false;
- mutex.lock();
+ QMutexLocker locker(&mutex);
if (abort) {
- mutex.unlock();
return;
}
if (this->path.isEmpty())
@@ -214,8 +207,9 @@ void QFileInfoGatherer::run()
this->files.pop_front();
updateFiles = true;
}
- mutex.unlock();
- if (updateFiles) getFileInfos(path, list);
+ locker.unlock();
+ if (updateFiles)
+ getFileInfos(path, list);
}
}
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 49a3f2e..44adc75 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1095,6 +1095,7 @@ private:
*/
void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent)
{
+ Q_Q(QFileSystemModel);
QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
if (indexNode->children.count() == 0)
return;
@@ -1118,6 +1119,16 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent
indexNode->visibleChildren.append(values.at(i).first->fileName);
values.at(i).first->isVisible = true;
}
+
+ if (!disableRecursiveSort) {
+ for (int i = 0; i < q->rowCount(parent); ++i) {
+ const QModelIndex childIndex = q->index(i, 0, parent);
+ QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);
+ //Only do a recursive sort on visible nodes
+ if (indexNode->isVisible)
+ sortChildren(column, childIndex);
+ }
+ }
}
/*!
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h
index 0a1265a..af4fada 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/gui/dialogs/qfilesystemmodel_p.h
@@ -164,9 +164,12 @@ public:
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
- if (!path.isEmpty())
- iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
- else
+ if (!path.isEmpty()) {
+ if (path.endsWith(QLatin1Char('/')))
+ iterator.value()->updateIcon(iconProvider, path + iterator.value()->fileName);
+ else
+ iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ } else
iterator.value()->updateIcon(iconProvider, iterator.value()->fileName);
}
}
@@ -177,9 +180,12 @@ public:
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
- if (!path.isEmpty())
- iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
- else
+ if (!path.isEmpty()) {
+ if (path.endsWith(QLatin1Char('/')))
+ iterator.value()->retranslateStrings(iconProvider, path + iterator.value()->fileName);
+ else
+ iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ } else
iterator.value()->retranslateStrings(iconProvider, iterator.value()->fileName);
}
}
@@ -202,7 +208,8 @@ public:
readOnly(true),
setRootPath(false),
filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs),
- nameFilterDisables(true) // false on windows, true on mac and unix
+ nameFilterDisables(true), // false on windows, true on mac and unix
+ disableRecursiveSort(false)
{
delayedSortTimer.setSingleShot(true);
}
@@ -288,6 +295,10 @@ public:
QDir::Filters filters;
QHash<const QFileSystemNode*, bool> bypassFilters;
bool nameFilterDisables;
+ //This flag is an optimization for the QFileDialog
+ //It enable a sort which is not recursive, it means
+ //we sort only what we see.
+ bool disableRecursiveSort;
#ifndef QT_NO_REGEXP
QList<QRegExp> nameFilters;
#endif
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index 4c5bf4f..9ea06ac 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -337,6 +337,14 @@ void QFontDialogPrivate::init()
QFontDialog::~QFontDialog()
{
+#ifdef Q_WS_MAC
+ Q_D(QFontDialog);
+ if (d->delegate) {
+ QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
+ QFontDialogPrivate::sharedFontPanelAvailable = true;
+ return;
+ }
+#endif
}
/*!
@@ -932,7 +940,7 @@ bool QFontDialogPrivate::sharedFontPanelAvailable = true;
\since 4.5
\overload
- Opens the dialog and connects its accepted() signal to the slot specified
+ Opens the dialog and connects its fontSelected() signal to the slot specified
by \a receiver and \a member.
The signal will be disconnected from the slot when the dialog is closed.
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index 50917a1..3be53db 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -47,6 +47,7 @@
#include <private/qapplication_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
+#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
#include <qdebug.h>
#import <AppKit/AppKit.h>
@@ -123,16 +124,16 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
QFont newFont;
if (cocoaFont) {
int pSize = qRound([cocoaFont pointSize]);
- QString family(QCFString::toQString(reinterpret_cast<CFStringRef>([cocoaFont familyName])));
- QString typeface(QCFString::toQString(reinterpret_cast<CFStringRef>([cocoaFont fontName])));
-// qDebug() << "original family" << family << "typeface" << typeface << "psize" << pSize;
+ QString family(qt_mac_NSStringToQString([cocoaFont familyName]));
+ QString typeface(qt_mac_NSStringToQString([cocoaFont fontName]));
+
int hyphenPos = typeface.indexOf(QLatin1Char('-'));
if (hyphenPos != -1) {
typeface.remove(0, hyphenPos + 1);
} else {
typeface = QLatin1String("Normal");
}
-// qDebug() << " massaged family" << family << "typeface" << typeface << "psize" << pSize;
+
newFont = QFontDatabase().font(family, typeface, pSize);
newFont.setUnderline(resolveFont.underline());
newFont.setStrikeOut(resolveFont.strikeOut());
@@ -566,6 +567,7 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
void QFontDialogPrivate::closeCocoaFontPanel(void *delegate)
{
+ QMacCocoaAutoReleasePool pool;
QCocoaFontPanelDelegate *theDelegate = static_cast<QCocoaFontPanelDelegate *>(delegate);
NSWindow *ourPanel = [theDelegate actualPanel];
[ourPanel close];
@@ -597,15 +599,37 @@ QFont QFontDialogPrivate::execCocoaFontPanel(bool *ok, const QFont &initial,
}
}
-void QFontDialogPrivate::setFont(void * delegate, const QFont &font)
+void QFontDialogPrivate::setFont(void *delegate, const QFont &font)
{
+ QMacCocoaAutoReleasePool pool;
QFontEngine *fe = font.d->engineForScript(QUnicodeTables::Common);
+ NSFontManager *mgr = [NSFontManager sharedFontManager];
+ NSFont *nsFont = 0;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
if (qstrcmp(fe->name(), "CoreText") == 0) {
- const NSFont *nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
- [[NSFontManager sharedFontManager] setSelectedFont:nsFont isMultiple:NO];
- }
+ nsFont = reinterpret_cast<const NSFont *>(static_cast<QCoreTextFontEngineMulti *>(fe)->ctfont);
+ } else
#endif
+ {
+ int weight = 5;
+ NSFontTraitMask mask = 0;
+ if (font.style() == QFont::StyleItalic) {
+ mask |= NSItalicFontMask;
+ }
+ if (font.weight() == QFont::Bold) {
+ weight = 9;
+ mask |= NSBoldFontMask;
+ }
+
+ NSFontManager *mgr = [NSFontManager sharedFontManager];
+ nsFont = [mgr fontWithFamily:qt_mac_QStringToNSString(font.family())
+ traits:mask
+ weight:weight
+ size:font.pointSize()];
+ }
+
+ [mgr setSelectedFont:nsFont isMultiple:NO];
[static_cast<QCocoaFontPanelDelegate *>(delegate) setQtFont:font];
}
diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h
new file mode 100644
index 0000000..37d9c74
--- /dev/null
+++ b/src/gui/dialogs/qfscompleter_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMPLETOR_P_H
+#define QCOMPLETOR_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 "qcompleter.h"
+#include <QtGui/qfilesystemmodel.h>
+
+#ifndef QT_NO_COMPLETER
+/*!
+ QCompleter that can deal with QFileSystemModel
+ */
+class QFSCompleter : public QCompleter {
+public:
+ QFSCompleter(QFileSystemModel *model, QObject *parent = 0)
+ : QCompleter(model, parent), proxyModel(0), sourceModel(model)
+ {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#endif
+ }
+ QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString& path) const;
+
+ QAbstractProxyModel *proxyModel;
+ QFileSystemModel *sourceModel;
+};
+#endif // QT_NO_COMPLETER
+
+#endif // QCOMPLETOR_P_H
+
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp
index 78d99e3..8754324 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/gui/dialogs/qinputdialog.cpp
@@ -1020,8 +1020,16 @@ QString QInputDialog::cancelButtonText() const
\since 4.5
\overload
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
+ This function connects one of its signals to the slot specified by \a receiver
+ and \a member. The specific signal depends on the arguments that are specified
+ in \a member. These are:
+
+ \list
+ \o textValueSelected() if \a member has a QString for its first argument.
+ \o intValueSelected() if \a member has an int for its first argument.
+ \o doubleValueSelected() if \a member has a double for its first argument.
+ \o accepted() if \a member has NO arguments.
+ \endlist
The signal will be disconnected from the slot when the dialog is closed.
*/
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 15a99af..00baf01 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -706,15 +706,10 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
Constructs a message box with no text and no buttons. \a parent is
passed to the QDialog constructor.
- If \a parent is 0, the message box is an \l{Qt::ApplicationModal}
- {application modal} dialog box. If \a parent is a widget, the
- message box is \l{Qt::WindowModal} {window modal} relative to \a
- parent.
-
- On Mac OS X, if \a parent is not 0 and you want your message box
- to appear as a Qt::Sheet of that parent, set the message box's
- \l{setWindowModality()} {window modality} to Qt::WindowModal
- (default). Otherwise, the message box will be a standard dialog.
+ On Mac OS X, if you want your message box to appear
+ as a Qt::Sheet of its \a parent, set the message box's
+ \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
+ Otherwise, the message box will be a standard dialog.
*/
QMessageBox::QMessageBox(QWidget *parent)
@@ -1728,7 +1723,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
QMessageBox *msgBox = new QMessageBox(parent);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
- msgBox->setText(translatedTextAboutQt);
+ msgBox->setInformativeText(translatedTextAboutQt);
QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
if (!pm.isNull())
diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/gui/dialogs/qpagesetupdialog.cpp
index 63775d2..682071a 100644
--- a/src/gui/dialogs/qpagesetupdialog.cpp
+++ b/src/gui/dialogs/qpagesetupdialog.cpp
@@ -180,6 +180,12 @@ void QPageSetupDialog::open(QObject *receiver, const char *member)
QDialog::open();
}
+#if defined(Q_WS_MAC) || defined(Q_OS_WIN)
+/*! \fn void QPageSetupDialog::setVisible(bool visible)
+ \reimp
+*/
+#endif
+
QT_END_NAMESPACE
#endif
diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/gui/dialogs/qpagesetupdialog_mac.mm
index 401d95f..24aef34 100644
--- a/src/gui/dialogs/qpagesetupdialog_mac.mm
+++ b/src/gui/dialogs/qpagesetupdialog_mac.mm
@@ -251,9 +251,6 @@ QPageSetupDialog::QPageSetupDialog(QWidget *parent)
d->ep = static_cast<QMacPrintEngine *>(d->printer->paintEngine())->d_func();
}
-/*!
- \reimp
-*/
void QPageSetupDialog::setVisible(bool visible)
{
Q_D(QPageSetupDialog);
diff --git a/src/gui/dialogs/qpagesetupdialog_win.cpp b/src/gui/dialogs/qpagesetupdialog_win.cpp
index 4bb571c..bdce8ab 100644
--- a/src/gui/dialogs/qpagesetupdialog_win.cpp
+++ b/src/gui/dialogs/qpagesetupdialog_win.cpp
@@ -71,7 +71,7 @@ int QPageSetupDialog::exec()
return Rejected;
QWin32PrintEngine *engine = static_cast<QWin32PrintEngine*>(d->printer->paintEngine());
- QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr);
+ QWin32PrintEnginePrivate *ep = static_cast<QWin32PrintEnginePrivate *>(engine->d_ptr.data());
PAGESETUPDLG psd;
memset(&psd, 0, sizeof(PAGESETUPDLG));
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp
index 87a4e65..17d0047 100644
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ b/src/gui/dialogs/qprintdialog_unix.cpp
@@ -44,7 +44,6 @@
#ifndef QT_NO_PRINTDIALOG
#include "private/qabstractprintdialog_p.h"
-#include "qfiledialog_p.h"
#include <QtGui/qmessagebox.h>
#include "qprintdialog.h"
#include "qfiledialog.h"
@@ -55,6 +54,7 @@
#include <QtGui/qdialogbuttonbox.h>
+#include "qfscompleter_p.h"
#include "ui_qprintpropertieswidget.h"
#include "ui_qprintsettingsoutput.h"
#include "ui_qprintwidget.h"
@@ -696,7 +696,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
fsm->setRootPath(QDir::homePath());
#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG)
- widget.filename->setCompleter(new QFSCompletor(fsm, widget.filename));
+ widget.filename->setCompleter(new QFSCompleter(fsm, widget.filename));
#endif
#endif
_q_printerChanged(currentPrinterIndex);
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
index c00bd14..61949d8 100644
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ b/src/gui/dialogs/qprintpreviewdialog.cpp
@@ -42,6 +42,7 @@
#include "qprintpreviewdialog.h"
#include "qprintpreviewwidget.h"
#include <private/qprinter_p.h>
+#include "private/qdialog_p.h"
#include <QtGui/qaction.h>
#include <QtGui/qboxlayout.h>
@@ -128,12 +129,12 @@ private:
};
} // anonymous namespace
-class QPrintPreviewDialogPrivate
+class QPrintPreviewDialogPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QPrintPreviewDialog)
public:
- QPrintPreviewDialogPrivate(QPrintPreviewDialog *q)
- : q_ptr(q), printDialog(0), ownPrinter(false),
+ QPrintPreviewDialogPrivate()
+ : printDialog(0), ownPrinter(false),
initialized(false) {}
// private slots
@@ -158,7 +159,6 @@ public:
void updatePageNumLabel();
void updateZoomFactor();
- QPrintPreviewDialog *q_ptr;
QPrintDialog *printDialog;
QPrintPreviewWidget *preview;
QPrinter *printer;
@@ -680,7 +680,7 @@ void QPrintPreviewDialogPrivate::_q_zoomFactorChanged()
\sa QWidget::setWindowFlags()
*/
QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags)
- : QDialog(parent, flags), d_ptr(new QPrintPreviewDialogPrivate(this))
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, flags)
{
Q_D(QPrintPreviewDialog);
d->init(printer);
@@ -694,7 +694,7 @@ QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt:
system default printer.
*/
QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent, f), d_ptr(new QPrintPreviewDialogPrivate(this))
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, f)
{
Q_D(QPrintPreviewDialog);
d->init();
@@ -709,7 +709,6 @@ QPrintPreviewDialog::~QPrintPreviewDialog()
if (d->ownPrinter)
delete d->printer;
delete d->printDialog;
- delete d_ptr;
}
/*!
diff --git a/src/gui/dialogs/qprintpreviewdialog.h b/src/gui/dialogs/qprintpreviewdialog.h
index c3a4d57..49262db 100644
--- a/src/gui/dialogs/qprintpreviewdialog.h
+++ b/src/gui/dialogs/qprintpreviewdialog.h
@@ -94,7 +94,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_previewChanged())
Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged())
- QPrintPreviewDialogPrivate *d_ptr;
+ void *dummy; // ### Qt 5 - remove me
};
diff --git a/src/gui/dialogs/qwizard.cpp b/src/gui/dialogs/qwizard.cpp
index 32395c4..298f23f 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/gui/dialogs/qwizard.cpp
@@ -1465,7 +1465,7 @@ void QWizardPrivate::handleAeroStyleChange()
return; // prevent recursion
inHandleAeroStyleChange = true;
- vistaHelper->backButton()->disconnect();
+ vistaHelper->disconnectBackButton();
q->removeEventFilter(vistaHelper);
if (isVistaThemeEnabled()) {
@@ -1491,7 +1491,7 @@ void QWizardPrivate::handleAeroStyleChange()
q->setMouseTracking(true); // ### original value possibly different
q->unsetCursor(); // ### ditto
antiFlickerWidget->move(0, 0);
- vistaHelper->backButton()->hide();
+ vistaHelper->hideBackButton();
vistaHelper->setTitleBarIconAndCaptionVisible(true);
}
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
index 64696de..8aad4af 100644
--- a/src/gui/dialogs/qwizard_win.cpp
+++ b/src/gui/dialogs/qwizard_win.cpp
@@ -239,9 +239,11 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
QVistaHelper::QVistaHelper(QWizard *wizard)
: pressed(false)
, wizard(wizard)
+ , backButton_(0)
{
is_vista = resolveSymbols();
- backButton_ = new QVistaBackButton(wizard);
+ if (is_vista)
+ backButton_ = new QVistaBackButton(wizard);
}
QVistaHelper::~QVistaHelper()
@@ -310,6 +312,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
QRect(0, 0, wizard->width(), titleBarSize() + topOffset()),
painter->paintEngine()->getDC());
+ Q_ASSERT(backButton_);
const int btnTop = backButton_->mapToParent(QPoint()).y();
const int btnHeight = backButton_->size().height();
const int verticalCenter = (btnTop + btnHeight / 2);
diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h
index cbb3b17..148be26 100644
--- a/src/gui/dialogs/qwizard_win_p.h
+++ b/src/gui/dialogs/qwizard_win_p.h
@@ -94,6 +94,8 @@ public:
void resizeEvent(QResizeEvent *event);
void paintEvent(QPaintEvent *event);
QVistaBackButton *backButton() const { return backButton_; }
+ void disconnectBackButton() { if (backButton_) backButton_->disconnect(); }
+ void hideBackButton() { if (backButton_) backButton_->hide(); }
void setWindowPosHack();
QColor basicWindowFrameColor();
enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index b588e55..7c162bc 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -97,6 +97,7 @@ private slots:
private:
QWSPC101KeyboardHandler *handler;
struct termios origTermData;
+ int originalKbdMode;
};
QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device)
@@ -156,6 +157,7 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSPC101KeyboardHandler *h, const QString &devi
tcgetattr(kbdFD, &termdata);
#if defined(Q_OS_LINUX)
+ ioctl(kbdFD, KDGKBMODE, &originalKbdMode);
# ifdef QT_QWS_USE_KEYCODES
ioctl(kbdFD, KDSKBMODE, K_MEDIUMRAW);
# else
@@ -202,7 +204,7 @@ QWSTtyKbPrivate::~QWSTtyKbPrivate()
{
if (kbdFD >= 0) {
#if defined(Q_OS_LINUX)
- ioctl(kbdFD, KDSKBMODE, K_XLATE);
+ ioctl(kbdFD, KDSKBMODE, originalKbdMode);
#endif
tcsetattr(kbdFD, TCSANOW, &origTermData);
::close(kbdFD);
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
index 6741f2c..39a74d5 100644
--- a/src/gui/embedded/qscreen_qws.cpp
+++ b/src/gui/embedded/qscreen_qws.cpp
@@ -1394,7 +1394,7 @@ QImage::Format QScreenPrivate::preferredImageFormat() const
altered. Note that the default implementations of these functions
do nothing.
- Reimplement the the mapFromDevice() and mapToDevice() functions to
+ Reimplement the mapFromDevice() and mapToDevice() functions to
map objects from the framebuffer coordinate system to the
coordinate space used by the application, and vice versa. Be aware
that the default implementations simply return the given objects
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp
index 283bbd3..ed988ca 100644
--- a/src/gui/embedded/qsoundqss_qws.cpp
+++ b/src/gui/embedded/qsoundqss_qws.cpp
@@ -1036,24 +1036,28 @@ void QWSSoundServerPrivate::stopFile(int wid, int sid)
void QWSSoundServerPrivate::stopAll(int wid)
{
QWSSoundServerProvider *bucket;
- QList<QWSSoundServerProvider*>::Iterator it = active.begin();
- while (it != active.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = active.erase(it);
- delete bucket;
- } else {
- ++it;
+ if (!active.isEmpty()) {
+ QList<QWSSoundServerProvider*>::Iterator it = active.begin();
+ while (it != active.end()) {
+ bucket = *it;
+ if (bucket->groupId() == wid) {
+ it = active.erase(it);
+ delete bucket;
+ } else {
+ ++it;
+ }
}
}
- it = inactive.begin();
- while (it != inactive.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = inactive.erase(it);
- delete bucket;
- } else {
- ++it;
+ if (!inactive.isEmpty()) {
+ QList<QWSSoundServerProvider*>::Iterator it = inactive.begin();
+ while (it != inactive.end()) {
+ bucket = *it;
+ if (bucket->groupId() == wid) {
+ it = inactive.erase(it);
+ delete bucket;
+ } else {
+ ++it;
+ }
}
}
}
diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp
index fdcd193..e3d56ad 100644
--- a/src/gui/embedded/qwindowsystem_qws.cpp
+++ b/src/gui/embedded/qwindowsystem_qws.cpp
@@ -1304,7 +1304,13 @@ QWSServer::QWSServer(int flags, QObject *parent) :
QObject(*new QWSServerPrivate, parent)
{
Q_D(QWSServer);
- d->initServer(flags);
+ QT_TRY {
+ d->initServer(flags);
+ } QT_CATCH(...) {
+ qwsServer = 0;
+ qwsServerPrivate = 0;
+ QT_RETHROW;
+ }
}
#ifdef QT3_SUPPORT
@@ -1750,21 +1756,23 @@ void QWSServerPrivate::cleanupFonts(bool force)
#if defined(QWS_DEBUG_FONTCLEANUP)
qDebug() << "cleanupFonts()";
#endif
- QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin();
- while (it != fontReferenceCount.end()) {
- if (it.value() && !force) {
- ++it;
- continue;
- }
+ if (!fontReferenceCount.isEmpty()) {
+ QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin();
+ while (it != fontReferenceCount.end()) {
+ if (it.value() && !force) {
+ ++it;
+ continue;
+ }
- const QByteArray &fontName = it.key();
+ const QByteArray &fontName = it.key();
#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "removing unused font file" << fontName;
+ qDebug() << "removing unused font file" << fontName;
#endif
- QFile::remove(QFile::decodeName(fontName));
- sendFontRemovedEvent(fontName);
+ QFile::remove(QFile::decodeName(fontName));
+ sendFontRemovedEvent(fontName);
- it = fontReferenceCount.erase(it);
+ it = fontReferenceCount.erase(it);
+ }
}
if (crashedClientIds.isEmpty())
@@ -3966,7 +3974,8 @@ void QWSServerPrivate::openDisplay()
void QWSServerPrivate::closeDisplay()
{
- qt_screen->shutdownDevice();
+ if (qt_screen)
+ qt_screen->shutdownDevice();
}
/*!
@@ -4065,9 +4074,14 @@ void QWSServer::startup(int flags)
void QWSServer::closedown()
{
- unlink(qws_qtePipeFilename().toLatin1().constData());
- delete qwsServer;
+ QScopedPointer<QWSServer> server(qwsServer);
qwsServer = 0;
+ QT_TRY {
+ unlink(qws_qtePipeFilename().toLatin1().constData());
+ } QT_CATCH(const std::bad_alloc &) {
+ // ### TODO - what to do when we run out of memory
+ // when calling toLatin1?
+ }
}
void QWSServerPrivate::emergency_cleanup()
diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp
index 3a5bd2c..b25e9b1 100644
--- a/src/gui/embedded/qwscursor_qws.cpp
+++ b/src/gui/embedded/qwscursor_qws.cpp
@@ -531,7 +531,7 @@ void QWSCursor::set(const uchar *data, const uchar *mask,
cursor = QImage(width,height, QImage::Format_Indexed8);
- if (!width || !height || !data || !mask)
+ if (!width || !height || !data || !mask || cursor.isNull())
return;
cursor.setNumColors(3);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 4908296..596326b 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -515,6 +515,7 @@
#include <QtGui/qpixmapcache.h>
#include <QtGui/qstyleoption.h>
#include <QtGui/qevent.h>
+#include <QInputContext>
#include <private/qgraphicsitem_p.h>
#include <private/qgraphicswidget_p.h>
@@ -874,8 +875,6 @@ QGraphicsItem::~QGraphicsItem()
if (d_ptr->scene)
d_ptr->scene->d_func()->_q_removeItemLater(this);
- delete d_ptr;
-
qt_dataStore()->data.remove(this);
}
@@ -1522,6 +1521,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
if (visible == quint32(newVisible))
return;
+ // Don't show child if parent is not visible
+ if (parent && newVisible && !parent->d_ptr->visible)
+ return;
+
// Modify the property.
const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
quint32(newVisible)));
@@ -2727,7 +2730,7 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
QTransform x;
const QGraphicsItem *p = child;
do {
- const QGraphicsItemPrivate *pd = p->d_ptr;
+ const QGraphicsItemPrivate *pd = p->d_ptr.data();
if (pd->hasTransform)
x *= p->transform();
if (!pd->pos.isNull())
@@ -3065,7 +3068,7 @@ QRectF QGraphicsItem::sceneBoundingRect() const
const QGraphicsItem *parentItem = this;
const QGraphicsItemPrivate *itemd;
do {
- itemd = parentItem->d_ptr;
+ itemd = parentItem->d_ptr.data();
if (itemd->hasTransform)
break;
offset += itemd->pos;
@@ -7605,7 +7608,7 @@ class QGraphicsTextItemPrivate
{
public:
QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false)
+ : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
{ }
mutable QTextControl *control;
@@ -7626,6 +7629,8 @@ public:
bool useDefaultImpl;
bool tabChangesFocus;
+ uint clickCausedFocus : 1;
+
QGraphicsTextItem *qq;
};
@@ -7952,7 +7957,13 @@ void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
dd->useDefaultImpl = false;
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7964,7 +7975,13 @@ void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mouseMoveEvent(event);
return;
}
+
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -7984,7 +8001,23 @@ void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
return;
}
+
+ if (event->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!dd->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent _event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(event->widget(), &_event);
+ } else {
+ QGraphicsItem::mouseReleaseEvent(event);
+ }
+ dd->clickCausedFocus = 0;
+
dd->sendControlEvent(event);
+
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8003,6 +8036,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
}
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8011,6 +8049,11 @@ void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8019,6 +8062,18 @@ void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8027,6 +8082,18 @@ void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
{
dd->sendControlEvent(event);
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->update();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8035,7 +8102,22 @@ void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
void QGraphicsTextItem::focusInEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
+ if (event->reason() == Qt::MouseFocusReason) {
+ dd->clickCausedFocus = 1;
+ }
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8045,6 +8127,18 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
{
dd->sendControlEvent(event);
update();
+ QList<QGraphicsView *> views = scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ Q_ASSERT(view->viewport());
+ if(view->viewport()->hasFocus()) {
+ QInputContext *qic = view->viewport()->inputContext();
+ if(qic){
+ qic->reset();
+ }
+ break;
+ }
+ }
}
/*!
@@ -8053,6 +8147,11 @@ void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8061,6 +8160,11 @@ void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8069,6 +8173,11 @@ void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8077,6 +8186,11 @@ void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8093,6 +8207,11 @@ void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)
void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8101,6 +8220,11 @@ void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
@@ -8109,6 +8233,11 @@ void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
dd->sendControlEvent(event);
+ Q_ASSERT(event->widget());
+ QInputContext *qic = event->widget()->inputContext();
+ if(qic) {
+ qic->update();
+ }
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index b98882d..25678a6 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -46,6 +46,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qrect.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainterpath.h>
#include <QtGui/qpixmap.h>
@@ -380,7 +381,7 @@ protected:
protected:
QGraphicsItem(QGraphicsItemPrivate &dd,
QGraphicsItem *parent, QGraphicsScene *scene);
- QGraphicsItemPrivate *d_ptr;
+ QScopedPointer<QGraphicsItemPrivate> d_ptr;
void addToIndex();
void removeFromIndex();
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp
index eaa97ff..c291763 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp
@@ -255,7 +255,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const
passing a QGraphicsLayoutItem pointer to QGraphicsLayoutItem's
protected constructor, or by calling setParentLayoutItem(). The
parentLayoutItem() function returns a pointer to the item's layoutItem
- parent. If the item's parent is 0 or if the the parent does not inherit
+ parent. If the item's parent is 0 or if the parent does not inherit
from QGraphicsItem, the parentLayoutItem() function then returns 0.
isLayout() returns true if the QGraphicsLayoutItem subclass is itself a
layout, or false otherwise.
@@ -307,7 +307,6 @@ QGraphicsLayoutItem::~QGraphicsLayoutItem()
}
}
}
- delete d_ptr;
}
/*!
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h
index 31f5d90..d667c4f 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.h
+++ b/src/gui/graphicsview/qgraphicslayoutitem.h
@@ -42,6 +42,7 @@
#ifndef QGRAPHICSLAYOUTITEM_H
#define QGRAPHICSLAYOUTITEM_H
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qsizepolicy.h>
#include <QtGui/qevent.h>
@@ -112,7 +113,7 @@ protected:
QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
- QGraphicsLayoutItemPrivate *d_ptr;
+ QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
private:
QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.h b/src/gui/graphicsview/qgraphicsproxywidget.h
index b2c3c8f..f006319 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.h
+++ b/src/gui/graphicsview/qgraphicsproxywidget.h
@@ -127,7 +127,7 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QGraphicsProxyWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QGraphicsProxyWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget)
Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot())
friend class QWidget;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index b89e352..5114351 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1824,8 +1824,8 @@ void QGraphicsScenePrivate::invalidateSortCache()
inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2)
{
// Return true if sibling item1 is on top of item2.
- const QGraphicsItemPrivate *d1 = item1->d_ptr;
- const QGraphicsItemPrivate *d2 = item2->d_ptr;
+ const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
+ const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
bool f1 = d1->flags & QGraphicsItem::ItemStacksBehindParent;
bool f2 = d2->flags & QGraphicsItem::ItemStacksBehindParent;
if (f1 != f2) return f2;
@@ -1852,8 +1852,8 @@ inline bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem
bool QGraphicsScenePrivate::closestItemFirst_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2)
{
// Siblings? Just check their z-values.
- const QGraphicsItemPrivate *d1 = item1->d_ptr;
- const QGraphicsItemPrivate *d2 = item2->d_ptr;
+ const QGraphicsItemPrivate *d1 = item1->d_ptr.data();
+ const QGraphicsItemPrivate *d2 = item2->d_ptr.data();
if (d1->parent == d2->parent)
return qt_closestLeaf(item1, item2);
@@ -4687,7 +4687,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
const QStyleOptionGraphicsItem *option, QWidget *widget,
bool painterStateProtection)
{
- QGraphicsItemPrivate *itemd = item->d_ptr;
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
// Render directly, using no cache.
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index b819c2c..ad57aac 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -313,7 +313,6 @@ QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type ty
*/
QGraphicsSceneEvent::~QGraphicsSceneEvent()
{
- delete d_ptr;
}
/*!
@@ -844,7 +843,7 @@ QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
/*!
Returns the position of the mouse cursor in item coordinates at the moment
- the the context menu was requested.
+ the context menu was requested.
\sa scenePos(), screenPos()
*/
@@ -992,7 +991,7 @@ QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
/*!
Returns the position of the mouse cursor in item coordinates at the moment
- the the hover event was sent.
+ the hover event was sent.
\sa scenePos(), screenPos()
*/
@@ -1017,7 +1016,7 @@ void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in scene coordinates at the
- moment the the hover event was sent.
+ moment the hover event was sent.
\sa pos(), screenPos()
*/
@@ -1042,7 +1041,7 @@ void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in screen coordinates at the
- moment the the hover event was sent.
+ moment the hover event was sent.
\sa pos(), scenePos()
*/
@@ -1138,7 +1137,7 @@ void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
/*!
\since 4.4
- Returns the keyboard modifiers at the moment the the hover event was sent.
+ Returns the keyboard modifiers at the moment the hover event was sent.
*/
Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
{
@@ -1184,7 +1183,7 @@ QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
/*!
Returns the position of the mouse cursor in scene coordinates at the
- moment the the help event was sent.
+ moment the help event was sent.
\sa screenPos()
*/
@@ -1209,7 +1208,7 @@ void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
/*!
Returns the position of the mouse cursor in screen coordinates at the
- moment the the help event was sent.
+ moment the help event was sent.
\sa scenePos()
*/
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index be50e96..4ebe3df 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -44,6 +44,7 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -70,7 +71,7 @@ public:
protected:
QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None);
- QGraphicsSceneEventPrivate *d_ptr;
+ QScopedPointer<QGraphicsSceneEventPrivate> d_ptr;
Q_DECLARE_PRIVATE(QGraphicsSceneEvent)
};
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a795fb4..96e9a96 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -753,7 +753,7 @@ QRect QGraphicsViewPrivate::mapToViewRect(const QGraphicsItem *item, const QRect
const QGraphicsItem *parentItem = item;
const QGraphicsItemPrivate *itemd;
do {
- itemd = parentItem->d_ptr;
+ itemd = parentItem->d_ptr.data();
if (itemd->hasTransform)
break;
offset += itemd->pos;
@@ -1195,6 +1195,11 @@ QGraphicsView::QGraphicsView(QWidget *parent)
// using a simple reference count. The same goes for acceptDrops and mouse
// tracking.
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
@@ -1209,6 +1214,11 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
@@ -1221,6 +1231,11 @@ QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
setAcceptDrops(true);
setBackgroundRole(QPalette::Base);
setAttribute(Qt::WA_InputMethodEnabled);
+
+ // viewport part of the graphics view has to be enabled
+ // as well, because when events come this widget is asked
+ // for input context and so on
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 7f02fb9..aa2b9bf 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -366,7 +366,7 @@ void QGraphicsWidget::resize(const QSizeF &size)
void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
QRectF newGeom;
QPointF oldPos = d->geom.topLeft();
if (!wd->inSetPos) {
@@ -1887,8 +1887,10 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action)
}
d->actions.insert(pos, action);
- QActionPrivate *apriv = action->d_func();
- apriv->graphicsWidgets.append(this);
+ if (index == -1) {
+ QActionPrivate *apriv = action->d_func();
+ apriv->graphicsWidgets.append(this);
+ }
QActionEvent e(QEvent::ActionAdded, action, before);
QApplication::sendEvent(this, &e);
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 34f1c5f..49de542 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -225,7 +225,7 @@ protected:
private:
Q_DISABLE_COPY(QGraphicsWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QGraphicsWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget)
friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
friend class QGraphicsView;
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index d3b7388..30aaa51 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -42,4 +42,7 @@ QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist
DEFINES += Q_INTERNAL_QAPP_SRC
-symbian:TARGET.UID3=0x2001B2DD \ No newline at end of file
+symbian:TARGET.UID3=0x2001B2DD
+
+# ro-section in gui can exceed default allocated space, so more rw-section little further
+symbian-sbsv2: MMP_RULES += "LINKEROPTION armcc --rw-base 0x800000" \ No newline at end of file
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 53430ab..0799ea7 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -428,10 +428,13 @@ bool QPixmapIconEngine::read(QDataStream &in)
in >> sz;
in >> mode;
in >> state;
- if (pm.isNull())
+ if (pm.isNull()) {
addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
- else
- addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
+ } else {
+ QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
+ pe.pixmap = pm;
+ pixmaps += pe;
+ }
}
return true;
}
@@ -922,7 +925,7 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const
\relates QIcon
\since 4.2
- Writes the given \a icon to the the given \a stream as a PNG
+ Writes the given \a icon to the given \a stream as a PNG
image. If the icon contains more than one image, all images will
be written to the stream. Note that writing the stream to a file
will not produce a valid image file.
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index c7a20db..34ad99c 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -185,6 +185,13 @@ static int depthForFormat(QImage::Format format)
return depth;
}
+/*! \fn QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
+
+ \internal
+
+ Creates a new image data.
+ Returns 0 if invalid parameters are give or anything else failed.
+*/
QImageData * QImageData::create(const QSize &size, QImage::Format format, int numColors)
{
if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
@@ -223,7 +230,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
|| INT_MAX/sizeof(uchar *) < uint(height))
return 0;
- QImageData *d = new QImageData;
+ QScopedPointer<QImageData> d(new QImageData);
d->colortable.resize(numColors);
if (depth == 1) {
d->colortable[0] = QColor(Qt::black).rgba();
@@ -246,12 +253,11 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
d->data = (uchar *)malloc(d->nbytes);
if (!d->data) {
- delete d;
return 0;
}
d->ref.ref();
- return d;
+ return d.take();
}
@@ -1621,6 +1627,7 @@ int QImage::numColors() const
/*!
Returns a pointer to the scanline pointer table. This is the
beginning of the data block for the image.
+ Returns 0 in case of an error.
Use the bits() or scanLine() function instead.
*/
@@ -1636,6 +1643,8 @@ uchar **QImage::jumpTable()
if (!d->jumptable) {
d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
+ if (!d->jumptable)
+ return 0;
uchar *data = d->data;
int height = d->height;
uchar **p = d->jumptable;
@@ -1656,6 +1665,8 @@ const uchar * const *QImage::jumpTable() const
return 0;
if (!d->jumptable) {
d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
+ if (!d->jumptable)
+ return 0;
uchar *data = d->data;
int height = d->height;
uchar **p = d->jumptable;
@@ -4996,7 +5007,7 @@ QPoint QImage::offset() const
/*!
\fn void QImage::setOffset(const QPoint& offset)
- Sets the the number of pixels by which the image is intended to be
+ Sets the number of pixels by which the image is intended to be
offset by when positioning relative to other images, to \a offset.
\sa offset(), {QImage#Image Information}{Image Information}
diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp
index a47c69e..f432f87 100644
--- a/src/gui/image/qimageiohandler.cpp
+++ b/src/gui/image/qimageiohandler.cpp
@@ -272,7 +272,6 @@ QImageIOHandler::QImageIOHandler(QImageIOHandlerPrivate &dd)
*/
QImageIOHandler::~QImageIOHandler()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index 3b654f3..34de715 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -44,6 +44,7 @@
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -109,7 +110,7 @@ public:
protected:
QImageIOHandler(QImageIOHandlerPrivate &dd);
- QImageIOHandlerPrivate *d_ptr;
+ QScopedPointer<QImageIOHandlerPrivate> d_ptr;
private:
Q_DISABLE_COPY(QImageIOHandler)
};
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 92023e0..8528173 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -132,7 +132,6 @@ QPicture::QPicture(int formatVersion)
{
Q_D(QPicture);
d_ptr->q_ptr = this;
- d->paintEngine = 0;
if (formatVersion == 0)
qWarning("QPicture: invalid format version 0");
@@ -155,7 +154,7 @@ QPicture::QPicture(int formatVersion)
*/
QPicture::QPicture(const QPicture &pic)
- : QPaintDevice(), d_ptr(pic.d_ptr)
+ : QPaintDevice(), d_ptr(pic.d_ptr.data())
{
d_func()->ref.ref();
}
@@ -173,10 +172,6 @@ QPicture::QPicture(QPicturePrivate &dptr)
*/
QPicture::~QPicture()
{
- if (!d_func()->ref.deref()) {
- delete d_func()->paintEngine;
- delete d_func();
- }
}
/*!
@@ -1030,9 +1025,7 @@ void QPicture::detach_helper()
x->formatMinor = d->formatMinor;
x->brect = d->brect;
x->override_rect = d->override_rect;
- if (!d->ref.deref())
- delete d;
- d_ptr = x;
+ d_ptr.reset(x);
}
/*!
@@ -1041,7 +1034,7 @@ void QPicture::detach_helper()
*/
QPicture& QPicture::operator=(const QPicture &p)
{
- qAtomicAssign<QPicturePrivate>(d_ptr, p.d_ptr);
+ d_ptr.assign(p.d_ptr.data());
return *this;
}
@@ -1135,8 +1128,8 @@ bool QPicturePrivate::checkFormat()
QPaintEngine *QPicture::paintEngine() const
{
if (!d_func()->paintEngine)
- const_cast<QPicture*>(this)->d_func()->paintEngine = new QPicturePaintEngine;
- return d_func()->paintEngine;
+ const_cast<QPicture*>(this)->d_func()->paintEngine.reset(new QPicturePaintEngine);
+ return d_func()->paintEngine.data();
}
/*****************************************************************************
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index fe86e8d..7de1f79 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -106,7 +106,7 @@ private:
bool exec(QPainter *p, QDataStream &ds, int i);
void detach_helper();
- QPicturePrivate *d_ptr;
+ QScopedSharedPointer<QPicturePrivate> d_ptr;
friend class QPicturePaintEngine;
friend class Q3Picture;
friend class QAlphaPaintEngine;
@@ -114,7 +114,7 @@ private:
public:
typedef QPicturePrivate* DataPtr;
- inline DataPtr &data_ptr() { return d_ptr; }
+ inline DataPtr &data_ptr() { return d_ptr.data_ptr(); }
};
Q_DECLARE_SHARED(QPicture)
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index a3fd34f..e0c3117 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -156,7 +156,7 @@ public:
int formatMinor;
QRect brect;
QRect override_rect;
- QPaintEngine *paintEngine;
+ QScopedPointer<QPaintEngine> paintEngine;
bool in_memory_only;
QList<QImage> image_list;
QList<QPixmap> pixmap_list;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 82be1b9..f85e21a 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -1236,7 +1236,7 @@ bool QPixmap::convertFromImage(const QImage &image, ColorMode mode)
/*!
\relates QPixmap
- Writes the given \a pixmap to the the given \a stream as a PNG
+ Writes the given \a pixmap to the given \a stream as a PNG
image. Note that writing the stream to a file will not produce a
valid image file.
@@ -2021,4 +2021,99 @@ QPixmapData* QPixmap::pixmapData() const
return data;
}
+/*!
+ \enum QPixmap::HBitmapFormat
+
+ \bold{Win32 only:} This enum defines how the conversion between \c
+ HBITMAP and QPixmap is performed.
+
+ \warning This enum is only available on Windows.
+
+ \value NoAlpha The alpha channel is ignored and always treated as
+ being set to fully opaque. This is preferred if the \c HBITMAP is
+ used with standard GDI calls, such as \c BitBlt().
+
+ \value PremultipliedAlpha The \c HBITMAP is treated as having an
+ alpha channel and premultiplied colors. This is preferred if the
+ \c HBITMAP is accessed through the \c AlphaBlend() GDI function.
+
+ \value Alpha The \c HBITMAP is treated as having a plain alpha
+ channel. This is the preferred format if the \c HBITMAP is going
+ to be used as an application icon or systray icon.
+
+ \sa fromWinHBITMAP(), toWinHBITMAP()
+*/
+
+/*! \fn HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
+ \bold{Win32 only:} Creates a \c HBITMAP equivalent to the QPixmap,
+ based on the given \a format. Returns the \c HBITMAP handle.
+
+ It is the caller's responsibility to free the \c HBITMAP data
+ after use.
+
+ \warning This function is only available on Windows.
+
+ \sa fromWinHBITMAP()
+*/
+
+/*! \fn QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
+ \bold{Win32 only:} Returns a QPixmap that is equivalent to the
+ given \a bitmap. The conversion is based on the specified \a
+ format.
+
+ \warning This function is only available on Windows.
+
+ \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+
+*/
+
+/*! \fn const QX11Info &QPixmap::x11Info() const
+ \bold{X11 only:} Returns information about the configuration of
+ the X display used to display the widget.
+
+ \warning This function is only available on X11.
+
+ \sa {QPixmap#Pixmap Information}{Pixmap Information}
+*/
+
+/*! \fn Qt::HANDLE QPixmap::x11PictureHandle() const
+ \bold{X11 only:} Returns the X11 Picture handle of the pixmap for
+ XRender support.
+
+ This function will return 0 if XRender support is not compiled
+ into Qt, if the XRender extension is not supported on the X11
+ display, or if the handle could not be created. Use of this
+ function is not portable.
+
+ \warning This function is only available on X11.
+
+ \sa {QPixmap#Pixmap Information}{Pixmap Information}
+*/
+
+/*! \fn int QPixmap::x11SetDefaultScreen(int screen)
+ \internal
+*/
+
+/*! \fn void QPixmap::x11SetScreen(int screen)
+ \internal
+*/
+
+/*! \fn QRgb* QPixmap::clut() const
+ \internal
+*/
+
+/*! \fn int QPixmap::numCols() const
+ \internal
+*/
+
+/*! \fn const uchar* QPixmap::qwsBits() const
+ \internal
+ \since 4.1
+*/
+
+/*! \fn int QPixmap::qwsBytesPerLine() const
+ \internal
+ \since 4.1
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 1863273..9ef5347 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -62,6 +62,10 @@ class QX11Info;
class QPixmapData;
+#if defined(Q_OS_SYMBIAN)
+class CFbsBitmap;
+#endif
+
class Q_GUI_EXPORT QPixmap : public QPaintDevice
{
public:
@@ -152,6 +156,11 @@ public:
static QPixmap fromMacCGImageRef(CGImageRef image);
#endif
+#if defined(Q_OS_SYMBIAN)
+ CFbsBitmap *toSymbianCFbsBitmap() const;
+ static QPixmap fromSymbianCFbsBitmap(CFbsBitmap *bitmap);
+#endif
+
inline QPixmap copy(int x, int y, int width, int height) const;
QPixmap copy(const QRect &rect = QRect()) const;
diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp
index 6cc7981..7e383ab 100644
--- a/src/gui/image/qpixmap_qws.cpp
+++ b/src/gui/image/qpixmap_qws.cpp
@@ -109,9 +109,6 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
return QPixmap::fromImage(img);
}
-/*!
- \internal
-*/
QRgb* QPixmap::clut() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -122,9 +119,6 @@ QRgb* QPixmap::clut() const
return 0;
}
-/*!
- \internal
-*/
int QPixmap::numCols() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -135,10 +129,6 @@ int QPixmap::numCols() const
return 0;
}
-/*!
- \internal
- \since 4.1
-*/
const uchar* QPixmap::qwsBits() const
{
if (data->classId() == QPixmapData::RasterClass) {
@@ -149,10 +139,6 @@ const uchar* QPixmap::qwsBits() const
return 0;
}
-/*!
- \internal
- \since 4.1
-*/
int QPixmap::qwsBytesPerLine() const
{
if (data->classId() == QPixmapData::RasterClass) {
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index 625988a..132e26e 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -5,9 +5,40 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
+#include <exception>
#include <w32std.h>
#include <fbs.h>
@@ -61,14 +92,142 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
return QPixmap();
}
- QImage::Format format = qt_TDisplayMode2Format( displayMode );
- int bytesPerLine = CFbsBitmap::ScanLineLength(temporary->SizeInPixels().iWidth,displayMode);
- temporary->LockHeap();
- QImage image = QImage((uchar*)temporary->DataAddress(), srcRect.Width(), srcRect.Height(), bytesPerLine, format);
- QPixmap pixmap = QPixmap::fromImage(image.copy());
- temporary->UnlockHeap();
+ QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(temporary);
CBase::Delete(temporary);
return pixmap;
+}
+
+/*!
+\since 4.6
+
+Returns a \c CFbsBitmap that is equivalent to the QPixmap by copying the data.
+
+It is the caller's responsibility to delete the \c CFbsBitmap after use.
+
+\warning This function is only available on Symbian OS.
+
+\sa fromSymbianCFbsBitmap()
+*/
+
+CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const
+{
+ if (isNull())
+ return 0;
+
+ TDisplayMode mode;
+ const QImage img = toImage();
+ QImage::Format destFormat = img.format();
+ switch (img.format()) {
+ case QImage::Format_Mono:
+ destFormat = QImage::Format_MonoLSB;
+ // Fall through intended
+ case QImage::Format_MonoLSB:
+ mode = EGray2;
+ break;
+ case QImage::Format_Indexed8:
+ if (img.isGrayscale())
+ mode = EGray256;
+ else
+ mode = EColor256;
+ break;
+ case QImage::Format_RGB32:
+ mode = EColor16MU;
+ break;
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ destFormat = QImage::Format_ARGB32_Premultiplied;
+ // Fall through intended
+ case QImage::Format_ARGB32_Premultiplied:
+#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+ // ### TODO: Add runtime detection as well?
+ mode = EColor16MAP;
+ break;
+#endif
+ destFormat = QImage::Format_ARGB32;
+ // Fall through intended
+ case QImage::Format_ARGB32:
+ mode = EColor16MA;
+ break;
+ case QImage::Format_RGB555:
+ destFormat = QImage::Format_RGB16;
+ // Fall through intended
+ case QImage::Format_RGB16:
+ mode = EColor64K;
+ break;
+ case QImage::Format_RGB666:
+ destFormat = QImage::Format_RGB888;
+ // Fall through intended
+ case QImage::Format_RGB888:
+ mode = EColor16M;
+ break;
+ case QImage::Format_RGB444:
+ mode = EColor4K;
+ break;
+ case QImage::Format_Invalid:
+ return 0;
+ default:
+ qWarning("Image format not supported: %d", img.format());
+ return 0;
+ }
+
+ CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+ TSize size(width(), height());
+ if (bitmap->Create(size, mode) != KErrNone) {
+ CBase::Delete(bitmap);
+ return 0;
+ }
+
+ const QImage converted = img.convertToFormat(destFormat);
+
+ bitmap->LockHeap();
+ const uchar *sptr = converted.bits();
+ uchar *dptr = (uchar*)bitmap->DataAddress();
+ Mem::Copy(dptr, sptr, converted.numBytes());
+ bitmap->UnlockHeap();
+ return bitmap;
+}
+
+/*!
+\since 4.6
+
+Returns a QPixmap that is equivalent to the \c CFbsBitmap by copying the data.
+If the CFbsBitmap is not valid or is compressed in memory, this function will
+return a null QPixmap.
+
+\warning This function is only available on Symbian OS.
+
+\sa toSymbianCFbsBitmap(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+*/
+QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap)
+{
+ int width = bitmap->SizeInPixels().iWidth;
+ int height = bitmap->SizeInPixels().iHeight;
+
+ if (!bitmap || width <= 0 || height <= 0 || bitmap->IsCompressedInRAM())
+ return QPixmap();
+
+ TDisplayMode displayMode = bitmap->DisplayMode();
+ QImage::Format format = qt_TDisplayMode2Format(displayMode);
+ int bytesPerLine = CFbsBitmap::ScanLineLength(width, displayMode);
+ bitmap->LockHeap();
+ QImage image = QImage((const uchar*)bitmap->DataAddress(), width, height, bytesPerLine, format);
+ if (displayMode == EGray2) {
+ image.setNumColors(2);
+ image.setColor(0, QColor(Qt::color0).rgba());
+ image.setColor(1, QColor(Qt::color1).rgba());
+ } else if (displayMode == EGray256) {
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, qRgb(i, i, i));
+ }else if (displayMode == EColor256) {
+ const TColor256Util *palette = TColor256Util::Default();
+ for (int i=0; i < 256; ++i)
+ image.setColor(i, (QRgb)(palette->Color256(i).Value()));
+ }
+ QPixmap pixmap = QPixmap::fromImage(image.copy());
+ bitmap->UnlockHeap();
+ return pixmap;
}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index cbe9004..6a8b38a 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -119,42 +119,6 @@ QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
return pixmap;
}
-
-
-/*!
- \enum QPixmap::HBitmapFormat
-
- This enum defines how the conversion between \c HBITMAP
- and QPixmap is performed.
-
- \warning This enum is only available on Windows.
-
- \value NoAlpha The alpha channel is ignored and always treated as
- being set to fully opaque. This is preferred if the \c HBITMAP is
- used with standard GDI calls, such as \c BitBlt().
-
- \value PremultipliedAlpha The \c HBITMAP is treated as having an
- alpha channel and premultiplied colors. This is preferred if the
- \c HBITMAP is accessed through the \c AlphaBlend() GDI function.
-
- \value Alpha The \c HBITMAP is treated as having a plain alpha
- channel. This is the preferred format if the \c HBITMAP is going
- to be used as an application icon or systray icon.
-
- \sa fromWinHBITMAP(), toWinHBITMAP()
-*/
-
-/*!
- Creates a \c HBITMAP equivalent to the QPixmap, based on the given
- \a format. Returns the \c HBITMAP handle.
-
- It is the caller's responsibility to free the \c HBITMAP data
- after use.
-
- \warning This function is only available on Windows.
-
- \sa fromWinHBITMAP()
-*/
HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
{
HBITMAP bitmap = 0;
@@ -209,15 +173,6 @@ HBITMAP QPixmap::toWinHBITMAP(HBitmapFormat format) const
return bitmap;
}
-/*!
- Returns a QPixmap that is equivalent to the given \a bitmap. The
- conversion is based on the specified \a format.
-
- \warning This function is only available on Windows.
-
- \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
-
-*/
QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
{
// Verify size
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index 38916c7..d2e8d84 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -1914,9 +1914,6 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform,
}
}
-/*!
- \internal
-*/
int QPixmap::x11SetDefaultScreen(int screen)
{
int old = defaultScreen;
@@ -1924,9 +1921,6 @@ int QPixmap::x11SetDefaultScreen(int screen)
return old;
}
-/*!
- \internal
-*/
void QPixmap::x11SetScreen(int screen)
{
if (paintingActive()) {
@@ -2034,14 +2028,6 @@ bool QX11PixmapData::hasAlphaChannel() const
return d == 32;
}
-/*!
- Returns information about the configuration of the X display used to display
- the widget.
-
- \warning This function is only available on X11.
-
- \sa {QPixmap#Pixmap Information}{Pixmap Information}
-*/
const QX11Info &QPixmap::x11Info() const
{
if (data->classId() == QPixmapData::X11Class)
@@ -2098,20 +2084,6 @@ QPaintEngine* QX11PixmapData::paintEngine() const
return that->pengine;
}
-/*!
- Returns the X11 Picture handle of the pixmap for XRender
- support.
-
- This function will return 0 if XRender support is not compiled
- into Qt, if the XRender extension is not supported on the X11
- display, or if the handle could not be created. Use of this
- function is not portable.
-
- \warning This function is only available on X11.
-
- \sa {QPixmap#Pixmap Information}{Pixmap Information}
-*/
-
Qt::HANDLE QPixmap::x11PictureHandle() const
{
#ifndef QT_NO_XRENDER
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index c9973d0..4f71e09 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -323,7 +323,12 @@ void QPixmapCache::remove(const QString &key)
void QPixmapCache::clear()
{
- pm_cache()->clear();
+ QT_TRY {
+ pm_cache()->clear();
+ } QT_CATCH(const std::bad_alloc &) {
+ // if we ran out of memory during pm_cache(), it's no leak,
+ // so just ignore it.
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h
index 50f8a12..b33489e 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/gui/inputmethod/qcoefepinputcontext_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -62,7 +92,7 @@ public:
TCoeInputCapabilities inputCapabilities();
private:
- void commitCurrentString();
+ void commitCurrentString(bool triggeredBySymbian);
void updateHints();
void applyHints(Qt::InputMethodHints hints);
void applyFormat(QList<QInputMethodEvent::Attribute> *attributes);
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 8612e55..7d79422 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -58,10 +88,9 @@ QCoeFepInputContext::~QCoeFepInputContext()
// This is to make sure that the FEP manager "forgets" about us,
// otherwise we may get callbacks even after we're destroyed.
- // The call is asynchronous though, so we must spin the event loop
- // to make sure it gets detected.
- CCoeEnv::Static()->InputCapabilitiesChanged();
- QApplication::processEvents();
+ // The call below is essentially equivalent to InputCapabilitiesChanged(),
+ // but is synchronous, rather than asynchronous.
+ CCoeEnv::Static()->SyncNotifyFocusObserversOfChangeInFocus();
if (m_fepState)
delete m_fepState;
@@ -89,9 +118,7 @@ void QCoeFepInputContext::update()
void QCoeFepInputContext::setFocusWidget(QWidget *w)
{
- commitCurrentString();
-
- CCoeEnv::Static()->Fep()->CancelTransaction();
+ commitCurrentString(false);
QInputContext::setFocusWidget(w);
@@ -258,56 +285,17 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event)
void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event)
{
Q_ASSERT(m_isEditing);
+ Q_ASSERT(focusWidget());
- if (!m_pointerHandler) {
- QInputContext::mouseHandler(x, event);
- }
-
- TPointerEvent::TType type;
- TUint modifiers = 0;
-
- if (event->type() == QEvent::MouseButtonPress) {
- if (event->button() == Qt::LeftButton) {
- type = TPointerEvent::EButton1Down;
- } else if (event->button() == Qt::RightButton) {
- type = TPointerEvent::EButton3Down;
- } else if (event->button() == Qt::MidButton) {
- type = TPointerEvent::EButton2Down;
- } else {
- return;
- }
- } else if (event->type() == QEvent::MouseButtonRelease) {
- if (event->button() == Qt::LeftButton) {
- type = TPointerEvent::EButton1Up;
- } else if (event->button() == Qt::RightButton) {
- type = TPointerEvent::EButton3Up;
- } else if (event->button() == Qt::MidButton) {
- type = TPointerEvent::EButton2Up;
- } else {
- return;
- }
- } else if (event->type() == QEvent::MouseMove) {
- type = TPointerEvent::EMove;
- } else if (event->type() == QEvent::DragMove) {
- type = TPointerEvent::EDrag;
- } else {
- return;
- }
+ if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) {
+ commitCurrentString(false);
+ int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
- if (event->modifiers() & Qt::ShiftModifier) {
- modifiers |= EModifierShift;
- }
- if (event->modifiers() & Qt::AltModifier) {
- modifiers |= EModifierAlt;
- }
- if (event->modifiers() & Qt::ControlModifier) {
- modifiers |= EModifierCtrl;
- }
- if (event->modifiers() & Qt::KeypadModifier) {
- modifiers |= EModifierKeypad;
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant());
+ QInputMethodEvent event("", attributes);
+ sendEvent(event);
}
-
- m_pointerHandler->HandlePointerEventInInlineTextL(type, modifiers, x);
}
TCoeInputCapabilities QCoeFepInputContext::inputCapabilities()
@@ -341,6 +329,8 @@ void QCoeFepInputContext::updateHints()
m_lastImHints = hints;
applyHints(hints);
}
+ } else {
+ CCoeEnv::Static()->InputCapabilitiesChanged();
}
}
@@ -606,13 +596,13 @@ void QCoeFepInputContext::SetCursorSelectionForFepL(const TCursorSelection& aCur
if (!w)
return;
- int pos = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + aCursorSelection.iCursorPos + 1;
+ int pos = aCursorSelection.iAnchorPos;
+ int length = aCursorSelection.iCursorPos - pos;
QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1, QVariant());
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos, length, QVariant());
QInputMethodEvent event(m_preeditString, attributes);
- // ### FIXME Sets preeditcursor and not cursor. Probably needs new API.
- //sendEvent(event);
+ sendEvent(event);
}
void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
@@ -621,9 +611,8 @@ void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSele
if (!w)
return;
- QVariant cursorVar = w->inputMethodQuery(Qt::ImCursorPosition);
- int cursor = cursorVar.toInt() + m_preeditString.size();
- int anchor = cursor - w->inputMethodQuery(Qt::ImCurrentSelection).toString().size();
+ int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size();
+ int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size();
aCursorSelection.iAnchorPos = anchor;
aCursorSelection.iCursorPos = cursor;
}
@@ -679,12 +668,10 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin
void QCoeFepInputContext::DoCommitFepInlineEditL()
{
- commitCurrentString();
-
- m_isEditing = false;
+ commitCurrentString(true);
}
-void QCoeFepInputContext::commitCurrentString()
+void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian)
{
if (m_preeditString.size() == 0) {
return;
@@ -695,6 +682,12 @@ void QCoeFepInputContext::commitCurrentString()
event.setCommitString(m_preeditString, 0, 0);//m_preeditString.size());
m_preeditString.clear();
sendEvent(event);
+
+ m_isEditing = false;
+
+ if (!triggeredBySymbian) {
+ CCoeEnv::Static()->Fep()->CancelTransaction();
+ }
}
MCoeFepAwareTextEditor_Extension1* QCoeFepInputContext::Extension1(TBool& aSetToTrue)
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index e3e8aa4..d670f5a 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -759,7 +759,12 @@ void QInputContextPrivate::updateImeStatus(QWidget *w, bool hasFocus)
{
if (!w)
return;
- bool e = w->testAttribute(Qt::WA_InputMethodEnabled) && w->isEnabled();
+ // It's always the proxy that carries the hints.
+ QWidget *focusProxyWidget = w->focusProxy();
+ if (!focusProxyWidget)
+ focusProxyWidget = w;
+ bool e = w->testAttribute(Qt::WA_InputMethodEnabled) && w->isEnabled()
+ && !(focusProxyWidget->inputMethodHints() & Qt::ImhExclusiveInputMask);
bool hasIme = e && hasFocus;
#ifdef Q_IME_DEBUG
qDebug("%s HasFocus = %d hasIme = %d e = %d ", w->className(), hasFocus, hasIme, e);
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index c320fb4..60ea15b 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -610,7 +610,7 @@ void QXIMInputContext::setFocusWidget(QWidget *w)
QInputContext::setFocusWidget(w);
- if (!w)
+ if (!w || w->inputMethodHints() & Qt::ImhExclusiveInputMask)
return;
ICData *data = ximData.value(w->effectiveWinId());
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d1f3791..2576724 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -61,6 +61,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <qaccessible.h>
#endif
+#include <private/qactiontokeyeventmapper_p.h>
QT_BEGIN_NAMESPACE
@@ -1338,7 +1339,7 @@ QSize QAbstractItemView::iconSize() const
/*!
\property QAbstractItemView::textElideMode
- \brief the the position of the "..." in elided text.
+ \brief the position of the "..." in elided text.
The default value for all item views is Qt::ElideRight.
*/
@@ -2003,16 +2004,18 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event)
if (QApplication::keypadNavigationEnabled()) {
if (!hasEditFocus()) {
setEditFocus(true);
+ QActionToKeyEventMapper::addSoftKey(QAction::BackSoftKey, Qt::Key_Back, this);
return;
}
}
break;
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there
- if (QApplication::keypadNavigationEnabled() && hasEditFocus())
+ if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
+ QActionToKeyEventMapper::removeSoftkey(this);
setEditFocus(false);
- else
+ } else {
event->ignore();
+ }
return;
default:
if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
@@ -3221,9 +3224,9 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const
option.state &= ~QStyle::State_MouseOver;
option.font = font();
-#ifdef Q_WS_WIN
- // Note this is currently required on Windows
- // do give non-focused item views inactive appearance
+#ifndef Q_WS_MAC
+ // On mac the focus appearance follows window activation
+ // not widget activation
if (!hasFocus())
option.state &= ~QStyle::State_Active;
#endif
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 16bd1ab..c4bf4db 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -304,7 +304,7 @@ public:
*/
inline bool isPersistent(const QModelIndex &index) const
{
- return static_cast<QAbstractItemModelPrivate *>(model->d_ptr)->persistent.indexes.contains(index);
+ return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
}
QModelIndexList selectedDraggableIndexes() const;
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index ac62551..af4d42a 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -180,7 +180,6 @@ QFileIconProvider::QFileIconProvider()
QFileIconProvider::~QFileIconProvider()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/itemviews/qfileiconprovider.h b/src/gui/itemviews/qfileiconprovider.h
index 7928552..a6152ea 100644
--- a/src/gui/itemviews/qfileiconprovider.h
+++ b/src/gui/itemviews/qfileiconprovider.h
@@ -42,8 +42,9 @@
#ifndef QFILEICONPROVIDER_H
#define QFILEICONPROVIDER_H
-#include <QtGui/qicon.h>
#include <QtCore/qfileinfo.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qicon.h>
QT_BEGIN_HEADER
@@ -67,7 +68,7 @@ public:
private:
Q_DECLARE_PRIVATE(QFileIconProvider)
- QFileIconProviderPrivate *d_ptr;
+ QScopedPointer<QFileIconProviderPrivate> d_ptr;
Q_DISABLE_COPY(QFileIconProvider)
};
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index d373163..f888f5f 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1267,8 +1267,10 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order)
d->sortIndicatorSection = logicalIndex;
d->sortIndicatorOrder = order;
- if (logicalIndex >= d->sectionCount)
+ if (logicalIndex >= d->sectionCount) {
+ emit sortIndicatorChanged(logicalIndex, order);
return; // nothing to do
+ }
if (old != logicalIndex
&& ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents)
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp
index 147f523..fda6255 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/gui/itemviews/qitemdelegate.cpp
@@ -47,6 +47,7 @@
#include <qbrush.h>
#include <qlineedit.h>
#include <qtextedit.h>
+#include <qplaintextedit.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qpoint.h>
@@ -218,7 +219,7 @@ QSizeF QItemDelegatePrivate::doTextLayout(int lineWidth) const
editor widget, which is a widget that is placed on top of the view
while editing takes place. Editors are created with a
QItemEditorFactory; a default static instance provided by
- QItemEditorFactory is installed on all item delagates. You can set
+ QItemEditorFactory is installed on all item delegates. You can set
a custom factory using setItemEditorFactory() or set a new default
factory with QItemEditorFactory::setDefaultFactory(). It is the
data stored in the item model with the Qt::EditRole that is edited.
@@ -1194,7 +1195,7 @@ bool QItemDelegate::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Enter:
case Qt::Key_Return:
#ifndef QT_NO_TEXTEDIT
- if (qobject_cast<QTextEdit*>(editor))
+ if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
return false; // don't filter enter key events for QTextEdit
// We want the editor to be able to process the key press
// before committing the data (e.g. so it can do
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 7a366d1..bf3b43c 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -1158,7 +1158,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
/*!
\fn void QListWidget::addItem(QListWidgetItem *item)
- Inserts the \a item at the the end of the list widget.
+ Inserts the \a item at the end of the list widget.
\warning A QListWidgetItem can only be added to a
QListWidget once. Adding the same QListWidgetItem multiple
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 43feda8..92dfd19 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1518,7 +1518,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
d->clear_mapping();
reset();
- d->update_source_sort_column();
+ if (d->update_source_sort_column() && d->dynamic_sortfilter)
+ d->sort();
}
/*!
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp
index 61e410d..4ec00bb 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/gui/itemviews/qstandarditemmodel.cpp
@@ -778,8 +778,6 @@ QStandardItem &QStandardItem::operator=(const QStandardItem &other)
*/
QStandardItem::~QStandardItem()
{
- Q_D(QStandardItem);
- delete d;
}
/*!
diff --git a/src/gui/itemviews/qstandarditemmodel.h b/src/gui/itemviews/qstandarditemmodel.h
index f24f0ab..66d7576 100644
--- a/src/gui/itemviews/qstandarditemmodel.h
+++ b/src/gui/itemviews/qstandarditemmodel.h
@@ -240,7 +240,7 @@ protected:
QStandardItem(const QStandardItem &other);
QStandardItem(QStandardItemPrivate &dd);
QStandardItem &operator=(const QStandardItem &other);
- QStandardItemPrivate *d_ptr;
+ QScopedPointer<QStandardItemPrivate> d_ptr;
void emitDataChanged();
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp
index 4dc54a1..b75f151 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/gui/itemviews/qstyleditemdelegate.cpp
@@ -47,6 +47,7 @@
#include <qbrush.h>
#include <qlineedit.h>
#include <qtextedit.h>
+#include <qplaintextedit.h>
#include <qpainter.h>
#include <qpalette.h>
#include <qpoint.h>
@@ -646,7 +647,7 @@ bool QStyledItemDelegate::eventFilter(QObject *object, QEvent *event)
case Qt::Key_Enter:
case Qt::Key_Return:
#ifndef QT_NO_TEXTEDIT
- if (qobject_cast<QTextEdit*>(editor))
+ if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor))
return false; // don't filter enter key events for QTextEdit
// We want the editor to be able to process the key press
// before committing the data (e.g. so it can do
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 62c1277..1070648 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -246,7 +246,7 @@ void QTreeView::setModel(QAbstractItemModel *model)
connect(d->model, SIGNAL(modelAboutToBeReset()), SLOT(_q_modelAboutToBeReset()));
if (d->sortingEnabled)
- sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
+ d->_q_sortIndicatorChanged(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
}
/*!
@@ -846,17 +846,19 @@ void QTreeView::setExpanded(const QModelIndex &index, bool expanded)
void QTreeView::setSortingEnabled(bool enable)
{
Q_D(QTreeView);
- d->sortingEnabled = enable;
header()->setSortIndicatorShown(enable);
header()->setClickable(enable);
if (enable) {
+ //sortByColumn has to be called before we connect or set the sortingEnabled flag
+ // because otherwise it will not call sort on the model.
+ sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)));
- sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
} else {
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
this, SLOT(_q_sortIndicatorChanged(int, Qt::SortOrder)));
}
+ d->sortingEnabled = enable;
}
bool QTreeView::isSortingEnabled() const
diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp
index 6103225..0f2a27c 100644
--- a/src/gui/itemviews/qtreewidget.cpp
+++ b/src/gui/itemviews/qtreewidget.cpp
@@ -853,7 +853,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
items->replace(r, item);
for (int c = 0; c < colCount; ++c) {
QModelIndex from = createIndex(oldRow, c, item);
- if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
+ if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) {
QModelIndex to = createIndex(r, c, item);
fromList << from;
toList << to;
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.cpp b/src/gui/itemviews/qtreewidgetitemiterator.cpp
index 3e30e03..7e167b9 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/gui/itemviews/qtreewidgetitemiterator.cpp
@@ -97,7 +97,7 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFl
Q_ASSERT(widget);
QTreeModel *model = qobject_cast<QTreeModel*>(widget->model());
Q_ASSERT(model);
- d_ptr = new QTreeWidgetItemIteratorPrivate(this, model);
+ d_ptr.reset(new QTreeWidgetItemIteratorPrivate(this, model));
model->iterators.append(this);
if (!model->rootItem->children.isEmpty()) current = model->rootItem->children.first();
if (current && !matchesFlags(current))
@@ -150,7 +150,6 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidgetItem *item, Iterator
QTreeWidgetItemIterator::~QTreeWidgetItemIterator()
{
d_func()->m_model->iterators.removeAll(this);
- delete d_ptr;
}
/*!
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.h b/src/gui/itemviews/qtreewidgetitemiterator.h
index 8a76c69..535339d 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.h
+++ b/src/gui/itemviews/qtreewidgetitemiterator.h
@@ -43,6 +43,7 @@
#define QTREEWIDGETITEMITERATOR_H
#include <QtCore/qglobal.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -105,7 +106,7 @@ public:
private:
bool matchesFlags(const QTreeWidgetItem *item) const;
- QTreeWidgetItemIteratorPrivate *d_ptr;
+ QScopedPointer<QTreeWidgetItemIteratorPrivate> d_ptr;
QTreeWidgetItem *current;
IteratorFlags flags;
Q_DECLARE_PRIVATE(QTreeWidgetItemIterator)
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index abb17d7..b1db8d6 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -81,7 +81,8 @@ static QString qt_strippedText(QString s)
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
- menuRole(QAction::TextHeuristicRole), iconVisibleInMenu(-1)
+ menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::OptionsSoftKey),
+ iconVisibleInMenu(-1)
{
#ifdef QT3_SUPPORT
static int qt_static_action_id = -1;
@@ -1348,6 +1349,32 @@ QAction::MenuRole QAction::menuRole() const
}
/*!
+ \property QAction::softKeyRole
+ \brief the action's softkey role
+ \since 4.6
+
+ This indicates what softkey action this action is. Usually used on mobile
+ platforms to map QActions to hardware keys.
+
+ The softkey role can be changed any time.
+*/
+void QAction::setSoftKeyRole(SoftKeyRole softKeyRole)
+{
+ Q_D(QAction);
+ if (d->softKeyRole == softKeyRole)
+ return;
+
+ d->softKeyRole = softKeyRole;
+ d->sendDataChanged();
+}
+
+QAction::SoftKeyRole QAction::softKeyRole() const
+{
+ Q_D(const QAction);
+ return d->softKeyRole;
+}
+
+/*!
\property QAction::iconVisibleInMenu
\brief Whether or not an action should show an icon in a menu
\since 4.4
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index d7bf8c3..dfa4933 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/kernel/qaction.h
@@ -67,6 +67,7 @@ class Q_GUI_EXPORT QAction : public QObject
Q_DECLARE_PRIVATE(QAction)
Q_ENUMS(MenuRole)
+ Q_ENUMS(SoftKeyRole)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
@@ -84,11 +85,17 @@ class Q_GUI_EXPORT QAction : public QObject
#endif
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole)
+ Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole)
Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu)
public:
enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
AboutRole, PreferencesRole, QuitRole };
+ enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey,
+ OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey,
+ EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey,
+ MenuSoftKey, ContextMenuSoftKey, ExitSoftKey, Key1SoftKey, Key2SoftKey,
+ Key3SoftKey, Key4SoftKey, CustomSoftKey };
explicit QAction(QObject* parent);
QAction(const QString &text, QObject* parent);
QAction(const QIcon &icon, const QString &text, QObject* parent);
@@ -168,6 +175,9 @@ public:
void setMenuRole(MenuRole menuRole);
MenuRole menuRole() const;
+ void setSoftKeyRole(SoftKeyRole softKeyRole);
+ SoftKeyRole softKeyRole() const;
+
void setIconVisibleInMenu(bool visible);
bool isIconVisibleInMenu() const;
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index 0617ef5..6051d9a 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -102,6 +102,7 @@ public:
uint separator : 1;
uint fontSet : 1;
QAction::MenuRole menuRole;
+ QAction::SoftKeyRole softKeyRole;
int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
QList<QWidget *> widgets;
#ifndef QT_NO_GRAPHICSVIEW
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index fb002a3..aa6d21e 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -1006,7 +1006,8 @@ QApplication::~QApplication()
if (QWidgetPrivate::mapper) {
QWidgetMapper * myMapper = QWidgetPrivate::mapper;
QWidgetPrivate::mapper = 0;
- for (QWidgetMapper::Iterator it = myMapper->begin(); it != myMapper->end(); ++it) {
+ for (QWidgetMapper::ConstIterator it = myMapper->constBegin();
+ it != myMapper->constEnd(); ++it) {
register QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
@@ -1018,7 +1019,7 @@ QApplication::~QApplication()
if (QWidgetPrivate::uncreatedWidgets) {
QWidgetSet *mySet = QWidgetPrivate::uncreatedWidgets;
QWidgetPrivate::uncreatedWidgets = 0;
- for (QWidgetSet::Iterator it = mySet->begin(); it != mySet->end(); ++it) {
+ for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
register QWidget *w = *it;
if (!w->parent()) // window
w->destroy(true, true);
@@ -4764,7 +4765,7 @@ void QApplicationPrivate::emitLastWindowClosed()
If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus.
- This feature is available in Qt for Embedded Linux only.
+ This feature is available in Qt for Embedded Linux and Symbian only.
\sa keypadNavigationEnabled()
*/
@@ -4775,9 +4776,9 @@ void QApplication::setKeypadNavigationEnabled(bool enable)
/*!
Returns true if Qt is set to use keypad navigation; otherwise returns
- false. The default is false.
+ false. The default value is true on Symbian, but false on other platforms.
- This feature is available in Qt for Embedded Linux only.
+ This feature is available in Qt for Embedded Linux and Symbian only.
\sa setKeypadNavigationEnabled()
*/
@@ -4993,8 +4994,7 @@ void QApplication::setInputContext(QInputContext *inputContext)
qWarning("QApplication::setInputContext: called with 0 input context");
return;
}
- if (d->inputContext)
- delete d->inputContext;
+ delete d->inputContext;
d->inputContext = inputContext;
}
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index ca0eb98..e1b8b26 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -233,7 +233,8 @@ public:
#if defined(Q_WS_S60)
int s60ProcessEvent(TWsEvent *event);
virtual bool s60EventFilter(TWsEvent *aEvent);
- void s60HandleCommandL(int command);
+ void symbianHandleCommand(int command);
+ void symbianResourceChange(int type);
#endif
#if defined(Q_WS_QWS)
virtual bool qwsEventFilter(QWSEvent *);
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index a6fc602..35a532a 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -100,6 +100,7 @@ extern QSysInfo::MacVersion qt_macver;
#if defined(Q_WS_QWS)
class QWSManager;
class QDirectPainter;
+struct QWSServerCleaner { ~QWSServerCleaner(); };
#endif
#ifndef QT_NO_TABLET
@@ -382,6 +383,7 @@ public:
#ifdef Q_WS_QWS
QPointer<QWSManager> last_manager;
+ QWSServerCleaner qwsServerCleaner;
# ifndef QT_NO_DIRECTPAINTER
QMap<WId, QDirectPainter *> *directPainters;
# endif
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 018440f..aeebde4 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -159,6 +159,8 @@ bool qws_overrideCursor = false;
#ifndef QT_NO_QWS_MANAGER
#include "qdecorationfactory_qws.h"
+extern Q_GUI_EXPORT QWSServer *qwsServer;
+
QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
@@ -485,8 +487,13 @@ QList<QWSCommand*> *qt_get_server_queue()
void qt_server_enqueue(const QWSCommand *command)
{
QWSCommand *copy = QWSCommand::factory(command->type);
- copy->copyFrom(command);
- outgoing.append(copy);
+ QT_TRY {
+ copy->copyFrom(command);
+ outgoing.append(copy);
+ } QT_CATCH(...) {
+ delete copy;
+ QT_RETHROW;
+ }
}
QWSDisplay::Data::Data(QObject* parent, bool singleProcess)
@@ -2295,7 +2302,7 @@ void qt_init(QApplicationPrivate *priv, int type)
qws_decoration = QApplication::qwsSetDecoration(decoration);
#endif // QT_NO_QWS_MANAGER
#ifndef QT_NO_QWS_INPUTMETHODS
- qApp->setInputContext(new QWSInputContext);
+ qApp->setInputContext(new QWSInputContext(qApp));
#endif
}
@@ -3542,10 +3549,10 @@ bool QETWidget::translateKeyEvent(const QWSKeyEvent *event, bool grab) /* grab i
#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
if (type == QEvent::KeyPress && !grab
- && static_cast<QApplicationPrivate*>(qApp->d_ptr)->use_compat()) {
+ && static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->use_compat()) {
// send accel events if the keyboard is not grabbed
QKeyEvent a(type, code, state, text, autor, int(text.length()));
- if (static_cast<QApplicationPrivate*>(qApp->d_ptr)->qt_tryAccelEvent(this, &a))
+ if (static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->qt_tryAccelEvent(this, &a))
return true;
}
#else
@@ -3745,4 +3752,14 @@ void QApplication::setArgs(int c, char **v)
d->argv = v;
}
+/* \internal
+ This is used to clean up the qws server
+ in case the QApplication constructor threw an exception
+ */
+QWSServerCleaner::~QWSServerCleaner()
+{
+ if (qwsServer && qws_single_process)
+ QWSServer::closedown();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index dd51fcd..4c008fb 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -14,6 +44,7 @@
#include "qevent.h"
#include "qeventdispatcher_s60_p.h"
#include "qwidget.h"
+#include "qdesktopwidget.h"
#include "private/qbackingstore_p.h"
#include "qt_s60_p.h"
#include "private/qevent_p.h"
@@ -27,7 +58,7 @@
#endif
#include "private/qwindowsurface_s60_p.h"
#include "qpaintengine.h"
-#include "qmenubar.h"
+#include "private/qmenubar_p.h"
#include "apgwgnam.h" // For CApaWindowGroupName
#include <MdaAudioTonePlayer.h> // For CMdaAudioToneUtility
@@ -49,6 +80,8 @@ static bool appNoGrab = false; // Grabbing enabled
Q_GUI_EXPORT QS60Data *qt_s60Data = 0;
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*);
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
+
QWidget *qt_button_down = 0; // widget got last button-down
bool qt_nograb() // application no-grab option
@@ -201,7 +234,7 @@ static void mapS60MouseEventTypeToQt(QEvent::Type *type, Qt::MouseButton *button
*type = QEvent::MouseButtonDblClick;
}
- if (*type == QEvent::MouseButtonPress)
+ if (*type == QEvent::MouseButtonPress || *type == QEvent::MouseButtonDblClick)
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons | (*button);
else if (*type == QEvent::MouseButtonRelease)
QApplicationPrivate::mouse_buttons = QApplicationPrivate::mouse_buttons &(~(*button));
@@ -310,7 +343,7 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons
QMouseEvent mEvent(QEvent::MouseButtonPress, alienWidget->mapFrom(qwidget, widgetPos), globalPos,
Qt::RightButton, QApplicationPrivate::mouse_buttons, Qt::NoModifier);
sendMouseEvent(alienWidget, &mEvent);
- m_previousEventLongTap = true;
+ m_previousEventLongTap = false;
}
void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
@@ -339,7 +372,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
TPoint controlScreenPos = PositionRelativeToScreen();
QPoint globalPos = QPoint(controlScreenPos.iX, controlScreenPos.iY) + widgetPos;
- if (type == QEvent::MouseButtonPress)
+ if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick)
{
// get the button press target
alienWidget = qwidget->childAt(widgetPos);
@@ -359,7 +392,7 @@ void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
alienWidget = S60->mousePressTarget;
if (alienWidget != S60->lastPointerEventTarget)
- if (type == QEvent::MouseButtonPress || type == QEvent::MouseMove)
+ if (type == QEvent::MouseButtonPress || type == QEvent::MouseButtonDblClick || type == QEvent::MouseMove)
{
//moved to another widget, create enter and leave events
if (S60->lastPointerEventTarget)
@@ -408,6 +441,13 @@ void QSymbianControl::sendMouseEvent(QWidget *widget, QMouseEvent *mEvent)
TKeyResponse QSymbianControl::OfferKeyEventL(const TKeyEvent& keyEvent, TEventCode type)
{
+ TKeyResponse r = EKeyWasNotConsumed;
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(r = OfferKeyEvent(keyEvent, type));
+ return r;
+}
+
+TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCode type)
+{
switch (type) {
//case EEventKeyDown: // <-- Intentionally left out. See below.
case EEventKeyUp:
@@ -521,7 +561,14 @@ TKeyResponse QSymbianControl::sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent)
#ifndef QT_NO_IM
TCoeInputCapabilities QSymbianControl::InputCapabilities() const
{
- QWidget *w = qwidget->focusWidget();
+ QWidget *w = 0;
+
+ if(qwidget->hasFocus()) {
+ w = qwidget;
+ } else {
+ w = qwidget->focusWidget();
+ }
+
QCoeFepInputContext *ic;
if (w && w->isEnabled() && w->testAttribute(Qt::WA_InputMethodEnabled)
&& (ic = qobject_cast<QCoeFepInputContext *>(w->inputContext()))) {
@@ -639,21 +686,7 @@ void QSymbianControl::HandleResourceChange(int resourceType)
// font change event
break;
case KEikDynamicLayoutVariantSwitch:
- {
-#ifndef QT_NO_STYLE_S60
- QS60Style *s60Style = 0;
-
-#ifndef QT_NO_STYLE_STYLESHEET
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
- if (proxy)
- s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
- else
-#endif
- s60Style = qobject_cast<QS60Style*>(QApplication::style());
-
- if (s60Style)
- s60Style->handleDynamicLayoutVariantSwitch();
-#endif
+ {
if (qwidget->isFullScreen()) {
SetExtentToWholeScreen();
} else if (qwidget->isMaximized()) {
@@ -662,12 +695,6 @@ void QSymbianControl::HandleResourceChange(int resourceType)
}
break;
}
-#ifndef QT_NO_STYLE_S60
- case KAknsMessageSkinChange:
- if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
- s60Style->handleSkinChange();
- break;
-#endif
default:
break;
}
@@ -988,6 +1015,13 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
case EEventScreenDeviceChanged:
if (S60)
S60->updateScreenSize();
+ if (qt_desktopWidget) {
+ QSize oldSize = qt_desktopWidget->size();
+ qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
+ qt_desktopWidget->data->crect.setHeight(S60->screenHeightInPixels);
+ QResizeEvent e(qt_desktopWidget->size(), oldSize);
+ QApplication::sendEvent(qt_desktopWidget, &e);
+ }
return 0; // Propagate to CONE
case EEventWindowVisibilityChanged:
if (controlInMap) {
@@ -1001,6 +1035,7 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
} else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible)
&& !w->d_func()->maybeBackingStore()) {
w->d_func()->topData()->backingStore = new QWidgetBackingStore(w);
+ w->update();
}
return 1;
}
@@ -1020,17 +1055,67 @@ bool QApplication::s60EventFilter(TWsEvent *aEvent)
return false;
}
-void QApplication::s60HandleCommandL(int command)
+/*!
+ Handles commands which are typically handled by CAknAppUi::HandleCommandL()
+ Qts Ui integration into Symbian is partially achieved by deriving from CAknAppUi.
+ Currently, exit, menu and softkey commands are handled
+
+ \sa s60EventFilter(), s60ProcessEvent()
+*/
+void QApplication::symbianHandleCommand(int command)
{
switch (command) {
case EEikCmdExit:
- case EAknSoftkeyBack:
case EAknSoftkeyExit:
- qApp->exit();
+ exit();
+ break;
+ default:
+ if (command >= SOFTKEYSTART && command <= SOFTKEYEND) {
+ int index= command-SOFTKEYSTART;
+ QWidget* focused = QApplication::focusWidget();
+ const QList<QAction*>& softKeys = focused->softKeys();
+ Q_ASSERT(index<softKeys.count());
+ softKeys.at(index)->activate(QAction::Trigger);
+ }
+ else
+ QMenuBarPrivate::symbianCommands(command);
+ break;
+ }
+}
+
+void QApplication::symbianResourceChange(int type)
+{
+ switch (type) {
+ case KEikDynamicLayoutVariantSwitch:
+ {
+ if (S60)
+ S60->updateScreenSize();
+
+#ifndef QT_NO_STYLE_S60
+ QS60Style *s60Style = 0;
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplication::style());
+ if (proxy)
+ s60Style = qobject_cast<QS60Style*>(proxy->baseStyle());
+ else
+#endif
+ s60Style = qobject_cast<QS60Style*>(QApplication::style());
+
+ if (s60Style)
+ s60Style->handleDynamicLayoutVariantSwitch();
+#endif
+ }
break;
+
+#ifndef QT_NO_STYLE_S60
+ case KAknsMessageSkinChange:
+ if (QS60Style *s60Style = qobject_cast<QS60Style*>(QApplication::style()))
+ s60Style->handleSkinChange();
+ break;
+#endif
+
default:
- // For now assume all unknown menu items are Qt menu items
- QMenuBar::symbianCommands(command);
break;
}
}
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index f14ad6f..239ee14 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1675,20 +1675,23 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// send the context menu event is a different one
if (!alienWidget->testAttribute(Qt::WA_NativeWindow) && !alienWidget->testAttribute(Qt::WA_PaintOnScreen)) {
alienWidget = QApplication::widgetAt(globalPos);
- pos = alienWidget->mapFromGlobal(globalPos);
+ if (alienWidget)
+ pos = alienWidget->mapFromGlobal(globalPos);
}
- SHRGINFO shrg;
- shrg.cbSize = sizeof(shrg);
- shrg.hwndClient = hwnd;
- shrg.ptDown.x = GET_X_LPARAM(lParam);
- shrg.ptDown.y = GET_Y_LPARAM(lParam);
- shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
- resolveAygLibs();
- if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
- if (qApp->activePopupWidget())
- qApp->activePopupWidget()->close();
- QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
- result = qt_sendSpontaneousEvent(alienWidget, &e);
+ if (alienWidget) {
+ SHRGINFO shrg;
+ shrg.cbSize = sizeof(shrg);
+ shrg.hwndClient = hwnd;
+ shrg.ptDown.x = GET_X_LPARAM(lParam);
+ shrg.ptDown.y = GET_Y_LPARAM(lParam);
+ shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
+ resolveAygLibs();
+ if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
+ if (qApp->activePopupWidget())
+ qApp->activePopupWidget()->close();
+ QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos);
+ result = qt_sendSpontaneousEvent(alienWidget, &e);
+ }
}
}
}
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index a3c9406..12155f0 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -2955,10 +2955,10 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
Window wid = widget->internalWinId();
while (ctarget && !w) {
X11->ignoreBadwindow();
- XTranslateCoordinates(X11->display,
- QX11Info::appRootWindow(screen),
- ctarget, x, y, &unused, &unused, &ctarget);
- if (X11->badwindow())
+ if (!XTranslateCoordinates(X11->display,
+ QX11Info::appRootWindow(screen),
+ ctarget, x, y, &unused, &unused, &ctarget)
+ || X11->badwindow())
break;
if (ctarget == wid) {
// Found!
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 917b5d5..bab3449 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -466,7 +466,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
The \a mode argument is used to control which part of the system
clipboard is used. If \a mode is QClipboard::Clipboard, this
- function clears the the global clipboard contents. If \a mode is
+ function clears the global clipboard contents. If \a mode is
QClipboard::Selection, this function clears the global mouse
selection contents. If \a mode is QClipboard::FindBuffer, this
function clears the search string buffer.
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index ec595b5..f89f3e5 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index 9a24645..2ca6a3d 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -90,6 +90,7 @@
QT_BEGIN_NAMESPACE
extern void onApplicationChangedActivation(bool); // qapplication_mac.mm
+extern void qt_release_apple_event_handler(); //qapplication_mac.mm
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QDesktopWidgetImplementation)
@@ -207,7 +208,6 @@ static void cleanupCocoaApplicationDelegate()
{
Q_UNUSED(aNotification);
inLaunch = false;
- extern void qt_release_apple_event_handler(); //qapplication_mac.mm
qt_release_apple_event_handler();
}
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index c69826f..b2941fe 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -107,9 +107,16 @@ QT_USE_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- [self retain];
-
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]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 4ceae3f..f1a7f39 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -789,10 +789,22 @@ extern "C" {
bool wheelOK = false;
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
+ QWidget *widgetToGetMouse = qwidget;
+ if (widgetToGetMouse->testAttribute(Qt::WA_TransparentForMouseEvents)) {
+ // Simulate passing the event through since Cocoa doesn't do that for us.
+ // Start by building a tree up.
+ NSView *candidateView = [self viewUnderTransparentForMouseView:self
+ widget:widgetToGetMouse
+ withWindowPoint:windowPoint];
+ if (candidateView != nil) {
+ widgetToGetMouse = QWidget::find(WId(candidateView));
+ }
+ }
+
// Mouse wheel deltas seem to tick in at increments of 0.1. Qt widgets
- // expect the delta to be a multiple of 120.
+ // expect the delta to be a multiple of 120.
const int ScrollFactor = 10 * 120;
- // The qMax(...) factor reduces the
+ // The qMax(...) factor reduces the
// acceleration for large wheel deltas.
int deltaX = [theEvent deltaX] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaX]));
int deltaY = [theEvent deltaY] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaY]));
@@ -800,10 +812,10 @@ extern "C" {
if (deltaX != 0) {
QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
- qt_sendSpontaneousEvent(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaX, buttons, keyMods, Qt::Horizontal);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
@@ -813,10 +825,10 @@ extern "C" {
if (deltaY) {
QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical);
- qt_sendSpontaneousEvent(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaY, buttons, keyMods, Qt::Vertical);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
@@ -828,10 +840,10 @@ extern "C" {
// 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(qwidget, &qwe);
+ qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
wheelOK = qwe.isAccepted();
if (!wheelOK && QApplicationPrivate::focus_widget
- && QApplicationPrivate::focus_widget != qwidget) {
+ && QApplicationPrivate::focus_widget != widgetToGetMouse) {
QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
deltaZ, buttons, keyMods, (Qt::Orientation)3);
qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 983c762..527b1a6 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -59,6 +59,7 @@ QT_FORWARD_DECLARE_CLASS(QWidgetPrivate);
QT_FORWARD_DECLARE_CLASS(QWidget);
QT_FORWARD_DECLARE_CLASS(QEvent);
QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
+QT_FORWARD_DECLARE_CLASS(QStringList);
QT_BEGIN_NAMESPACE
struct DnDParams
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 89f481f..8e62f02 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -128,12 +128,19 @@ QT_USE_NAMESPACE
- (void)sendEvent:(NSEvent *)event
{
- [self retain];
-
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]);
-
// sometimes need to redirect mouse events to the popup.
QWidget *popup = qAppInstance()->activePopupWidget();
if (popup && popup != widget) {
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index c24abc4..21a4287 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -375,7 +375,9 @@ void QCursorData::cleanup()
return;
for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
- delete qt_cursorTable[shape];
+ // In case someone has a static QCursor defined with this shape
+ if (!qt_cursorTable[shape]->ref.deref())
+ delete qt_cursorTable[shape];
qt_cursorTable[shape] = 0;
}
QCursorData::initialized = false;
diff --git a/src/gui/kernel/qcursor_qws.cpp b/src/gui/kernel/qcursor_qws.cpp
index 097b982..99800a8 100644
--- a/src/gui/kernel/qcursor_qws.cpp
+++ b/src/gui/kernel/qcursor_qws.cpp
@@ -66,7 +66,11 @@ QCursorData::~QCursorData()
{
delete bm;
delete bmm;
- QPaintDevice::qwsDisplay()->destroyCursor(id);
+ QT_TRY {
+ QPaintDevice::qwsDisplay()->destroyCursor(id);
+ } QT_CATCH(const std::bad_alloc &) {
+ // do nothing.
+ }
}
diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/gui/kernel/qcursor_s60.cpp
index 4d3f067..a281130 100644
--- a/src/gui/kernel/qcursor_s60.cpp
+++ b/src/gui/kernel/qcursor_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index 029892e..eefd0ef 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -32,34 +62,58 @@ public:
static int screenCount;
static int primaryScreen;
+
+ static QVector<QRect> *rects;
+ static QVector<QRect> *workrects;
+
+ static int refcount;
};
int QDesktopWidgetPrivate::screenCount = 1;
int QDesktopWidgetPrivate::primaryScreen = 0;
+QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
+QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
+int QDesktopWidgetPrivate::refcount = 0;
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
{
+ ++refcount;
}
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
+ if (!--refcount)
+ cleanup();
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
- TInt screenCount=0;
- TInt result=0;
+ int screenCount=0;
+
+ if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
+ QDesktopWidgetPrivate::screenCount = screenCount;
+ else
+ QDesktopWidgetPrivate::screenCount = 0;
+
+ rects = new QVector<QRect>();
+ workrects = new QVector<QRect>();
- result = HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount);
- QDesktopWidgetPrivate::screenCount = screenCount;
- if( result != KErrNone)
- {
- // ### What to do if no screens found?
- }
+ rects->resize(QDesktopWidgetPrivate::screenCount);
+ workrects->resize(QDesktopWidgetPrivate::screenCount);
+
+ // ### TODO: Implement proper multi-display support
+ rects->resize(1);
+ rects->replace(0, that->rect());
+ workrects->resize(1);
+ workrects->replace(0, that->rect());
}
void QDesktopWidgetPrivate::cleanup()
{
+ delete rects;
+ rects = 0;
+ delete workrects;
+ workrects = 0;
}
@@ -120,6 +174,29 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
+ Q_D(QDesktopWidget);
+ QVector<QRect> oldrects;
+ oldrects = *d->rects;
+ QVector<QRect> oldworkrects;
+ oldworkrects = *d->workrects;
+ int oldscreencount = d->screenCount;
+
+ QDesktopWidgetPrivate::cleanup();
+ QDesktopWidgetPrivate::init(this);
+
+ for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
+ QRect oldrect = oldrects[i];
+ QRect newrect = d->rects->at(i);
+ if (oldrect != newrect)
+ emit resized(i);
+ }
+
+ for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
+ QRect oldrect = oldworkrects[j];
+ QRect newrect = d->workrects->at(j);
+ if (oldrect != newrect)
+ emit workAreaResized(j);
+ }
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/gui/kernel/qdnd_s60.cpp
index 09605be..c459f8f 100644
--- a/src/gui/kernel/qdnd_s60.cpp
+++ b/src/gui/kernel/qdnd_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 2aed287..ba85eea 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1665,6 +1665,17 @@ Qt::ButtonState QContextMenuEvent::state() const
several are specified for any character in the string the behaviour
is undefined.
+ \value Selection
+ If set, the edit cursor should be moved to the specified position
+ in the editor text contents. In contrast with \c Cursor, this
+ attribute does not work on the preedit text, but on the surrounding
+ text. The cursor will be moved after the commit string has been
+ committed, and the preedit string will be located at the new edit
+ position.
+ The start position specifies the new position and the length
+ variable can be used to set a selection starting from that point.
+ The value is unused.
+
\sa Attribute
*/
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 2724315..7696d05 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -424,7 +424,8 @@ public:
TextFormat,
Cursor,
Language,
- Ruby
+ Ruby,
+ Selection
};
class Attribute {
public:
diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/gui/kernel/qeventdispatcher_s60.cpp
index 862f4ef..fcf572e 100644
--- a/src/gui/kernel/qeventdispatcher_s60.cpp
+++ b/src/gui/kernel/qeventdispatcher_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -32,18 +62,22 @@ bool QEventDispatcherS60::processEvents ( QEventLoop::ProcessEventsFlags flags )
{
bool ret = false;
- bool oldNoInputEventsValue = m_noInputEvents;
- if (flags & QEventLoop::ExcludeUserInputEvents) {
- m_noInputEvents = true;
- } else {
- m_noInputEvents = false;
- ret = sendDeferredInputEvents() || ret;
+ QT_TRY {
+ bool oldNoInputEventsValue = m_noInputEvents;
+ if (flags & QEventLoop::ExcludeUserInputEvents) {
+ m_noInputEvents = true;
+ } else {
+ m_noInputEvents = false;
+ ret = sendDeferredInputEvents() || ret;
+ }
+
+ ret = QEventDispatcherSymbian::processEvents(flags) || ret;
+
+ m_noInputEvents = oldNoInputEventsValue;
+ } QT_CATCH (const std::exception& ex) {
+ CActiveScheduler::Current()->Error(qt_translateExceptionToSymbianError(ex));
}
- ret = QEventDispatcherSymbian::processEvents(flags) || ret;
-
- m_noInputEvents = oldNoInputEventsValue;
-
return ret;
}
diff --git a/src/gui/kernel/qeventdispatcher_s60_p.h b/src/gui/kernel/qeventdispatcher_s60_p.h
index fec8773..e42af95 100644
--- a/src/gui/kernel/qeventdispatcher_s60_p.h
+++ b/src/gui/kernel/qeventdispatcher_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp
index 2919551..bb074c1 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/gui/kernel/qkeymapper_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 352d26a..3bcf9e3 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -629,8 +629,6 @@ const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate
This enum represent standard key bindings. They can be used to
assign platform dependent keyboard shortcuts to a QAction.
- QKeyEvent also provides the function QKeyEvent::standardKey() to
- query if it matches an existing key binding.
Note that the key bindings are platform dependent. The currently
bound shortcuts can be queried using keyBindings().
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index 86894b4..7a19252 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -148,9 +148,8 @@ public:
QShortcutMap constructor.
*/
QShortcutMap::QShortcutMap()
+ : d_ptr(new QShortcutMapPrivate(this))
{
- d_ptr = new QShortcutMapPrivate(this);
- Q_ASSERT(d_ptr != 0);
resetState();
}
@@ -159,8 +158,6 @@ QShortcutMap::QShortcutMap()
*/
QShortcutMap::~QShortcutMap()
{
- delete d_ptr;
- d_ptr = 0;
}
/*! \internal
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index 3fe9546..28ee1f0 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_p.h
@@ -55,6 +55,7 @@
#include "QtGui/qkeysequence.h"
#include "QtCore/qvector.h"
+#include "QtCore/qscopedpointer.h"
QT_BEGIN_NAMESPACE
@@ -104,7 +105,7 @@ private:
#ifndef QT_NO_ACTION
bool correctContext(Qt::ShortcutContext context,QAction *a, QWidget *active_window) const;
#endif
- QShortcutMapPrivate *d_ptr;
+ QScopedPointer<QShortcutMapPrivate> d_ptr;
QKeySequence::SequenceMatch find(QKeyEvent *e);
QKeySequence::SequenceMatch matches(const QKeySequence &seq1, const QKeySequence &seq2) const;
diff --git a/src/gui/kernel/qsound_s60.cpp b/src/gui/kernel/qsound_s60.cpp
index 2ac7e26..00fc2fe 100644
--- a/src/gui/kernel/qsound_s60.cpp
+++ b/src/gui/kernel/qsound_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -116,10 +146,11 @@ QAuServer* qt_new_audio_server()
QAuBucketS60::QAuBucketS60( QAuServerS60 *server, QSound *sound )
: m_sound( sound ), m_server( server ), m_prepared(false), m_playCalled(false)
{
+ QString filepath = QFileInfo( m_sound->fileName() ).absoluteFilePath();
+ filepath = QDir::toNativeSeparators(filepath);
+ TPtrC filepathPtr(qt_QString2TPtrC(filepath));
TRAPD(err, m_playUtility = CMdaAudioPlayerUtility::NewL(*this);
- QString filepath = QFileInfo( m_sound->fileName() ).absoluteFilePath();
- filepath = QDir::toNativeSeparators(filepath);
- m_playUtility->OpenFileL(qt_QString2TPtrC(filepath)));
+ m_playUtility->OpenFileL(filepathPtr));
if(err){
m_server->playCompleted(this, err);
}
diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h
index 4eac35e..2d47a14 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/gui/kernel/qt_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -117,6 +147,7 @@ protected:
void FocusChanged(TDrawNow aDrawNow);
private:
+ TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType);
TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent);
void sendMouseEvent(QWidget *widget, QMouseEvent *mEvent);
void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
@@ -212,37 +243,40 @@ static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec)
static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode)
{
- QImage::Format format;
- switch(mode) {
- case EColor256:
- // TODO: is the correct?
- format = QImage::Format_Indexed8;
- break;
- case EColor4K:
- format = QImage::Format_RGB444;
- break;
- case EColor64K:
- format = QImage::Format_RGB16;
- break;
- case EColor16M:
- format = QImage::Format_RGB666;
- break;
- case EColor16MU:
- format = QImage::Format_RGB32;
- break;
- case EColor16MA:
- format = QImage::Format_ARGB32;
- break;
-#ifdef __S60_50__
- case EColor16MAP:
- format = QImage::Format_ARGB32_Premultiplied;
- break;
-#endif
- default:
- qFatal("Screen format not supported");
- break;
- }
- return format;
+ QImage::Format format;
+ switch(mode) {
+ case EGray2:
+ format = QImage::Format_MonoLSB;
+ break;
+ case EColor256:
+ case EGray256:
+ format = QImage::Format_Indexed8;
+ break;
+ case EColor4K:
+ format = QImage::Format_RGB444;
+ break;
+ case EColor64K:
+ format = QImage::Format_RGB16;
+ break;
+ case EColor16M:
+ format = QImage::Format_RGB666;
+ break;
+ case EColor16MU:
+ format = QImage::Format_RGB32;
+ break;
+ case EColor16MA:
+ format = QImage::Format_ARGB32;
+ break;
+#if !defined(__SERIES60_31__) && !defined(__S60_32__)
+ case EColor16MAP:
+ format = QImage::Format_ARGB32_Premultiplied;
+ break;
+#endif
+ default:
+ format = QImage::Format_Invalid;
+ break;
+ }
+ return format;
}
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 06f618d..a83a79f 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -172,7 +172,8 @@ extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version) :
- QObjectPrivate(version), extra(0), focus_child(0)
+ QObjectPrivate(version), extra(0),
+ focus_next(0), focus_prev(0), focus_child(0)
,layout(0), widgetItem(0)
,leftmargin(0), topmargin(0), rightmargin(0), bottommargin(0)
,leftLayoutItemMargin(0), topLayoutItemMargin(0), rightLayoutItemMargin(0)
@@ -884,6 +885,30 @@ void QWidget::setAutoFillBackground(bool enabled)
\endlist
\sa QEvent, QPainter, QGridLayout, QBoxLayout
+
+ \section1 SoftKeys
+ \since 4.6
+ \preliminary
+
+ Softkeys API is a platform independent way of mapping actions to (hardware)keys
+ and toolbars provided by the underlying platform.
+
+ There are three major use cases supported. First one is a mobile device
+ with keypad navigation and no touch ui. Second use case is a mobile
+ device with touch ui. Third use case is desktop. For now the softkey API is
+ only implemented for Series60.
+
+ QActions are set to widget(s) via softkey API. Actions in focused widget are
+ mapped to native toolbar or hardware keys. Even though the API allows to set
+ any amount of widgets there might be physical restrictions to amount of
+ softkeys that can be used by the device.
+
+ \o Series60: For series60 menu button is automatically mapped to left
+ soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy.
+
+ \sa softKeys()
+ \sa setSoftKey()
+
*/
QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
@@ -927,6 +952,23 @@ QRegion qt_dirtyRegion(QWidget *widget)
\endlist
*/
+struct QWidgetExceptionCleaner
+{
+ /* this cleans up when the constructor throws an exception */
+ static inline void cleanup(QWidget *that, QWidgetPrivate *d)
+ {
+#ifndef QT_NO_EXCEPTIONS
+ QWidgetPrivate::uncreatedWidgets->remove(that);
+ if (d->focus_next != that) {
+ if (d->focus_next)
+ d->focus_next->d_func()->focus_prev = d->focus_prev;
+ if (d->focus_prev)
+ d->focus_prev->d_func()->focus_next = d->focus_next;
+ }
+#endif
+ }
+};
+
/*!
Constructs a widget which is a child of \a parent, with widget
flags set to \a f.
@@ -956,7 +998,12 @@ QRegion qt_dirtyRegion(QWidget *widget)
QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
: QObject(*new QWidgetPrivate, 0), QPaintDevice()
{
- d_func()->init(parent, f);
+ QT_TRY {
+ d_func()->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
#ifdef QT3_SUPPORT
@@ -967,8 +1014,13 @@ QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
: QObject(*new QWidgetPrivate, 0), QPaintDevice()
{
- d_func()->init(parent , f);
- setObjectName(QString::fromAscii(name));
+ QT_TRY {
+ d_func()->init(parent , f);
+ setObjectName(QString::fromAscii(name));
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
#endif
@@ -977,7 +1029,13 @@ QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f)
: QObject(dd, 0), QPaintDevice()
{
- d_func()->init(parent, f);
+ Q_D(QWidget);
+ QT_TRY {
+ d->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
}
/*!
@@ -2046,17 +2104,20 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin
// Defined in qmacstyle_mac.cpp
extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush);
qt_mac_fill_background(painter, rgn, offset, brush);
-#elif defined(Q_WS_S60)
- // Defined in qs60style_symbian.cpp
- extern void qt_s60_fill_background(QPainter *painter, const QRegion &rgn,
- const QPoint &offset, const QBrush &brush);
- qt_s60_fill_background(painter, rgn, offset, brush);
#else
- const QRegion translated = rgn.translated(offset);
- const QRect rect(translated.boundingRect());
- painter->setClipRegion(translated);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
-#endif
+#if !defined(QT_NO_STYLE_S60)
+ // Defined in qs60style.cpp
+ extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn,
+ const QPoint &offset, const QBrush &brush);
+ if (!qt_s60_fill_background(painter, rgn, offset, brush))
+#endif // !defined(QT_NO_STYLE_S60)
+ {
+ const QRegion translated = rgn.translated(offset);
+ const QRect rect(translated.boundingRect());
+ painter->setClipRegion(translated);
+ painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
+ }
+#endif // Q_WS_MAC
} else {
const QVector<QRect> &rects = rgn.rects();
for (int i = 0; i < rects.size(); ++i)
@@ -2361,13 +2422,26 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
)
{
Q_Q(QWidget);
- createExtra();
-
QStyle *oldStyle = q->style();
#ifndef QT_NO_STYLE_STYLESHEET
- QStyle *origStyle = extra->style;
+ QStyle *origStyle = 0;
+#endif
+
+#ifdef Q_WS_MAC
+ // the metalhack boolean allows Qt/Mac to do a proper re-polish depending
+ // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever
+ // set when changing that attribute and passes the widget's CURRENT style.
+ // therefore no need to do a reassignment.
+ if (!metalHack)
+#endif
+ {
+ createExtra();
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ origStyle = extra->style;
#endif
- extra->style = newStyle;
+ extra->style = newStyle;
+ }
// repolish
if (q->windowType() != Qt::Desktop) {
@@ -4864,6 +4938,13 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
d->extra->inRenderWithPainter = false;
}
+#if !defined(Q_WS_S60)
+void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
+{
+ Q_UNUSED(softkeys)
+}
+#endif // !defined(Q_WS_S60)
+
bool QWidgetPrivate::isAboutToShow() const
{
if (data.in_show)
@@ -5052,7 +5133,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
#ifndef QT_NO_SCROLLAREA
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(q->parent());
if (scrollArea && scrollArea->viewport() == q) {
- QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr;
+ QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
scrollAreaOffset = priv->contentsOffset();
p.translate(-scrollAreaOffset);
@@ -5699,9 +5780,12 @@ bool QWidget::hasFocus() const
void QWidget::setFocus(Qt::FocusReason reason)
{
+ Q_D(QWidget);
+ d->setSoftKeys_sys(softKeys());
+
if (!isEnabled())
return;
-
+
QWidget *f = this;
while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
f = f->d_func()->extra->focus_proxy;
@@ -5809,8 +5893,9 @@ void QWidget::setFocus(Qt::FocusReason reason)
void QWidget::clearFocus()
{
QWidget *w = this;
- while (w && w->d_func()->focus_child == this) {
- w->d_func()->focus_child = 0;
+ while (w) {
+ if (w->d_func()->focus_child == this)
+ w->d_func()->focus_child = 0;
w = w->parentWidget();
}
#ifndef QT_NO_GRAPHICSVIEW
@@ -6287,7 +6372,7 @@ QByteArray QWidget::saveGeometry() const
returns false.
If the restored geometry is off-screen, it will be modified to be
- inside the the available screen geometry.
+ inside the available screen geometry.
To restore geometry saved using QSettings, you can use code like
this:
@@ -8484,6 +8569,9 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
return QRect(width()/2, 0, 1, height());
case Qt::ImFont:
return font();
+ case Qt::ImAnchorPosition:
+ // Fallback.
+ return inputMethodQuery(Qt::ImCursorPosition);
default:
return QVariant();
}
@@ -11490,6 +11578,66 @@ void QWidget::clearMask()
setMask(QRegion());
}
+/*!
+ \preliminary
+ \since 4.6
+
+ Returns the (possibly empty) list of this widget's softkeys.
+ Returned list cannot be changed. Softkeys should be added
+ and removed via method called setSoftKeys
+
+ \sa setSoftKey(), setSoftKeys()
+*/
+const QList<QAction*>& QWidget::softKeys() const
+{
+ Q_D(const QWidget);
+ if( d->softKeys.count() > 0)
+ return d->softKeys;
+ if (isWindow() || !parentWidget())
+ return d->softKeys;
+
+ return parentWidget()->softKeys();
+}
+
+/*!
+ \preliminary
+ \since 4.6
+
+ Sets the softkey \a softkey to this widget's list of softkeys,
+ Setting 0 as softkey will clear all the existing softkeys set
+ to the widget
+ A QWidget can have 0 or more softkeys
+
+ \sa softKeys(), setSoftKeys()
+*/
+void QWidget::setSoftKey(QAction *softKey)
+{
+ Q_D(QWidget);
+ qDeleteAll(d->softKeys);
+ d->softKeys.clear();
+ if (softKey)
+ d->softKeys.append(softKey);
+ if (QApplication::focusWidget() == this)
+ d->setSoftKeys_sys(this->softKeys());
+}
+
+/*!
+ Sets the list of softkeys \a softkeys to this widget's list of softkeys,
+ A QWidget can have 0 or more softkeys
+
+ \sa softKeys(), setSoftKey()
+*/
+void QWidget::setSoftKeys(const QList<QAction*> &softKeys)
+{
+ Q_D(QWidget);
+ qDeleteAll(d->softKeys);
+ d->softKeys.clear();
+ d->softKeys = softKeys;
+
+ if ((QApplication::focusWidget() == this) || (QApplication::focusWidget()==0))
+ d->setSoftKeys_sys(this->softKeys());
+}
+
/*! \fn const QX11Info &QWidget::x11Info() const
Returns information about the configuration of the X display used to display
the widget.
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 0dd470d..1edd466 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -554,6 +554,9 @@ public:
void removeAction(QAction *action);
QList<QAction*> actions() const;
#endif
+ const QList<QAction*>& softKeys() const;
+ void setSoftKey(QAction *softKey);
+ void setSoftKeys(const QList<QAction*> &softKeys);
QWidget *parentWidget() const;
@@ -728,6 +731,7 @@ private:
friend class QGraphicsProxyWidget;
friend class QGraphicsProxyWidgetPrivate;
friend class QStyleSheetStyle;
+ friend struct QWidgetExceptionCleaner;
#ifdef Q_WS_MAC
friend class QCoreGraphicsPaintEnginePrivate;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f863428..e2197c6 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -1215,7 +1215,7 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(widget->parent());
QPoint scrollAreaOffset;
if (scrollArea && scrollArea->viewport() == widget) {
- QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr);
+ QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr.data());
scrollAreaOffset = priv->contentsOffset();
p.translate(-scrollAreaOffset);
}
@@ -3600,11 +3600,15 @@ void QWidgetPrivate::raise_sys()
}
} else {
// Cocoa doesn't really have an idea of Z-ordering, but you can
- // fake it by changing the order of it.
+ // fake it by changing the order of it. But beware, removing an
+ // NSView will also remove it as the first responder. So we re-set
+ // the first responder just in case:
NSView *view = qt_mac_nativeview_for(q);
NSView *parentView = [view superview];
+ NSResponder *firstResponder = [[view window] firstResponder];
[view removeFromSuperview];
[parentView addSubview:view];
+ [[view window] makeFirstResponder:firstResponder];
}
#else
if(q->isWindow()) {
@@ -3642,6 +3646,7 @@ void QWidgetPrivate::lower_sys()
NSArray *tmpViews = [parentView subviews];
NSMutableArray *subviews = [[NSMutableArray alloc] initWithCapacity:[tmpViews count]];
[subviews addObjectsFromArray:tmpViews];
+ NSResponder *firstResponder = [[myview window] firstResponder];
// Implicit assumption that myViewIndex is included in subviews, that's why I'm not checking
// myViewIndex.
NSUInteger index = 0;
@@ -3661,6 +3666,7 @@ void QWidgetPrivate::lower_sys()
for (NSView *subview in subviews)
[parentView addSubview:subview];
[subviews release];
+ [[myview window] makeFirstResponder:firstResponder];
}
#else
if(q->isWindow()) {
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index d5f1b98..084439c 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -84,6 +84,9 @@ class RDrawableWindow;
class CCoeControl;
class CAknTitlePane;
class CAknContextPane;
+// The following 2 defines may only be needed for s60. To be seen.
+const int SOFTKEYSTART=5000;
+const int SOFTKEYEND=5004;
#endif
QT_BEGIN_NAMESPACE
@@ -224,6 +227,7 @@ public:
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
~QWidgetPrivate();
+ void setSoftKeys_sys(const QList<QAction*> &softkeys);
QWExtra *extraData() const;
QTLWExtra *topData() const;
QTLWExtra *maybeTopData() const;
@@ -511,6 +515,7 @@ public:
#ifndef QT_NO_ACTION
QList<QAction*> actions;
#endif
+ QList<QAction*> softKeys;
QLayout *layout;
QWidgetItemV2 *widgetItem;
#if !defined(QT_NO_IM)
diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp
index 1445f57..0073d3f 100644
--- a/src/gui/kernel/qwidget_qws.cpp
+++ b/src/gui/kernel/qwidget_qws.cpp
@@ -652,7 +652,8 @@ void QWidgetPrivate::hide_sys()
q->releaseMouse();
// requestWindowRegion(QRegion());
- extra->topextra->backingStore->releaseBuffer();
+ if (extra->topextra->backingStore)
+ extra->topextra->backingStore->releaseBuffer();
QWidget::qwsDisplay()->requestFocus(data.winid,false);
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index 5c3055d..bc69d6d 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -22,6 +52,8 @@
#include <qinputcontext.h>
+#include <aknappui.h>
+
QT_BEGIN_NAMESPACE
extern bool qt_nograb();
@@ -29,6 +61,56 @@ extern bool qt_nograb();
QWidget *QWidgetPrivate::mouseGrabber = 0;
QWidget *QWidgetPrivate::keyboardGrabber = 0;
+static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b)
+{
+ if ( a.count() != b.count())
+ return false;
+ int index=0;
+ while (index<a.count()) {
+ if (a.at(index)->softKeyRole() != b.at(index)->softKeyRole())
+ return false;
+ if (a.at(index)->text().compare(b.at(index)->text())!=0)
+ return false;
+ index++;
+ }
+ return true;
+}
+
+
+void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
+{
+ Q_Q(QWidget);
+ if (QApplication::focusWidget() && q!=QApplication::focusWidget()) {
+ QList<QAction *> old = QApplication::focusWidget()->softKeys();
+ if (isEqual(old, softkeys ))
+ return;
+ }
+ CCoeAppUi* appui = CEikonEnv::Static()->AppUi();
+ CAknAppUi* aknAppUi = static_cast <CAknAppUi*>(appui);
+ CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba();
+ nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+
+ int placeInScreen=0;
+ for (int index = 0; index < softkeys.count(); index++) {
+ const QAction* softKeyAction = softkeys.at(index);
+ if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) {
+
+ HBufC* text = qt_QString2HBufC(softKeyAction->text());
+ CleanupStack::PushL(text);
+ if (softKeyAction->softKeyRole() == QAction::MenuSoftKey) {
+ nativeContainer->SetCommandL(placeInScreen, EAknSoftkeyOptions, *text);
+ } else {
+ nativeContainer->SetCommandL(placeInScreen, SOFTKEYSTART + index, *text);
+ }
+ CleanupStack::PopAndDestroy();
+ placeInScreen++;
+ }
+ if (placeInScreen==1)
+ placeInScreen=2;
+ }
+ nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation
+}
+
void QWidgetPrivate::setWSGeometry(bool dontShow)
{
@@ -289,7 +371,8 @@ void QWidgetPrivate::hide_sys()
deactivateWidgetCleanup();
WId id = q->internalWinId();
if (q->isWindow() && id) {
- id->SetFocus(false);
+ if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ id->SetFocus(false);
id->MakeVisible(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
if (QWidgetBackingStore *bs = maybeBackingStore())
@@ -305,7 +388,8 @@ void QWidgetPrivate::setFocus_sys()
{
Q_Q(QWidget);
if (q->testAttribute(Qt::WA_WState_Created) && q->window()->windowType() != Qt::Popup)
- q->effectiveWinId()->SetFocus(true);
+ if(!q->effectiveWinId()->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ q->effectiveWinId()->SetFocus(true);
}
void QWidgetPrivate::raise_sys()
@@ -892,7 +976,8 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
releaseKeyboard();
if (destroyWindow && !(windowType() == Qt::Desktop) && internalWinId()) {
WId id = internalWinId();
- id->SetFocus(false);
+ if(id->IsFocused()) // Avoid unnecessry calls to FocusChanged()
+ id->SetFocus(false);
id->ControlEnv()->AppUi()->RemoveFromStack(id);
CBase::Delete(id);
@@ -973,5 +1058,4 @@ void QWidget::activateWindow()
rw->SetOrdinalPosition(0);
}
}
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 6202b35..6250fb77 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -1509,7 +1509,6 @@ QWidget *QWidget::keyboardGrabber()
void QWidget::activateWindow()
{
- Q_D(QWidget);
QWidget *tlw = window();
if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) {
if (X11->userTime == 0)
@@ -2487,6 +2486,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
QRect sr = valid_rect ? r : clipRect();
if (just_update)
q->update();
+ else if (!valid_rect)
+ dirty.translate(dx, dy);
int x1, y1, x2, y2, w = sr.width(), h = sr.height();
if (dx > 0) {
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 33d53e4..693e506 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -190,7 +190,8 @@ embedded {
symbian {
SOURCES += \
painting/qpaintdevice_s60.cpp \
- painting/qregion_s60.cpp
+ painting/qregion_s60.cpp \
+ painting/qcolormap_s60.cpp
}
x11|embedded {
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 854d0aa..c22791a 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -221,7 +221,7 @@ bool qHasPixmapTexture(const QBrush& brush)
{
if (brush.style() != Qt::TexturePattern)
return false;
- QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d);
+ QTexturedBrushData *tx_data = static_cast<QTexturedBrushData *>(brush.d.data());
return tx_data->m_has_pixmap_texture;
}
@@ -230,6 +230,37 @@ struct QGradientBrushData : public QBrushData
QGradient gradient;
};
+struct QBrushDataPointerHandler
+{
+ static inline void deleteData(QBrushData *d)
+ {
+ switch (d->style) {
+ case Qt::TexturePattern:
+ delete static_cast<QTexturedBrushData*>(d);
+ break;
+ case Qt::LinearGradientPattern:
+ case Qt::RadialGradientPattern:
+ case Qt::ConicalGradientPattern:
+ delete static_cast<QGradientBrushData*>(d);
+ break;
+ default:
+ delete d;
+ }
+ }
+
+ static inline void cleanup(QBrushData *d)
+ {
+ if (d && !d->ref.deref()) {
+ deleteData(d);
+ }
+ }
+
+ static inline void reset(QBrushData *&d, QBrushData *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
/*!
\class QBrush
@@ -364,20 +395,20 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
{
switch(style) {
case Qt::NoBrush:
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
if (d->color != color) setColor(color);
return;
case Qt::TexturePattern:
- d = new QTexturedBrushData;
+ d.data_ptr() = new QTexturedBrushData;
break;
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
- d = new QGradientBrushData;
+ d.data_ptr() = new QGradientBrushData;
break;
default:
- d = new QBrushData;
+ d.data_ptr() = new QBrushData;
break;
}
d->ref = 1;
@@ -391,8 +422,8 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
*/
QBrush::QBrush()
+ : d(nullBrushInstance())
{
- d = nullBrushInstance();
Q_ASSERT(d);
d->ref.ref();
}
@@ -435,7 +466,7 @@ QBrush::QBrush(Qt::BrushStyle style)
if (qbrush_check_type(style))
init(Qt::black, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -451,7 +482,7 @@ QBrush::QBrush(const QColor &color, Qt::BrushStyle style)
if (qbrush_check_type(style))
init(color, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -468,7 +499,7 @@ QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style)
if (qbrush_check_type(style))
init(color, style);
else {
- d = nullBrushInstance();
+ d.data_ptr() = nullBrushInstance();
d->ref.ref();
}
}
@@ -510,8 +541,8 @@ QBrush::QBrush(Qt::GlobalColor color, const QPixmap &pixmap)
*/
QBrush::QBrush(const QBrush &other)
+ : d(other.d.data())
{
- d = other.d;
d->ref.ref();
}
@@ -535,7 +566,7 @@ QBrush::QBrush(const QGradient &gradient)
};
init(QColor(), enum_table[gradient.type()]);
- QGradientBrushData *grad = static_cast<QGradientBrushData *>(d);
+ QGradientBrushData *grad = static_cast<QGradientBrushData *>(d.data());
grad->gradient = gradient;
}
@@ -545,24 +576,11 @@ QBrush::QBrush(const QGradient &gradient)
QBrush::~QBrush()
{
- if (!d->ref.deref())
- cleanUp(d);
}
void QBrush::cleanUp(QBrushData *x)
{
- switch (x->style) {
- case Qt::TexturePattern:
- delete static_cast<QTexturedBrushData*>(x);
- break;
- case Qt::LinearGradientPattern:
- case Qt::RadialGradientPattern:
- case Qt::ConicalGradientPattern:
- delete static_cast<QGradientBrushData*>(x);
- break;
- default:
- delete x;
- }
+ QBrushDataPointerHandler::deleteData(x);
}
@@ -571,38 +589,36 @@ void QBrush::detach(Qt::BrushStyle newStyle)
if (newStyle == d->style && d->ref == 1)
return;
- QBrushData *x;
+ QScopedPointer<QBrushData> x;
switch(newStyle) {
case Qt::TexturePattern: {
QTexturedBrushData *tbd = new QTexturedBrushData;
if (d->style == Qt::TexturePattern) {
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
if (data->m_has_pixmap_texture)
tbd->setPixmap(data->pixmap());
else
tbd->setImage(data->image());
}
- x = tbd;
+ x.reset(tbd);
break;
}
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
- x = new QGradientBrushData;
- static_cast<QGradientBrushData *>(x)->gradient =
- static_cast<QGradientBrushData *>(d)->gradient;
+ x.reset(new QGradientBrushData);
+ static_cast<QGradientBrushData *>(x.data())->gradient =
+ static_cast<QGradientBrushData *>(d.data())->gradient;
break;
default:
- x = new QBrushData;
+ x.reset(new QBrushData);
break;
}
x->ref = 1;
x->style = newStyle;
x->color = d->color;
x->transform = d->transform;
- if (!d->ref.deref())
- cleanUp(d);
- d = x;
+ d.reset(x.take());
}
@@ -615,10 +631,11 @@ void QBrush::detach(Qt::BrushStyle newStyle)
QBrush &QBrush::operator=(const QBrush &b)
{
+ if (this == &b)
+ return *this;
+
b.d->ref.ref();
- if (!d->ref.deref())
- cleanUp(d);
- d = b.d;
+ d.reset(b.d.data());
return *this;
}
@@ -713,7 +730,7 @@ QPixmap *QBrush::pixmap() const
{
if (d->style != Qt::TexturePattern)
return 0;
- QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d.data());
QPixmap &pixmap = data->pixmap();
return pixmap.isNull() ? 0 : &pixmap;
}
@@ -730,7 +747,7 @@ QPixmap *QBrush::pixmap() const
QPixmap QBrush::texture() const
{
return d->style == Qt::TexturePattern
- ? ((QTexturedBrushData*) d)->pixmap()
+ ? (static_cast<QTexturedBrushData *>(d.data()))->pixmap()
: QPixmap();
}
@@ -748,7 +765,7 @@ void QBrush::setTexture(const QPixmap &pixmap)
{
if (!pixmap.isNull()) {
detach(Qt::TexturePattern);
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
data->setPixmap(pixmap);
} else {
detach(Qt::NoBrush);
@@ -771,7 +788,7 @@ void QBrush::setTexture(const QPixmap &pixmap)
QImage QBrush::textureImage() const
{
return d->style == Qt::TexturePattern
- ? ((QTexturedBrushData *) d)->image()
+ ? (static_cast<QTexturedBrushData *>(d.data()))->image()
: QImage();
}
@@ -796,7 +813,7 @@ void QBrush::setTextureImage(const QImage &image)
{
if (!image.isNull()) {
detach(Qt::TexturePattern);
- QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d);
+ QTexturedBrushData *data = static_cast<QTexturedBrushData *>(d.data());
data->setImage(image);
} else {
detach(Qt::NoBrush);
@@ -812,7 +829,7 @@ const QGradient *QBrush::gradient() const
if (d->style == Qt::LinearGradientPattern
|| d->style == Qt::RadialGradientPattern
|| d->style == Qt::ConicalGradientPattern) {
- return &static_cast<const QGradientBrushData *>(d)->gradient;
+ return &static_cast<const QGradientBrushData *>(d.data())->gradient;
}
return 0;
}
@@ -923,16 +940,16 @@ bool QBrush::operator==(const QBrush &b) const
if (b.d->style == d->style && b.d->color == d->color) {
switch (d->style) {
case Qt::TexturePattern: {
- QPixmap &us = ((QTexturedBrushData *) d)->pixmap();
- QPixmap &them = ((QTexturedBrushData *) b.d)->pixmap();
+ QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap();
+ QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap();
return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey());
}
case Qt::LinearGradientPattern:
case Qt::RadialGradientPattern:
case Qt::ConicalGradientPattern:
{
- QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d);
- QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d);
+ QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data());
+ QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data());
return d1->gradient == d2->gradient;
}
default:
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index d6d0da3..b3aa04d 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -45,6 +45,7 @@
#include <QtCore/qpair.h>
#include <QtCore/qpoint.h>
#include <QtCore/qvector.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qcolor.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -61,6 +62,7 @@ struct QBrushData;
class QPixmap;
class QGradient;
class QVariant;
+struct QBrushDataPointerHandler;
class Q_GUI_EXPORT QBrush
{
@@ -126,13 +128,13 @@ private:
friend bool qHasPixmapTexture(const QBrush& brush);
void detach(Qt::BrushStyle newStyle);
void init(const QColor &color, Qt::BrushStyle bs);
- QBrushData *d;
+ QScopedCustomPointer<QBrushData, QBrushDataPointerHandler> d;
void cleanUp(QBrushData *x);
public:
inline bool isDetached() const;
typedef QBrushData * DataPtr;
- inline DataPtr &data_ptr() { return d; }
+ inline DataPtr &data_ptr() { return d.data_ptr(); }
};
inline void QBrush::setColor(Qt::GlobalColor acolor)
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 1723a19..c50004e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2241,4 +2241,12 @@ QDataStream &operator>>(QDataStream &stream, QColor &color)
\sa QColor::rgb(), QColor::rgba()
*/
+/*! \fn void QColormap::initialize()
+ \internal
+*/
+
+/*! \fn void QColormap::cleanup()
+ \internal
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/gui/painting/qcolormap_s60.cpp
new file mode 100644
index 0000000..1b58598
--- /dev/null
+++ b/src/gui/painting/qcolormap_s60.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcolormap.h"
+#include "qcolor.h"
+
+QT_BEGIN_NAMESPACE
+
+class QColormapPrivate
+{
+public:
+ inline QColormapPrivate()
+ : ref(1)
+ { }
+
+ QAtomicInt ref;
+};
+
+void QColormap::initialize()
+{
+}
+
+void QColormap::cleanup()
+{
+}
+
+QColormap QColormap::instance(int)
+{
+ return QColormap();
+}
+
+QColormap::QColormap() : d(new QColormapPrivate)
+{}
+
+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 QColormap::Direct; }
+
+int QColormap::depth() const
+{
+ return 32;
+}
+
+int QColormap::size() const
+{
+ return -1;
+}
+
+uint QColormap::pixel(const QColor &color) const
+{ return color.rgba(); }
+
+const QColor QColormap::colorAt(uint pixel) const
+{ return QColor(pixel); }
+
+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/qcolormap_x11.cpp b/src/gui/painting/qcolormap_x11.cpp
index ccf6955..c9186b1 100644
--- a/src/gui/painting/qcolormap_x11.cpp
+++ b/src/gui/painting/qcolormap_x11.cpp
@@ -337,8 +337,6 @@ static void init_direct(QColormapPrivate *d, bool ownColormap)
static QColormap **cmaps = 0;
-/*! \internal
-*/
void QColormap::initialize()
{
Display *display = QX11Info::display();
@@ -578,8 +576,6 @@ void QColormap::initialize()
}
}
-/*! \internal
-*/
void QColormap::cleanup()
{
Display *display = QX11Info::display();
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index ed4dd57..0b5e5bb 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -7426,8 +7426,8 @@ void qt_build_pow_tables() {
}
#else
for (int i=0; i<256; ++i) {
- qt_pow_rgb_gamma[i] = uchar(qRound(pow(i / 255.0, smoothing) * 255));
- qt_pow_rgb_invgamma[i] = uchar(qRound(pow(i / 255.0, 1 / smoothing) * 255));
+ qt_pow_rgb_gamma[i] = uchar(qRound(pow(i / qreal(255), smoothing) * 255));
+ qt_pow_rgb_invgamma[i] = uchar(qRound(pow(i / qreal(255), 1 / smoothing) * 255));
}
#endif
diff --git a/src/gui/painting/qpaintdevice_s60.cpp b/src/gui/painting/qpaintdevice_s60.cpp
index ec1b765..a2c4499 100644
--- a/src/gui/painting/qpaintdevice_s60.cpp
+++ b/src/gui/painting/qpaintdevice_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index 7de1ec4..c5be802 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -713,7 +713,6 @@ QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps)
*/
QPaintEngine::~QPaintEngine()
{
- delete d_ptr;
}
/*!
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index 520f71f..6f56adb 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -44,6 +44,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpainter.h>
QT_BEGIN_HEADER
@@ -239,7 +240,7 @@ protected:
uint selfDestruct : 1;
uint extended : 1;
- QPaintEnginePrivate *d_ptr;
+ QScopedPointer<QPaintEnginePrivate> d_ptr;
private:
void setAutoDestruct(bool autoDestr) { selfDestruct = autoDestr; }
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 1192a58..ada3ebf 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -349,6 +349,7 @@ void QRasterPaintEngine::init()
#else
(unsigned char *) malloc(d->rasterPoolSize);
#endif
+ Q_CHECK_PTR(d->rasterPoolBase);
// The antialiasing raster.
d->grayRaster = new QT_FT_Raster;
@@ -1055,7 +1056,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = x + iw - cx2;
iw -= d;
}
- if (iw < 0)
+ if (iw <= 0)
return;
// adapt the y paremeters...
@@ -1072,7 +1073,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
int d = y + ih - cy2;
ih -= d;
}
- if (ih < 0)
+ if (ih <= 0)
return;
// call the blend function...
@@ -3878,11 +3879,7 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
{
Q_ASSERT(c1->clipSpanHeight == c2->clipSpanHeight && c1->clipSpanHeight == result->clipSpanHeight);
- // ### buffer overflow possible
- const int BUFFER_SIZE = 4096;
- int buffer[BUFFER_SIZE];
- int *b = buffer;
- int bsize = BUFFER_SIZE;
+ QVarLengthArray<short, 4096> buffer;
QClipData::ClipLine *c1ClipLines = const_cast<QClipData *>(c1)->clipLines();
QClipData::ClipLine *c2ClipLines = const_cast<QClipData *>(c2)->clipLines();
@@ -3908,12 +3905,9 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
// find required length
int max = qMax(c1_spans[c1_count - 1].x + c1_spans[c1_count - 1].len,
- c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len);
- if (max > bsize) {
- b = (int *)realloc(bsize == BUFFER_SIZE ? 0 : b, max*sizeof(int));
- bsize = max;
- }
- memset(buffer, 0, BUFFER_SIZE * sizeof(int));
+ c2_spans[c2_count - 1].x + c2_spans[c2_count - 1].len);
+ buffer.resize(max);
+ memset(buffer.data(), 0, buffer.size() * sizeof(short));
// Fill with old spans.
for (int i = 0; i < c1_count; ++i) {
@@ -3949,8 +3943,6 @@ static void qt_merge_clip(const QClipData *c1, const QClipData *c2, QClipData *r
result->appendSpan(sx, x - sx, y, coverage);
}
}
- if (b != buffer)
- free(b);
}
void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data)
@@ -3967,7 +3959,7 @@ void QRasterPaintEnginePrivate::initializeRasterizer(QSpanData *data)
const QClipData *c = clip();
if (c) {
const QRect r(QPoint(c->xmin, c->ymin),
- QPoint(c->xmax, c->ymax));
+ QPoint(c->xmax, c->ymax));
clipRect = clipRect.intersected(r);
blend = data->blend;
} else {
@@ -4075,6 +4067,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline,
#else
(unsigned char *) malloc(rasterPoolSize);
#endif
+ Q_CHECK_PTR(rasterPoolBase); // note: we just freed the old rasterPoolBase. I hope it's not fatal.
qt_ft_grays_raster.raster_done(*grayRaster);
qt_ft_grays_raster.raster_new(0, grayRaster);
@@ -4310,93 +4303,107 @@ void QClipData::initialize()
return;
m_clipLines = (ClipLine *)calloc(sizeof(ClipLine), clipSpanHeight);
- m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan));
+ Q_CHECK_PTR(m_clipLines);
+ QT_TRY {
+ m_spans = (QSpan *)malloc(clipSpanHeight*sizeof(QSpan));
+ Q_CHECK_PTR(m_spans);
+
+ QT_TRY {
+ if (hasRectClip) {
+ int y = 0;
+ while (y < ymin) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- if (hasRectClip) {
- int y = 0;
- while (y < ymin) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
+ const int len = clipRect.width();
+ count = 0;
+ while (y < ymax) {
+ QSpan *span = m_spans + count;
+ span->x = xmin;
+ span->len = len;
+ span->y = y;
+ span->coverage = 255;
+ ++count;
- const int len = clipRect.width();
- count = 0;
- while (y < ymax) {
- QSpan *span = m_spans + count;
- span->x = xmin;
- span->len = len;
- span->y = y;
- span->coverage = 255;
- ++count;
-
- m_clipLines[y].spans = span;
- m_clipLines[y].count = 1;
- ++y;
- }
+ m_clipLines[y].spans = span;
+ m_clipLines[y].count = 1;
+ ++y;
+ }
- while (y < clipSpanHeight) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
- } else if (hasRegionClip) {
+ while (y < clipSpanHeight) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
+ } else if (hasRegionClip) {
+
+ const QVector<QRect> rects = clipRegion.rects();
+ const int numRects = rects.size();
+
+ { // resize
+ const int maxSpans = (ymax - ymin) * numRects;
+ if (maxSpans > allocated) {
+ QSpan *newSpans = (QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan));
+ Q_CHECK_PTR(newSpans);
+ m_spans = newSpans;
+ allocated = maxSpans;
+ }
+ }
- const QVector<QRect> rects = clipRegion.rects();
- const int numRects = rects.size();
+ int y = 0;
+ int firstInBand = 0;
+ while (firstInBand < numRects) {
+ const int currMinY = rects.at(firstInBand).y();
+ const int currMaxY = currMinY + rects.at(firstInBand).height();
- { // resize
- const int maxSpans = (ymax - ymin) * numRects;
- if (maxSpans > allocated) {
- m_spans = (QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan));
- allocated = maxSpans;
- }
- }
+ while (y < currMinY) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- int y = 0;
- int firstInBand = 0;
- while (firstInBand < numRects) {
- const int currMinY = rects.at(firstInBand).y();
- const int currMaxY = currMinY + rects.at(firstInBand).height();
+ int lastInBand = firstInBand;
+ while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
+ ++lastInBand;
- while (y < currMinY) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
- }
+ while (y < currMaxY) {
- int lastInBand = firstInBand;
- while (lastInBand + 1 < numRects && rects.at(lastInBand+1).top() == y)
- ++lastInBand;
+ m_clipLines[y].spans = m_spans + count;
+ m_clipLines[y].count = lastInBand - firstInBand + 1;
- while (y < currMaxY) {
-
- m_clipLines[y].spans = m_spans + count;
- m_clipLines[y].count = lastInBand - firstInBand + 1;
+ for (int r = firstInBand; r <= lastInBand; ++r) {
+ const QRect &currRect = rects.at(r);
+ QSpan *span = m_spans + count;
+ span->x = currRect.x();
+ span->len = currRect.width();
+ span->y = y;
+ span->coverage = 255;
+ ++count;
+ }
+ ++y;
+ }
- for (int r = firstInBand; r <= lastInBand; ++r) {
- const QRect &currRect = rects.at(r);
- QSpan *span = m_spans + count;
- span->x = currRect.x();
- span->len = currRect.width();
- span->y = y;
- span->coverage = 255;
- ++count;
+ firstInBand = lastInBand + 1;
}
- ++y;
- }
- firstInBand = lastInBand + 1;
- }
+ Q_ASSERT(count <= allocated);
- Q_ASSERT(count <= allocated);
+ while (y < clipSpanHeight) {
+ m_clipLines[y].spans = 0;
+ m_clipLines[y].count = 0;
+ ++y;
+ }
- while (y < clipSpanHeight) {
- m_clipLines[y].spans = 0;
- m_clipLines[y].count = 0;
- ++y;
+ }
+ } QT_CATCH(...) {
+ free(m_spans);
+ QT_RETHROW;
}
-
+ } QT_CATCH(...) {
+ free(m_clipLines);
+ QT_RETHROW;
}
}
@@ -4773,8 +4780,10 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData)
&newspans, newClip->allocated - newClip->count);
newClip->count = newspans - newClip->m_spans;
if (spans < end) {
+ QSpan *newSpan = (QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan));
+ Q_CHECK_PTR(newSpan);
+ newClip->m_spans = newSpan;
newClip->allocated *= 2;
- newClip->m_spans = (QSpan *)realloc(newClip->m_spans, newClip->allocated*sizeof(QSpan));
}
}
}
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 9cc9683..2e6d593 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -1826,9 +1826,10 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
const int h = rect.height();
QImage im;
- if ((QSysInfo::ByteOrder == QSysInfo::BigEndian
- && ((ImageByteOrder(X11->display) == LSBFirst) || bgr_layout))
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
+ int image_byte_order = ImageByteOrder(X11->display);
+ if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
{
im = image.copy(rect);
const int iw = im.bytesPerLine() / 4;
@@ -1836,19 +1837,21 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
for (int i=0; i < h; i++) {
uint *p = data;
uint *end = p + w;
- if (bgr_layout && ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
+ if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
while (p < end) {
*p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if ((ImageByteOrder(X11->display) == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
+ } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
while (p < end) {
*p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
| ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
+ {
while (p < end) {
*p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
| ((*p ) & 0xff00ff00);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index cc48d24..0caf13b 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -83,6 +83,21 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
bool qt_show_painter_debug_output = true;
#endif
+class QPainterPrivateCleaner
+{
+public:
+ static inline void cleanup(QPainterPrivate *d)
+ {
+ delete d;
+ }
+
+ static inline void reset(QPainterPrivate *&d, QPainterPrivate *other)
+ {
+ delete d;
+ d = other;
+ }
+};
+
extern QPixmap qt_pixmapForBrush(int style, bool invert);
void qt_format_text(const QFont &font,
@@ -259,14 +274,17 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
// in 99% of all cases). E.g: A renders B which renders C which renders D.
sp->d_ptr->d_ptrs_size = 4;
sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *));
+ Q_CHECK_PTR(sp->d_ptr->d_ptrs);
} else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) {
// However, to support corner cases we grow the array dynamically if needed.
sp->d_ptr->d_ptrs_size <<= 1;
const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);
- sp->d_ptr->d_ptrs = (QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize);
+ QPainterPrivate ** newPointers = (QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize);
+ Q_CHECK_PTR(newPointers);
+ sp->d_ptr->d_ptrs = newPointers;
}
- sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr;
- q->d_ptr = sp->d_ptr;
+ sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();
+ q->d_ptr.data_ptr() = sp->d_ptr.data();
Q_ASSERT(q->d_ptr->state);
@@ -315,7 +333,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q)
d_ptrs[refcount - 1] = 0;
q->restore();
- q->d_ptr = original;
+ q->d_ptr.data_ptr() = original;
if (emulationEngine) {
extended = emulationEngine->real_engine;
@@ -1374,8 +1392,8 @@ void QPainterPrivate::updateState(QPainterState *newState)
*/
QPainter::QPainter()
+ : d_ptr(new QPainterPrivate(this))
{
- d_ptr = new QPainterPrivate(this);
}
/*!
@@ -1407,7 +1425,7 @@ QPainter::QPainter(QPaintDevice *pd)
{
Q_ASSERT(pd != 0);
if (!QPainterPrivate::attachPainterPrivate(this, pd)) {
- d_ptr = new QPainterPrivate(this);
+ d_ptr.reset(new QPainterPrivate(this));
begin(pd);
}
Q_ASSERT(d_ptr);
@@ -1419,11 +1437,14 @@ QPainter::QPainter(QPaintDevice *pd)
QPainter::~QPainter()
{
d_ptr->inDestructor = true;
- if (isActive())
- end();
- else if (d_ptr->refcount > 1)
- d_ptr->detachPainterPrivate(this);
-
+ QT_TRY {
+ if (isActive())
+ end();
+ else if (d_ptr->refcount > 1)
+ d_ptr->detachPainterPrivate(this);
+ } QT_CATCH(...) {
+ // don't throw anything in the destructor.
+ }
if (d_ptr) {
// Make sure we haven't messed things up.
Q_ASSERT(d_ptr->inDestructor);
@@ -1431,7 +1452,6 @@ QPainter::~QPainter()
Q_ASSERT(d_ptr->refcount == 1);
if (d_ptr->d_ptrs)
free(d_ptr->d_ptrs);
- delete d_ptr;
}
}
@@ -7417,8 +7437,21 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
void qt_painter_removePaintDevice(QPaintDevice *dev)
{
- QMutexLocker locker(globalRedirectionsMutex());
- if(QPaintDeviceRedirectionList *redirections = globalRedirections()) {
+ QMutex *mutex = 0;
+ QT_TRY {
+ mutex = globalRedirectionsMutex();
+ } QT_CATCH(...) {
+ // ignore the missing mutex, since we could be called from
+ // a destructor, and destructors shall not throw
+ }
+ QMutexLocker locker(mutex);
+ QPaintDeviceRedirectionList *redirections = 0;
+ QT_TRY {
+ redirections = globalRedirections();
+ } QT_CATCH(...) {
+ // do nothing - code below is safe with redirections being 0.
+ }
+ if (redirections) {
for (int i = 0; i < redirections->size(); ) {
if(redirections->at(i) == dev || redirections->at(i).replacement == dev)
redirections->removeAt(i);
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index f3df7a3..d8c6980 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -45,6 +45,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
#include <QtGui/qtextoption.h>
@@ -78,6 +79,8 @@ class QTextItem;
class QMatrix;
class QTransform;
+class QPainterPrivateCleaner;
+
class Q_GUI_EXPORT QPainter
{
Q_DECLARE_PRIVATE(QPainter)
@@ -497,7 +500,7 @@ private:
Q_DISABLE_COPY(QPainter)
friend class Q3Painter;
- QPainterPrivate *d_ptr;
+ QScopedCustomPointer<QPainterPrivate, QPainterPrivateCleaner> d_ptr;
friend class QFontEngine;
friend class QFontEngineBox;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index e1f5eea..635218e 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -73,6 +73,24 @@
QT_BEGIN_NAMESPACE
+struct QPainterPathPrivateHandler
+{
+ static inline void cleanup(QPainterPathPrivate *d)
+ {
+ // note - we must up-cast to QPainterPathData since QPainterPathPrivate
+ // has a non-virtual destructor!
+ if (d && !d->ref.deref())
+ delete static_cast<QPainterPathData *>(d);
+ }
+
+ static inline void reset(QPainterPathPrivate *&d, QPainterPathPrivate *other)
+ {
+ QPainterPathPrivate *oldD = d;
+ d = other;
+ cleanup(oldD);
+ }
+};
+
// This value is used to determine the length of control point vectors
// when approximating arc segments as curves. The factor is multiplied
// with the radius of the circle.
@@ -506,10 +524,10 @@ QPainterPath::QPainterPath()
\sa operator=()
*/
QPainterPath::QPainterPath(const QPainterPath &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
- if (d_func())
- d_func()->ref.ref();
+ if (d_ptr)
+ d_ptr->ref.ref();
}
/*!
@@ -530,9 +548,7 @@ QPainterPath::QPainterPath(const QPointF &startPoint)
void QPainterPath::detach_helper()
{
QPainterPathPrivate *data = new QPainterPathData(*d_func());
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
}
/*!
@@ -544,9 +560,7 @@ void QPainterPath::ensureData_helper()
data->elements.reserve(16);
QPainterPath::Element e = { 0, 0, QPainterPath::MoveToElement };
data->elements << e;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
Q_ASSERT(d_ptr != 0);
}
@@ -563,9 +577,7 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
QPainterPathPrivate *data = other.d_func();
if (data)
data->ref.ref();
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = data;
+ d_ptr.reset(data);
}
return *this;
}
@@ -575,8 +587,6 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
*/
QPainterPath::~QPainterPath()
{
- if (d_func() && !d_func()->ref.deref())
- delete d_func();
}
/*!
@@ -1006,7 +1016,7 @@ void QPainterPath::addPolygon(const QPolygonF &polygon)
/*!
\fn void QPainterPath::addEllipse(const QRectF &boundingRectangle)
- Creates an ellipse within the the specified \a boundingRectangle
+ Creates an ellipse within the specified \a boundingRectangle
and adds it to the painter path as a closed subpath.
The ellipse is composed of a clockwise curve, starting and
@@ -2408,7 +2418,6 @@ QPainterPathStroker::QPainterPathStroker()
*/
QPainterPathStroker::~QPainterPathStroker()
{
- delete d_ptr;
}
@@ -2695,7 +2704,7 @@ qreal QPainterPath::length() const
/*!
Returns percentage of the whole path at the specified length \a len.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2812,7 +2821,7 @@ static inline QBezier bezierAtT(const QPainterPath &path, qreal t, qreal *starti
Returns the point at at the percentage \a t of the current path.
The argument \a t has to be between 0 and 1.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2843,7 +2852,7 @@ QPointF QPainterPath::pointAtPercent(qreal t) const
Positive values for the angles mean counter-clockwise while negative values
mean the clockwise direction. Zero degrees is at the 3 o'clock position.
- Note that similarly to the other percent methods, the percentage measurment
+ Note that similarly to the other percent methods, the percentage measurement
is not linear with regards to the length if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
@@ -2875,7 +2884,7 @@ qreal QPainterPath::angleAtPercent(qreal t) const
Returns the slope of the path at the percentage \a t. The
argument \a t has to be between 0 and 1.
- Note that similarly to other percent methods, the percentage measurment
+ Note that similarly to other percent methods, the percentage measurement
is not linear with regards to the length, if curves are present
in the path. When curves are present the percentage argument is mapped
to the t parameter of the Bezier equations.
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 6cd2af8..e12194e 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -47,6 +47,7 @@
#include <QtCore/qrect.h>
#include <QtCore/qline.h>
#include <QtCore/qvector.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -56,6 +57,7 @@ QT_MODULE(Gui)
class QFont;
class QPainterPathPrivate;
+struct QPainterPathPrivateHandler;
class QPainterPathData;
class QPainterPathStrokerPrivate;
class QPolygonF;
@@ -195,7 +197,7 @@ public:
QPainterPath &operator-=(const QPainterPath &other);
private:
- QPainterPathPrivate *d_ptr;
+ QScopedCustomPointer<QPainterPathPrivate, QPainterPathPrivateHandler> d_ptr;
inline void ensureData() { if (!d_ptr) ensureData_helper(); }
void ensureData_helper();
@@ -205,7 +207,7 @@ private:
void computeBoundingRect() const;
void computeControlPointRect() const;
- QPainterPathData *d_func() const { return reinterpret_cast<QPainterPathData *>(d_ptr); }
+ QPainterPathData *d_func() const { return reinterpret_cast<QPainterPathData *>(d_ptr.data()); }
friend class QPainterPathData;
friend class QPainterPathStroker;
@@ -229,6 +231,7 @@ public:
friend class QPainterPathStrokerPrivate;
friend class QMatrix;
friend class QTransform;
+ friend struct QPainterPathPrivateHandler;
#ifndef QT_NO_DATASTREAM
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
@@ -279,7 +282,7 @@ public:
private:
friend class QX11PaintEngine;
- QPainterPathStrokerPrivate *d_ptr;
+ QScopedPointer<QPainterPathStrokerPrivate> d_ptr;
};
inline void QPainterPath::moveTo(qreal x, qreal y)
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 5090b3a..ba6baa6 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -480,26 +480,26 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
\value A7 74 x 105 mm
\value A8 52 x 74 mm
\value A9 37 x 52 mm
- \value B0 1030 x 1456 mm
- \value B1 728 x 1030 mm
- \value B10 32 x 45 mm
- \value B2 515 x 728 mm
- \value B3 364 x 515 mm
- \value B4 257 x 364 mm
- \value B5 182 x 257 mm, 7.17 x 10.13 inches
- \value B6 128 x 182 mm
- \value B7 91 x 128 mm
- \value B8 64 x 91 mm
- \value B9 45 x 64 mm
+ \value B0 1000 x 1414 mm
+ \value B1 707 x 1000 mm
+ \value B2 500 x 707 mm
+ \value B3 353 x 500 mm
+ \value B4 250 x 353 mm
+ \value B5 176 x 250 mm, 6.93 x 9.84 inches
+ \value B6 125 x 176 mm
+ \value B7 88 x 125 mm
+ \value B8 62 x 88 mm
+ \value B9 33 x 62 mm
+ \value B10 31 x 44 mm
\value C5E 163 x 229 mm
\value Comm10E 105 x 241 mm, U.S. Common 10 Envelope
\value DLE 110 x 220 mm
- \value Executive 7.5 x 10 inches, 191 x 254 mm
+ \value Executive 7.5 x 10 inches, 190.5 x 254 mm
\value Folio 210 x 330 mm
- \value Ledger 432 x 279 mm
- \value Legal 8.5 x 14 inches, 216 x 356 mm
- \value Letter 8.5 x 11 inches, 216 x 279 mm
- \value Tabloid 279 x 432 mm
+ \value Ledger 431.8 x 279.4 mm
+ \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm
+ \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm
+ \value Tabloid 279.4 x 431.8 mm
\value Custom Unknown, or a user defined size.
With setFullPage(false) (the default), the metrics will be a bit
@@ -712,7 +712,6 @@ QPrinter::~QPrinter()
#ifndef QT_NO_PRINTPREVIEWWIDGET
delete d->previewEngine;
#endif
- delete d;
}
/*!
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 949c8f9..24e867b 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -42,8 +42,9 @@
#ifndef QPRINTER_H
#define QPRINTER_H
-#include <QtGui/qpaintdevice.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtGui/qpaintdevice.h>
QT_BEGIN_HEADER
@@ -288,7 +289,7 @@ private:
Q_DISABLE_COPY(QPrinter)
- QPrinterPrivate *d_ptr;
+ QScopedPointer<QPrinterPrivate> d_ptr;
friend class QPrintDialogPrivate;
friend class QAbstractPrintDialog;
diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h
index b826306..d188d73 100644
--- a/src/gui/painting/qprinterinfo.h
+++ b/src/gui/painting/qprinterinfo.h
@@ -53,6 +53,7 @@ QT_MODULE(Gui)
#ifndef QT_NO_PRINTER
class QPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup;
class Q_GUI_EXPORT QPrinterInfo
{
Q_DECLARE_PRIVATE(QPrinterInfo)
@@ -76,7 +77,7 @@ public:
private:
QPrinterInfo(const QString& name);
- QPrinterInfoPrivate* d_ptr;
+ QScopedCustomPointer<QPrinterInfoPrivate, QPrinterInfoPrivateCleanup> d_ptr;
};
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index ecd4b5b..ae689f4 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -65,6 +65,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size);
/////////////////////////////////////////////////////////////////////////////
@@ -106,8 +122,8 @@ QPrinterInfo QPrinterInfo::defaultPrinter(){
/////////////////////////////////////////////////////////////////////////////
QPrinterInfo::QPrinterInfo(const QPrinter& prn)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
QList<QPrinterInfo> list = availablePrinters();
for (int c = 0; c < list.size(); ++c) {
if (prn.printerName() == list[c].printerName()) {
@@ -115,39 +131,33 @@ QPrinterInfo::QPrinterInfo(const QPrinter& prn)
return;
}
}
-
- *this = QPrinterInfo();
}
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index 0f33ea7..55e3226 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -82,6 +82,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -867,19 +883,19 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
}
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo::QPrinterInfo(const QPrinter& printer)
+ : d_ptr(new QPrinterInfoPrivate(printer.printerName()))
{
- d_ptr = new QPrinterInfoPrivate(printer.printerName());
Q_D(QPrinterInfo);
d->q_ptr = this;
@@ -929,28 +945,23 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer)
#endif
// Printer not found.
- delete d;
- d_ptr = &nullQPrinterInfoPrivate;
+ d_ptr.reset(&nullQPrinterInfoPrivate);
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 7cd3cf3..7607391 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -69,6 +69,22 @@ private:
static QPrinterInfoPrivate nullQPrinterInfoPrivate;
+class QPrinterInfoPrivateCleanup
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &nullQPrinterInfoPrivate)
+ delete d;
+ }
+
+ static inline void reset(QPrinterInfoPrivate *&d, QPrinterInfoPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -155,25 +171,25 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
/////////////////////////////////////////////////////////////////////////////
QPrinterInfo::QPrinterInfo()
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
}
QPrinterInfo::QPrinterInfo(const QString& name)
+ : d_ptr(new QPrinterInfoPrivate(name))
{
- d_ptr = new QPrinterInfoPrivate(name);
d_ptr->q_ptr = this;
}
QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
*this = src;
}
QPrinterInfo::QPrinterInfo(const QPrinter& prn)
+ : d_ptr(&nullQPrinterInfoPrivate)
{
- d_ptr = &nullQPrinterInfoPrivate;
QList<QPrinterInfo> list = availablePrinters();
for (int c = 0; c < list.size(); ++c) {
if (prn.printerName() == list[c].printerName()) {
@@ -187,16 +203,12 @@ QPrinterInfo::QPrinterInfo(const QPrinter& prn)
QPrinterInfo::~QPrinterInfo()
{
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
}
QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
{
Q_ASSERT(d_ptr);
- if (d_ptr != &nullQPrinterInfoPrivate)
- delete d_ptr;
- d_ptr = new QPrinterInfoPrivate(*src.d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
d_ptr->q_ptr = this;
return *this;
}
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 583885c..3c06bb4 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -436,8 +436,11 @@ void QScanConverter::end()
inline void QScanConverter::allocate(int size)
{
if (m_alloc < size) {
- m_alloc = qMax(size, 2 * m_alloc);
- m_intersections = (Intersection *)realloc(m_intersections, m_alloc * sizeof(Intersection));
+ int newAlloc = qMax(size, 2 * m_alloc);
+ Intersection *newIntersections = (Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection));
+ Q_CHECK_PTR(newIntersections);
+ m_alloc = newAlloc;
+ m_intersections = newIntersections;
}
}
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index c88af7c..65964de 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -3167,6 +3167,7 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline,
{
tmpSLLBlock =
(ScanLineListBlock *)malloc(sizeof(ScanLineListBlock));
+ Q_CHECK_PTR(tmpSLLBlock);
(*SLLBlock)->next = tmpSLLBlock;
tmpSLLBlock->next = (ScanLineListBlock *)NULL;
*SLLBlock = tmpSLLBlock;
@@ -3553,6 +3554,8 @@ static void PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock,
* Scan converts a polygon by returning a run-length
* encoding of the resultant bitmap -- the run-length
* encoding is in the form of an array of rectangles.
+ *
+ * Can return 0 in case of errors.
*/
static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
//Point *Pts; /* the pts */
@@ -3624,75 +3627,28 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
}
- if (rule == EvenOddRule) {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
-
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
-
+ QT_TRY {
+ if (rule == EvenOddRule) {
/*
- * for each active edge
+ * for each scanline
*/
- while (pAET) {
- pts->setX(pAET->bres.minor_axis);
- pts->setY(y);
- ++pts;
- ++iPts;
+ for (y = ET.ymin; y < ET.ymax; ++y) {
/*
- * send out the buffer
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
*/
- if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK));
- tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
- curPtBlock->next = tmpPtBlock;
- curPtBlock = tmpPtBlock;
- pts = curPtBlock->pts;
- ++numFullPtBlocks;
- iPts = 0;
+ if (pSLL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ pSLL = pSLL->next;
}
- EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
- }
- InsertionSort(&AET);
- }
- } else {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- computeWAET(&AET);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
- pWETE = pAET;
+ pPrevAET = &AET;
+ pAET = AET.next;
- /*
- * for each active edge
- */
- while (pAET) {
/*
- * add to the buffer only those edges that
- * are in the Winding active edge table.
+ * for each active edge
*/
- if (pWETE == pAET) {
+ while (pAET) {
pts->setX(pAET->bres.minor_axis);
pts->setY(y);
++pts;
@@ -3702,7 +3658,8 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
* send out the buffer
*/
if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK)));
+ tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK));
+ Q_CHECK_PTR(tmpPtBlock);
tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
@@ -3710,21 +3667,81 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule)
++numFullPtBlocks;
iPts = 0;
}
- pWETE = pWETE->nextWETE;
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
}
- EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
+ InsertionSort(&AET);
}
-
+ } else {
/*
- * recompute the winding active edge table if
- * we just resorted or have exited an edge.
+ * for each scanline
*/
- if (InsertionSort(&AET) || fixWAET) {
- computeWAET(&AET);
- fixWAET = false;
+ for (y = ET.ymin; y < ET.ymax; ++y) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ computeWAET(&AET);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+ pWETE = pAET;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ /*
+ * add to the buffer only those edges that
+ * are in the Winding active edge table.
+ */
+ if (pWETE == pAET) {
+ pts->setX(pAET->bres.minor_axis);
+ pts->setY(y);
+ ++pts;
+ ++iPts;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK)));
+ tmpPtBlock->pts = reinterpret_cast<QPoint *>(tmpPtBlock->data);
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ ++numFullPtBlocks;
+ iPts = 0;
+ }
+ pWETE = pWETE->nextWETE;
+ }
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
+ }
+
+ /*
+ * recompute the winding active edge table if
+ * we just resorted or have exited an edge.
+ */
+ if (InsertionSort(&AET) || fixWAET) {
+ computeWAET(&AET);
+ fixWAET = false;
+ }
}
}
+ } QT_CATCH(...) {
+ FreeStorage(SLLBlock.next);
+ PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
+ for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
+ tmpPtBlock = curPtBlock->next;
+ free(curPtBlock);
+ curPtBlock = tmpPtBlock;
+ }
+ free(pETEs);
+ return 0; // this function returns 0 in case of an error
}
+
FreeStorage(SLLBlock.next);
PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
@@ -3923,11 +3940,10 @@ QRegion &QRegion::operator=(const QRegion &r)
/*!
\internal
*/
-
QRegion QRegion::copy() const
{
QRegion r;
- QRegionData *x = new QRegionData;
+ QScopedPointer<QRegionData> x(new QRegionData);
x->ref = 1;
#if defined(Q_WS_X11)
x->rgn = 0;
@@ -3941,7 +3957,7 @@ QRegion QRegion::copy() const
x->qt_rgn = new QRegionPrivate;
if (!r.d->ref.deref())
cleanUp(r.d);
- r.d = x;
+ r.d = x.take();
return r;
}
diff --git a/src/gui/painting/qregion_s60.cpp b/src/gui/painting/qregion_s60.cpp
index 4504118..4d96910 100644
--- a/src/gui/painting/qregion_s60.cpp
+++ b/src/gui/painting/qregion_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 3fd1ffb..89df869 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -92,8 +92,8 @@ void QTextureGlyphCache::populate(const QTextItemInt &ti,
int glyph_height = metrics.height.ceil().toInt();
if (glyph_height == 0 || glyph_width == 0)
continue;
- glyph_width += margin * 2 + 2;
- glyph_height += margin * 2 + 2;
+ glyph_width += margin * 2 + 4;
+ glyph_height += margin * 2 + 4;
// align to 8-bit boundary
if (m_type == QFontEngineGlyphCache::Raster_Mono)
glyph_width = (glyph_width+7)&~7;
@@ -189,7 +189,11 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
int QImageTextureGlyphCache::glyphMargin() const
{
+#ifdef Q_WS_MAC
return 2;
+#else
+ return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
+#endif
}
void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g)
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
index 110ba2f..97178a6 100644
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ b/src/gui/painting/qwindowsurface_raster.cpp
@@ -115,8 +115,6 @@ QRasterWindowSurface::~QRasterWindowSurface()
#endif
if (d_ptr->image)
delete d_ptr->image;
-
- delete d_ptr;
}
@@ -229,7 +227,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi
{
const QImage &src = d->image->image;
br = br.intersected(src.rect());
- if (src.format() != QImage::Format_RGB32) {
+ if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) {
QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
data->xinfo = widget->x11Info();
data->fromImage(src, Qt::AutoColor);
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
index 2a3535f..c10bec3 100644
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ b/src/gui/painting/qwindowsurface_raster_p.h
@@ -112,7 +112,7 @@ public:
private:
void prepareBuffer(QImage::Format format, QWidget *widget);
Q_DECLARE_PRIVATE(QRasterWindowSurface)
- QRasterWindowSurfacePrivate *d_ptr;
+ QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index 2618ce2..2a20b44 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
index 7b70fd5..40a866d 100644
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ b/src/gui/painting/qwindowsurface_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 0842ec7..d8a67c2 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -633,31 +633,14 @@ GtkStyle* QGtk::gtkStyle(const QString &path)
return 0;
}
-#ifdef Q_OS_LINUX
-QT_END_NAMESPACE
-
-int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
-int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
-
-QT_BEGIN_NAMESPACE
-#endif
-
void QGtk::initGtkWidgets()
{
// From gtkmain.c
-
- uid_t ruid, rgid, euid, egid, suid, sgid;
-
-#ifdef Q_OS_LINUX
- if (getresuid (&ruid, &euid, &suid) != 0 || getresgid (&rgid, &egid, &sgid) != 0)
-#endif
- {
- suid = ruid = getuid ();
- sgid = rgid = getgid ();
- euid = geteuid ();
- egid = getegid ();
- }
- if (ruid != euid || ruid != suid || rgid != egid || rgid != sgid) {
+ uid_t ruid = getuid ();
+ uid_t rgid = getgid ();
+ uid_t euid = geteuid ();
+ uid_t egid = getegid ();
+ if (ruid != euid || rgid != egid) {
qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
"therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
"\'kdesudo\' or a similar tool.\n\n"
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3cae08a..f3d1537 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1693,7 +1693,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
pr.setHeight(pmSize.height() + 6);
- tr.adjust(0, pr.height(), 0, -3);
+ tr.adjust(0, pr.height() - 1, 0, -3);
pr.translate(shiftX, shiftY);
if (!hasArrow) {
drawItemPixmap(p, pr, Qt::AlignCenter, pm);
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index ca71da2..0e54af8 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -140,10 +140,7 @@ static const char * const dock_widget_restore_xpm[] =
class QGtkStyleFilter : public QObject
{
public:
- QGtkStyleFilter() {
- qApp->installEventFilter(this);
- }
-
+ QGtkStyleFilter() {}
private:
bool eventFilter(QObject *obj, QEvent *e);
};
@@ -167,7 +164,12 @@ class QGtkStylePrivate : public QCleanlooksStylePrivate
public:
QGtkStylePrivate()
: QCleanlooksStylePrivate()
- {}
+ {
+ QGtk::initGtkWidgets();
+ if (QGtk::isThemeAvailable())
+ qApp->installEventFilter(&filter);
+
+ }
QGtkStyleFilter filter;
};
@@ -243,7 +245,6 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const
QGtkStyle::QGtkStyle()
: QCleanlooksStyle(*new QGtkStylePrivate)
{
- QGtk::initGtkWidgets();
}
/*!
@@ -939,10 +940,6 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameLineEdit: {
GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
- if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
gboolean interior_focus;
gint focus_line_width;
@@ -956,6 +953,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (!interior_focus && option->state & State_HasFocus)
rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN, gtkEntry->style,
@@ -964,6 +964,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
}
break;
@@ -1049,17 +1052,13 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
style, isDefault ? QLS("d") : QString());
- } else
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ }
bool hasFocus = option->state & State_HasFocus;
if (hasFocus) {
key += QLS("def");
GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
}
if (!interiorFocus)
@@ -1070,6 +1069,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
style, key);
+ if (isDefault)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ if (hasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
}
break;
@@ -1333,6 +1336,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GtkWidget *gtkToggleButton = QGtk::gtkWidget(buttonPath);
QGtk::gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
// Draw the combo box as a line edit with a button next to it
if (comboBox->editable || appears_as_list) {
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
@@ -1346,22 +1351,16 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
else
frameRect.setRight(arrowButtonRect.left());
- // Required for inner blue highlight with clearlooks
- if (focus) {
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- }
-
// Fill the line edit background
// We could have used flat_box with "entry_bg" but that is probably not worth the overhead
uint resolve_mask = option->palette.resolve();
int xt = gtkEntry->style->xthickness;
int yt = gtkEntry->style->ythickness;
QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
+ // Required for inner blue highlight with clearlooks
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
p->fillRect(contentRect, option->palette.base().color());
@@ -1375,6 +1374,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
GTK_SHADOW_IN, gtkEntry->style, entryPath +
QString::number(focus) + QString::number(comboBox->editable) +
QString::number(option->direction));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
}
GtkStateType buttonState = GTK_STATE_NORMAL;
@@ -1393,22 +1394,21 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
shadow, gtkToggleButton->style, buttonPath +
QString::number(focus) + QString::number(option->direction));
-
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
} else {
// Draw combo box as a button
QRect buttonRect = option->rect;
- if (focus) { // Clearlooks actually check the widget for the default state
+ if (focus) // Clearlooks actually check the widget for the default state
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
-
- } else {
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- }
-
gtkCachedPainter.paintBox(gtkToggleButton, "button",
buttonRect, state,
shadow, gtkToggleButton->style,
buttonPath + QString::number(focus));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+
// Draw the separator between label and arrows
QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator");
@@ -1774,15 +1774,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
shadow = GTK_SHADOW_IN;
style = gtkPainter.getStyle(gtkSpinButton);
- if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
QString key;
-
- if (option->state & State_HasFocus)
+ if (option->state & State_HasFocus) {
key = QLS("f");
+ GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ }
uint resolve_mask = option->palette.resolve();
@@ -1815,6 +1812,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
else
gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
}
if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
@@ -2343,7 +2343,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_SizeGrip: {
GtkWidget *gtkStatusbar = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
- gtkPainter.paintResizeGrip( gtkStatusbar, "window", gripRect, GTK_STATE_NORMAL,
+ gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
gtkStatusbar->style);
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 7a870fe..1be3d6e 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -39,6 +39,11 @@
**
****************************************************************************/
+/*
+ Note: The qdoc comments for QMacStyle are contained in
+ .../doc/src/qstyles.qdoc.
+*/
+
#include "qmacstyle_mac.h"
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
@@ -1988,87 +1993,12 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD
p->drawPixmap(int(macRect.origin.x), int(macRect.origin.y) + finalyoff, width, height, pm);
}
-/*!
- \class QMacStyle
- \brief The QMacStyle class provides a Mac OS X style using the Apple Appearance Manager.
-
- \ingroup appearance
-
- This class is implemented as a wrapper to the HITheme
- APIs, allowing applications to be styled according to the current
- theme in use on Mac OS X. This is done by having primitives
- in QStyle implemented in terms of what Mac OS X would normally theme.
-
- \warning This style is only available on Mac OS X because it relies on the
- HITheme APIs.
-
- There are additional issues that should be taken
- into consideration to make an application compatible with the
- \link http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html
- Apple Human Interface Guidelines \endlink. Some of these issues are outlined
- below.
-
- \list
-
- \i Layout - The restrictions on window layout are such that some
- aspects of layout that are style-dependent cannot be achieved
- using QLayout. Changes are being considered (and feedback would be
- appreciated) to make layouts QStyle-able. Some of the restrictions
- involve horizontal and vertical widget alignment and widget size
- (covered below).
-
- \i Widget size - Mac OS X allows widgets to have specific fixed sizes. Qt
- does not fully implement this behavior so as to maintain cross-platform
- compatibility. As a result some widgets sizes may be inappropriate (and
- subsequently not rendered correctly by the HITheme APIs).The
- QWidget::sizeHint() will return the appropriate size for many
- managed widgets (widgets enumerated in \l QStyle::ContentsType).
-
- \i Effects - QMacStyle uses HITheme for performing most of the drawing, but
- also uses emulation in a few cases where HITheme does not provide the
- required functionality (for example, tab bars on Panther, the toolbar
- separator, etc). We tried to make the emulation as close to the original as
- possible. Please report any issues you see in effects or non-standard
- widgets.
-
- \endlist
-
- There are other issues that need to be considered in the feel of
- your application (including the general color scheme to match the
- Aqua colors). The Guidelines mentioned above will remain current
- with new advances and design suggestions for Mac OS X.
-
- Note that the functions provided by QMacStyle are
- reimplementations of QStyle functions; see QStyle for their
- documentation.
-
- \img qmacstyle.png
- \sa QWindowsXPStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle, QMotifStyle
-*/
-
-
-/*!
- \enum QMacStyle::WidgetSizePolicy
-
- \value SizeSmall
- \value SizeLarge
- \value SizeMini
- \value SizeDefault
- \omitvalue SizeNone
-*/
-
-/*!
- Constructs a QMacStyle object.
-*/
QMacStyle::QMacStyle()
: QWindowsStyle()
{
d = new QMacStylePrivate(this);
}
-/*!
- Destructs a QMacStyle object.
-*/
QMacStyle::~QMacStyle()
{
delete qt_mac_backgroundPattern;
@@ -2142,7 +2072,6 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint
}
}
-/*! \reimp */
void QMacStyle::polish(QPalette &pal)
{
if (!qt_mac_backgroundPattern) {
@@ -2166,17 +2095,14 @@ void QMacStyle::polish(QPalette &pal)
}
}
-/*! \reimp */
void QMacStyle::polish(QApplication *)
{
}
-/*! \reimp */
void QMacStyle::unpolish(QApplication *)
{
}
-/*! \reimp */
void QMacStyle::polish(QWidget* w)
{
d->addWidget(w);
@@ -2240,7 +2166,6 @@ void QMacStyle::polish(QWidget* w)
}
}
-/*! \reimp */
void QMacStyle::unpolish(QWidget* w)
{
d->removeWidget(w);
@@ -2271,7 +2196,6 @@ void QMacStyle::unpolish(QWidget* w)
QWindowsStyle::unpolish(w);
}
-/*! \reimp */
int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const
{
int controlSize = getControlSize(opt, widget);
@@ -2650,7 +2574,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
return ret;
}
-/*! \reimp */
QPalette QMacStyle::standardPalette() const
{
QPalette pal = QWindowsStyle::standardPalette();
@@ -2660,7 +2583,6 @@ QPalette QMacStyle::standardPalette() const
return pal;
}
-/*! \reimp */
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
QStyleHintReturn *hret) const
{
@@ -2955,7 +2877,6 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
return ret;
}
-/*! \reimp */
QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const
{
@@ -2981,7 +2902,6 @@ QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixm
}
-/*! \reimp */
QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -3012,31 +2932,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt
}
return icon.pixmap(size, size);
}
-/*!
- \enum QMacStyle::FocusRectPolicy
-
- This type is used to signify a widget's focus rectangle policy.
-
- \value FocusEnabled show a focus rectangle when the widget has focus.
- \value FocusDisabled never show a focus rectangle for the widget.
- \value FocusDefault show a focus rectangle when the widget has
- focus and the widget is a QSpinWidget, QDateTimeEdit, QLineEdit,
- QListBox, QListView, editable QTextEdit, or one of their
- subclasses.
-*/
-
-/*!
- \obsolete
- Sets the focus rectangle policy of \a w. The \a policy can be one of
- \l{QMacStyle::FocusRectPolicy}.
-
- This is now simply an interface to the Qt::WA_MacShowFocusRect attribute and the
- FocusDefault value does nothing anymore. If you want to set a widget back
- to its default value, you must save the old value of the attribute before
- you change it.
- \sa focusRectPolicy() QWidget::setAttribute()
-*/
void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
{
switch (policy) {
@@ -3049,29 +2945,11 @@ void QMacStyle::setFocusRectPolicy(QWidget *w, FocusRectPolicy policy)
}
}
-/*!
- \obsolete
- Returns the focus rectangle policy for the widget \a w.
-
- The focus rectangle policy can be one of \l{QMacStyle::FocusRectPolicy}.
-
- In 4.3 and up this function will simply test for the
- Qt::WA_MacShowFocusRect attribute and will never return
- QMacStyle::FocusDefault.
-
- \sa setFocusRectPolicy(), QWidget::testAttribute()
-*/
QMacStyle::FocusRectPolicy QMacStyle::focusRectPolicy(const QWidget *w)
{
return w->testAttribute(Qt::WA_MacShowFocusRect) ? FocusEnabled : FocusDisabled;
}
-/*!
- \obsolete
-
- Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
{
QWidget *wadget = const_cast<QWidget *>(widget);
@@ -3080,12 +2958,6 @@ void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy poli
wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
}
-/*!
- \obsolete
-
- Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
{
while (widget) {
@@ -3101,7 +2973,6 @@ QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget)
return SizeDefault;
}
-/*! \reimp */
void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
@@ -3534,7 +3405,6 @@ static inline QPixmap darkenPixmap(const QPixmap &pixmap)
-/*! \reimp */
void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
{
@@ -4558,7 +4428,7 @@ static void setLayoutItemMargins(int left, int top, int right, int bottom, QRect
rect->adjust(left, top, right, bottom);
}
}
-/*! \reimp */
+
QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -4852,7 +4722,6 @@ static inline void drawToolbarButtonArrow(const QRect &toolButtonRect, ThemeDraw
HIThemeDrawPopupArrow(&hirect, &padi, cg, kHIThemeOrientationNormal);
}
-/*! \reimp */
void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
const QWidget *widget) const
{
@@ -5235,7 +5104,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
arrowOpt.state = tb->state;
arrowOpt.palette = tb->palette;
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
- } else if (tb->features & QStyleOptionToolButton::HasMenu) {
+ } else if ((tb->features & QStyleOptionToolButton::HasMenu)
+ && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) {
drawToolbarButtonArrow(tb->rect, tds, cg);
}
if (tb->state & State_On) {
@@ -5349,7 +5219,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
}
-/*! \reimp */
QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
const QStyleOptionComplex *opt,
const QPoint &pt, const QWidget *widget) const
@@ -5480,7 +5349,6 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
return sc;
}
-/*! \reimp */
QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
const QWidget *widget) const
{
@@ -5820,7 +5688,6 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
return ret;
}
-/*! \reimp */
QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &csz, const QWidget *widget) const
{
@@ -6107,9 +5974,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
return sz;
}
-/*!
- \reimp
-*/
void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
bool enabled, const QString &text, QPalette::ColorRole textRole) const
{
@@ -6118,9 +5982,6 @@ void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPale
QWindowsStyle::drawItemText(p, r, flags, pal, enabled, text, textRole);
}
-/*!
- \reimp
-*/
bool QMacStyle::event(QEvent *e)
{
if(e->type() == QEvent::FocusIn) {
@@ -6195,9 +6056,6 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI
}
}
-/*!
- \internal
-*/
QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
const QWidget *widget) const
{
@@ -6311,9 +6169,6 @@ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const Q
return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget);
}
-/*!
- \internal
-*/
int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2,
Qt::Orientation orientation,
diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp
index 7d4fab8..d19750f 100644
--- a/src/gui/styles/qmotifstyle.cpp
+++ b/src/gui/styles/qmotifstyle.cpp
@@ -298,8 +298,11 @@ void QMotifStyle::unpolish(QWidget* widget)
{
QCommonStyle::unpolish(widget);
#ifndef QT_NO_PROGRESSBAR
- if (qobject_cast<QProgressBar *>(widget))
+ if (qobject_cast<QProgressBar *>(widget)) {
+ Q_D(QMotifStyle);
widget->removeEventFilter(this);
+ d->bars.removeAll(static_cast<QProgressBar*>(widget));
+ }
#endif
}
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index bf73494..c6118d6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -14,13 +44,12 @@
#include "qapplication.h"
#include "qpainter.h"
#include "qstyleoption.h"
-#include "qresizeevent"
-#include "qpixmapcache"
+#include "qevent.h"
+#include "qpixmapcache.h"
#include "qcalendarwidget.h"
#include "qdial.h"
#include "qdialog.h"
-#include "qerrormessage.h"
#include "qgroupbox.h"
#include "qheaderview.h"
#include "qlist.h"
@@ -28,12 +57,13 @@
#include "qlistview.h"
#include "qmenu.h"
#include "qmenubar.h"
-#include "qmessagebox.h"
#include "qpushbutton.h"
+#include "qscrollarea.h"
#include "qscrollbar.h"
#include "qtabbar.h"
#include "qtablewidget.h"
#include "qtableview.h"
+#include "qtextedit.h"
#include "qtoolbar.h"
#include "qtoolbutton.h"
#include "qtreeview.h"
@@ -41,6 +71,7 @@
#include "private/qtoolbarextension_p.h"
#include "private/qcombobox_p.h"
#include "private/qwidget_p.h"
+#include "private/qapplication_p.h"
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
@@ -55,7 +86,6 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl
static const QByteArray propertyKeyLayouts = "layouts";
static const QByteArray propertyKeyCurrentlayout = "currentlayout";
-#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
// *** generated layout data ***
{240,320,1,14,true,QLatin1String("QVGA Landscape Mirrored")},
@@ -85,15 +115,16 @@ const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1},
{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}
-
-
// *** End of generated data ***
};
const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0];
-#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-bool QS60StylePrivate::m_backgroundValid = false;
+// theme background texture
+QPixmap *QS60StylePrivate::m_background = 0;
+
+// theme palette
+QPalette *QS60StylePrivate::m_themePalette = 0;
const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = {
{SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter},
@@ -109,111 +140,20 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme
{SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter},
{SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed},
{SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter},
+ {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive},
+ {SE_Editor, QS60StyleEnums::SP_QsnFrNotepadCenter},
};
+
static const int frameElementsCount =
int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0]));
-const int KNotFound = -1;
+const int KNotFound = -909;
+const double KTabFontMul = 0.72;
-void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
- QPainter *painter, const QRect &rect, SkinElementFlags flags)
+QS60StylePrivate::~QS60StylePrivate()
{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
- if (!skinPartPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), skinPartPixMap);
-}
-
-void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
-{
- static const bool doCache =
-#if defined(Q_WS_S60)
- // Freezes on 3.1. Anyways, caching is only really needed on touch UI
- !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
-#else
- true;
-#endif
- const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
- if (!frameElementPixMap.isNull())
- painter->drawPixmap(rect.topLeft(), frameElementPixMap);
-}
-
-void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
- QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
- Qt::Orientation orientation, QPainter *painter, const QRect &rect,
- SkinElementFlags flags)
-{
- QSize startEndSize(partSize(start, flags));
- startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
-
- QRect startRect = QRect(rect.topLeft(), startEndSize);
- QRect middleRect = rect;
- QRect endRect;
-
- if (orientation == Qt::Horizontal) {
- startRect.setWidth(qMin(rect.width() / 2 - 1, startRect.width()));
- endRect = startRect.translated(rect.width() - startRect.width(), 0);
- middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
- } else {
- startRect.setHeight(qMin(rect.height() / 2 - 1, startRect.height()));
- endRect = startRect.translated(0, rect.height() - startRect.height());
- middleRect.adjust(0, startRect.height(), 0, -startRect.height());
- }
-
-#if 0
- painter->save();
- painter->setOpacity(.3);
- painter->fillRect(startRect, Qt::red);
- painter->fillRect(middleRect, Qt::green);
- painter->fillRect(endRect, Qt::blue);
- painter->restore();
-#else
- drawPart(start, painter, startRect, flags);
- if (middleRect.isValid())
- drawPart(middle, painter, middleRect, flags);
- drawPart(end, painter, endRect, flags);
-#endif
-}
-
-QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
- const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinElementFlags=%4")
- .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::part(part, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
-{
- QPixmap result;
- const QString cacheKey =
- QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
- .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
- if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::frame(frame, size, flags);
- QPixmapCache::insert(cacheKey, result);
- }
- return result;
-}
-
-void QS60StylePrivate::refreshUI()
-{
- foreach (QWidget *topLevelWidget, QApplication::allWidgets()) {
- topLevelWidget->updateGeometry();
- QCoreApplication::postEvent(topLevelWidget, new QResizeEvent(topLevelWidget->size(), topLevelWidget->size()));
- }
+ clearCaches(); //deletes also background image
+ deleteThemePalette();
}
void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
@@ -335,88 +275,33 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter,
drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed,
QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth);
break;
+ case SE_ButtonInactive:
+ drawFrame(SF_ButtonInactive, painter, rect, flags | SF_PointNorth);
+ break;
+ case SE_Editor:
+ drawFrame(SF_Editor, painter, rect, flags | SF_PointNorth);
+ break;
default:
break;
}
}
-QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
-{
- QSize result(20, 20);
- switch (part)
- {
- case QS60StyleEnums::SP_QgnGrafBarProgress:
- result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
- break;
- case QS60StyleEnums::SP_QgnGrafTabActiveM:
- case QS60StyleEnums::SP_QgnGrafTabPassiveM:
- case QS60StyleEnums::SP_QgnGrafTabActiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveR:
- case QS60StyleEnums::SP_QgnGrafTabPassiveL:
- case QS60StyleEnums::SP_QgnGrafTabActiveL:
- break;
- case QS60StyleEnums::SP_QgnIndiSliderEdit:
- result.scale(pixelMetric(QStyle::PM_SliderLength),
- pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
- break;
-
- case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
- case QS60StyleEnums::SP_QsnCpScrollBgBottom:
- case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
- case QS60StyleEnums::SP_QsnCpScrollBgTop:
- case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
- case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
- case QS60StyleEnums::SP_QsnCpScrollHandleTop:
- result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
- result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
- break;
- default:
- // Generic frame part size gathering.
- for (int i = 0; i < frameElementsCount; ++i)
- {
- switch (m_frameElementsData[i].center - part) {
- case 8: /* CornerTl */
- case 7: /* CornerTr */
- case 6: /* CornerBl */
- case 5: /* CornerBr */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- // Falltrough intended...
- case 4: /* SideT */
- case 3: /* SideB */
- result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
- break;
- case 2: /* SideL */
- case 1: /* SideR */
- result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
- break;
- case 0: /* center */
- default:
- break;
- }
- }
- break;
- }
- if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) {
- const int temp = result.width();
- result.setWidth(result.height());
- result.setHeight(temp);
- }
- return result;
-}
-
-
void QS60StylePrivate::drawSkinPart(QS60StyleEnums::SkinParts part,
QPainter *painter, const QRect &rect, SkinElementFlags flags)
{
drawPart(part, painter, rect, flags);
}
+short QS60StylePrivate::pixelMetric(int metric)
+{
+ Q_ASSERT(metric < MAX_PIXELMETRICS);
+ const short returnValue = m_pmPointer[metric];
+ return returnValue;
+}
+
void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
{
if (name == propertyKeyCurrentlayout) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
static const QStringList layouts = styleProperty(propertyKeyLayouts).toStringList();
const QString layout = value.toString();
Q_ASSERT(layouts.contains(layout));
@@ -425,23 +310,118 @@ void QS60StylePrivate::setStyleProperty(const char *name, const QVariant &value)
QApplication::setLayoutDirection(m_layoutHeaders[layoutIndex].mirroring ? Qt::RightToLeft : Qt::LeftToRight);
clearCaches();
refreshUI();
- return;
-#else
- qFatal("Cannot set static layout. Dynamic layouts are used!");
-#endif
+ }
+}
+
+QVariant QS60StylePrivate::styleProperty(const char *name) const
+{
+ if (name == propertyKeyLayouts) {
+ static QStringList layouts;
+ if (layouts.isEmpty())
+ for (int i = 0; i < m_numberOfLayouts; i++)
+ layouts.append(m_layoutHeaders[i].layoutName);
+ return layouts;
+ }
+ return QVariant();
+}
+
+QColor QS60StylePrivate::stateColor(const QColor &color, const QStyleOption *option)
+{
+ QColor retColor (color);
+ if (option && !(option->state & QStyle::State_Enabled)) {
+ QColor hsvColor = retColor.toHsv();
+ int colorSat = hsvColor.saturation();
+ int colorVal = hsvColor.value();
+ colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
+ colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
+ hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
+ retColor = hsvColor.toRgb();
+ }
+ return retColor;
+}
+
+QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+{
+ QColor result(baseColor);
+ bool modifyColor = false;
+ if (result.saturation() == 0) {
+ result.setHsv(result.hue(), 128, result.value());
+ modifyColor = true;
+ }
+ if (result.value() == 0) {
+ result.setHsv(result.hue(), result.saturation(), 128);
+ modifyColor = true;
+ }
+ if (modifyColor)
+ result = result.lighter(175);
+ else
+ result = result.lighter(225);
+ return result;
+}
+
+bool QS60StylePrivate::drawsOwnThemeBackground(const QWidget *widget)
+{
+ return qobject_cast<const QDialog *> (widget);
+}
+
+QFont QS60StylePrivate::s60Font(
+ QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+{
+ QFont result;
+ int actualPointSize = pointSize;
+ if (actualPointSize <= 0) {
+ const QFont appFont = QApplication::font();
+ actualPointSize = appFont.pointSize();
+ if (actualPointSize <= 0)
+ actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
+ }
+ Q_ASSERT(actualPointSize > 0);
+ const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
+ if (!m_mappedFontsCache.contains(key)) {
+ result = s60Font_specific(fontCategory, actualPointSize);
+ m_mappedFontsCache.insert(key, result);
+ } else {
+ result = m_mappedFontsCache.value(key);
+ if (result.pointSize() != actualPointSize)
+ result.setPointSize(actualPointSize);
+ }
+ return result;
+}
+
+void QS60StylePrivate::clearCaches(CacheClearReason reason)
+{
+ switch(reason){
+ case CC_LayoutChange:
+ // when layout changes, the colors remain in cache, but graphics and fonts can change
+ m_mappedFontsCache.clear();
+ deleteBackground();
+ QPixmapCache::clear();
+ break;
+ case CC_ThemeChange:
+ m_colorCache.clear();
+ QPixmapCache::clear();
+ deleteBackground();
+ break;
+ case CC_UndefinedChange:
+ default:
+ m_colorCache.clear();
+ m_mappedFontsCache.clear();
+ QPixmapCache::clear();
+ deleteBackground();
+ break;
}
}
// Since S60Style has 'button' and 'tooltip' as a graphic, we don't have any native color which to use
-// for QPalette::Button and QPalette::ToolTipBase. Therefore we need to guesstimate
-// this by calculating average rgb values for button pixels.
+// for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate
+// palette colors by calculating average rgb values for button pixels.
// Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found).
-QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const
+QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const
{
const bool cachedColorExists = m_colorCache.contains(frame);
if (!cachedColorExists) {
- const int frameCornerWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- const int frameCornerHeight = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
+ const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth);
+ const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight);
Q_ASSERT(2*frameCornerWidth<32);
Q_ASSERT(2*frameCornerHeight<32);
@@ -453,7 +433,6 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme
const int pixels = frameImage.numBytes()/sizeof(QRgb);
const int bytesPerLine = frameImage.bytesPerLine();
Q_ASSERT(bytesPerLine);
- const int rows = frameImage.numBytes()/(sizeof(QRgb)*bytesPerLine);
int estimatedRed = 0;
int estimatedGreen = 0;
@@ -494,284 +473,400 @@ QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameEleme
}
-int QS60StylePrivate::focusRectPenWidth()
+void QS60StylePrivate::setThemePalette(QApplication *app) const
{
- return pixelMetric(QS60Style::PM_DefaultFrameWidth);
+ Q_UNUSED(app)
+ QPalette widgetPalette = QPalette(Qt::white);
+ setThemePalette(&widgetPalette);
+ QApplication::setPalette(widgetPalette);
}
-void QS60StylePrivate::setThemePalette(QApplication *app) const
+void QS60StylePrivate::setThemePalette(QStyleOption *option) const
{
- if (!app)
- return;
-
- QPalette widgetPalette = QPalette(Qt::white);
+ setThemePalette(&option->palette);
+}
- // basic colors
- widgetPalette.setColor(QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Text,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::ToolTipText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0));
- widgetPalette.setColor(QPalette::BrightText, widgetPalette.color(QPalette::WindowText).lighter());
- widgetPalette.setColor(QPalette::HighlightedText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
- widgetPalette.setColor(QPalette::Link,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0));
- widgetPalette.setColor(QPalette::LinkVisited, widgetPalette.color(QPalette::Link).darker());
- widgetPalette.setColor(QPalette::Highlight,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
- // set these as transparent so that styled full screen theme background is visible
- widgetPalette.setColor(QPalette::AlternateBase, Qt::transparent);
- widgetPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture());
- widgetPalette.setColor(QPalette::Base, Qt::transparent);
- // set button and tooltipbase based on pixel colors
- const QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal);
- widgetPalette.setColor(QPalette::Button, buttonColor );
- widgetPalette.setColor(QPalette::Light, widgetPalette.color(QPalette::Button).lighter());
- widgetPalette.setColor(QPalette::Dark, widgetPalette.color(QPalette::Button).darker());
- widgetPalette.setColor(QPalette::Midlight, widgetPalette.color(QPalette::Button).lighter(125));
- widgetPalette.setColor(QPalette::Mid, widgetPalette.color(QPalette::Button).darker(150));
- widgetPalette.setColor(QPalette::Shadow, Qt::black);
- QColor toolTipColor = colorFromFrameGraphics(QS60StylePrivate::SF_ToolTip);
- widgetPalette.setColor(QPalette::ToolTipBase, toolTipColor );
-
- app->setPalette(widgetPalette);
+QPalette* QS60StylePrivate::themePalette()
+{
+ return m_themePalette;
}
void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
{
- if (!app)
- return;
- QPalette applicationPalette = app->palette();
- applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture());
- app->setPalette(applicationPalette);
+ Q_UNUSED(app)
+ QPalette applicationPalette = QApplication::palette();
+ applicationPalette.setBrush(QPalette::Window, backgroundTexture());
+ QApplication::setPalette(applicationPalette);
}
-void QS60Style::polish(QApplication *application)
+void QS60StylePrivate::deleteBackground()
{
- Q_D(const QS60Style);
- originalPalette = application->palette();
- d->setThemePalette(application);
+ if (m_background) {
+ delete m_background;
+ m_background = 0;
+ }
}
-void QS60Style::polish(QWidget *widget)
+int QS60StylePrivate::focusRectPenWidth()
{
- Q_D(const QS60Style);
- QCommonStyle::polish(widget);
+ return pixelMetric(QS60Style::PM_DefaultFrameWidth);
+}
- if (!widget)
- return;
+void QS60StylePrivate::setCurrentLayout(int index)
+{
+ m_pmPointer = data[index];
+}
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground);
- }
+void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
+ QPainter *painter, const QRect &rect, SkinElementFlags flags)
+{
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
+ if (!skinPartPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), skinPartPixMap);
+}
- QPalette widgetPalette = widget->palette();
+void QS60StylePrivate::drawFrame(SkinFrameElements frameElement, QPainter *painter, const QRect &rect, SkinElementFlags flags)
+{
+ static const bool doCache =
+#if defined(Q_WS_S60)
+ // Freezes on 3.1. Anyways, caching is only really needed on touch UI
+ !(QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
+#else
+ true;
+#endif
+ const QPixmap frameElementPixMap((doCache ? cachedFrame : frame)(frameElement, rect.size(), flags));
+ if (!frameElementPixMap.isNull())
+ painter->drawPixmap(rect.topLeft(), frameElementPixMap);
+}
- // widget specific colors and fonts
- if (qobject_cast<QSlider *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0));
- QApplication::setPalette(widgetPalette, "QSlider");
- } else if (qobject_cast<QPushButton *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Primary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- QApplication::setPalette(widgetPalette, "QPushButton");
- } else if (qobject_cast<QToolButton *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Primary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- QApplication::setPalette(widgetPalette, "QToolButton");
- } else if (qobject_cast<QHeaderView *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Secondary, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
- QHeaderView* header = qobject_cast<QHeaderView *>(widget);
- widgetPalette.setColor(QPalette::Button, Qt::transparent );
- if ( header->viewport() )
- header->viewport()->setPalette(widgetPalette);
- QApplication::setPalette(widgetPalette, "QHeaderView");
- } else if (qobject_cast<QMenuBar *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::ButtonText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0));
- QApplication::setPalette(widgetPalette, "QMenuBar");
- } else if (qobject_cast<QTabBar *>(widget)){
- widgetPalette.setColor(QPalette::Active, QPalette::WindowText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
- QApplication::setPalette(widgetPalette, "QTabBar");
- } else if (qobject_cast<QTableView *>(widget)){
- widgetPalette.setColor(QPalette::All, QPalette::Text,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
- QApplication::setPalette(widgetPalette, "QTableView");
- } else if (qobject_cast<QGroupBox *>(widget)){
- const QFont suggestedFont = d->s60Font(
- QS60StyleEnums::FC_Title, widget->font().pointSizeF());
- widget->setFont(suggestedFont);
- } else if (qobject_cast<QLineEdit *>(widget)) {
- widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
- QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
- QApplication::setPalette(widgetPalette, "QLineEdit");
- } else if (qobject_cast<QDial *> (widget)) {
- const QColor color(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
- widgetPalette.setColor(QPalette::WindowText, color);
- widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button));
- widgetPalette.setColor(QPalette::Dark, color.darker());
- widgetPalette.setColor(QPalette::Light, color.lighter());
- QApplication::setPalette(widgetPalette, "QDial");
+void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
+ QS60StyleEnums::SkinParts middle, QS60StyleEnums::SkinParts end,
+ Qt::Orientation orientation, QPainter *painter, const QRect &rect,
+ SkinElementFlags flags)
+{
+ QSize startEndSize(partSize(start, flags));
+ startEndSize.scale(rect.size(), Qt::KeepAspectRatio);
+
+ QRect startRect = QRect(rect.topLeft(), startEndSize);
+ QRect middleRect = rect;
+ QRect endRect;
+
+ if (orientation == Qt::Horizontal) {
+ startRect.setWidth(qMin(rect.width() >>1 - 1, startRect.width()));
+ endRect = startRect.translated(rect.width() - startRect.width(), 0);
+ middleRect.adjust(startRect.width(), 0, -startRect.width(), 0);
+ if (startRect.bottomRight().x() > endRect.topLeft().x()) {
+ const int overlap = (startRect.bottomRight().x() - endRect.topLeft().x())>>1;
+ startRect.setWidth(startRect.width()-overlap);
+ endRect.adjust(overlap,0,0,0);
+ }
+ } else {
+ startRect.setHeight(qMin(rect.height() >>1 - 1, startRect.height()));
+ endRect = startRect.translated(0, rect.height() - startRect.height());
+ middleRect.adjust(0, startRect.height(), 0, -startRect.height());
+ if (startRect.topRight().y() > endRect.bottomLeft().y()) {
+ const int overlap = (startRect.topRight().y() - endRect.bottomLeft().y())>>1;
+ startRect.setHeight(startRect.height()-overlap);
+ endRect.adjust(0,overlap,0,0);
+ }
}
+
+#if 0
+ painter->save();
+ painter->setOpacity(.3);
+ painter->fillRect(startRect, Qt::red);
+ painter->fillRect(middleRect, Qt::green);
+ painter->fillRect(endRect, Qt::blue);
+ painter->restore();
+#else
+ drawPart(start, painter, startRect, flags);
+ if (middleRect.isValid())
+ drawPart(middle, painter, middleRect, flags);
+ drawPart(end, painter, endRect, flags);
+#endif
}
-void QS60Style::unpolish(QApplication *application)
+QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
+ const QSize &size, SkinElementFlags flags)
{
- application->setPalette(originalPalette);
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4")
+ .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::part(part, size, flags);
+ QPixmapCache::insert(cacheKey, result);
+ }
+ return result;
}
-void QS60Style::unpolish(QWidget *widget)
+QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size, SkinElementFlags flags)
{
- if (QS60StylePrivate::isSkinnableDialog(widget)) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_MENU
- || qobject_cast<const QMenu *> (widget)
-#endif // QT_NO_MENU
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
- } else if (false
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- ) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
+ QPixmap result;
+ const QString cacheKey =
+ QString::fromLatin1("S60Style: SkinFrameElements=%1 QSize=%2|%3 SkinElementFlags=%4")
+ .arg((int)frame).arg(size.width()).arg(size.height()).arg((int)flags);
+ if (!QPixmapCache::find(cacheKey, result)) {
+ result = QS60StylePrivate::frame(frame, size, flags);
+ QPixmapCache::insert(cacheKey, result);
}
+ return result;
+}
- if (widget) {
- widget->setPalette(QPalette());
- }
+void QS60StylePrivate::refreshUI()
+{
+ QList<QWidget *> widgets = QApplication::allWidgets();
- QCommonStyle::unpolish(widget);
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *widget = widgets.at(i);
+ if (widget == 0)
+ continue;
+
+ if (widget->style()) {
+ widget->style()->polish(widget);
+ QEvent event(QEvent::StyleChange);
+ qApp->sendEvent(widget, &event);
+ }
+ widget->update();
+ widget->updateGeometry();
+ }
}
-QVariant QS60StylePrivate::styleProperty(const char *name) const
+void QS60StylePrivate::setFont(QWidget *widget) const
{
- if (name == propertyKeyLayouts) {
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
- static QStringList layouts;
- if (layouts.isEmpty())
- for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++)
- layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName);
- return layouts;
-#else
- qFatal("Cannot return list of 'canned' static layouts. Dynamic layouts are used!");
-#endif
+ QS60StyleEnums::FontCategories fontCategory = QS60StyleEnums::FC_Undefined;
+ if (!widget)
+ return;
+ if (qobject_cast<QPushButton *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Primary;
+ } else if (qobject_cast<QToolButton *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Primary;
+ } else if (qobject_cast<QHeaderView *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Secondary;
+ } else if (qobject_cast<QGroupBox *>(widget)){
+ fontCategory = QS60StyleEnums::FC_Title;
+ }
+ if (fontCategory != QS60StyleEnums::FC_Undefined) {
+ const QFont suggestedFont =
+ s60Font(fontCategory, widget->font().pointSizeF());
+ widget->setFont(suggestedFont);
}
- return QVariant();
}
-QFont QS60StylePrivate::s60Font(
- QS60StyleEnums::FontCategories fontCategory, int pointSize) const
+void QS60StylePrivate::setThemePalette(QWidget *widget) const
{
- QFont result;
- int actualPointSize = pointSize;
- if (actualPointSize <= 0) {
- const QFont appFont = QApplication::font();
- actualPointSize = appFont.pointSize();
- if (actualPointSize <= 0)
- actualPointSize = appFont.pixelSize() * 72 / qt_defaultDpiY();
- }
- Q_ASSERT(actualPointSize > 0);
- const QPair<QS60StyleEnums::FontCategories, int> key(fontCategory, actualPointSize);
- if (!m_mappedFontsCache.contains(key)) {
- result = s60Font_specific(fontCategory, actualPointSize);
- m_mappedFontsCache.insert(key, result);
- } else {
- result = m_mappedFontsCache.value(key);
- if (result.pointSize() != actualPointSize)
- result.setPointSize(actualPointSize);
+ if(!widget)
+ return;
+ QPalette widgetPalette = widget->palette();
+
+ //header view and its viewport need to be set 100% transparent button color, since drawing code will
+ //draw transparent theme graphics to table column and row headers.
+ if (qobject_cast<QHeaderView *>(widget)){
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
+ QHeaderView* header = qobject_cast<QHeaderView *>(widget);
+ widgetPalette.setColor(QPalette::Button, Qt::transparent );
+ if ( header->viewport() )
+ header->viewport()->setPalette(widgetPalette);
+ QApplication::setPalette(widgetPalette, "QHeaderView");
}
- return result;
}
-//todo: you could pass a reason to clear cache here, so that we could
-// deduce whether or not the specific cache needs to be cleared
-void QS60StylePrivate::clearCaches()
+void QS60StylePrivate::setThemePalette(QPalette *palette) const
{
- m_colorCache.clear();
- m_mappedFontsCache.clear();
- QPixmapCache::clear();
- m_backgroundValid = false;
+ if (!palette)
+ return;
+
+ // basic colors
+ palette->setColor(QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0));
+ palette->setColor(QPalette::ToolTipText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0));
+ palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter());
+ palette->setColor(QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ palette->setColor(QPalette::Link,
+ s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0));
+ palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker());
+ palette->setColor(QPalette::Highlight,
+ s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
+ // set background image as a texture brush
+ palette->setBrush(QPalette::Window, backgroundTexture());
+ // set these as transparent so that styled full screen theme background is visible
+ palette->setColor(QPalette::AlternateBase, Qt::transparent);
+ palette->setBrush(QPalette::Base, Qt::transparent);
+ // set button and tooltipbase based on pixel colors
+ const QColor buttonColor = this->colorFromFrameGraphics(SF_ButtonNormal);
+ palette->setColor(QPalette::Button, buttonColor );
+ const QColor toolTipColor = this->colorFromFrameGraphics(SF_ToolTip);
+ palette->setColor(QPalette::ToolTipBase, toolTipColor );
+ palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter());
+ palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker());
+ palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125));
+ palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150));
+ palette->setColor(QPalette::Shadow, Qt::black);
+
+ setThemePaletteHash(palette);
+ storeThemePalette(palette);
}
-QColor QS60StylePrivate::lighterColor(const QColor &baseColor)
+void QS60StylePrivate::deleteThemePalette()
{
- QColor result(baseColor);
- bool modifyColor = false;
- if (result.saturation() == 0) {
- result.setHsv(result.hue(), 128, result.value());
- modifyColor = true;
- }
- if (result.value() == 0) {
- result.setHsv(result.hue(), result.saturation(), 128);
- modifyColor = true;
+ if (m_themePalette) {
+ delete m_themePalette;
+ m_themePalette = 0;
}
- if (modifyColor)
- result = result.lighter(175);
- else
- result = result.lighter(225);
- return result;
}
-bool QS60StylePrivate::isSkinnableDialog(const QWidget *widget)
+void QS60StylePrivate::storeThemePalette(QPalette *palette)
{
- return (qobject_cast<const QMessageBox *> (widget) ||
- qobject_cast<const QErrorMessage *> (widget));
+ deleteThemePalette();
+ //store specified palette for latter use.
+ m_themePalette = new QPalette(*palette);
}
-#if !defined(QT_WS_S60) || defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
-void QS60StylePrivate::setCurrentLayout(int index)
+// set widget specific palettes
+void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
{
- m_pmPointer = data[index];
+ if (!palette)
+ return;
+
+ //store the original palette
+ QPalette widgetPalette = *palette;
+ const QColor mainAreaTextColor =
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0);
+
+ widgetPalette.setColor(QPalette::All, QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0));
+ QApplication::setPalette(widgetPalette, "QSlider");
+ // return to original palette after each widget
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor);
+ const QStyleOption opt;
+ widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt));
+ QApplication::setPalette(widgetPalette, "QPushButton");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor);
+ QApplication::setPalette(widgetPalette, "QToolButton");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0));
+ QApplication::setPalette(widgetPalette, "QHeaderView");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::ButtonText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0));
+ QApplication::setPalette(widgetPalette, "QMenuBar");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::Active, QPalette::WindowText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
+ QApplication::setPalette(widgetPalette, "QTabBar");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::Text,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
+ QApplication::setPalette(widgetPalette, "QTableView");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
+ s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
+ QApplication::setPalette(widgetPalette, "QLineEdit");
+ widgetPalette = *palette;
+
+ widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor);
+ widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button));
+ widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker());
+ widgetPalette.setColor(QPalette::Light, mainAreaTextColor.lighter());
+ QApplication::setPalette(widgetPalette, "QDial");
+ widgetPalette = *palette;
+
+ widgetPalette.setBrush(QPalette::Window, QBrush());
+ QApplication::setPalette(widgetPalette, "QScrollArea");
+ widgetPalette = *palette;
}
-#endif
-QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *option)
+QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlags flags)
{
- QColor retColor (color);
- if (option && !(option->state & QStyle::State_Enabled)) {
- QColor hsvColor = retColor.toHsv();
- int colorSat = hsvColor.saturation();
- int colorVal = hsvColor.value();
- colorSat = (colorSat!=0) ? (colorSat>>1) : 128;
- colorVal = (colorVal!=0) ? (colorVal>>1) : 128;
- hsvColor.setHsv(hsvColor.hue(), colorSat, colorVal);
- retColor = hsvColor.toRgb();
+ QSize result(20, 20);
+ switch (part)
+ {
+ case QS60StyleEnums::SP_QgnGrafBarProgress:
+ result.setWidth(pixelMetric(QStyle::PM_ProgressBarChunkWidth));
+ break;
+ case QS60StyleEnums::SP_QgnGrafTabActiveM:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveM:
+ case QS60StyleEnums::SP_QgnGrafTabActiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveR:
+ case QS60StyleEnums::SP_QgnGrafTabPassiveL:
+ case QS60StyleEnums::SP_QgnGrafTabActiveL:
+ break;
+ case QS60StyleEnums::SP_QgnIndiSliderEdit:
+ result.scale(pixelMetric(QStyle::PM_SliderLength),
+ pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio);
+ break;
+
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed:
+ case QS60StyleEnums::SP_QsnCpScrollBgBottom:
+ case QS60StyleEnums::SP_QsnCpScrollBgMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollBgTop:
+ case QS60StyleEnums::SP_QsnCpScrollHandleBottom:
+ case QS60StyleEnums::SP_QsnCpScrollHandleMiddle:
+ case QS60StyleEnums::SP_QsnCpScrollHandleTop:
+ result.setHeight(pixelMetric(QStyle::PM_ScrollBarExtent));
+ result.setWidth(pixelMetric(QStyle::PM_ScrollBarExtent));
+ break;
+ default:
+ // Generic frame part size gathering.
+ for (int i = 0; i < frameElementsCount; ++i)
+ {
+ switch (m_frameElementsData[i].center - part) {
+ case 8: /* CornerTl */
+ case 7: /* CornerTr */
+ case 6: /* CornerBl */
+ case 5: /* CornerBr */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ // Falltrough intended...
+ case 4: /* SideT */
+ case 3: /* SideB */
+ result.setHeight(pixelMetric(PM_Custom_FrameCornerHeight));
+ break;
+ case 2: /* SideL */
+ case 1: /* SideR */
+ result.setWidth(pixelMetric(PM_Custom_FrameCornerWidth));
+ break;
+ case 0: /* center */
+ default:
+ break;
+ }
+ }
+ break;
}
- return retColor;
+ if (flags & (SF_PointEast | SF_PointWest)) {
+ const int temp = result.width();
+ result.setWidth(result.height());
+ result.setHeight(temp);
+ }
+ return result;
}
/*!
@@ -783,14 +878,6 @@ QColor QS60StylePrivate::stateColor(const QColor& color, const QStyleOption *opt
\sa QMacStyle, QWindowsStyle, QWindowsXPStyle, QWindowsVistaStyle, QPlastiqueStyle, QCleanlooksStyle, QMotifStyle
*/
-/*!
- Constructs a QS60Style object.
-*/
-QS60Style::QS60Style()
- : QCommonStyle(*new QS60StylePrivate)
-{
-}
-
QS60Style::~QS60Style()
{
}
@@ -803,8 +890,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
SubControls sub = option->subControls;
- Q_D(const QS60Style);
-
switch (control) {
#ifndef QT_NO_SCROLLBAR
case CC_ScrollBar:
@@ -817,18 +902,18 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
const QS60StylePrivate::SkinElements grooveElement =
horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical;
QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags);
-
- QStyle::SubControls subControls = optionSlider->subControls;
-
+
+ const QStyle::SubControls subControls = optionSlider->subControls;
+
// select correct slider (horizontal/vertical/pressed)
const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider));
const QS60StylePrivate::SkinElements handleElement =
- horizontal ?
- ( sliderPressed ?
- QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal :
- QS60StylePrivate::SE_ScrollBarHandleHorizontal ) :
- ( sliderPressed ?
- QS60StylePrivate::SE_ScrollBarHandlePressedVertical :
+ horizontal ?
+ ( sliderPressed ?
+ QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal :
+ QS60StylePrivate::SE_ScrollBarHandleHorizontal ) :
+ ( sliderPressed ?
+ QS60StylePrivate::SE_ScrollBarHandlePressedVertical :
QS60StylePrivate::SE_ScrollBarHandleVertical);
QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags);
}
@@ -870,11 +955,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
const QRect cmbxEditField = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
const QRect cmbxFrame = subControlRect(CC_ComboBox, option, SC_ComboBoxFrame, widget);
-
const bool direction = cmb->direction == Qt::LeftToRight;
// Button frame
- //todo: why calc rect here for button? Is there no suitable SE_xxx for that?
QStyleOptionFrame buttonOption;
buttonOption.QStyleOption::operator=(*cmb);
const int maxHeight = cmbxFrame.height();
@@ -884,15 +967,15 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
buttonOption.rect = buttonRect;
buttonOption.state = cmb->state & (State_Enabled | State_MouseOver);
drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget);
- // todo: we could draw qgn_prop_set_button skin item here
// draw label background - label itself is drawn separately
const QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_FrameLineEdit;
QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags);
+ // Draw the combobox arrow
if (sub & SC_ComboBoxArrow) {
- // Draw the little arrow
- buttonOption.rect.adjust(1, 1, -1, -1);
+ // Make rect slightly smaller
+ buttonOption.rect.adjust(1, 1, -1, -1);
painter->save();
painter->setPen(option->palette.buttonText().color());
drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget);
@@ -1032,14 +1115,13 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (spinBox->subControls & SC_SpinBoxUp) {
copy.subControls = SC_SpinBoxUp;
- QPalette pal2 = spinBox->palette;
+ QPalette spinBoxPal = spinBox->palette;
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
+ spinBoxPal.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
+ copy.palette = spinBoxPal;
}
- copy.palette = pal2;
-
if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) {
copy.state |= State_On;
copy.state |= State_Sunken;
@@ -1047,8 +1129,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
- pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
- : PE_IndicatorSpinUp);
+ pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ?
+ PE_IndicatorSpinPlus :
+ PE_IndicatorSpinUp;
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget);
drawPrimitive(PE_PanelButtonBevel, &copy, painter, widget);
@@ -1059,12 +1142,12 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (spinBox->subControls & SC_SpinBoxDown) {
copy.subControls = SC_SpinBoxDown;
copy.state = spinBox->state;
- QPalette pal2 = spinBox->palette;
+ QPalette spinBoxPal = spinBox->palette;
if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
+ spinBoxPal.setCurrentColorGroup(QPalette::Disabled);
copy.state &= ~State_Enabled;
+ copy.palette = spinBoxPal;
}
- copy.palette = pal2;
if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) {
copy.state |= State_On;
@@ -1073,8 +1156,9 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
copy.state |= State_Raised;
copy.state &= ~State_Sunken;
}
- pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
- : PE_IndicatorSpinDown);
+ pe = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) ?
+ PE_IndicatorSpinMinus :
+ PE_IndicatorSpinDown;
copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget);
drawPrimitive(PE_PanelButtonBevel, &copy, painter, widget);
@@ -1134,23 +1218,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
break;
#endif //QT_NO_GROUPBOX
-#ifndef QT_NO_DIAL
- case CC_Dial:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- QStyleOptionSlider optionSlider = *slider;
- QCommonStyle::drawComplexControl(control, &optionSlider, painter, widget);
- }
- break;
-#endif //QT_NO_DIAL
-
- //todo: remove non-used complex widgets in final version
- case CC_TitleBar:
-#ifdef QT3_SUPPORT
- case CC_Q3ListView:
-#endif //QT3_SUPPORT
-#ifndef QT_NO_WORKSPACE
- case CC_MdiControls:
-#endif //QT_NO_WORKSPACE
default:
QCommonStyle::drawComplexControl(control, option, painter, widget);
}
@@ -1171,21 +1238,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
- if (buttonWidget->isCheckable()) {
- QStyleOptionButton checkopt = subopt;
-
- const int indicatorHeight(pixelMetric(PM_IndicatorHeight));
- const int verticalAdjust = (option->rect.height() - indicatorHeight) >> 1;
-
- checkopt.rect.adjust(pixelMetric(PM_ButtonMargin), verticalAdjust, 0, 0);
- checkopt.rect.setWidth(pixelMetric(PM_IndicatorWidth));
- checkopt.rect.setHeight(indicatorHeight);
-
- drawPrimitive(PE_IndicatorCheckBox, &checkopt, painter, widget);
- }
- }
-
drawControl(CE_PushButtonLabel, &subopt, painter, widget);
if (btn->state & State_HasFocus) {
QStyleOptionFocusRect fropt;
@@ -1197,55 +1249,43 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
break;
case CE_PushButtonBevel:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- const bool isPressed = option->state & QStyle::State_Sunken;
- if (button->features & QStyleOptionButton::Flat) {
- const QS60StyleEnums::SkinParts skinPart =
- isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter;
- QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+ const bool isDisabled = !(option->state & QStyle::State_Enabled);
+ const bool isFlat = button->features & QStyleOptionButton::Flat;
+ QS60StyleEnums::SkinParts skinPart;
+ QS60StylePrivate::SkinElements skinElement;
+ if (!isDisabled) {
+ const bool isPressed = (option->state & QStyle::State_Sunken) ||
+ (option->state & QStyle::State_On);
+ if (isFlat) {
+ skinPart =
+ isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter;
+ } else {
+ skinElement =
+ isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
+ }
} else {
- const QS60StylePrivate::SkinElements skinElement =
- isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ if (isFlat)
+ skinPart =QS60StyleEnums::SP_QsnFrButtonCenterInactive;
+ else
+ skinElement = QS60StylePrivate::SE_ButtonInactive;
}
- }
- break;
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionButton = *button;
-
- if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) {
- if (buttonWidget->isCheckable()) {
- // space for check box.
- optionButton.rect.adjust(pixelMetric(PM_IndicatorWidth)
- + pixelMetric(PM_ButtonMargin) + pixelMetric(PM_CheckBoxLabelSpacing), 0, 0, 0);
- }
+ if (isFlat)
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+ else
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
}
- QCommonStyle::drawControl(element, &optionButton, painter, widget);
- }
- break;
- case CE_CheckBoxLabel:
- if (const QStyleOptionButton *checkBox = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionCheckBox = *checkBox;
- QCommonStyle::drawControl(element, &optionCheckBox, painter, widget);
- }
- break;
- case CE_RadioButtonLabel:
- if (const QStyleOptionButton *radioButton = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QStyleOptionButton optionRadioButton = *radioButton;
- QCommonStyle::drawControl(element, &optionRadioButton, painter, widget);
- }
break;
#ifndef QT_NO_TOOLBUTTON
case CE_ToolButtonLabel:
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
QStyleOptionToolButton optionToolButton = *toolBtn;
-
- if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken)
+
+ if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken)
&& (optionToolButton.state & State_Enabled)) {
-
+
const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off;
const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize),
- QIcon::Normal, state));
+ QIcon::Normal, state));
optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton);
}
@@ -1253,12 +1293,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif //QT_NO_TOOLBUTTON
- case CE_HeaderLabel:
- if (const QStyleOptionHeader *headerLabel = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- QStyleOptionHeader optionHeaderLabel = *headerLabel;
- QCommonStyle::drawControl(element, &optionHeaderLabel, painter, widget);
- }
- break;
#ifndef QT_NO_COMBOBOX
case CE_ComboBoxLabel:
if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
@@ -1330,28 +1364,30 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget);
QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget);
- // draw the background
- const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
- const QTableView *table = qobject_cast<const QTableView *>(widget);
- if (table && tableOption) {
- const QModelIndex index = tableOption->index;
- //todo: Draw cell background only once - for the first cell.
- QStyleOptionViewItemV4 voptAdj2 = voptAdj2;
- const QModelIndex indexFirst = table->model()->index(0,0);
- const QModelIndex indexLast = table->model()->index(
- table->model()->rowCount()-1,table->model()->columnCount()-1);
- if (table->viewport())
- voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(),
- table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect());
- drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget);
- }
+ // draw themed background for table unless background brush has been defined.
+ if (vopt->backgroundBrush == Qt::NoBrush) {
+ const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
+ const QTableView *table = qobject_cast<const QTableView *>(widget);
+ if (table && tableOption) {
+ const QModelIndex index = tableOption->index;
+ //todo: Draw cell background only once - for the first cell.
+ QStyleOptionViewItemV4 voptAdj2 = voptAdj;
+ const QModelIndex indexFirst = table->model()->index(0,0);
+ const QModelIndex indexLast = table->model()->index(
+ table->model()->rowCount()-1,table->model()->columnCount()-1);
+ if (table->viewport())
+ voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(),
+ table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect());
+ drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget);
+ }
+ } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);}
// draw the focus rect
if (isSelected)
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
// draw the icon
- const QIcon::Mode mode = !(voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled;
+ const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled;
const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off;
voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state);
@@ -1361,17 +1397,15 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
listView &&
(listView->selectionMode() == QAbstractItemView::SingleSelection ||
listView->selectionMode() == QAbstractItemView::NoSelection);
- QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
- if (voptAdj.state & QStyle::State_Selected &&
- !singleSelection) {
+ const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
+ if (voptAdj.state & QStyle::State_Selected && !singleSelection) {
QStyleOptionViewItemV4 option(voptAdj);
option.rect = selectionRect;
// Draw selection mark.
drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
if ( textRect.right() > selectionRect.left() )
textRect.setRight(selectionRect.left());
- }
- else if (singleSelection &&
+ } else if (singleSelection &&
voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) {
// draw the check mark
if (selectionRect.isValid()) {
@@ -1400,9 +1434,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
if (isSelected) {
if (qobject_cast<const QTableView *>(widget) && tableOption)
- voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
+ voptAdj.palette.setColor(
+ QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
else
- voptAdj.palette.setColor(QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
+ voptAdj.palette.setColor(
+ QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0));
}
painter->setPen(voptAdj.palette.text().color());
d->viewItemDrawText(painter, &voptAdj, textRect);
@@ -1454,7 +1490,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const int tabOverlap =
QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness;
//todo: draw navi wipe behind tabbar - must be drawn with first draw
- //QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, windowRect, flags);
if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive||
skinElement==QS60StylePrivate::SE_TabBarTabEastActive||
@@ -1501,7 +1536,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
painter->save();
QFont f = painter->font();
- f.setPointSizeF(f.pointSizeF() * 0.72);
+ f.setPointSizeF(f.pointSizeF() * KTabFontMul);
painter->setFont(f);
if (option->state & QStyle::State_Selected){
@@ -1509,27 +1544,27 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 3, option));
}
- bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
+ const bool verticalTabs = optionTab.shape == QTabBar::RoundedEast
|| optionTab.shape == QTabBar::RoundedWest
|| optionTab.shape == QTabBar::TriangularEast
|| optionTab.shape == QTabBar::TriangularWest;
- bool selected = optionTab.state & State_Selected;
+ const bool selected = optionTab.state & State_Selected;
if (verticalTabs) {
painter->save();
- int newX, newY, newRot;
+ int newX, newY, newRotation;
if (optionTab.shape == QTabBar::RoundedEast || optionTab.shape == QTabBar::TriangularEast) {
newX = tr.width();
newY = tr.y();
- newRot = 90;
+ newRotation = 90;
} else {
newX = 0;
newY = tr.y() + tr.height();
- newRot = -90;
+ newRotation = -90;
}
tr.setRect(0, 0, tr.height(), tr.width());
QTransform m;
m.translate(newX, newY);
- m.rotate(newRot);
+ m.rotate(newRotation);
painter->setTransform(m, true);
}
tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget),
@@ -1551,9 +1586,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QPixmap tabIcon = optionTab.icon.pixmap(iconSize,
(optionTab.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
if (tab->text.isEmpty())
- painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1), tr.center().y() - (tabIcon.height() >>1), tabIcon);
+ painter->drawPixmap(tr.center().x() - (tabIcon.height() >>1),
+ tr.center().y() - (tabIcon.height() >>1),
+ tabIcon);
else
- painter->drawPixmap(tr.left() + tabOverlap, tr.center().y() - (tabIcon.height() >>1), tabIcon);
+ painter->drawPixmap(tr.left() + tabOverlap,
+ tr.center().y() - (tabIcon.height() >>1),
+ tabIcon);
tr.setLeft(tr.left() + iconSize.width() + 4);
}
@@ -1563,13 +1602,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (optionTab.state & State_HasFocus) {
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
- const int x1 = optionTab.rect.left();
- const int x2 = optionTab.rect.right() - 1;
+ const int leftBorder = optionTab.rect.left();
+ const int rightBorder = optionTab.rect.right() - 1;
QStyleOptionFocusRect fropt;
fropt.QStyleOption::operator=(*tab);
- fropt.rect.setRect(x1 + 1 + OFFSET, optionTab.rect.y() + OFFSET,
- x2 - x1 - 2*OFFSET, optionTab.rect.height() - 2*OFFSET);
+ fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET,
+ rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET);
drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
}
@@ -1619,31 +1658,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif // QT_NO_PROGRESSBAR
-#ifndef QT_NO_MENUBAR
- case CE_MenuBarItem:
- if (const QStyleOptionMenuItem *menuBarItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- QStyleOptionMenuItem optionMenuBarItem = *menuBarItem;
- QCommonStyle::drawControl(element, &optionMenuBarItem, painter, widget);
- }
- break;
-#endif //QT_NO_MENUBAR
#ifndef QT_NO_MENU
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
QStyleOptionMenuItem optionMenuItem = *menuItem;
- const bool enabled = optionMenuItem.state & State_Enabled;
- const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable;
-
- uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip
- | Qt::TextSingleLine | Qt::AlignVCenter;
- if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
- text_flags |= Qt::TextHideMnemonic;
-
- QRect iconRect =
- subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
- QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
+
bool drawSubMenuIndicator = false;
-
switch(menuItem->menuItemType) {
case QStyleOptionMenuItem::Scroller:
case QStyleOptionMenuItem::Separator:
@@ -1654,20 +1674,29 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
default:
break;
}
+ const bool enabled = optionMenuItem.state & State_Enabled;
+ const bool checkable = optionMenuItem.checkType != QStyleOptionMenuItem::NotCheckable;
+
+ uint text_flags = Qt::AlignLeading | Qt::TextShowMnemonic | Qt::TextDontClip
+ | Qt::TextSingleLine | Qt::AlignVCenter;
+ if (!styleHint(SH_UnderlineShortcut, menuItem, widget))
+ text_flags |= Qt::TextHideMnemonic;
+
+ QRect iconRect =
+ subElementRect(SE_ItemViewItemDecoration, &optionMenuItem, widget);
+ QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget);
if ((option->state & State_Selected) && (option->state & State_Enabled))
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags);
//todo: move the vertical spacing stuff into subElementRect
const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing);
- QStyleOptionMenuItem optionCheckBox;
if (checkable){
- QRect checkBoxRect = optionMenuItem.rect;
- checkBoxRect.setWidth(pixelMetric(PM_IndicatorWidth));
- checkBoxRect.setHeight(pixelMetric(PM_IndicatorHeight));
+ QStyleOptionMenuItem optionCheckBox;
optionCheckBox.QStyleOption::operator=(*menuItem);
- optionCheckBox.rect = checkBoxRect;
- const int moveByX = checkBoxRect.width()+vSpacing;
+ optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth));
+ optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight));
+ const int moveByX = optionCheckBox.rect.width()+vSpacing;
if (optionMenuItem.direction == Qt::LeftToRight) {
textRect.translate(moveByX,0);
iconRect.translate(moveByX, 0);
@@ -1718,21 +1747,18 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text)));
painter->save();
painter->setOpacity(0.5);
- QCommonStyle::drawItemText(painter, textRect, text_flags,
+ }
+ QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
optionMenuItem.text, QPalette::Text);
+ if (!enabled)
painter->restore();
- } else {
- QCommonStyle::drawItemText(painter, textRect, text_flags,
- optionMenuItem.palette, enabled,
- optionMenuItem.text, QPalette::Text);
- }
}
break;
+ case CE_MenuEmptyArea:
+ break;
#endif //QT_NO_MENU
- //todo: remove non-used widgets in final version
- case CE_MenuEmptyArea:
#ifndef QT_NO_MENUBAR
case CE_MenuBarEmptyArea:
break;
@@ -1762,19 +1788,20 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_HeaderEmptyArea:
{
QS60StylePrivate::SkinElementFlags adjFlags = flags;
- QRect mtyRect = option->rect;
+ QRect emptyAreaRect = option->rect;
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
if (option->state & QStyle::State_Horizontal) {
- mtyRect.adjust(-2,-2,2,-2);
+ emptyAreaRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth);
} else {
if ( option->direction == Qt::LeftToRight ) {
- mtyRect.adjust(-2,-2,0,2);
+ emptyAreaRect.adjust(-frameWidth,-frameWidth,0,frameWidth);
adjFlags |= QS60StylePrivate::SF_PointWest;
} else {
- mtyRect.adjust(2,2,0,-2);
+ emptyAreaRect.adjust(frameWidth,frameWidth,0,-frameWidth);
adjFlags |= QS60StylePrivate::SF_PointEast;
}
}
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags);
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, emptyAreaRect, adjFlags);
}
break;
case CE_Header:
@@ -1782,19 +1809,32 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::SkinElementFlags adjFlags = flags;
QRect mtyRect = header->rect;
QRect parentRect = widget->parentWidget()->rect();
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
if (header->orientation == Qt::Horizontal) {
- mtyRect.adjust(-2,-2,2,-2);
+ mtyRect.adjust(-frameWidth,-frameWidth,frameWidth,-frameWidth);
} else {
if ( header->direction == Qt::LeftToRight ) {
- mtyRect.adjust(-2,-2,0,2);
+ mtyRect.adjust(-frameWidth,-frameWidth,0,frameWidth);
adjFlags |= QS60StylePrivate::SF_PointWest;
} else {
- mtyRect.adjust(2,2,0,-2);
+ mtyRect.adjust(frameWidth,frameWidth,0,-frameWidth);
adjFlags |= QS60StylePrivate::SF_PointEast;
}
}
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, mtyRect, adjFlags);
- QCommonStyle::drawControl(element, header, painter, widget);
+
+ QRegion clipRegion = painter->clipRegion();
+ painter->setClipRect(option->rect);
+ drawControl(CE_HeaderSection, header, painter, widget);
+ QStyleOptionHeader subopt = *header;
+ subopt.rect = subElementRect(SE_HeaderLabel, header, widget);
+ if (subopt.rect.isValid())
+ drawControl(CE_HeaderLabel, &subopt, painter, widget);
+ if (header->sortIndicator != QStyleOptionHeader::None) {
+ subopt.rect = subElementRect(SE_HeaderArrow, option, widget);
+ drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget);
+ }
+ painter->setClipRegion(clipRegion);
}
break;
#ifndef QT_NO_TOOLBAR
@@ -1802,6 +1842,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
const QToolBar *tbWidget = qobject_cast<const QToolBar *>(widget);
+ //toolbar within a toolbar, skip
if (!tbWidget || (widget && qobject_cast<QToolBar *>(widget->parentWidget())))
break;
@@ -1839,48 +1880,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
break;
#endif //QT_NO_TOOLBAR
-
case CE_ShapedFrame:
- case CE_MenuVMargin:
- case CE_MenuHMargin:
-#ifndef QT_NO_MENU
- case CE_MenuScroller:
- case CE_MenuTearoff:
-#endif //QT_NO_MENU
-
- case CE_CheckBox:
- case CE_RadioButton:
-#ifndef QT_NO_TABBAR
- case CE_TabBarTab:
-#endif //QT_NO_TABBAR
-#ifndef QT_NO_PROGRESSBAR
- case CE_ProgressBar:
-#endif // QT_NO_PROGRESSBAR
- case CE_Q3DockWindowEmptyArea:
-#ifndef QT_NO_SIZEGRIP
- case CE_SizeGrip:
-#endif //QT_NO_SIZEGRIP
- case CE_Splitter:
-#ifndef QT_NO_RUBBERBAND
- case CE_RubberBand:
-#endif //QT_NO_RUBBERBAND
-#ifndef QT_NO_DOCKWIDGET
- case CE_DockWidgetTitle:
-#endif //QT_NO_DOCKWIDGET
- case CE_ScrollBarAddLine:
- case CE_ScrollBarSubLine:
- case CE_ScrollBarAddPage:
- case CE_ScrollBarSubPage:
- case CE_ScrollBarSlider:
- case CE_ScrollBarFirst:
- case CE_ScrollBarLast:
- case CE_FocusFrame:
-#ifndef QT_NO_TOOLBOX
- case CE_ToolBoxTab:
- case CE_ToolBoxTabShape:
- case CE_ToolBoxTabLabel:
-#endif //QT_NO_TOOLBOX
- case CE_ColumnViewGrip:
+ if (qobject_cast<const QTextEdit *>(widget))
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
+ if (option->state & State_HasFocus)
+ drawPrimitive(PE_FrameFocusRect, option, painter, widget);
+ break;
default:
QCommonStyle::drawControl(element, option, painter, widget);
}
@@ -1919,6 +1924,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
break;
case PE_IndicatorViewItemCheck:
+#ifndef QT_NO_ITEMVIEWS
if (const QListView *listItem = (qobject_cast<const QListView *>(widget))) {
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
const bool checkBoxVisible = vopt->features & QStyleOptionViewItemV2::HasCheckIndicator;
@@ -1931,7 +1937,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
} else if (option->state & QStyle::State_Selected) {
QRect tickRect = option->rect;
const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- // adjust tickmark rect to exclude frame border
+ // adjust tickmark rect to exclude frame border
tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth);
QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd;
QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect,
@@ -1939,9 +1945,9 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
}
}
+#endif //QT_NO_ITEMVIEWS
break;
- case PE_IndicatorRadioButton:
- {
+ case PE_IndicatorRadioButton: {
QRect buttonRect = option->rect;
//there is empty (a. 33%) space in svg graphics for radiobutton
const qreal reduceWidth = (qreal)buttonRect.width()/3.0;
@@ -1964,8 +1970,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_PanelButtonCommand:
case PE_PanelButtonTool:
case PE_PanelButtonBevel:
- case PE_FrameButtonBevel:
- {
+ case PE_FrameButtonBevel: {
const bool isPressed = option->state & QStyle::State_Sunken;
const QS60StylePrivate::SkinElements skinElement =
isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
@@ -1976,8 +1981,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorArrowDown:
case PE_IndicatorArrowLeft:
case PE_IndicatorArrowRight:
- case PE_IndicatorArrowUp:
- {
+ case PE_IndicatorArrowUp: {
QS60StyleEnums::SkinParts skinPart;
if (element==PE_IndicatorArrowDown)
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
@@ -1987,7 +1991,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight;
else if (element==PE_IndicatorArrowUp)
skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp;
-
+
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
}
break;
@@ -1997,11 +2001,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
QStyleOptionSpinBox optionSpinBox = *spinBox;
- const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
- QS60StyleEnums::SP_QgnGrafScrollArrowUp :
+ const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
+ QS60StyleEnums::SP_QgnGrafScrollArrowUp :
QS60StyleEnums::SP_QgnGrafScrollArrowDown;
const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6;
- optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags);
}
#ifndef QT_NO_COMBOBOX
@@ -2010,11 +2014,11 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
QStyleOptionFrame comboBox = *cmb;
const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6;
- comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags);
}
#endif //QT_NO_COMBOBOX
- break;
+ break;
case PE_IndicatorSpinMinus:
case PE_IndicatorSpinPlus:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
@@ -2025,15 +2029,27 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
// We want to draw down arrow here for comboboxes as well.
QStyleOptionFrame comboBox = *cmb;
- comboBox.rect.adjust(0,2,0,-2);
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
+ comboBox.rect.adjust(0,frameWidth,0,-frameWidth);
QCommonStyle::drawPrimitive(element, &comboBox, painter, widget);
}
#endif //QT_NO_COMBOBOX
break;
#endif //QT_NO_SPINBOX
case PE_FrameFocusRect:
- if (!(widget && qobject_cast<const QCalendarWidget *>(widget->parent())) ||
- qobject_cast<const QComboBoxListView *>(widget)) {
+// Calendar widget and combox both do not use styled itemDelegate
+ if ( widget && (
+#ifndef QT_NO_CALENDARWIDGET
+ (qobject_cast<const QCalendarWidget *>(widget->parent()))
+#else
+ false
+#endif //QT_NO_CALENDARWIDGET
+#ifndef QT_NO_COMBOBOX
+ || (qobject_cast<const QComboBoxListView *>(widget))
+#else
+ || false
+#endif //QT_NO_COMBOBOX
+ )) {
// no focus selection for touch
if (option->state & State_HasFocus && !QS60StylePrivate::isTouchSupported()) {
painter->save();
@@ -2062,11 +2078,16 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
break;
case PE_Widget:
- if (QS60StylePrivate::isSkinnableDialog(widget) ||
- qobject_cast<const QComboBoxListView *>(widget) ||
- qobject_cast<const QMenu *> (widget)) {
- QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif //QT_NO_MENU
+ ) {
+ QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
}
break;
case PE_FrameWindow:
@@ -2132,8 +2153,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
break; //disable frame in menu
case PE_IndicatorBranch:
- {
#if defined(Q_WS_S60)
+ // 3.1 AVKON UI does not have tree view component, use common style for drawing there
if (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1) {
#else
if (true) {
@@ -2157,29 +2178,26 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
drawSkinPart = true;
}
- if ( drawSkinPart ) {
- QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect,
- (flags | QS60StylePrivate::SF_ColorSkinned));
- }
-
+ if ( drawSkinPart )
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
+
if (option->state & State_Children) {
- QS60StyleEnums::SkinParts skinPart =
- (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
+ QS60StyleEnums::SkinParts skinPart =
+ (option->state & State_Open) ? QS60StyleEnums::SP_QgnIndiHlColSuper : QS60StyleEnums::SP_QgnIndiHlExpSuper;
int minDimension = qMin(option->rect.width(), option->rect.height());
const int resizeValue = minDimension >> 1;
minDimension += resizeValue; // Adjust the icon bigger because of empty space in svg icon.
QRect iconRect(option->rect.topLeft(), QSize(minDimension, minDimension));
int verticalMagic(0);
// magic values for positioning svg icon.
- if (option->rect.width() <= option->rect.height())
- verticalMagic = 3;
+ if (option->rect.width() <= option->rect.height())
+ verticalMagic = 3;
iconRect.translate(3, verticalMagic - resizeValue);
- QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags);
- }
+ QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags);
+ }
}
- }
- break;
-
+ break;
+
// todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases
case PE_FrameLineEdit:
case PE_IndicatorButtonDropDown:
@@ -2210,18 +2228,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
}
}
-/*!
- \reimp - sets the default colors
-*/
-void QS60Style::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette & palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const
-{
- QPalette override = palette;
- QCommonStyle::drawItemText(painter, rectangle, alignment, override, enabled, text, textRole);
-}
-
-/*!
- \reimp
-*/
+/*! \reimp */
int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
{
int metricValue = QS60StylePrivate::pixelMetric(metric);
@@ -2229,7 +2236,6 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
metricValue = QCommonStyle::pixelMetric(metric, option, widget);
if (metric == PM_SubMenuOverlap && widget){
- const int widgetWidth = widget->width();
const QMenu *menu = qobject_cast<const QMenu *>(widget);
if (menu && menu->activeAction() && menu->activeAction()->menu()) {
const int menuWidth = menu->activeAction()->menu()->sizeHint().width();
@@ -2238,6 +2244,7 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
}
return metricValue;
}
+
/*! \reimp */
QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
const QSize &csz, const QWidget *widget) const
@@ -2247,7 +2254,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
case CT_PushButton:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget)))
- if (buttonWidget->isCheckable())
+ if (buttonWidget->isCheckable())
sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0);
break;
case CT_LineEdit:
@@ -2260,22 +2267,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
}
return sz;
}
+
/*! \reimp */
int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget,
QStyleHintReturn *hret) const
{
int retValue = -1;
switch (sh) {
- case SH_Table_GridLineColor: {
- QColor lineColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0);
- retValue = lineColor.rgb();
- }
- break;
- case SH_GroupBox_TextLabelColor: {
- QColor groupBoxTxtColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0);
- retValue = groupBoxTxtColor.rgb();
- }
- break;
+ case SH_Table_GridLineColor:
+ retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors,2,0).rgb();
+ break;
+ case SH_GroupBox_TextLabelColor:
+ retValue = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors,6,0).rgb();
+ break;
case SH_ScrollBar_ScrollWhenPointerLeavesControl:
retValue = true;
break;
@@ -2289,10 +2293,39 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
retValue = '*';
break;
case SH_ComboBox_PopupFrameStyle:
- retValue = QFrame::NoFrame;
+ retValue = QFrame::NoFrame | QFrame::Plain;
break;
case SH_Dial_BackgroundRole:
retValue = QPalette::Base;
+ break;
+ case SH_ItemView_ActivateItemOnSingleClick:
+ retValue = true;
+ break;
+ case SH_ProgressDialog_TextLabelAlignment:
+ retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ?
+ Qt::AlignLeft :
+ Qt::AlignRight;
+ break;
+ case SH_Menu_SubMenuPopupDelay:
+ retValue = 300;
+ break;
+ case SH_Menu_Scrollable:
+ retValue = true;
+ break;
+ case SH_Menu_SelectionWrap:
+ retValue = true;
+ break;
+ case SH_ItemView_ShowDecorationSelected:
+ retValue = true;
+ break;
+ case SH_ToolBar_Movable:
+ retValue = false;
+ break;
+ case SH_BlinkCursorWhenTextSelected:
+ retValue = true;
+ break;
+ case SH_UnderlineShortcut:
+ retValue = 0;
default:
break;
}
@@ -2301,10 +2334,7 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
return retValue;
}
-
-/*!
- \reimp
-*/
+/*! \reimp */
QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget) const
{
QRect ret;
@@ -2324,6 +2354,11 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
sliderlen = (qint64(scrollbarOption->pageStep) * maxlen) / (range + scrollbarOption->pageStep);
int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbarOption, widget);
+ if (isHorizontal && slidermin < scrollBarRect.height())
+ slidermin = scrollBarRect.height();
+ else if (!isHorizontal && slidermin < scrollBarRect.width())
+ slidermin = scrollBarRect.width();
+
if (sliderlen < slidermin || range > (INT_MAX>>1))
sliderlen = slidermin;
if (sliderlen > maxlen)
@@ -2339,35 +2374,33 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
scrollbarOption->upsideDown);
switch (scontrol) {
- case SC_ScrollBarSubLine: // top/left button
- case SC_ScrollBarAddLine: // bottom/right button
- break;
- case SC_ScrollBarSubPage: // between top/left button and slider
- if (isHorizontal)
- ret.setRect(0, 0, sliderstart, scrollBarRect.height());
- else
- ret.setRect(0, 0, scrollBarRect.width(), sliderstart);
- break;
- case SC_ScrollBarAddPage: // between bottom/right button and slider
- {
+ case SC_ScrollBarSubPage: // between top/left button and slider
+ if (isHorizontal)
+ ret.setRect(0, 0, sliderstart, scrollBarRect.height());
+ else
+ ret.setRect(0, 0, scrollBarRect.width(), sliderstart);
+ break;
+ case SC_ScrollBarAddPage: { // between bottom/right button and slider
const int addPageLength = sliderstart + sliderlen;
if (isHorizontal)
ret = scrollBarRect.adjusted(addPageLength, 0, 0, 0);
else
ret = scrollBarRect.adjusted(0, addPageLength, 0, 0);
- }
- break;
- case SC_ScrollBarGroove:
- ret = scrollBarRect;
- break;
- case SC_ScrollBarSlider:
- if (scrollbarOption->orientation == Qt::Horizontal)
- ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
- else
- ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
- break;
- default:
- break;
+ }
+ break;
+ case SC_ScrollBarGroove:
+ ret = scrollBarRect;
+ break;
+ case SC_ScrollBarSlider:
+ if (scrollbarOption->orientation == Qt::Horizontal)
+ ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height());
+ else
+ ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen);
+ break;
+ case SC_ScrollBarSubLine: // top/left button
+ case SC_ScrollBarAddLine: // bottom/right button
+ default:
+ break;
}
ret = visualRect(scrollbarOption->direction, scrollBarRect, ret);
}
@@ -2387,35 +2420,35 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
const int x = spinbox->rect.x() + spinbox->rect.width() - frameThickness - 2*buttonSize.width();
switch (scontrol) {
- case SC_SpinBoxUp:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- ret = QRect(x, y, buttonWidth, buttonSize.height());
- break;
- case SC_SpinBoxDown:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height());
- break;
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- ret = QRect(
- frameThickness,
- frameThickness,
- spinbox->rect.width() - 2*frameThickness,
- spinbox->rect.height() - 2*frameThickness);
- else
- ret = QRect(
- frameThickness,
- frameThickness,
- x - frameThickness,
- spinbox->rect.height() - 2*frameThickness);
- break;
- case SC_SpinBoxFrame:
- ret = spinbox->rect;
- break;
- default:
- break;
+ case SC_SpinBoxUp:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ ret = QRect(x, y, buttonWidth, buttonSize.height());
+ break;
+ case SC_SpinBoxDown:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ ret = QRect(x+buttonSize.width(), y, buttonWidth, buttonSize.height());
+ break;
+ case SC_SpinBoxEditField:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ ret = QRect(
+ frameThickness,
+ frameThickness,
+ spinbox->rect.width() - 2*frameThickness,
+ spinbox->rect.height() - 2*frameThickness);
+ else
+ ret = QRect(
+ frameThickness,
+ frameThickness,
+ x - frameThickness,
+ spinbox->rect.height() - 2*frameThickness);
+ break;
+ case SC_SpinBoxFrame:
+ ret = spinbox->rect;
+ break;
+ default:
+ break;
}
ret = visualRect(spinbox->direction, spinbox->rect, ret);
}
@@ -2429,7 +2462,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
// lets use spinbox frame here as well, as no combobox specific value available.
const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0;
const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize);
- int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
+ const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth;
const int ypos = cmb->rect.y();
QSize buttonSize;
@@ -2458,26 +2491,26 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
ret = QCommonStyle::subControlRect(control, option, scontrol, widget);
switch (scontrol) {
- case SC_GroupBoxCheckBox: //fallthrough
- case SC_GroupBoxLabel:
- //slightly indent text and boxes, so that dialog border does not mess with them.
- const int horizontalSpacing =
- QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- const int bottomMargin = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutBottomMargin);
- ret.adjust(2,horizontalSpacing-3,0,0);
- break;
- case SC_GroupBoxFrame: {
- const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);
- const int tbHeight = textBox.height();
- ret.translate(0, -ret.y());
- // include title to within the groupBox frame
- ret.setHeight(ret.height()+tbHeight);
- if (widget && ret.bottom() > widget->rect().bottom())
- ret.setBottom(widget->rect().bottom());
- }
- break;
- default:
- break;
+ case SC_GroupBoxCheckBox: //fallthrough
+ case SC_GroupBoxLabel: {
+ //slightly indent text and boxes, so that dialog border does not mess with them.
+ const int horizontalSpacing =
+ QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
+ ret.adjust(2,horizontalSpacing-3,0,0);
+ }
+ break;
+ case SC_GroupBoxFrame: {
+ const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);
+ const int tbHeight = textBox.height();
+ ret.translate(0, -ret.y());
+ // include title to within the groupBox frame
+ ret.setHeight(ret.height()+tbHeight);
+ if (widget && ret.bottom() > widget->rect().bottom())
+ ret.setBottom(widget->rect().bottom());
+ }
+ break;
+ default:
+ break;
}
}
break;
@@ -2494,9 +2527,8 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
case SE_LineEditContents: {
// in S60 the input text box doesn't start from line Edit's TL, but
// a bit indented.
- // todo: Should we NOT do this for combo boxes and spin boxes?
QRect lineEditRect = opt->rect;
- int adjustment = opt->rect.height()>>2;
+ const int adjustment = opt->rect.height()>>2;
lineEditRect.adjust(adjustment,0,0,0);
ret = lineEditRect;
}
@@ -2568,13 +2600,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
}
} else if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
const bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
- const bool subMenu = menuItem->menuItemType == QStyleOptionMenuItem::SubMenu;
- int indicatorWidth = checkable ?
+ const int indicatorWidth = checkable ?
pixelMetric(PM_ListViewIconSize, opt, widget) :
pixelMetric(PM_SmallIconSize, opt, widget);
ret = menuItem->rect;
- const int verticalSpacing =
- QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing);
if (element == SE_ItemViewItemDecoration) {
if (menuItem->direction == Qt::RightToLeft)
@@ -2591,11 +2620,10 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// Make room for submenu indicator
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu){
// submenu indicator is very small, so lets halve the rect
- indicatorWidth = indicatorWidth >> 1;
if (menuItem->direction == Qt::LeftToRight)
- ret.adjust(0,0,-indicatorWidth,0);
+ ret.adjust(0,0,-(indicatorWidth >> 1),0);
else
- ret.adjust(indicatorWidth,0,0,0);
+ ret.adjust((indicatorWidth >> 1),0,0,0);
}
}
}
@@ -2624,11 +2652,15 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
// Move rect and make it slightly smaller, so that
// a) highlight border does not cross the rect
// b) in s60 list checkbox is smaller than normal checkbox
- ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset, indicatorWidth-3, indicatorHeight-3);
+ //todo; magic three
+ ret.setRect(opt->rect.left()+3, opt->rect.top() + heightOffset,
+ indicatorWidth-3, indicatorHeight-3);
} else {
ret.setRect(opt->rect.right() - indicatorWidth - spacing, opt->rect.top() + heightOffset,
indicatorWidth, indicatorHeight);
}
+ } else {
+ ret = QCommonStyle::subElementRect(element, opt, widget);
}
break;
case SE_HeaderLabel:
@@ -2658,6 +2690,88 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
return ret;
}
+void QS60Style::polish(QWidget *widget)
+{
+ Q_D(const QS60Style);
+ QCommonStyle::polish(widget);
+
+ if (!widget)
+ return;
+
+ if (false
+#ifndef QT_NO_SCROLLBAR
+ || qobject_cast<QScrollBar *>(widget)
+#endif
+ ) {
+ widget->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ }
+
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground);
+ }
+ d->setThemePalette(widget);
+ d->setFont(widget);
+}
+
+void QS60Style::unpolish(QWidget *widget)
+{
+ if (false
+ #ifndef QT_NO_SCROLLBAR
+ || qobject_cast<QScrollBar *>(widget)
+ #endif
+ )
+ widget->setAttribute(Qt::WA_OpaquePaintEvent);
+
+ if (QS60StylePrivate::drawsOwnThemeBackground(widget)) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_MENU
+ || qobject_cast<const QMenu *> (widget)
+#endif // QT_NO_MENU
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ } else if (false
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBoxListView *>(widget)
+#endif //QT_NO_COMBOBOX
+ ) {
+ widget->setAttribute(Qt::WA_StyledBackground, false);
+ }
+
+ if (widget)
+ widget->setPalette(QPalette());
+
+ QCommonStyle::unpolish(widget);
+}
+
+void QS60Style::polish(QApplication *application)
+{
+ Q_D(QS60Style);
+ d->m_originalPalette = application->palette();
+ d->setThemePalette(application);
+}
+
+void QS60Style::unpolish(QApplication *application)
+{
+ Q_UNUSED(application)
+ Q_D(QS60Style);
+ const QPalette newPalette = QApplication::style()->standardPalette();
+ QApplication::setPalette(newPalette);
+ QApplicationPrivate::setSystemPalette(d->m_originalPalette);
+}
+
void QS60Style::setStyleProperty(const char *name, const QVariant &value)
{
Q_D(QS60Style);
@@ -2678,7 +2792,9 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
QS60StyleEnums::SkinParts part;
QS60StylePrivate::SkinElementFlags adjustedFlags;
if (option)
- adjustedFlags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
+ adjustedFlags = (option->state & State_Enabled) ?
+ QS60StylePrivate::SF_StateEnabled :
+ QS60StylePrivate::SF_StateDisabled;
switch(standardIcon) {
case QStyle::SP_MessageBoxWarning:
@@ -2755,6 +2871,29 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap);
}
+extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget);
+
+bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset,
+ const QBrush &brush)
+{
+ const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
+ if (backgroundTexture.cacheKey() != brush.texture().cacheKey())
+ return false;
+
+ const QPaintDevice *target = painter->device();
+ if (target->devType() == QInternal::Widget) {
+ const QWidget *widget = static_cast<const QWidget *>(target);
+ const QRegion translated = rgn.translated(offset);
+ const QVector<QRect> &rects = translated.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect rect(rects.at(i));
+ painter->drawPixmap(rect.topLeft(), backgroundTexture,
+ rect.translated(qt_s60_fill_background_offset(widget)));
+ }
+ }
+ return true;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_STYLE_S60 || QT_PLUGIN
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index 945e182..d8e9a40 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -36,7 +66,6 @@ public:
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w = 0) const;
int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
@@ -56,22 +85,23 @@ public:
static QStringList colorListKeys();
void setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors);
+ bool loadS60ThemeFromBlob(const QString &blobFile);
+ bool saveS60ThemeToBlob(const QString &blobFile) const;
#endif // !Q_WS_S60
#ifdef Q_WS_S60
-public slots:
+public Q_SLOTS:
void handleDynamicLayoutVariantSwitch();
void handleSkinChange();
#endif // Q_WS_S60
-protected slots:
+protected Q_SLOTS:
QIcon standardIconImplementation(
StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0 ) const;
private:
Q_DISABLE_COPY(QS60Style)
friend class QStyleFactory;
- QPalette originalPalette;
};
#endif // QT_NO_STYLE_S60
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index da34efb..7240978 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -113,7 +143,7 @@ public:
SP_QgnPropFolderCurrent,
SP_QgnPropFolderSmall,
SP_QgnPropFolderSmallNew,
- SP_QgnPropPhoneMemcLarge,
+ SP_QgnPropPhoneMemcLarge,
SP_QsnCpScrollHandleBottomPressed, //ScrollBar handle, pressed state
SP_QsnCpScrollHandleMiddlePressed,
SP_QsnCpScrollHandleTopPressed,
@@ -231,7 +261,25 @@ public:
SP_QsnFrSctrlButtonSideBPressed,
SP_QsnFrSctrlButtonSideLPressed,
SP_QsnFrSctrlButtonSideRPressed,
- SP_QsnFrSctrlButtonCenterPressed
+ SP_QsnFrSctrlButtonCenterPressed,
+ SP_QsnFrButtonCornerTlInactive, // Inactive button
+ SP_QsnFrButtonCornerTrInactive,
+ SP_QsnFrButtonCornerBlInactive,
+ SP_QsnFrButtonCornerBrInactive,
+ SP_QsnFrButtonSideTInactive,
+ SP_QsnFrButtonSideBInactive,
+ SP_QsnFrButtonSideLInactive,
+ SP_QsnFrButtonSideRInactive,
+ SP_QsnFrButtonCenterInactive,
+ SP_QsnFrNotepadCornerTl,
+ SP_QsnFrNotepadCornerTr,
+ SP_QsnFrNotepadCornerBl,
+ SP_QsnFrNotepadCornerBr,
+ SP_QsnFrNotepadSideT,
+ SP_QsnFrNotepadSideB,
+ SP_QsnFrNotepadSideL,
+ SP_QsnFrNotepadSideR,
+ SP_QsnFrNotepadCenter
};
enum ColorLists {
@@ -292,6 +340,8 @@ public:
SE_PanelBackground,
SE_ScrollBarHandlePressedHorizontal, //only for 5.0+
SE_ScrollBarHandlePressedVertical,
+ SE_ButtonInactive,
+ SE_Editor,
};
enum SkinFrameElements {
@@ -307,7 +357,9 @@ public:
SF_ToolBar,
SF_ToolBarButton,
SF_ToolBarButtonPressed,
- SF_PanelBackground
+ SF_PanelBackground,
+ SF_ButtonInactive,
+ SF_Editor,
};
enum SkinElementFlag {
@@ -320,6 +372,13 @@ public:
SF_StateDisabled = 0x0020,
SF_ColorSkinned = 0x0040,
};
+
+ enum CacheClearReason {
+ CC_UndefinedChange = 0,
+ CC_LayoutChange,
+ CC_ThemeChange
+ };
+
Q_DECLARE_FLAGS(SkinElementFlags, SkinElementFlag)
// draws skin element
@@ -344,27 +403,35 @@ public:
int index, const QStyleOption *option);
// gets state specific color
static QColor stateColor(const QColor &color, const QStyleOption *option);
+ // gets lighter color than base color
static QColor lighterColor(const QColor &baseColor);
- static bool isSkinnableDialog(const QWidget *widget);
- // gets layout
- static const QHash<QStyle::PixelMetric, int> &s60StyleLayout();
+ //deduces if the given widget should have separately themeable background
+ static bool drawsOwnThemeBackground(const QWidget *widget);
QFont s60Font(QS60StyleEnums::FontCategories fontCategory,
int pointSize = -1) const;
- void clearCaches();
- static QPixmap backgroundTexture();
+ // clears all style caches (fonts, colors, pixmaps)
+ void clearCaches(CacheClearReason reason = CC_UndefinedChange);
+
+ // themed main background oprations
+ void setBackgroundTexture(QApplication *application) const;
+ static void deleteBackground();
static bool isTouchSupported();
static bool isToolBarBackground();
// calculates average color based on button skin graphics (minus borders).
- QColor colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const;
+ QColor colorFromFrameGraphics(SkinFrameElements frame) const;
+
+ //set theme palette for application
void setThemePalette(QApplication *application) const;
- void setBackgroundTexture(QApplication *application) const;
+ //set theme palette for style option
+ void setThemePalette(QStyleOption *option) const;
+ //access to theme palette
+ static QPalette* themePalette();
static int focusRectPenWidth();
-#if defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
static const layoutHeader m_layoutHeaders[];
static const short data[][MAX_PIXELMETRICS];
@@ -374,10 +441,9 @@ public:
static short const *m_pmPointer;
// number of layouts supported by the style
static const int m_numberOfLayouts;
-#endif // defined(QT_S60STYLE_LAYOUTDATA_SIMULATED)
mutable QHash<QPair<QS60StyleEnums::FontCategories , int>, QFont> m_mappedFontsCache;
- mutable QHash<QS60StylePrivate::SkinFrameElements, QColor> m_colorCache;
+ mutable QHash<SkinFrameElements, QColor> m_colorCache;
// Has one entry per SkinFrameElements
static const struct frameElementCenter {
@@ -387,6 +453,7 @@ public:
static QPixmap frame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap backgroundTexture();
private:
static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter,
@@ -397,23 +464,36 @@ private:
static void drawFrame(SkinFrameElements frame, QPainter *painter,
const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
- static QSize partSize(QS60StyleEnums::SkinParts part,
- SkinElementFlags flags = KDefaultSkinElementFlags);
- static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
- SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
- static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
-
static void refreshUI();
+ // set S60 font for widget
+ void setFont(QWidget *widget) const;
+ void setThemePalette(QWidget *widget) const;
+ void setThemePalette(QPalette *palette) const;
+ void setThemePaletteHash(QPalette *palette) const;
+ static void storeThemePalette(QPalette *palette);
+ static void deleteThemePalette();
+
+ static QSize partSize(QS60StyleEnums::SkinParts part,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
+ static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
+ SkinElementFlags flags = KDefaultSkinElementFlags);
+
+ static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
+
static QSize screenSize();
- static bool m_backgroundValid;
+ // Contains background texture.
+ static QPixmap *m_background;
const static SkinElementFlags KDefaultSkinElementFlags;
+ // defined theme palette
+ static QPalette *m_themePalette;
+ QPalette m_originalPalette;
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_s60.cpp
index 35dfe13..1f02efa 100644
--- a/src/gui/styles/qs60style_symbian.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -47,8 +77,10 @@ enum TSupportRelease {
ES60_3_1 = 0x0001,
ES60_3_2 = 0x0002,
ES60_5_0 = 0x0004,
+ ES60_5_1 = 0x0008,
+ ES60_5_2 = 0x0010,
// Add all new releases here
- ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0
+ ES60_AllReleases = ES60_3_1 | ES60_3_2 | ES60_5_0 | ES60_5_1 | ES60_5_2
};
typedef struct {
@@ -59,17 +91,6 @@ typedef struct {
int newMinorSkinId;
} partMapEntry;
-enum TFallbackMbmFile {
- EAvkonMbm = 0,
- ELastMbm
-};
-
-typedef struct {
- const QS60StyleEnums::SkinParts partID;
- TFallbackMbmFile fallbackFileID; //to avoid putting large char strings to table, lets only have a mapping value
- int fallbackGraphicID;
-} fallbackMapEntry;
-
class QS60StyleModeSpecifics
{
public:
@@ -80,6 +101,8 @@ public:
const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex);
static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format);
+ static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part);
+ static bool disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame);
static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
private:
@@ -103,187 +126,209 @@ private:
};
const partMapEntry QS60StyleModeSpecifics::m_partMap[] = {
- /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveL */ {KAknsIIDQgnGrafTabPassiveL, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveM */ {KAknsIIDQgnGrafTabPassiveM, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnGrafTabPassiveR */ {KAknsIIDQgnGrafTabPassiveR, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiCheckboxOff */ {KAknsIIDQgnIndiCheckboxOff, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiCheckboxOn */ {KAknsIIDQgnIndiCheckboxOn, EDrawIcon, ES60_AllReleases, -1,-1},
// Following 5 items (SP_QgnIndiHlColSuper - SP_QgnIndiHlLineStraight) are available starting from S60 release 3.2.
// In 3.1 CommonStyle drawing is used for these QTreeView elements, since no similar icons in AVKON UI.
- /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */},
- /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */},
- /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */},
- /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */},
- /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_None, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */},
- /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiHlColSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d5 /* KAknsIIDQgnIndiHlColSuper */},
+ /* SP_QgnIndiHlExpSuper */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d6 /* KAknsIIDQgnIndiHlExpSuper */},
+ /* SP_QgnIndiHlLineBranch */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d7 /* KAknsIIDQgnIndiHlLineBranch */},
+ /* SP_QgnIndiHlLineEnd */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d8 /* KAknsIIDQgnIndiHlLineEnd */},
+ /* SP_QgnIndiHlLineStraight */ {KAknsIIDNone, EDrawIcon, ES60_3_1, EAknsMajorGeneric, 0x17d9 /* KAknsIIDQgnIndiHlLineStraight */},
+ /* SP_QgnIndiMarkedAdd */ {KAknsIIDQgnIndiMarkedAdd, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiNaviArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiNaviArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiRadiobuttOff */ {KAknsIIDQgnIndiRadiobuttOff, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiRadiobuttOn */ {KAknsIIDQgnIndiRadiobuttOn, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiSliderEdit */ {KAknsIIDQgnIndiSliderEdit, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnIndiSubMenu */ {KAknsIIDQgnIndiSubmenu, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteErased */ {KAknsIIDQgnNoteErased, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteError */ {KAknsIIDQgnNoteError, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteInfo */ {KAknsIIDQgnNoteInfo, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteOk */ {KAknsIIDQgnNoteOk, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteQuery */ {KAknsIIDQgnNoteQuery, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnNoteWarning */ {KAknsIIDQgnNoteWarning, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFileSmall */ {KAknsIIDQgnPropFileSmall, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderCurrent */ {KAknsIIDQgnPropFolderCurrent, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderSmall */ {KAknsIIDQgnPropFolderSmall, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1},
// 3.1 & 3.2 do not have pressed state for scrollbar, so use normal scrollbar graphics instead.
- /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/
- /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/
- /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/
-
- /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1},
-
- /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
- /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_AllReleases, -1,-1},
-
- /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/
+ /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/
+ /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/
+
+ /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollBgMiddle */ {KAknsIIDQsnCpScrollBgMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollBgTop */ {KAknsIIDQsnCpScrollBgTop, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnCpScrollHandleBottom */ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleMiddle */ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_AllReleases, -1,-1},
+ /* SP_QsnCpScrollHandleTop */ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrButtonTbCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_AllReleases, -1,-1}, //todo: use "normal button" from 5.0 onwards
+ /* SP_QsnFrButtonTbCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCenter */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrButtonTbCornerTlPressed */{KAknsIIDQsnFrButtonTbCornerTlPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerTrPressed */{KAknsIIDQsnFrButtonTbCornerTrPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBlPressed */{KAknsIIDQsnFrButtonTbCornerBlPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCornerBrPressed */{KAknsIIDQsnFrButtonTbCornerBrPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideTPressed */ {KAknsIIDQsnFrButtonTbSideTPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideBPressed */ {KAknsIIDQsnFrButtonTbSideBPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideLPressed */ {KAknsIIDQsnFrButtonTbSideLPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbSideRPressed */ {KAknsIIDQsnFrButtonTbSideRPressed, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrButtonTbCenterPressed */ {KAknsIIDQsnFrButtonTbCenterPressed, EDrawIcon, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrCaleCornerTl */ {KAknsIIDQsnFrCaleCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerTr */ {KAknsIIDQsnFrCaleCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerBl */ {KAknsIIDQsnFrCaleCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCornerBr */ {KAknsIIDQsnFrCaleCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideT */ {KAknsIIDQsnFrCaleSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideB */ {KAknsIIDQsnFrCaleSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideL */ {KAknsIIDQsnFrCaleSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleGSideR */ {KAknsIIDQsnFrCaleSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleCenter */ {KAknsIIDQsnFrCaleCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrCaleHeadingCornerTl */ {KAknsIIDQsnFrCaleHeadingCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerTr */ {KAknsIIDQsnFrCaleHeadingCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerBl */ {KAknsIIDQsnFrCaleHeadingCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCornerBr */ {KAknsIIDQsnFrCaleHeadingCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideT */ {KAknsIIDQsnFrCaleHeadingSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideB */ {KAknsIIDQsnFrCaleHeadingSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideL */ {KAknsIIDQsnFrCaleHeadingSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingSideR */ {KAknsIIDQsnFrCaleHeadingSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrCaleHeadingCenter */ {KAknsIIDQsnFrCaleHeadingCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrInputCornerTl */ {KAknsIIDQsnFrInputCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerTr */ {KAknsIIDQsnFrInputCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerBl */ {KAknsIIDQsnFrInputCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCornerBr */ {KAknsIIDQsnFrInputCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideT */ {KAknsIIDQsnFrInputSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideB */ {KAknsIIDQsnFrInputSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideL */ {KAknsIIDQsnFrInputSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputSideR */ {KAknsIIDQsnFrInputSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrInputCenter */ {KAknsIIDQsnFrInputCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrListCornerTl */ {KAknsIIDQsnFrListCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerTr */ {KAknsIIDQsnFrListCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerBl */ {KAknsIIDQsnFrListCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCornerBr */ {KAknsIIDQsnFrListCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideT */ {KAknsIIDQsnFrListSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideB */ {KAknsIIDQsnFrListSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideL */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListSideR */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrListCenter */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_AllReleases, -1,-1},
+
+ /* SP_QsnFrPopupCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_AllReleases, -1,-1},
// ToolTip graphics different in 3.1 vs. 3.2+.
- /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */
- /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6},
- /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3},
- /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4},
- /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca},
- /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7},
- /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8},
- /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9},
- /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2},
-
- /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_AllReleases, -1,-1},
- /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */
+ /* SP_QsnFrPopupPreviewCornerTr */ {KAknsIIDQsnFrPopupCornerTr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c6},
+ /* SP_QsnFrPopupPreviewCornerBl */ {KAknsIIDQsnFrPopupCornerBl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c3},
+ /* SP_QsnFrPopupPreviewCornerBr */ {KAknsIIDQsnFrPopupCornerBr, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c4},
+ /* SP_QsnFrPopupPreviewSideT */ {KAknsIIDQsnFrPopupSideT, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19ca},
+ /* SP_QsnFrPopupPreviewSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c7},
+ /* SP_QsnFrPopupPreviewSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c8},
+ /* SP_QsnFrPopupPreviewSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c9},
+ /* SP_QsnFrPopupPreviewCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c2},
+
+ /* SP_QsnFrSetOptCornerTl */ {KAknsIIDQsnFrSetOptCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerTr */ {KAknsIIDQsnFrSetOptCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerBl */ {KAknsIIDQsnFrSetOptCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCornerBr */ {KAknsIIDQsnFrSetOptCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideT */ {KAknsIIDQsnFrSetOptSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideB */ {KAknsIIDQsnFrSetOptSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideL */ {KAknsIIDQsnFrSetOptSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptSideR */ {KAknsIIDQsnFrSetOptSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrSetOptCenter */ {KAknsIIDQsnFrSetOptCenter, ENoDraw, ES60_AllReleases, -1,-1},
// No toolbar frame for 5.0+ releases.
- /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
- /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerTl */ {KAknsIIDQsnFrPopupSubCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerTr */ {KAknsIIDQsnFrPopupSubCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerBl */ {KAknsIIDQsnFrPopupSubCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCornerBr */ {KAknsIIDQsnFrPopupSubCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideT */ {KAknsIIDQsnFrPopupSubSideT, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideB */ {KAknsIIDQsnFrPopupSubSideB, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideL */ {KAknsIIDQsnFrPopupSubSideL, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubSideR */ {KAknsIIDQsnFrPopupSubSideR, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
+ /* SP_QsnFrPopupSubCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_3_1 | ES60_3_2, -1,-1},
// Toolbar graphics is different in 3.1/3.2 vs. 5.0
- /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/
- /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2302},
- /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2303},
- /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2304},
- /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2305},
- /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2306},
- /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2307},
- /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2308},
- /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/
+ /* SP_QsnFrSctrlButtonCornerTl */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2301}, /* KAknsIIDQgnFrSctrlButtonCornerTl*/
+ /* SP_QsnFrSctrlButtonCornerTr */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2302},
+ /* SP_QsnFrSctrlButtonCornerBl */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2303},
+ /* SP_QsnFrSctrlButtonCornerBr */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2304},
+ /* SP_QsnFrSctrlButtonSideT */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2305},
+ /* SP_QsnFrSctrlButtonSideB */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2306},
+ /* SP_QsnFrSctrlButtonSideL */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2307},
+ /* SP_QsnFrSctrlButtonSideR */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2308},
+ /* SP_QsnFrSctrlButtonCenter */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2309}, /*KAknsIIDQgnFrSctrlButtonCenter*/
// No pressed state for toolbar button in 3.1/3.2.
- /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/
- /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622},
- /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623},
- /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624},
- /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625},
- /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626},
- /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627},
- /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628},
- /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629}
+ /* SP_QsnFrSctrlButtonCornerTlPressed */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2621}, /*KAknsIIDQsnFrSctrlButtonCornerTlPressed*/
+ /* SP_QsnFrSctrlButtonCornerTrPressed */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2622},
+ /* SP_QsnFrSctrlButtonCornerBlPressed */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2623},
+ /* SP_QsnFrSctrlButtonCornerBrPressed */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2624},
+ /* SP_QsnFrSctrlButtonSideTPressed */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2625},
+ /* SP_QsnFrSctrlButtonSideBPressed */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2626},
+ /* SP_QsnFrSctrlButtonSideLPressed */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2627},
+ /* SP_QsnFrSctrlButtonSideRPressed */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2628},
+ /* SP_QsnFrSctrlButtonCenterPressed */ {KAknsIIDQsnFrButtonTbCenter, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x2629},
+
+ // No inactive button graphics in 3.1/3.2
+ /* SP_QsnFrButtonCornerTlInactive */ {KAknsIIDQsnFrButtonTbCornerTl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b1}, /*KAknsIIDQsnFrButtonCornerTlInactive*/
+ /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerTr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b2},
+ /* SP_QsnFrButtonCornerBlInactive */ {KAknsIIDQsnFrButtonTbCornerBl, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b3},
+ /* SP_QsnFrButtonCornerTrInactive */ {KAknsIIDQsnFrButtonTbCornerBr, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b4},
+ /* SP_QsnFrButtonSideTInactive */ {KAknsIIDQsnFrButtonTbSideT, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b5},
+ /* SP_QsnFrButtonSideBInactive */ {KAknsIIDQsnFrButtonTbSideB, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b6},
+ /* SP_QsnFrButtonSideLInactive */ {KAknsIIDQsnFrButtonTbSideL, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b7},
+ /* SP_QsnFrButtonSideRInactive */ {KAknsIIDQsnFrButtonTbSideR, ENoDraw, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b8},
+ /* SP_QsnFrButtonCenterInactive */ {KAknsIIDQsnFrButtonTbCenter, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorSkin, 0x21b9},
+
+ /*SP_QsnFrNotepadCornerTl */ {KAknsIIDQsnFrNotepadCornerTl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerTr */ {KAknsIIDQsnFrNotepadCornerTr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerBl */ {KAknsIIDQsnFrNotepadCornerBl, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCornerBr */ {KAknsIIDQsnFrNotepadCornerBr, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideT */ {KAknsIIDQsnFrNotepadSideT, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideB */ {KAknsIIDQsnFrNotepadSideB, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideL */ {KAknsIIDQsnFrNotepadSideL, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadSideR */ {KAknsIIDQsnFrNotepadSideR, ENoDraw, ES60_AllReleases, -1,-1},
+ /* SP_QsnFrNotepadCenter */ {KAknsIIDQsnFrNotepadCenter, EDrawIcon, ES60_AllReleases, -1,-1}
+
};
QPixmap QS60StyleModeSpecifics::skinnedGraphics(
@@ -323,7 +368,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics(
}
void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex)
-{
+{
switch(stylepart) {
case QS60StyleEnums::SP_QgnGrafBarWait:
fallbackFileName = KAvkonBitmapFile();
@@ -377,19 +422,19 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = EMbmAvkonQgn_indi_checkbox_on;
break;
- case QS60StyleEnums::SP_QgnIndiHlColSuper:
+ case QS60StyleEnums::SP_QgnIndiHlColSuper:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x4456; /* EMbmAvkonQgn_indi_hl_col_super */
break;
- case QS60StyleEnums::SP_QgnIndiHlExpSuper:
+ case QS60StyleEnums::SP_QgnIndiHlExpSuper:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x4458; /* EMbmAvkonQgn_indi_hl_exp_super */
break;
- case QS60StyleEnums::SP_QgnIndiHlLineBranch:
+ case QS60StyleEnums::SP_QgnIndiHlLineBranch:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x445A; /* EMbmAvkonQgn_indi_hl_line_branch */
break;
- case QS60StyleEnums::SP_QgnIndiHlLineEnd:
+ case QS60StyleEnums::SP_QgnIndiHlLineEnd:
fallbackFileName = KAvkonBitmapFile();
fallbackIndex = 0x445C; /* EMbmAvkonQgn_indi_hl_line_end */
break;
@@ -486,8 +531,8 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL(
TInt fallbackGraphicID = -1;
HBufC* iconFile = HBufC::NewLC( KMaxFileName );
TPtr fileNamePtr = iconFile->Des();
- fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID);
-
+ fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID);
+
TAknsItemID colorGroup = KAknsIIDQsnIconColors;
int colorIndex = 0;
colorGroupAndIndex(stylepart, colorGroup, colorIndex);
@@ -569,26 +614,6 @@ QPixmap QS60StyleModeSpecifics::fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask
return QPixmap::fromImage(iconImage);
}
-QPixmap QS60StylePrivate::backgroundTexture()
-{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
- result = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
- m_backgroundValid = true;
- }
- return result;
-}
-
bool QS60StylePrivate::isTouchSupported()
{
return bool(AknLayoutUtils::PenEnabled());
@@ -599,30 +624,11 @@ bool QS60StylePrivate::isToolBarBackground()
return (QSysInfo::s60Version() == QSysInfo::SV_S60_3_1 || QSysInfo::s60Version() == QSysInfo::SV_S60_3_2);
}
-void qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset,
- const QBrush &brush)
+QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
{
- const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
- if (backgroundTexture.cacheKey() == brush.texture().cacheKey()) {
- const QPaintDevice *target = painter->device();
- if (target->devType() == QInternal::Widget) {
- const QWidget *widget = static_cast<const QWidget *>(target);
- CCoeControl *control = widget->effectiveWinId();
- TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0);
- const QRegion translated = rgn.translated(offset);
- const QVector<QRect> &rects = translated.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect rect(rects.at(i));
- painter->drawPixmap(rect.topLeft(), backgroundTexture,
- rect.translated(globalPos.iX, globalPos.iY));
- }
- }
- } else {
- const QRegion translated = rgn.translated(offset);
- const QRect rect(translated.boundingRect());
- painter->setClipRegion(translated);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
- }
+ CCoeControl *control = targetWidget->effectiveWinId();
+ TPoint globalPos = control ? control->PositionRelativeToScreen() : TPoint(0,0);
+ return QPoint(globalPos.iX, globalPos.iY);
}
QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
@@ -639,7 +645,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
Q_ASSERT(drawType != ENoDraw);
const bool rotatedBy90or270 =
(flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest));
- TSize targetSize =
+ const TSize targetSize =
rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
@@ -647,65 +653,63 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(
QPixmap result;
switch (drawType) {
- case EDrawIcon:
- {
- TInt fallbackGraphicID = -1;
- HBufC* iconFile = HBufC::NewLC( KMaxFileName );
- TPtr fileNamePtr = iconFile->Des();
- fallbackInfo(part, fileNamePtr, fallbackGraphicID);
-
- CFbsBitmap *icon = 0;
- CFbsBitmap *iconMask = 0;
- const TInt fallbackGraphicsMaskID =
- fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files
-// QS60WindowSurface::unlockBitmapHeap();
- AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID);
- User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved));
- User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved));
- result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode()));
- CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile
-// QS60WindowSurface::lockBitmapHeap();
- break;
- }
- case EDrawBackground:
- {
-// QS60WindowSurface::unlockBitmapHeap();
- CFbsBitmap *background = new (ELeave) CFbsBitmap(); //offscreen
- CleanupStack::PushL(background);
- User::LeaveIfError(background->Create(targetSize, EColor16MA));
-
- // todo: push background into CleanupStack
- CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background);
- CleanupStack::PushL(dev);
- CFbsBitGc* gc = NULL;
- User::LeaveIfError(dev->CreateContext(gc));
- CleanupStack::PushL(gc);
-
- CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL(
- skinId,
- targetSize,
- EFalse);
- CleanupStack::PushL(bgContext);
-
- const TBool drawn = AknsDrawUtils::DrawBackground(
- skinInstance,
- bgContext,
- NULL,
- *gc,
- TPoint(),
- targetSize,
- KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
-
- if (drawn)
- result = fromFbsBitmap(background, NULL, flags, QImage::Format_RGB32);
-
- CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
-// QS60WindowSurface::lockBitmapHeap();
- break;
- }
+ case EDrawIcon: {
+ TInt fallbackGraphicID = -1;
+ HBufC* iconFile = HBufC::NewLC( KMaxFileName );
+ TPtr fileNamePtr = iconFile->Des();
+ fallbackInfo(part, fileNamePtr, fallbackGraphicID);
+ // todo: could we instead use AknIconUtils::AvkonIconFileName(); to avoid allocating each time?
+
+ CFbsBitmap *icon = 0;
+ CFbsBitmap *iconMask = 0;
+ const TInt fallbackGraphicsMaskID =
+ fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files
+ // QS60WindowSurface::unlockBitmapHeap();
+ AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID);
+ User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved));
+ User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved));
+ result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode()));
+ CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile
+ // QS60WindowSurface::lockBitmapHeap();
+ break;
+ }
+ case EDrawBackground: {
+ // QS60WindowSurface::unlockBitmapHeap();
+ CFbsBitmap *background = new (ELeave) CFbsBitmap(); //offscreen
+ CleanupStack::PushL(background);
+ User::LeaveIfError(background->Create(targetSize, EColor16MA));
+
+ CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background);
+ CleanupStack::PushL(dev);
+ CFbsBitGc* gc = NULL;
+ User::LeaveIfError(dev->CreateContext(gc));
+ CleanupStack::PushL(gc);
+
+ CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL(
+ skinId,
+ targetSize,
+ EFalse);
+ CleanupStack::PushL(bgContext);
+
+ const TBool drawn = AknsDrawUtils::DrawBackground(
+ skinInstance,
+ bgContext,
+ NULL,
+ *gc,
+ TPoint(),
+ targetSize,
+ KAknsDrawParamDefault | KAknsDrawParamRGBOnly);
+
+ if (drawn)
+ result = fromFbsBitmap(background, NULL, flags, QImage::Format_RGB32);
+
+ CleanupStack::PopAndDestroy(4, background); //background, dev, gc, bgContext
+ // QS60WindowSurface::lockBitmapHeap();
+ break;
+ }
}
- return result; // TODO: Let fromFbsBitmap return a QPixmap
+ return result;
}
QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFrameElements frameElement,
@@ -716,11 +720,10 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
const bool rotatedBy90or270 =
(flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest));
- TSize targetSize =
+ const TSize targetSize =
rotatedBy90or270 ? TSize(size.height(), size.width()) : qt_QSize2TSize(size);
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
-
QPixmap result;
// QS60WindowSurface::unlockBitmapHeap();
@@ -764,7 +767,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
skinInstance->GetCachedItemData(frameSkinID,EAknsITMaskedBitmap));
if (skinMaskedBmp && skinMaskedBmp->Mask())
maskDepth = skinMaskedBmp->Mask()->DisplayMode();
- }
+ }
if (maskDepth != ENone) {
CFbsBitmap *frameMask = new (ELeave) CFbsBitmap(); //offscreen
CleanupStack::PushL(frameMask);
@@ -792,11 +795,10 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL(QS60StylePrivate::SkinFra
result = fromFbsBitmap(frame, frameMask, flags, QImage::Format_ARGB32);
}
CleanupStack::PopAndDestroy(3, frameMask);
- }
}
+ }
CleanupStack::PopAndDestroy(3, frame); //frame, bitmapDev, bitmapGc
-
- return result; // TODO: Let fromFbsBitmap return a QPixmap
+ return result;
}
void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID &centerId)
@@ -807,7 +809,7 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
switch(frameElement) {
case QS60StylePrivate::SF_ToolTip:
- if (QSysInfo::s60Version()==QSysInfo::SV_S60_5_0 || QSysInfo::s60Version()==QSysInfo::SV_S60_3_2) {
+ if (QSysInfo::s60Version()!=QSysInfo::SV_S60_3_1) {
centerId.Set(EAknsMajorGeneric, 0x19c2);
frameId.Set(EAknsMajorSkin, 0x5300);
} else {
@@ -835,17 +837,19 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme
TRect QS60StyleModeSpecifics::innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect)
{
- TInt widthShrink = 0;
- TInt heightShrink = 0;
+ TInt widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
+ TInt heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
switch(frameElement) {
case QS60StylePrivate::SF_PanelBackground:
// panel should have slightly slimmer border to enable thin line of background graphics between closest component
- widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)-2;
- heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight)-2;
+ widthShrink = widthShrink-2;
+ heightShrink = heightShrink-2;
+ break;
+ case QS60StylePrivate::SF_ToolTip:
+ widthShrink = widthShrink>>1;
+ heightShrink = heightShrink>>1;
break;
default:
- widthShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth);
- heightShrink = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight);
break;
}
TRect innerRect(outerRect);
@@ -898,7 +902,7 @@ void QS60StyleModeSpecifics::checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBit
QFont QS60StylePrivate::s60Font_specific(
QS60StyleEnums::FontCategories fontCategory, int pointSize)
{
- enum TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
+ TAknFontCategory aknFontCategory = EAknFontCategoryUndefined;
switch (fontCategory) {
case QS60StyleEnums::FC_Primary:
aknFontCategory = EAknFontCategoryPrimary;
@@ -943,12 +947,10 @@ QFont QS60StylePrivate::s60Font_specific(
return result;
}
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
void QS60StylePrivate::setActiveLayout()
{
- //todo: how to find layouts that are of same size (QVGA1 vs. QVGA2)
const QSize activeScreenSize(screenSize());
- int activeLayoutIndex = 0;
+ int activeLayoutIndex = -1;
const bool mirrored = !QApplication::isLeftToRight();
const short screenHeight = (short)activeScreenSize.height();
const short screenWidth = (short)activeScreenSize.width();
@@ -960,35 +962,112 @@ void QS60StylePrivate::setActiveLayout()
break;
}
}
+
+ //not found, lets try without mirroring info
+ if (activeLayoutIndex==-1){
+ for (int i=0; i<m_numberOfLayouts; i++) {
+ if (screenHeight==m_layoutHeaders[i].height &&
+ screenWidth==m_layoutHeaders[i].width) {
+ activeLayoutIndex = i;
+ break;
+ }
+ }
+ }
+
+ //not found, lets try with either of dimensions
+ if (activeLayoutIndex==-1){
+ const QSysInfo::S60Version currentRelease = QSysInfo::s60Version();
+ const bool landscape = screenHeight < screenWidth;
+
+ activeLayoutIndex = (currentRelease == QSysInfo::SV_S60_3_1 || currentRelease == QSysInfo::SV_S60_3_2) ? 0 : 4;
+ activeLayoutIndex += (!landscape) ? 2 : 0;
+ activeLayoutIndex += (!mirrored) ? 1 : 0;
+ }
+
m_pmPointer = data[activeLayoutIndex];
}
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
QS60StylePrivate::QS60StylePrivate()
{
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
// No need to set active layout, if dynamic metrics API is available
setActiveLayout();
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
}
-QS60StylePrivate::~QS60StylePrivate()
+void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
{
- m_backgroundValid = false;
+ if (name == QLatin1String("foo")) {
+ // BaR
+ } else {
+ setStyleProperty(name, value);
+ }
}
-short QS60StylePrivate::pixelMetric(int metric)
+QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
{
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
- Q_ASSERT(metric < MAX_PIXELMETRICS);
- const short returnValue = m_pmPointer[metric];
- if (returnValue==-909)
- return -1;
- return returnValue;
-#else
- //todo - call the pixelmetrics API directly
- return 0;
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
+ if (name == QLatin1String("foo"))
+ return QLatin1String("Bar");
+ else
+ return styleProperty(name);
+}
+
+QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
+ int index, const QStyleOption *option)
+{
+ static const TAknsItemID *idMap[] = {
+ &KAknsIIDQsnHighlightColors,
+ &KAknsIIDQsnIconColors,
+ &KAknsIIDQsnLineColors,
+ &KAknsIIDQsnOtherColors,
+ &KAknsIIDQsnParentColors,
+ &KAknsIIDQsnTextColors
+ };
+ Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
+ const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
+ return option ? QS60StylePrivate::stateColor(color, option) : color;
+}
+
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these parts.
+bool QS60StyleModeSpecifics::disabledPartGraphic(QS60StyleEnums::SkinParts &part)
+{
+ bool disabledGraphic = false;
+ switch(part){
+ // inactive button graphics are available from 5.0 onwards
+ case QS60StyleEnums::SP_QsnFrButtonCornerTlInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerTrInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerBlInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCornerBrInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideTInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideBInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideLInactive:
+ case QS60StyleEnums::SP_QsnFrButtonSideRInactive:
+ case QS60StyleEnums::SP_QsnFrButtonCenterInactive:
+ if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 ||
+ QSysInfo::s60Version()==QSysInfo::SV_S60_3_2))
+ disabledGraphic = true;
+ break;
+ default:
+ break;
+ }
+ return disabledGraphic;
+}
+
+// In some cases, the AVKON UI themegraphic is already in 'disabled state'.
+// If so, return true for these frames.
+bool QS60StyleModeSpecifics::disabledFrameGraphic(QS60StylePrivate::SkinFrameElements &frame)
+{
+ bool disabledGraphic = false;
+ switch(frame){
+ // inactive button graphics are available from 5.0 onwards
+ case QS60StylePrivate::SF_ButtonInactive:
+ if (!(QSysInfo::s60Version()==QSysInfo::SV_S60_3_1 ||
+ QSysInfo::s60Version()==QSysInfo::SV_S60_3_2))
+ disabledGraphic = true;
+ break;
+ default:
+ break;
+ }
+ return disabledGraphic;
}
QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part,
@@ -1002,8 +1081,8 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
// AVKON UI has a abnormal handling for scrollbar graphics. It is possible that the root
// skin does not contain mandatory graphics for scrollbar pressed states. Therefore, AVKON UI
// creates dynamically these graphics by modifying the normal state scrollbar graphics slightly.
- // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss
- // (i.e. result is not valid), style needs to draw normal graphics instead and apply some
+ // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss
+ // (i.e. result is not valid), style needs to draw normal graphics instead and apply some
// modifications (similar to generatedIconPixmap()) to the result.
case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed:
updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleBottom;
@@ -1021,10 +1100,11 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
return QPixmap();
} else {
QPixmap result = skinnedGraphics(updatedPart, size, flags);
- // TODO: fix this
QStyleOption opt;
- // opt.palette = q->standardPalette();
-
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
+
// For now, always generate new icon based on "selected". In the future possibly, expand
// this to consist other possibilities as well.
result = QApplication::style()->generatedIconPixmap(QIcon::Selected, result, &opt);
@@ -1041,16 +1121,17 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part,
: QS60StyleModeSpecifics::skinnedGraphics(part, size, flags);
QS60WindowSurface::lockBitmapHeap();
- if (flags & SF_StateDisabled) {
- // TODO: fix this
+ if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledPartGraphic(part)) {
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
if (!result)
result = QS60StyleModeSpecifics::generateMissingThemeGraphic(part, size, flags);
-
+
return result;
}
@@ -1060,46 +1141,24 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin
QPixmap result = QS60StyleModeSpecifics::skinnedGraphics(frame, size, flags);
QS60WindowSurface::lockBitmapHeap();
- if (flags & SF_StateDisabled) {
- // TODO: fix this
+ if (flags & SF_StateDisabled && !QS60StyleModeSpecifics::disabledFrameGraphic(frame)) {
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
return result;
}
-void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
+QPixmap QS60StylePrivate::backgroundTexture()
{
- if (name == QLatin1String("foo")) {
- // BaR
- } else {
- setStyleProperty(name, value);
+ if (!m_background) {
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
+ QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
+ m_background = new QPixmap(background);
}
-}
-
-QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
-{
- if (name == QLatin1String("foo"))
- return QLatin1String("Bar");
- else
- return styleProperty(name);
-}
-
-QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
- int index, const QStyleOption *option)
-{
- static const TAknsItemID *idMap[] = {
- &KAknsIIDQsnHighlightColors,
- &KAknsIIDQsnIconColors,
- &KAknsIIDQsnLineColors,
- &KAknsIIDQsnOtherColors,
- &KAknsIIDQsnParentColors,
- &KAknsIIDQsnTextColors
- };
- Q_ASSERT((int)list <= (int)sizeof(idMap)/sizeof(idMap[0]));
- const QColor color = QS60StyleModeSpecifics::colorValue(*idMap[(int) list], index - 1);
- return option ? QS60StylePrivate::stateColor(color, option) : color;
+ return *m_background;
}
// If the public SDK returns compressed images, please let us also uncompress those!
@@ -1118,8 +1177,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
if (displayMode != aTrgBitmap->DisplayMode())
User::Leave(KErrArgument);
- TSize trgSize = aTrgBitmap->SizeInPixels();
- TSize srcSize = aSrcBitmap->SizeInPixels();
+ const TSize trgSize = aTrgBitmap->SizeInPixels();
+ const TSize srcSize = aSrcBitmap->SizeInPixels();
// calculate the valid drawing area
TRect drawRect = aTrgRect;
@@ -1155,14 +1214,14 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
const TInt drawWidth = drawRect.Width();
const TInt drawHeight = drawRect.Height();
- TRect offsetRect(aTrgRect.iTl, drawRect.iTl);
+ const TRect offsetRect(aTrgRect.iTl, drawRect.iTl);
const TInt yPosOffset = ySkip * offsetRect.Height();
const TInt xPosOffset = xSkip * offsetRect.Width();
if ((displayMode == EGray256) || (displayMode == EColor256)) {
- TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen8 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode);
- TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen8 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode);
TUint8* trgAddress8 = reinterpret_cast<TUint8*> (trgAddress);
@@ -1172,7 +1231,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress8 += trgScanLen8 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint8* srcAddress8 = reinterpret_cast<TUint8*> (srcAddress)
+ const TUint8* srcAddress8 = reinterpret_cast<const TUint8*> (srcAddress)
+ (srcScanLen8 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1186,9 +1245,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress8 += trgScanLen8 - drawWidth;
}
} else if (displayMode == EColor4K || displayMode == EColor64K) {
- TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen16 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode) >>1;
- TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen16 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode) >>1;
TUint16* trgAddress16 = reinterpret_cast<TUint16*> (trgAddress);
@@ -1198,7 +1257,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress16 += trgScanLen16 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint16* srcAddress16 = reinterpret_cast<TUint16*> (srcAddress)
+ const TUint16* srcAddress16 = reinterpret_cast<const TUint16*> (srcAddress)
+ (srcScanLen16 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1212,9 +1271,9 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress16 += trgScanLen16 - drawWidth;
}
} else if (displayMode == EColor16MU || displayMode == EColor16MA) {
- TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
+ const TInt srcScanLen32 = CFbsBitmap::ScanLineLength(srcSize.iWidth,
displayMode) >>2;
- TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
+ const TInt trgScanLen32 = CFbsBitmap::ScanLineLength(trgSize.iWidth,
displayMode) >>2;
TUint32* trgAddress32 = reinterpret_cast<TUint32*> (trgAddress);
@@ -1224,7 +1283,7 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
trgAddress32 += trgScanLen32 * drawRect.iTl.iY + drawRect.iTl.iX;
for (TInt y = 0; y < drawHeight; y++) {
- TUint32* srcAddress32 = reinterpret_cast<TUint32*> (srcAddress)
+ const TUint32* srcAddress32 = reinterpret_cast<const TUint32*> (srcAddress)
+ (srcScanLen32 * (yPos >> 8));
TInt xPos = xPosOffset;
@@ -1244,8 +1303,8 @@ void QS60StyleModeSpecifics::unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap
QSize QS60StylePrivate::screenSize()
{
- TSize mySize = QS60Data::screenDevice()->SizeInPixels();
- return QSize(mySize.iWidth, mySize.iHeight);
+ const TSize screenSize = QS60Data::screenDevice()->SizeInPixels();
+ return QSize(screenSize.iWidth, screenSize.iHeight);
}
void QS60StyleModeSpecifics::colorGroupAndIndex(
@@ -1253,30 +1312,34 @@ void QS60StyleModeSpecifics::colorGroupAndIndex(
{
switch(skinID) {
case QS60StyleEnums::SP_QgnIndiSubMenu:
- case QS60StyleEnums::SP_QgnIndiHlColSuper:
- case QS60StyleEnums::SP_QgnIndiHlExpSuper:
- case QS60StyleEnums::SP_QgnIndiHlLineBranch:
- case QS60StyleEnums::SP_QgnIndiHlLineEnd:
- case QS60StyleEnums::SP_QgnIndiHlLineStraight:
+ colorGroup = KAknsIIDQsnIconColors;
+ colorIndex = EAknsCIQsnIconColorsCG1;
+ break;
case QS60StyleEnums::SP_QgnIndiRadiobuttOff:
case QS60StyleEnums::SP_QgnIndiRadiobuttOn:
case QS60StyleEnums::SP_QgnIndiCheckboxOff:
case QS60StyleEnums::SP_QgnIndiCheckboxOn:
colorGroup = KAknsIIDQsnIconColors;
- colorIndex = EAknsCIQsnIconColorsCG1;
+ colorIndex = EAknsCIQsnIconColorsCG14;
break;
default:
break;
}
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+}
+
void QS60Style::handleDynamicLayoutVariantSwitch()
{
Q_D(QS60Style);
- d->clearCaches();
-#ifdef QT_S60STYLE_LAYOUTDATA_SIMULATED
+ d->clearCaches(QS60StylePrivate::CC_LayoutChange);
d->setActiveLayout();
-#endif // QT_S60STYLE_LAYOUTDATA_SIMULATED
d->refreshUI();
d->setBackgroundTexture(qApp);
foreach (QWidget *widget, QApplication::allWidgets())
@@ -1286,11 +1349,12 @@ void QS60Style::handleDynamicLayoutVariantSwitch()
void QS60Style::handleSkinChange()
{
Q_D(QS60Style);
- d->clearCaches();
+ d->clearCaches(QS60StylePrivate::CC_ThemeChange);
d->setThemePalette(qApp);
foreach (QWidget *topLevelWidget, QApplication::allWidgets()){
QEvent e(QEvent::StyleChange);
QApplication::sendEvent(topLevelWidget, &e);
+ d->setThemePalette(topLevelWidget);
topLevelWidget->ensurePolished();
}
}
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 5a88f9a..684f232 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -21,11 +51,117 @@
#include "qlayout.h"
#include "qpixmapcache.h"
#include "qmetaobject.h"
+#include "qdebug.h"
+#include "qbuffer.h"
+#include "qdesktopwidget.h"
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
QT_BEGIN_NAMESPACE
+static const quint32 blobVersion = 1;
+static const int pictureSize = 256;
+
+#if defined(Q_CC_GNU)
+#if __GNUC__ >= 2
+#define __FUNCTION__ __func__
+#endif
+#endif
+
+
+bool saveThemeToBlob(const QString &themeBlob,
+ const QHash<QString, QPicture> &partPictures,
+ const QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::WriteOnly)) {
+ qWarning() << __FUNCTION__ << ": Could not create blob: " << themeBlob;
+ return false;
+ }
+
+ QByteArray data;
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::WriteOnly);
+ QDataStream dataOut(&dataBuffer);
+
+ const int colorsCount = colors.count();
+ dataOut << colorsCount;
+ const QList<QPair<QString, int> > colorKeys = colors.keys();
+ for (int i = 0; i < colorsCount; ++i) {
+ const QPair<QString, int> &key = colorKeys.at(i);
+ dataOut << key;
+ const QColor color = colors.value(key);
+ dataOut << color;
+ }
+
+ const int picturesCount = partPictures.count();
+ dataOut << picturesCount;
+ foreach (const QString &key, partPictures.keys()) {
+ const QPicture picture = partPictures.value(key);
+ dataOut << key;
+ dataOut << picture;
+ }
+
+ QDataStream blobOut(&blob);
+ blobOut << blobVersion;
+ blobOut << qCompress(data);
+ return blobOut.status() == QDataStream::Ok;
+}
+
+bool loadThemeFromBlob(const QString &themeBlob,
+ QHash<QString, QPicture> &partPictures,
+ QHash<QPair<QString, int>, QColor> &colors)
+{
+ QFile blob(themeBlob);
+ if (!blob.open(QIODevice::ReadOnly)) {
+ qWarning() << __FUNCTION__ << ": Could not read blob: " << themeBlob;
+ return false;
+ }
+ QDataStream blobIn(&blob);
+
+ quint32 version;
+ blobIn >> version;
+
+ if (version != blobVersion) {
+ qWarning() << __FUNCTION__ << ": Invalid blob version: " << version << " ...expected: " << blobVersion;
+ return false;
+ }
+
+ QByteArray data;
+ blobIn >> data;
+ data = qUncompress(data);
+ QBuffer dataBuffer(&data);
+ dataBuffer.open(QIODevice::ReadOnly);
+ QDataStream dataIn(&dataBuffer);
+
+ int colorsCount;
+ dataIn >> colorsCount;
+ for (int i = 0; i < colorsCount; ++i) {
+ QPair<QString, int> key;
+ dataIn >> key;
+ QColor value;
+ dataIn >> value;
+ colors.insert(key, value);
+ }
+
+ int picturesCount;
+ dataIn >> picturesCount;
+ for (int i = 0; i < picturesCount; ++i) {
+ QString key;
+ dataIn >> key;
+ QPicture value;
+ dataIn >> value;
+ value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized.
+ partPictures.insert(key, value);
+ }
+
+ if (dataIn.status() != QDataStream::Ok) {
+ qWarning() << __FUNCTION__ << ": Invalid data blob: " << themeBlob;
+ return false;
+ }
+ return true;
+}
+
class QS60StyleModeSpecifics
{
public:
@@ -42,19 +178,6 @@ QS60StylePrivate::QS60StylePrivate()
setCurrentLayout(0);
}
-QS60StylePrivate::~QS60StylePrivate()
-{
-}
-
-short QS60StylePrivate::pixelMetric(int metric)
-{
- Q_ASSERT(metric < MAX_PIXELMETRICS);
- const short returnValue = m_pmPointer[metric];
- if (returnValue==-909)
- return -1;
- return returnValue;
-}
-
QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
int index, const QStyleOption *option)
{
@@ -106,9 +229,10 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size
QPixmap result = QPixmap::fromImage(partImage);
if (flags & SF_StateDisabled) {
- // TODO: fix this
QStyleOption opt;
-// opt.palette = q->standardPalette();
+ QPalette *themePalette = QS60StylePrivate::themePalette();
+ if (themePalette)
+ opt.palette = *themePalette;
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt);
}
@@ -150,7 +274,8 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size,
const QRect leftRect = rightRect.translated(cornerWidth - rectWidth, 0);
const QRect centerRect = drawOnlyCenter ? rect : rect.adjusted(cornerWidth, cornerWidth, -cornerWidth, -cornerWidth);
- QImage result(size, QImage::Format_ARGB32);
+ QPixmap result(size);
+ result.fill(Qt::transparent);
QPainter painter(&result);
#if 0
@@ -178,7 +303,7 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size,
drawPart(center, &painter, centerRect, flags);
#endif
- return QPixmap::fromImage(result);
+ return result;
}
void QS60StylePrivate::setStyleProperty_specific(const char *name, const QVariant &value)
@@ -193,23 +318,15 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const
QPixmap QS60StylePrivate::backgroundTexture()
{
- static QPixmap result;
- // Poor mans caching. + Making sure that there is always only one background image in memory at a time
-
-/*
- TODO: 1) Hold the background QPixmap as pointer in a static class member.
- Also add a deleteBackground() function and call that in ~QS60StylePrivate()
- 2) Don't cache the background at all as soon as we have native pixmap support
-*/
-
- if (!m_backgroundValid) {
- result = QPixmap();
- result = part(QS60StyleEnums::SP_QsnBgScreen, QApplication::activeWindow()->size());
- m_backgroundValid = true;
+ if (!m_background) {
+ const QSize size = QApplication::desktop()->screen()->size();
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size);
+ m_background = new QPixmap(background);
}
- return result;
+ return *m_background;
}
+
bool QS60StylePrivate::isTouchSupported()
{
#ifdef QT_KEYPAD_NAVIGATION
@@ -224,7 +341,6 @@ bool QS60StylePrivate::isToolBarBackground()
return true;
}
-
QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize)
{
QFont result;
@@ -244,6 +360,18 @@ QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCate
return result;
}
+/*!
+ Constructs a QS60Style object.
+*/
+QS60Style::QS60Style()
+ : QCommonStyle(*new QS60StylePrivate)
+{
+ // Assume, that the resource system has a ':/s60Stylethemes/Default.blob'
+ const QString defaultBlob = QString::fromLatin1(":/s60Stylethemes/Default.blob");
+ if (QFile::exists(defaultBlob))
+ loadS60ThemeFromBlob(defaultBlob);
+}
+
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, {
const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("SkinParts");
Q_ASSERT(enumIndex >= 0);
@@ -285,8 +413,35 @@ QStringList QS60Style::colorListKeys()
void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts,
const QHash<QPair<QString , int>, QColor> &colors)
{
+ Q_D(QS60Style);
QS60StyleModeSpecifics::m_partPictures = parts;
QS60StyleModeSpecifics::m_colors = colors;
+ d->clearCaches(QS60StylePrivate::CC_ThemeChange);
+ d->setBackgroundTexture(qApp);
+ d->setThemePalette(qApp);
+}
+
+bool QS60Style::loadS60ThemeFromBlob(const QString &blobFile)
+{
+ QHash<QString, QPicture> partPictures;
+ QHash<QPair<QString, int>, QColor> colors;
+
+ if (!loadThemeFromBlob(blobFile, partPictures, colors))
+ return false;
+ setS60Theme(partPictures, colors);
+ return true;
+}
+
+bool QS60Style::saveS60ThemeToBlob(const QString &blobFile) const
+{
+ return saveThemeToBlob(blobFile,
+ QS60StyleModeSpecifics::m_partPictures, QS60StyleModeSpecifics::m_colors);
+}
+
+QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
+{
+ Q_UNUSED(targetWidget)
+ return QPoint();
}
QT_END_NAMESPACE
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 714b8c5..bd80bb6 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5252,9 +5252,12 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
#ifndef QT_NO_COMBOBOX
if (qobject_cast<const QComboBox *>(w)) {
QAbstractItemView *view = qFindChild<QAbstractItemView *>(w);
- QRenderRule subRule = renderRule(view, PseudoElement_None);
- if (subRule.hasBox() || !subRule.hasNativeBorder())
- return QFrame::NoFrame;
+ if (view) {
+ view->ensurePolished();
+ QRenderRule subRule = renderRule(view, PseudoElement_None);
+ if (subRule.hasBox() || !subRule.hasNativeBorder())
+ return QFrame::NoFrame;
+ }
}
#endif // QT_NO_COMBOBOX
break;
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 9aa170e..050d81d 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -160,9 +160,8 @@ contains( styles, s60 ) {
styles/qs60style.h \
styles/qs60style_p.h
SOURCES += styles/qs60style.cpp
- DEFINES += QT_S60STYLE_LAYOUTDATA_SIMULATED
symbian {
- SOURCES += styles/qs60style_symbian.cpp
+ SOURCES += styles/qs60style_s60.cpp
# TODO: fix the following LIBS hack. Line 1 is for armv5, 2 for winscw
LIBS += aknicon aknskins aknskinsrv fontutils
LIBS += -laknicon -laknskins -laknskinsrv -lfontutils
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 5a97086..0bd2d9a 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1162,13 +1162,20 @@ static bool setFontWeightFromValue(const Value &value, QFont *font)
return true;
}
-static bool setFontFamilyFromValues(const QVector<Value> &values, QFont *font)
+/** \internal
+ * parse the font family from the values (starting from index \a start)
+ * 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)
{
QString family;
- for (int i = 0; i < values.count(); ++i) {
+ for (int i = start; i < values.count(); ++i) {
const Value &v = values.at(i);
- if (v.type == Value::TermOperatorComma)
- break;
+ if (v.type == Value::TermOperatorComma) {
+ family += QLatin1Char(',');
+ continue;
+ }
const QString str = v.variant.toString();
if (str.isEmpty())
break;
@@ -1222,9 +1229,7 @@ static void parseShorthandFontProperty(const QVector<Value> &values, QFont *font
}
if (i < values.count()) {
- QString fam = values.at(i).variant.toString();
- if (!fam.isEmpty())
- font->setFamily(fam);
+ setFontFamilyFromValues(values, font, i);
}
}
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 6ee1d03..e324db6 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -173,8 +173,7 @@ Q_GUI_EXPORT int qt_defaultDpiX()
screen = subScreens.at(0);
dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
#elif defined(Q_WS_S60)
- const TReal inchWidth = (TReal)S60->screenWidthInTwips / KTwipsPerInch;
- dpi = S60->screenWidthInPixels / inchWidth;
+ dpi = S60->defaultDpiX;
#endif // Q_WS_X11
return dpi;
@@ -202,8 +201,7 @@ Q_GUI_EXPORT int qt_defaultDpiY()
screen = subScreens.at(0);
dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
#elif defined(Q_WS_S60)
- const TReal inchHeight = (TReal)S60->screenHeightInTwips / KTwipsPerInch;
- dpi = S60->screenHeightInPixels / inchHeight;
+ dpi = S60->defaultDpiY;
#endif // Q_WS_X11
return dpi;
@@ -316,7 +314,7 @@ QFontPrivate *QFontPrivate::smallCapsFontPrivate() const
font.setPointSizeF(pointSize * .7);
else
font.setPixelSize((font.pixelSize() * 7 + 5) / 10);
- scFont = font.d;
+ scFont = font.d.data();
if (scFont != this)
scFont->ref.ref();
return scFont;
@@ -723,12 +721,11 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
const int screen = 0;
#endif
if (font.d->dpi != dpi || font.d->screen != screen ) {
- d = new QFontPrivate(*font.d);
+ d.reset(new QFontPrivate(*font.d));
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
- d->ref.ref();
+ d.assign(font.d.data());
}
#ifdef Q_WS_WIN
if (pd->devType() == QInternal::Printer && pd->getDC())
@@ -742,8 +739,7 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
QFont::QFont(QFontPrivate *data)
: resolve_mask(QFont::AllPropertiesResolved)
{
- d = data;
- d->ref.ref();
+ d.assign(data);
}
/*! \internal
@@ -755,13 +751,13 @@ void QFont::detach()
if (d->engineData)
d->engineData->ref.deref();
d->engineData = 0;
- if (d->scFont && d->scFont != d)
+ if (d->scFont && d->scFont != d.data())
d->scFont->ref.deref();
d->scFont = 0;
return;
}
- qAtomicDetach(d);
+ d.detach();
}
/*!
@@ -770,9 +766,9 @@ void QFont::detach()
\sa QApplication::setFont(), QApplication::font()
*/
QFont::QFont()
- :d(QApplication::font().d), resolve_mask(0)
+ :resolve_mask(0)
{
- d->ref.ref();
+ d.assign(QApplication::font().d.data());
}
/*!
@@ -792,13 +788,12 @@ QFont::QFont()
setStyleHint() QApplication::font()
*/
QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
- :d(new QFontPrivate)
{
+ d.reset(new QFontPrivate());
resolve_mask = QFont::FamilyResolved;
if (pointSize <= 0) {
#ifdef Q_WS_S60
- // TODO: What should the default QFont pointSize for Q_WS_S60 be?
pointSize = 7;
#else
pointSize = 12;
@@ -825,8 +820,7 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
*/
QFont::QFont(const QFont &font)
{
- d = font.d;
- d->ref.ref();
+ d.assign(font.d.data());
resolve_mask = font.resolve_mask;
}
@@ -835,8 +829,6 @@ QFont::QFont(const QFont &font)
*/
QFont::~QFont()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -844,7 +836,7 @@ QFont::~QFont()
*/
QFont &QFont::operator=(const QFont &font)
{
- qAtomicAssign(d, font.d);
+ d.assign(font.d.data());
resolve_mask = font.resolve_mask;
return *this;
}
@@ -1727,7 +1719,7 @@ QFont QFont::resolve(const QFont &other) const
QFont font(*this);
font.detach();
- font.d->resolve(resolve_mask, other.d);
+ font.d->resolve(resolve_mask, other.d.data());
return font;
}
@@ -1911,6 +1903,20 @@ void QFont::insertSubstitutions(const QString &familyName,
}
}
+/*! \fn void QFont::initialize()
+ \internal
+
+ Internal function that initializes the font system. The font cache
+ and font dict do not alloc the keys. The key is a QString which is
+ shared between QFontPrivate and QXFontName.
+*/
+
+/*! \fn void QFont::cleanup()
+ \internal
+
+ Internal function that cleans up the font system.
+*/
+
// ### mark: should be called removeSubstitutions()
/*!
Removes all the substitutions for \a familyName.
@@ -2166,11 +2172,11 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
s << (quint8) font.d->request.styleStrategy;
s << (quint8) 0
<< (quint8) font.d->request.weight
- << get_font_bits(s.version(), font.d);
+ << get_font_bits(s.version(), font.d.data());
if (s.version() >= QDataStream::Qt_4_3)
s << (quint16)font.d->request.stretch;
if (s.version() >= QDataStream::Qt_4_4)
- s << get_extended_font_bits(font.d);
+ s << get_extended_font_bits(font.d.data());
if (s.version() >= QDataStream::Qt_4_5) {
s << font.d->letterSpacing.value();
s << font.d->wordSpacing.value();
@@ -2189,10 +2195,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font)
*/
QDataStream &operator>>(QDataStream &s, QFont &font)
{
- if (!font.d->ref.deref())
- delete font.d;
-
- font.d = new QFontPrivate;
+ font.d.assign(0);
+ font.d.reset(new QFontPrivate);
font.resolve_mask = QFont::AllPropertiesResolved;
quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits;
@@ -2233,7 +2237,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
font.d->request.styleStrategy = styleStrategy;
font.d->request.weight = weight;
- set_font_bits(s.version(), bits, font.d);
+ set_font_bits(s.version(), bits, font.d.data());
if (s.version() >= QDataStream::Qt_4_3) {
quint16 stretch;
@@ -2244,7 +2248,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
if (s.version() >= QDataStream::Qt_4_4) {
quint8 extendedBits;
s >> extendedBits;
- set_extended_font_bits(extendedBits, font.d);
+ set_extended_font_bits(extendedBits, font.d.data());
}
if (s.version() >= QDataStream::Qt_4_5) {
int value;
@@ -2326,7 +2330,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
that is not screen-compatible.
*/
QFontInfo::QFontInfo(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{ d->ref.ref(); }
/*!
@@ -2599,7 +2603,14 @@ QFontCache *QFontCache::instance()
void QFontCache::cleanup()
{
- theFontCache()->setLocalData(0);
+ QThreadStorage<QFontCache *> *cache = 0;
+ QT_TRY {
+ cache = theFontCache();
+ } QT_CATCH (const std::bad_alloc &) {
+ // no cache - just ignore
+ }
+ if (cache && cache->hasLocalData())
+ cache->setLocalData(0);
}
#endif // QT_NO_THREAD
@@ -2612,8 +2623,8 @@ QFontCache::QFontCache()
QFontCache::~QFontCache()
{
{
- EngineDataCache::Iterator it = engineDataCache.begin(),
- end = engineDataCache.end();
+ EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
+ end = engineDataCache.constEnd();
while (it != end) {
if (it.value()->ref == 0)
delete it.value();
@@ -2623,8 +2634,8 @@ QFontCache::~QFontCache()
++it;
}
}
- EngineCache::Iterator it = engineCache.begin(),
- end = engineCache.end();
+ EngineCache::ConstIterator it = engineCache.constBegin(),
+ end = engineCache.constEnd();
while (it != end) {
if (--it.value().data->cache_count == 0) {
if (it.value().data->ref == 0) {
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index eec83b5..a513b7a 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -44,6 +44,7 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#if defined(Q_WS_X11) || defined(Q_WS_QWS)
typedef struct FT_FaceRec_* FT_Face;
@@ -312,7 +313,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QFont &);
#endif
- QFontPrivate *d;
+ QScopedSharedPointer<QFontPrivate> d;
uint resolve_mask;
};
diff --git a/src/gui/text/qfont_s60.cpp b/src/gui/text/qfont_s60.cpp
index 2606091..533e51f 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/gui/text/qfont_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfont_x11.cpp b/src/gui/text/qfont_x11.cpp
index 710792c..6b0e46c 100644
--- a/src/gui/text/qfont_x11.cpp
+++ b/src/gui/text/qfont_x11.cpp
@@ -129,13 +129,6 @@ Q_GUI_EXPORT void qt_x11_set_fallback_font_family(int script, const QString &fam
int QFontPrivate::defaultEncodingID = -1;
-/*!
- Internal function that initializes the font system.
-
- \internal
- The font cache and font dict do not alloc the keys. The key is a QString
- which is shared between QFontPrivate and QXFontName.
-*/
void QFont::initialize()
{
extern int qt_encoding_id_for_mib(int mib); // from qfontdatabase_x11.cpp
@@ -184,10 +177,6 @@ void QFont::initialize()
QFontPrivate::defaultEncodingID = qt_encoding_id_for_mib(mib);
}
-/*! \internal
-
- Internal function that cleans up the font system.
-*/
void QFont::cleanup()
{
QFontCache::cleanup();
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 1345d21..416017d 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -167,10 +167,13 @@ QtFontEncoding *QtFontSize::encodingID(int id, uint xpoint, uint xres,
if (!add) return 0;
- if (!(count % 4))
- encodings = (QtFontEncoding *)
+ if (!(count % 4)) {
+ QtFontEncoding *newEncodings = (QtFontEncoding *)
realloc(encodings,
(((count+4) >> 2) << 2) * sizeof(QtFontEncoding));
+ Q_CHECK_PTR(newEncodings);
+ encodings = newEncodings;
+ }
encodings[count].encoding = id;
encodings[count].xpoint = xpoint;
encodings[count].xres = xres;
@@ -274,10 +277,13 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add)
if (!add)
return 0;
- if (!(count % 8))
- pixelSizes = (QtFontSize *)
+ if (!(count % 8)) {
+ QtFontSize *newPixelSizes = (QtFontSize *)
realloc(pixelSizes,
(((count+8) >> 3) << 3) * sizeof(QtFontSize));
+ Q_CHECK_PTR(newPixelSizes);
+ pixelSizes = newPixelSizes;
+ }
pixelSizes[count].pixelSize = size;
#ifdef Q_WS_X11
pixelSizes[count].count = 0;
@@ -328,12 +334,16 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create)
return 0;
// qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos);
- if (!(count % 8))
- styles = (QtFontStyle **)
+ if (!(count % 8)) {
+ QtFontStyle **newStyles = (QtFontStyle **)
realloc(styles, (((count+8) >> 3) << 3) * sizeof(QtFontStyle *));
+ Q_CHECK_PTR(newStyles);
+ styles = newStyles;
+ }
+ QtFontStyle *style = new QtFontStyle(key);
memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *));
- styles[pos] = new QtFontStyle(key);
+ styles[pos] = style;
count++;
return styles[pos];
}
@@ -438,10 +448,13 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create)
if (!create)
return 0;
- if (!(count % 8))
- foundries = (QtFontFoundry **)
+ if (!(count % 8)) {
+ QtFontFoundry **newFoundries = (QtFontFoundry **)
realloc(foundries,
(((count+8) >> 3) << 3) * sizeof(QtFontFoundry *));
+ Q_CHECK_PTR(newFoundries);
+ foundries = newFoundries;
+ }
foundries[count] = new QtFontFoundry(f);
return foundries[count++];
@@ -684,13 +697,17 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
pos++;
// qDebug("adding family %s at %d total=%d", f.latin1(), pos, count);
- if (!(count % 8))
- families = (QtFontFamily **)
+ if (!(count % 8)) {
+ QtFontFamily **newFamilies = (QtFontFamily **)
realloc(families,
(((count+8) >> 3) << 3) * sizeof(QtFontFamily *));
+ Q_CHECK_PTR(newFamilies);
+ families = newFamilies;
+ }
+ QtFontFamily *family = new QtFontFamily(f);
memmove(families + pos + 1, families + pos, (count-pos)*sizeof(QtFontFamily *));
- families[pos] = new QtFontFamily(f);
+ families[pos] = family;
count++;
return families[pos];
}
@@ -969,6 +986,7 @@ static void getEngineData(const QFontPrivate *d, const QFontCache::Key &key)
d->engineData->ref.ref();
}
}
+#endif
static QStringList familyList(const QFontDef &req)
{
@@ -997,7 +1015,6 @@ static QStringList familyList(const QFontDef &req)
return family_list;
}
-#endif
Q_GLOBAL_STATIC(QFontDatabasePrivate, privateDb)
Q_GLOBAL_STATIC_WITH_ARGS(QMutex, fontDatabaseMutex, (QMutex::Recursive))
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp
index 80ddbd5..26d8687 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/gui/text/qfontdatabase_mac.cpp
@@ -281,14 +281,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
//find the font
- QStringList family_list = req.family.split(QLatin1Char(','));
- // append the substitute list for each family in family_list
- {
- QStringList subs_list;
- for(QStringList::ConstIterator it = family_list.constBegin(); it != family_list.constEnd(); ++it)
- subs_list += QFont::substitutes(*it);
- family_list += subs_list;
- }
+ QStringList family_list = familyList(req);
const char *stylehint = styleHint(req);
if (stylehint)
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
index 33b0728..978ff8e 100644
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ b/src/gui/text/qfontdatabase_qws.cpp
@@ -566,8 +566,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, res.data(), res.size());
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid! " << size->fileName;
delete fe;
+ qDebug() << "fontengine is not valid! " << size->fileName;
} else {
qDebug() << "Resource not valid" << size->fileName;
}
@@ -577,8 +577,8 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
QFontEngineQPF *fe = new QFontEngineQPF(request, f);
if (fe->isValid())
return fe;
- qDebug() << "fontengine is not valid!";
delete fe; // will close f
+ qDebug() << "fontengine is not valid!";
}
#endif
} else
@@ -592,70 +592,67 @@ QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
static bool dontShareFonts = !qgetenv("QWS_NO_SHARE_FONTS").isEmpty();
bool shareFonts = !dontShareFonts;
- QFontEngine *engine = 0;
+ QScopedPointer<QFontEngine> engine;
#ifndef QT_NO_LIBRARY
QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry->name));
- if (factory) {
- QFontEngineInfo info;
- info.setFamily(request.family);
- info.setPixelSize(request.pixelSize);
- info.setStyle(QFont::Style(request.style));
- info.setWeight(request.weight);
- // #### antialiased
-
- QAbstractFontEngine *customEngine = factory->create(info);
- if (customEngine) {
- engine = new QProxyFontEngine(customEngine, def);
-
- if (shareFonts) {
- QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
- if (hint.isValid())
- shareFonts = hint.toBool();
- else
- shareFonts = (pixelSize < 64);
- }
+ if (factory) {
+ QFontEngineInfo info;
+ info.setFamily(request.family);
+ info.setPixelSize(request.pixelSize);
+ info.setStyle(QFont::Style(request.style));
+ info.setWeight(request.weight);
+ // #### antialiased
+
+ QAbstractFontEngine *customEngine = factory->create(info);
+ if (customEngine) {
+ engine.reset(new QProxyFontEngine(customEngine, def));
+
+ if (shareFonts) {
+ QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
+ if (hint.isValid())
+ shareFonts = hint.toBool();
+ else
+ shareFonts = (pixelSize < 64);
}
+ }
}
#endif // QT_NO_LIBRARY
- if (!engine && !file.isEmpty() && QFile::exists(file) || privateDb()->isApplicationFont(file)) {
+ if ((engine.isNull() && !file.isEmpty() && QFile::exists(file)) || privateDb()->isApplicationFont(file)) {
QFontEngine::FaceId faceId;
faceId.filename = file.toLocal8Bit();
faceId.index = size->fileIndex;
#ifndef QT_NO_FREETYPE
- QFontEngineFT *fte = new QFontEngineFT(def);
+ QScopedPointer<QFontEngineFT> fte(new QFontEngineFT(def));
if (fte->init(faceId, style->antialiased,
style->antialiased ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
#ifdef QT_NO_QWS_QPF2
- return fte;
+ return fte.take();
#else
- engine = fte;
// try to distinguish between bdf and ttf fonts we can pre-render
// and don't try to share outline fonts
shareFonts = shareFonts
&& !fte->defaultGlyphs()->outline_drawing
&& !fte->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')).isEmpty();
+ engine.reset(fte.take());
#endif
- } else {
- delete fte;
}
#endif // QT_NO_FREETYPE
}
- if (engine) {
+ if (!engine.isNull()) {
#if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
if (shareFonts) {
- QFontEngineQPF *fe = new QFontEngineQPF(def, -1, engine);
- engine = 0;
+ QScopedPointer<QFontEngineQPF> fe(new QFontEngineQPF(def, -1, engine.data()));
+ engine.take();
if (fe->isValid())
- return fe;
+ return fe.take();
qWarning("Initializing QFontEngineQPF failed for %s", qPrintable(file));
- engine = fe->takeRenderingEngine();
- delete fe;
+ engine.reset(fe->takeRenderingEngine());
}
#endif
- return engine;
+ return engine.take();
}
} else
{
@@ -682,20 +679,22 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp,
QtFontFamily *family, QtFontFoundry *foundry,
QtFontStyle *style, QtFontSize *size)
{
- QFontEngine *fe = loadSingleEngine(script, fp, request, family, foundry,
- style, size);
- if (fe
+ QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
+ style, size));
+ if (!engine.isNull()
&& script == QUnicodeTables::Common
- && !(request.styleStrategy & QFont::NoFontMerging) && !fe->symbol) {
+ && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
QStringList fallbacks = privateDb()->fallbackFamilies;
if (family && !family->fallbackFamilies.isEmpty())
fallbacks = family->fallbackFamilies;
- fe = new QFontEngineMultiQWS(fe, script, fallbacks);
+ QFontEngine *fe = new QFontEngineMultiQWS(engine.data(), script, fallbacks);
+ engine.take();
+ engine.reset(fe);
}
- return fe;
+ return engine.take();
}
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 0b4567c..416c3d1 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -25,6 +55,39 @@
QT_BEGIN_NAMESPACE
+QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameFilters,
+ QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort,
+ bool uniqueFileNames = true)
+{
+ QFileInfoList result;
+
+ // Prepare a 'soft to hard' drive list: W:, X: ... A:, Z:
+ QStringList driveStrings;
+ foreach (const QFileInfo &drive, QDir::drives())
+ driveStrings.append(drive.absolutePath());
+ driveStrings.sort();
+ const QString zDriveString("Z:/");
+ driveStrings.removeAll(zDriveString);
+ driveStrings.prepend(zDriveString);
+
+ QStringList uniqueFileNameList;
+ for (int i = driveStrings.count() - 1; i >= 0; --i) {
+ const QDir dirOnDrive(driveStrings.at(i) + path);
+ const QFileInfoList entriesOnDrive = dirOnDrive.entryInfoList(nameFilters, filters, sort);
+ if (uniqueFileNames) {
+ foreach(const QFileInfo &entry, entriesOnDrive) {
+ if (!uniqueFileNameList.contains(entry.fileName())) {
+ uniqueFileNameList.append(entry.fileName());
+ result.append(entry);
+ }
+ }
+ } else {
+ result.append(entriesOnDrive);
+ }
+ }
+ return result;
+}
+
#if defined(QT_NO_FREETYPE)
class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store
{
@@ -47,10 +110,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation()
m_store = CFontStore::NewL(m_heap);
m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E));
m_store->InstallRasterizerL(m_rasterizer);
- QDir dir(QDesktopServices::storageLocation(QDesktopServices::FontsLocation));
- dir.setNameFilters(QStringList() << QLatin1String("*.ttf") << QLatin1String("*.ccc"));
- for (int i = 0; i < int(dir.count()); ++i) {
- const QString fontFile = QDir::toNativeSeparators(dir.absoluteFilePath(dir[i]));
+
+ QStringList filters;
+ filters.append(QString::fromLatin1("*.ttf"));
+ filters.append(QString::fromLatin1("*.ccc"));
+ const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters);
+ foreach (const QFileInfo &fontFileInfo, fontFiles) {
+ const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath());
m_store->AddFileL(qt_QString2TPtrC(fontFile));
}
}
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 15e626e..70e1599 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -494,7 +494,7 @@ static inline bool isFixedPitch(char **tokens)
Fills in a font definition (QFontDef) from an XLFD (X Logical Font
Description).
- Returns true if the the given xlfd is valid.
+ Returns true if the given xlfd is valid.
*/
bool qt_fillFontDef(const QByteArray &xlfd, QFontDef *fd, int dpi, QtFontDesc *desc)
{
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index c2c23ee..2f96984 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -191,18 +191,20 @@ QFontEngine::QFontEngine()
QFontEngine::~QFontEngine()
{
- for (GlyphPointerHash::iterator it = m_glyphPointerHash.begin(), end = m_glyphPointerHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphPointerHash::const_iterator it = m_glyphPointerHash.constBegin(),
+ end = m_glyphPointerHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphPointerHash.clear();
- for (GlyphIntHash::iterator it = m_glyphIntHash.begin(), end = m_glyphIntHash.end();
- it != end; ++it) {
- for (QList<QFontEngineGlyphCache*>::iterator it2 = it.value().begin(), end2 = it.value().end();
- it2 != end2; ++it2)
- delete *it2;
+ for (GlyphIntHash::const_iterator it = m_glyphIntHash.constBegin(),
+ end = m_glyphIntHash.constEnd(); it != end; ++it) {
+ for (QList<QFontEngineGlyphCache*>::const_iterator it2 = it.value().constBegin(),
+ end2 = it.value().constEnd(); it2 != end2; ++it2) {
+ delete *it2;
+ }
}
m_glyphIntHash.clear();
qHBFreeFace(hbFace);
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 6f5ee1f..f1dac96 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -193,6 +193,9 @@ HB_Error QFreetypeFace::getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 p
/*
* One font file can contain more than one font (bold/italic for example)
* find the right one and return it.
+ *
+ * Returns the freetype face or 0 in case of an empty file or any other problems
+ * (like not being able to open the file)
*/
QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
{
@@ -205,7 +208,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
QFreetypeFace *freetype = freetypeData->faces.value(face_id, 0);
if (!freetype) {
- freetype = new QFreetypeFace;
+ QScopedPointer<QFreetypeFace> newFreetype(new QFreetypeFace);
FT_Face face;
QFile file(QString::fromUtf8(face_id.filename));
if (face_id.filename.startsWith(":qmemoryfonts/")) {
@@ -214,84 +217,82 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id)
QByteArray idx = face_id.filename;
idx.remove(0, 14); // remove ':qmemoryfonts/'
bool ok = false;
- freetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
+ newFreetype->fontData = qt_fontdata_from_index(idx.toInt(&ok));
if (!ok)
- freetype->fontData = QByteArray();
+ newFreetype->fontData = QByteArray();
} else if (!(file.fileEngine()->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::LocalDiskFlag)) {
if (!file.open(QIODevice::ReadOnly)) {
- delete freetype;
return 0;
}
- freetype->fontData = file.readAll();
+ newFreetype->fontData = file.readAll();
}
- if (!freetype->fontData.isEmpty()) {
- if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)freetype->fontData.constData(), freetype->fontData.size(), face_id.index, &face)) {
- delete freetype;
+ if (!newFreetype->fontData.isEmpty()) {
+ if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)newFreetype->fontData.constData(), newFreetype->fontData.size(), face_id.index, &face)) {
return 0;
}
} else if (FT_New_Face(freetypeData->library, face_id.filename, face_id.index, &face)) {
- delete freetype;
return 0;
}
- freetype->face = face;
-
- freetype->hbFace = qHBNewFace(face, hb_getSFntTable);
- freetype->ref = 0;
- freetype->xsize = 0;
- freetype->ysize = 0;
- freetype->matrix.xx = 0x10000;
- freetype->matrix.yy = 0x10000;
- freetype->matrix.xy = 0;
- freetype->matrix.yx = 0;
- freetype->unicode_map = 0;
- freetype->symbol_map = 0;
+ newFreetype->face = face;
+
+ newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable);
+ newFreetype->ref = 0;
+ newFreetype->xsize = 0;
+ newFreetype->ysize = 0;
+ newFreetype->matrix.xx = 0x10000;
+ newFreetype->matrix.yy = 0x10000;
+ newFreetype->matrix.xy = 0;
+ newFreetype->matrix.yx = 0;
+ newFreetype->unicode_map = 0;
+ newFreetype->symbol_map = 0;
#ifndef QT_NO_FONTCONFIG
- freetype->charset = 0;
+ newFreetype->charset = 0;
#endif
- memset(freetype->cmapCache, 0, sizeof(freetype->cmapCache));
+ memset(newFreetype->cmapCache, 0, sizeof(newFreetype->cmapCache));
- for (int i = 0; i < freetype->face->num_charmaps; ++i) {
- FT_CharMap cm = freetype->face->charmaps[i];
+ for (int i = 0; i < newFreetype->face->num_charmaps; ++i) {
+ FT_CharMap cm = newFreetype->face->charmaps[i];
switch(cm->encoding) {
case FT_ENCODING_UNICODE:
- freetype->unicode_map = cm;
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_APPLE_ROMAN:
case FT_ENCODING_ADOBE_LATIN_1:
- if (!freetype->unicode_map || freetype->unicode_map->encoding != FT_ENCODING_UNICODE)
- freetype->unicode_map = cm;
+ if (!newFreetype->unicode_map || newFreetype->unicode_map->encoding != FT_ENCODING_UNICODE)
+ newFreetype->unicode_map = cm;
break;
case FT_ENCODING_ADOBE_CUSTOM:
case FT_ENCODING_MS_SYMBOL:
- if (!freetype->symbol_map)
- freetype->symbol_map = cm;
+ if (!newFreetype->symbol_map)
+ newFreetype->symbol_map = cm;
break;
default:
break;
}
}
- if (!FT_IS_SCALABLE(freetype->face) && freetype->face->num_fixed_sizes == 1)
- FT_Set_Char_Size (face, X_SIZE(freetype->face, 0), Y_SIZE(freetype->face, 0), 0, 0);
+ if (!FT_IS_SCALABLE(newFreetype->face) && newFreetype->face->num_fixed_sizes == 1)
+ FT_Set_Char_Size (face, X_SIZE(newFreetype->face, 0), Y_SIZE(newFreetype->face, 0), 0, 0);
# if 0
FcChar8 *name;
FcPatternGetString(pattern, FC_FAMILY, 0, &name);
qDebug("%s: using maps: default: %x unicode: %x, symbol: %x", name,
- freetype->face->charmap ? freetype->face->charmap->encoding : 0,
- freetype->unicode_map ? freetype->unicode_map->encoding : 0,
- freetype->symbol_map ? freetype->symbol_map->encoding : 0);
+ newFreetype->face->charmap ? newFreetype->face->charmap->encoding : 0,
+ newFreetype->unicode_map ? newFreetype->unicode_map->encoding : 0,
+ newFreetype->symbol_map ? newFreetype->symbol_map->encoding : 0);
for (int i = 0; i < 256; i += 8)
qDebug(" %x: %d %d %d %d %d %d %d %d", i,
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i),
- FcCharSetHasChar(freetype->charset, i), FcCharSetHasChar(freetype->charset, i));
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i),
+ FcCharSetHasChar(newFreetype->charset, i), FcCharSetHasChar(newFreetype->charset, i));
#endif
- FT_Set_Charmap(freetype->face, freetype->unicode_map);
- freetypeData->faces.insert(face_id, freetype);
+ FT_Set_Charmap(newFreetype->face, newFreetype->unicode_map);
+ freetypeData->faces.insert(face_id, newFreetype.data());
+ freetype = newFreetype.take();
}
freetype->ref.ref();
return freetype;
@@ -608,6 +609,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd)
kerning_pairs_loaded = false;
transform = false;
antialias = true;
+ freetype = 0;
default_load_flags = 0;
default_hint_style = HintNone;
subpixelType = Subpixel_None;
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 649d78b..b67895b 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -119,6 +119,7 @@ struct QFreetypeFace
static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool = false);
private:
+ friend class QScopedPointer<QFreetypeFace>;
QFreetypeFace() : _lock(QMutex::Recursive) {}
~QFreetypeFace() {}
QAtomicInt ref;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 425cab2..d397e4a 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -553,7 +553,9 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
8, im.bytesPerLine(), colorspace,
cgflags);
CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold
+ && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldSmoothFonts(ctx, false);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index e9fcac4..435a102 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -325,21 +325,21 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
fileName.replace(QLatin1Char(' '), QLatin1Char('_'));
fileName.prepend(qws_fontCacheDir());
- const QByteArray encodedName = QFile::encodeName(fileName);
- if (::access(encodedName, F_OK) == 0) {
+ encodedFileName = QFile::encodeName(fileName);
+ if (::access(encodedFileName, F_OK) == 0) {
#if defined(DEBUG_FONTENGINE)
qDebug() << "found existing qpf:" << fileName;
#endif
- if (::access(encodedName, W_OK | R_OK) == 0)
- fd = ::open(encodedName, O_RDWR);
- else if (::access(encodedName, R_OK) == 0)
- fd = ::open(encodedName, O_RDONLY);
+ if (::access(encodedFileName, W_OK | R_OK) == 0)
+ fd = ::open(encodedFileName, O_RDWR);
+ else if (::access(encodedFileName, R_OK) == 0)
+ fd = ::open(encodedFileName, O_RDONLY);
} else {
#if defined(DEBUG_FONTENGINE)
qDebug() << "creating qpf on the fly:" << fileName;
#endif
if (::access(QFile::encodeName(qws_fontCacheDir()), W_OK) == 0) {
- fd = ::open(encodedName, O_RDWR | O_EXCL | O_CREAT, 0644);
+ fd = ::open(encodedFileName, O_RDWR | O_EXCL | O_CREAT, 0644);
QBuffer buffer;
buffer.open(QIODevice::ReadWrite);
@@ -474,15 +474,21 @@ QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEng
#endif
#if defined(Q_WS_QWS)
if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, QFile::encodeName(fileName));
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, encodedFileName);
#endif
}
QFontEngineQPF::~QFontEngineQPF()
{
#if defined(Q_WS_QWS)
- if (isValid() && renderingFontEngine)
- qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, QFile::encodeName(fileName));
+ if (isValid() && renderingFontEngine) {
+ QT_TRY {
+ qt_fbdpy->sendFontCommand(QWSFontCommand::StoppedUsingFont, encodedFileName);
+ } QT_CATCH(...) {
+ qDebug("QFontEngineQPF::~QFontEngineQPF: Out of memory");
+ // ignore.
+ }
+ }
#endif
delete renderingFontEngine;
if (fontData)
@@ -1128,6 +1134,11 @@ void QPFGenerator::writeTaggedQFixed(QFontEngineQPF::HeaderTag tag, QFixed value
#endif // QT_NO_QWS_QPF2
+/*
+ Creates a new multi qws engine.
+
+ This function takes ownership of the QFontEngine, increasing it's refcount.
+*/
QFontEngineMultiQWS::QFontEngineMultiQWS(QFontEngine *fe, int _script, const QStringList &fallbacks)
: QFontEngineMulti(fallbacks.size() + 1),
fallbackFamilies(fallbacks), script(_script)
diff --git a/src/gui/text/qfontengine_qpf_p.h b/src/gui/text/qfontengine_qpf_p.h
index a9b87ff..629f5c6 100644
--- a/src/gui/text/qfontengine_qpf_p.h
+++ b/src/gui/text/qfontengine_qpf_p.h
@@ -243,6 +243,7 @@ private:
quint32 glyphDataOffset;
quint32 glyphDataSize;
QString fileName;
+ QByteArray encodedFileName;
bool readOnly;
QFreetypeFace *freetype;
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index eec09f4..2e1abb2 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -197,27 +227,14 @@ QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph)
glyph_metrics_t QFontEngineS60::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_metrics_t glyphBounds = boundingBox_const(glyphs.glyphs[i]);
- QFixed x = overall.xoff + glyphs.offsets[i].x + glyphBounds.x;
- QFixed y = overall.yoff + glyphs.offsets[i].y - glyphBounds.y;
- overall.x = qMin(overall.x, x);
- overall.y = qMin(overall.y, y);
- xmax = qMax(xmax, x + glyphBounds.width);
- ymax = qMax(ymax, y + glyphBounds.height);
- overall.xoff += glyphBounds.xoff;
- }
- overall.height = qMax(overall.height, ymax - overall.y);
- overall.width = xmax - overall.x;
+ if (glyphs.numGlyphs == 0)
+ return glyph_metrics_t();
+
+ QFixed w = 0;
+ for (int i = 0; i < glyphs.numGlyphs; ++i)
+ w += glyphs.effectiveAdvance(i);
- return overall;
+ return glyph_metrics_t(0, -ascent(), w, ascent()+descent()+1, w, 0);
}
glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index ef4a508..2998de8 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index bf3a176..dc2e1ff 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -1335,7 +1335,7 @@ bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) con
QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin,
- const QTransform &t)
+ const QTransform &t, QImage::Format mask_format)
{
glyph_metrics_t gm = boundingBox(glyph);
@@ -1406,9 +1406,9 @@ QNativeImage *QFontEngineWin::drawGDIGlyph(HFONT font, glyph_t glyph, int margin
#endif
#endif
- QNativeImage *ni = new QNativeImage(iw + 2 * margin + 2,
- ih + 2 * margin + 2,
- QNativeImage::systemFormat(), true);
+ QNativeImage *ni = new QNativeImage(iw + 2 * margin + 4,
+ ih + 2 * margin + 4,
+ mask_format, true);
ni->image.fill(0xffffffff);
HDC hdc = ni->hdc;
@@ -1448,8 +1448,12 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
lf.lfQuality = ANTIALIASED_QUALITY;
font = CreateFontIndirectW(&lf);
}
+ QImage::Format mask_format = QNativeImage::systemFormat();
+#ifndef Q_OS_WINCE
+ mask_format = QImage::Format_RGB32;
+#endif
- QNativeImage *mask = drawGDIGlyph(font, glyph, 2, xform);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
if (mask == 0)
return QImage();
@@ -1466,22 +1470,20 @@ QImage QFontEngineWin::alphaMapForGlyph(glyph_t glyph, const QTransform &xform)
// Alpha channel of the ni.image pixels...
for (int y=0; y<mask->height(); ++y) {
uchar *dest = indexed.scanLine(y);
- if (mask->systemFormat() == QImage::Format_RGB16) {
+ if (mask->image.format() == QImage::Format_RGB16) {
const qint16 *src = (qint16 *) ((const QImage &) mask->image).scanLine(y);
- for (int x=0; x<mask->width(); ++x) {
-#ifdef Q_OS_WINCE
+ for (int x=0; x<mask->width(); ++x)
dest[x] = 255 - qGray(src[x]);
-#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
-#endif
- }
} else {
const uint *src = (uint *) ((const QImage &) mask->image).scanLine(y);
for (int x=0; x<mask->width(); ++x) {
#ifdef Q_OS_WINCE
dest[x] = 255 - qGray(src[x]);
#else
- dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
+ if (QNativeImage::systemFormat() == QImage::Format_RGB16)
+ dest[x] = 255 - qGray(src[x]);
+ else
+ dest[x] = 255 - (qt_pow_gamma[qGray(src[x])] * 255. / 2047.);
#endif
}
}
@@ -1507,7 +1509,7 @@ QImage QFontEngineWin::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTra
SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &contrast, 0);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) 1000, 0);
- QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t);
+ QNativeImage *mask = drawGDIGlyph(font, glyph, margin, t, QImage::Format_RGB32);
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 0, (void *) contrast, 0);
if (mask == 0)
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index 6f37e91..f78bc6a 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -138,7 +138,8 @@ public:
mutable int designAdvancesSize;
private:
- QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform);
+ QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
+ QImage::Format mask_format);
};
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 88d0610..991fed7 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -164,7 +164,7 @@ extern int qt_defaultDpi();
metrics that are compatible with a certain paint device.
*/
QFontMetrics::QFontMetrics(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
d->ref.ref();
}
@@ -196,7 +196,7 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
+ d = font.d.data();
d->ref.ref();
}
@@ -670,8 +670,8 @@ QRect QFontMetrics::boundingRect(const QString &text) const
Returns the rectangle that is covered by ink if character \a ch
were to be drawn at the origin of the coordinate system.
- Note that the bounding rectangle may extend to the left of (0, 0),
- e.g. for italicized fonts, and that the text output may cover \e
+ Note that the bounding rectangle may extend to the left of (0, 0)
+ (e.g., for italicized fonts), and that the text output may cover \e
all pixels in the bounding rectangle. For a space character the rectangle
will usually be empty.
@@ -724,7 +724,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const
\o Qt::AlignCenter (== \c{Qt::AlignHCenter | Qt::AlignVCenter})
\o Qt::TextSingleLine ignores newline characters in the text.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
@@ -781,7 +781,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te
\list
\o Qt::TextSingleLine ignores newline characters.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordBreak breaks the text to fit the rectangle.
\endlist
@@ -1006,7 +1006,7 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
metrics that are compatible with a certain paint device.
*/
QFontMetricsF::QFontMetricsF(const QFont &font)
- : d(font.d)
+ : d(font.d.data())
{
d->ref.ref();
}
@@ -1038,7 +1038,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
- d = font.d;
+ d = font.d.data();
d->ref.ref();
}
@@ -1500,7 +1500,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const
\o Qt::AlignCenter (== \c{Qt::AlignHCenter | Qt::AlignVCenter})
\o Qt::TextSingleLine ignores newline characters in the text.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordWrap breaks the text to fit the rectangle.
\endlist
@@ -1559,7 +1559,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString&
\list
\o Qt::TextSingleLine ignores newline characters.
\o Qt::TextExpandTabs expands tabs (see below)
- \o Qt::TextShowMnemonic interprets "&amp;x" as \underline{x}, i.e. underlined.
+ \o Qt::TextShowMnemonic interprets "&x" as \underline{x}; i.e., underlined.
\o Qt::TextWordBreak breaks the text to fit the rectangle.
\endlist
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 737a717..0f0e0ff 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -214,6 +214,7 @@ private:
template <class Fragment>
QFragmentMapData<Fragment>::QFragmentMapData()
+ : fragments(0)
{
init();
}
@@ -222,6 +223,7 @@ template <class Fragment>
void QFragmentMapData<Fragment>::init()
{
fragments = (Fragment *)malloc(64*fragmentSize);
+ Q_CHECK_PTR(fragments);
head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
head->root = 0;
head->freelist = 1;
@@ -247,7 +249,9 @@ uint QFragmentMapData<Fragment>::createFragment()
// need to create some free space
uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
Q_ASSERT(needed/fragmentSize > head->allocated);
- fragments = (Fragment *)realloc(fragments, needed);
+ Fragment *newFragments = (Fragment *)realloc(fragments, needed);
+ Q_CHECK_PTR(newFragments);
+ fragments = newFragments;
head->allocated = needed/fragmentSize;
F(freePos).right = 0;
}
@@ -787,6 +791,8 @@ public:
QFragmentMap() {}
~QFragmentMap()
{
+ if (!data.fragments)
+ return; // in case of out-of-memory, we won't have fragments
for (Iterator it = begin(); !it.atEnd(); ++it)
it.value()->free();
}
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index c74af23..69e1ee4 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -1611,6 +1611,9 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
+ if (QInputContext *ic = inputContext()) {
+ ic->update();
+ }
} else {
//emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
if (cursor.position() != oldCursorPos)
@@ -1813,13 +1816,18 @@ bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &po
void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
+ Q_Q(QTextControl);
if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
e->ignore();
return;
}
- cursor.beginEditBlock();
+ bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty()
+ || e->replacementLength() > 0;
- cursor.removeSelectedText();
+ if (isGettingInput) {
+ cursor.beginEditBlock();
+ cursor.removeSelectedText();
+ }
// insert commit string
if (!e->commitString().isEmpty() || e->replacementLength()) {
@@ -1829,6 +1837,18 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
c.insertText(e->commitString());
}
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ QTextCursor oldCursor = cursor;
+ int blockStart = a.start + cursor.block().position();
+ cursor.setPosition(blockStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
+ q->ensureCursorVisible();
+ repaintOldAndNewSelection(oldCursor);
+ }
+ }
+
QTextBlock block = cursor.block();
QTextLayout *layout = block.layout();
layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
@@ -1852,7 +1872,9 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
}
}
layout->setAdditionalFormats(overrides);
- cursor.endEditBlock();
+
+ if (isGettingInput)
+ cursor.endEditBlock();
}
QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
@@ -1865,13 +1887,15 @@ QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImFont:
return QVariant(d->cursor.charFormat().font());
case Qt::ImCursorPosition:
- return QVariant(d->cursor.selectionEnd() - block.position());
+ return QVariant(d->cursor.position() - block.position());
case Qt::ImSurroundingText:
return QVariant(block.text());
case Qt::ImCurrentSelection:
return QVariant(d->cursor.selectedText());
case Qt::ImMaximumTextLength:
return QVariant(); // No limit.
+ case Qt::ImAnchorPosition:
+ return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
default:
return QVariant();
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 80a5425..0c55ce5 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1099,6 +1099,16 @@ void QTextEngine::shapeTextWithCE(int item) const
}
#endif
+static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)
+{
+ if (num > 0 && destination.glyphs != source.glyphs) {
+ memmove(destination.glyphs, source.glyphs, num * sizeof(HB_Glyph));
+ memmove(destination.attributes, source.attributes, num * sizeof(HB_GlyphAttributes));
+ memmove(destination.advances_x, source.advances_x, num * sizeof(HB_Fixed));
+ memmove(destination.offsets, source.offsets, num * sizeof(HB_FixedPoint));
+ }
+}
+
/// take the item from layoutData->items and
void QTextEngine::shapeTextWithHarfbuzz(int item) const
{
@@ -1189,7 +1199,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
- int initial_glyph_pos = 0;
+ int remaining_glyphs = entire_shaper_item.num_glyphs;
int glyph_pos = 0;
// for each item shape using harfbuzz and store the results in our layoutData's glyphs array.
for (int k = 0; k < itemBoundaries.size(); k += 2) { // for the +2, see the comment at the definition of itemBoundaries
@@ -1209,7 +1219,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
QFontEngine *actualFontEngine = font;
uint engineIdx = 0;
if (font->type() == QFontEngine::Multi) {
- engineIdx = uint(initialGlyphs.glyphs[itemBoundaries[k + 1]] >> 24);
+ engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24);
actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
}
@@ -1219,16 +1229,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
shaper_item.glyphIndicesPresent = true;
+ remaining_glyphs -= shaper_item.initialGlyphCount;
+
do {
- ensureSpace(glyph_pos + shaper_item.num_glyphs);
- initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- shaper_item.num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used - glyph_pos;
+ ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs);
- const QGlyphLayout g = availableGlyphs(&si);
- shaper_item.glyphs = g.glyphs + glyph_pos;
- shaper_item.attributes = g.attributes + glyph_pos;
- shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x + glyph_pos);
- shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets + glyph_pos);
+ const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
+
+ shaper_item.glyphs = g.glyphs;
+ shaper_item.attributes = g.attributes;
+ shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x);
+ shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);
if (shaper_item.glyphIndicesPresent) {
for (hb_uint32 i = 0; i < shaper_item.initialGlyphCount; ++i)
@@ -1241,18 +1253,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
} while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz.
QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
- for (hb_uint32 i = 0; i < shaper_item.item.length; ++i) {
+ for (hb_uint32 i = 0; i < shaper_item.num_glyphs; ++i)
g.glyphs[i] = g.glyphs[i] | (engineIdx << 24);
+
+ for (hb_uint32 i = 0; i < shaper_item.item.length; ++i)
shaper_item.log_clusters[i] += glyph_pos;
- }
if (kerningEnabled && !shaper_item.kerning_applied)
font->doKerning(&g, option.useDesignMetrics() ? QFlag(QTextEngine::DesignMetrics) : QFlag(0));
glyph_pos += shaper_item.num_glyphs;
-
- initial_glyph_pos += shaper_item.initialGlyphCount;
}
// qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs);
@@ -2057,10 +2069,12 @@ void QTextEngine::LayoutData::reallocate(int totalGlyphs)
int newAllocated = space_charAttributes + space_glyphs + space_logClusters;
Q_ASSERT(newAllocated >= allocated);
- void **old_mem = memory;
- memory = (void **)::realloc(memory_on_stack ? 0 : old_mem, newAllocated*sizeof(void *));
- if (memory_on_stack && memory)
- memcpy(memory, old_mem, allocated*sizeof(void *));
+ void **newMem = memory;
+ newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));
+ Q_CHECK_PTR(newMem);
+ if (memory_on_stack && newMem)
+ memcpy(newMem, memory, allocated*sizeof(void *));
+ memory = newMem;
memory_on_stack = false;
void **m = memory;
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 21bfc4d..38ac4ca 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -1449,7 +1449,7 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style)
/*!
\since 4.5
\fn bool QTextCharFormat::fontKerning() const
- Returns true if the the font kerning is enabled.
+ Returns true if the font kerning is enabled.
\sa setFontKerning()
\sa font()
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index fa624ef..6c67a68 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -367,7 +367,7 @@ QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *p
QFont f(font);
if (paintdevice)
f = QFont(font, paintdevice);
- d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d);
+ d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f.d.data());
}
/*!
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index e1b9844..0f24d9b 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -117,7 +117,13 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
{
if (this == &o)
return *this;
- delete d; d = 0;
+
+ QTextOptionPrivate* dNew = 0;
+ if (o.d)
+ dNew = new QTextOptionPrivate(*o.d);
+ delete d;
+ d = dNew;
+
align = o.align;
wordWrap = o.wordWrap;
design = o.design;
@@ -125,8 +131,6 @@ QTextOption &QTextOption::operator=(const QTextOption &o)
unused = o.unused;
f = o.f;
tab = o.tab;
- if (o.d)
- d = new QTextOptionPrivate(*o.d);
return *this;
}
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 48708c9..edba2c4 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -432,6 +432,13 @@ void QTextTablePrivate::fragmentRemoved(const QChar &type, uint fragment)
QTextFramePrivate::fragmentRemoved(type, fragment);
}
+/*!
+ /fn void QTextTablePrivate::update() const
+
+ This function is usually called when the table is "dirty".
+ It seems to update all kind of table information.
+
+*/
void QTextTablePrivate::update() const
{
Q_Q(const QTextTable);
@@ -439,7 +446,9 @@ void QTextTablePrivate::update() const
nRows = (cells.size() + nCols-1)/nCols;
// qDebug(">>>> QTextTablePrivate::update, nRows=%d, nCols=%d", nRows, nCols);
- grid = (int *)realloc(grid, nRows*nCols*sizeof(int));
+ int* newGrid = (int *)realloc(grid, nRows*nCols*sizeof(int));
+ Q_CHECK_PTR(newGrid);
+ grid = newGrid;
memset(grid, 0, nRows*nCols*sizeof(int));
QTextDocumentPrivate *p = pieceTable;
@@ -463,7 +472,9 @@ void QTextTablePrivate::update() const
cellIndices[i] = cell;
if (r + rowspan > nRows) {
- grid = (int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols);
+ newGrid = (int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols);
+ Q_CHECK_PTR(newGrid);
+ grid = newGrid;
memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols);
nRows = r + rowspan;
}
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index c6c2e69..04f081e 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -695,7 +695,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const
*/
QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(archive);
+ QScopedPointer<QFile> f(new QFile(archive));
f->open(mode);
QZipReader::Status status;
if (f->error() == QFile::NoError)
@@ -711,7 +711,8 @@ QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
status = FileError;
}
- d = new QZipReaderPrivate(f, /*ownDevice=*/true);
+ d = new QZipReaderPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
@@ -969,7 +970,7 @@ void QZipReader::close()
*/
QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
{
- QFile *f = new QFile(fileName);
+ QScopedPointer<QFile> f(new QFile(fileName));
f->open(mode);
QZipWriter::Status status;
if (f->error() == QFile::NoError)
@@ -985,7 +986,8 @@ QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
status = QZipWriter::FileError;
}
- d = new QZipWriterPrivate(f, /*ownDevice=*/true);
+ d = new QZipWriterPrivate(f.data(), /*ownDevice=*/true);
+ f.take();
d->status = status;
}
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index a32a91c..3588ec9 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -24,8 +54,8 @@
#include <eikenv.h> // CEikonEnv
#include <apgcli.h> // RApaLsSession
#include <apgtask.h> // TApaTaskList, TApaTask
-#include <sendui.h> // CSendUi
-#include <cmessagedata.h> // CMessageData
+#include <rsendas.h> // RSendAs
+#include <rsendasmessage.h> // RSendAsMessage
#include <pathinfo.h> // PathInfo
#ifdef USE_DOCUMENTHANDLER
#include <documenthandler.h> // CDocumentHandler
@@ -55,52 +85,57 @@ static void handleMailtoSchemeL(const QUrl &url)
QStringList bccs = bcc.split(",");
- CSendUi* sendUi = CSendUi::NewLC();
-
- // Construct symbian sendUI data holder
- CMessageData* messageData = CMessageData::NewLC();
-
- // Subject
- TPtrC subj( qt_QString2TPtrC(subject) );
- messageData->SetSubjectL( &subj );
-
- // Body
- CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
- CleanupStack::PushL( paraFormat );
- CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
- CleanupStack::PushL( charFormat );
- CRichText* bodyRichText = CRichText::NewL( paraFormat, charFormat );
- CleanupStack::PushL( bodyRichText );
-
- TPtrC bodyPtr( qt_QString2TPtrC(body) );
- if( bodyPtr.Length() )
- {
- bodyRichText->InsertL( 0, bodyPtr );
- }
- else
- {
- bodyRichText->InsertL( 0, KNullDesC );
- }
-
- messageData->SetBodyTextL( bodyRichText );
-
- // To
- foreach(QString item, recipients)
- messageData->AppendToAddressL(qt_QString2TPtrC(item));
-
- foreach(QString item, tos)
- messageData->AppendToAddressL(qt_QString2TPtrC(item));
-
- // Cc
- foreach(QString item, ccs)
- messageData->AppendCcAddressL(qt_QString2TPtrC(item));
-
- // Bcc
- foreach(QString item, bccs)
- messageData->AppendBccAddressL(qt_QString2TPtrC(item));
-
- sendUi->CreateAndSendMessageL( KUidMsgTypeSMTP, messageData );
- CleanupStack::PopAndDestroy( 5 ); // bodyRichText, charFormat, paraFormat, messageData, sendUi
+ RSendAs sendAs;
+ User::LeaveIfError(sendAs.Connect());
+ CleanupClosePushL(sendAs);
+
+
+ CSendAsAccounts* accounts = CSendAsAccounts::NewL();
+ CleanupStack::PushL(accounts);
+ sendAs.AvailableAccountsL(KUidMsgTypeSMTP, *accounts);
+ TInt count = accounts->Count();
+ CleanupStack::PopAndDestroy(accounts);
+
+ if(!count) {
+ // TODO: we should try to create account if count == 0
+ // CSendUi would provide account creation service for us, but it requires ridicilous
+ // capabilities: LocalServices NetworkServices ReadDeviceData ReadUserData WriteDeviceData WriteUserData
+ User::Leave(KErrNotSupported);
+ } else {
+ RSendAsMessage sendAsMessage;
+ sendAsMessage.CreateL(sendAs, KUidMsgTypeSMTP);
+ CleanupClosePushL(sendAsMessage);
+
+
+ // Subject
+ sendAsMessage.SetSubjectL(qt_QString2TPtrC(subject));
+
+ // Body
+ sendAsMessage.SetBodyTextL(qt_QString2TPtrC(body));
+
+ // To
+ foreach(QString item, recipients)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+
+ foreach(QString item, tos)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientTo );
+
+ // Cc
+ foreach(QString item, ccs)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientCc );
+
+ // Bcc
+ foreach(QString item, bccs)
+ sendAsMessage.AddRecipientL(qt_QString2TPtrC(item), RSendAsMessage::ESendAsRecipientBcc );
+
+ // send the message
+ sendAsMessage.LaunchEditorAndCloseL();
+
+ // sendAsMessage (already closed)
+ CleanupStack::Pop();
+ }
+ // sendAs
+ CleanupStack::PopAndDestroy();
}
static bool handleMailtoScheme(const QUrl &url)
diff --git a/src/gui/util/qundostack.cpp b/src/gui/util/qundostack.cpp
index 11f65e3..a6b9c23 100644
--- a/src/gui/util/qundostack.cpp
+++ b/src/gui/util/qundostack.cpp
@@ -715,7 +715,7 @@ int QUndoStack::index() const
}
/*!
- Repeatedly calls undo() or redo() until the the current command index reaches
+ Repeatedly calls undo() or redo() until the current command index reaches
\a idx. This function can be used to roll the state of the document forwards
of backwards. indexChanged() is emitted only once.
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index 69c53ae..e628229 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -35,11 +35,6 @@ embedded {
util/qsystemtrayicon_qws.cpp
}
-symbian {
- # QDesktopServices uses CSendUi which is located on app layer
- INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-}
-
!embedded:!x11:mac {
OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
}
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 9886969..1ff56e8 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -281,8 +281,8 @@ void QAbstractScrollAreaPrivate::init()
scrollBarContainers[Qt::Vertical]->setVisible(false);
QObject::connect(vbar, SIGNAL(valueChanged(int)), q, SLOT(_q_vslide(int)));
QObject::connect(vbar, SIGNAL(rangeChanged(int,int)), q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
- viewportFilter = new QAbstractScrollAreaFilter(this);
- viewport->installEventFilter(viewportFilter);
+ viewportFilter.reset(new QAbstractScrollAreaFilter(this));
+ viewport->installEventFilter(viewportFilter.data());
viewport->setFocusProxy(q);
q->setFocusPolicy(Qt::WheelFocus);
q->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
@@ -471,7 +471,12 @@ QAbstractScrollArea::QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget
:QFrame(dd, parent)
{
Q_D(QAbstractScrollArea);
- d->init();
+ QT_TRY {
+ d->init();
+ } QT_CATCH(...) {
+ d->viewportFilter.reset();
+ QT_RETHROW;
+ }
}
/*!
@@ -483,7 +488,12 @@ QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)
:QFrame(*new QAbstractScrollAreaPrivate, parent)
{
Q_D(QAbstractScrollArea);
- d->init();
+ QT_TRY {
+ d->init();
+ } QT_CATCH(...) {
+ d->viewportFilter.reset();
+ QT_RETHROW;
+ }
}
@@ -493,7 +503,8 @@ QAbstractScrollArea::QAbstractScrollArea(QWidget *parent)
QAbstractScrollArea::~QAbstractScrollArea()
{
Q_D(QAbstractScrollArea);
- delete d->viewportFilter;
+ // reset it here, otherwise we'll have a dangling pointer in ~QWidget
+ d->viewportFilter.reset();
}
@@ -517,7 +528,7 @@ void QAbstractScrollArea::setViewport(QWidget *widget)
d->viewport = widget;
d->viewport->setParent(this);
d->viewport->setFocusProxy(this);
- d->viewport->installEventFilter(d->viewportFilter);
+ d->viewport->installEventFilter(d->viewportFilter.data());
d->layoutChildren();
if (isVisible())
d->viewport->show();
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h
index e4c47e9..999bdfc 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/gui/widgets/qabstractscrollarea_p.h
@@ -98,7 +98,7 @@ public:
inline bool viewportEvent(QEvent *event)
{ return q_func()->viewportEvent(event); }
- QObject *viewportFilter;
+ QScopedPointer<QObject> viewportFilter;
};
class QAbstractScrollAreaFilter : public QObject
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index 347f89a..2bf1cda 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -659,7 +659,6 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
d->edit->setParent(this);
d->edit->setFrame(false);
- d->edit->setAttribute(Qt::WA_InputMethodEnabled, false);
d->edit->setFocusProxy(this);
d->edit->setAcceptDrops(false);
@@ -690,6 +689,18 @@ void QAbstractSpinBox::interpretText()
d->interpret(EmitIfChanged);
}
+/*
+ Reimplemented in 4.6, so be careful.
+ */
+/*!
+ \reimp
+*/
+QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QAbstractSpinBox);
+ return d->edit->inputMethodQuery(query);
+}
+
/*!
\reimp
*/
diff --git a/src/gui/widgets/qabstractspinbox.h b/src/gui/widgets/qabstractspinbox.h
index 4e7fc3f..aa8905f 100644
--- a/src/gui/widgets/qabstractspinbox.h
+++ b/src/gui/widgets/qabstractspinbox.h
@@ -122,6 +122,8 @@ public:
void interpretText();
bool event(QEvent *event);
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
virtual QValidator::State validate(QString &input, int &pos) const;
virtual void fixup(QString &input) const;
diff --git a/src/gui/widgets/qactiontokeyeventmapper.cpp b/src/gui/widgets/qactiontokeyeventmapper.cpp
new file mode 100644
index 0000000..280b1c6
--- /dev/null
+++ b/src/gui/widgets/qactiontokeyeventmapper.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qapplication.h"
+#include "qevent.h"
+#include "qactiontokeyeventmapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QActionToKeyEventMapper::QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent)
+ : QObject(parent)
+ , m_softKeyAction(softKeyAction)
+ , m_key(key)
+{
+
+}
+
+QString QActionToKeyEventMapper::roleText(QAction::SoftKeyRole role)
+{
+ switch (role) {
+ case QAction::OptionsSoftKey:
+ return QAction::tr("Options");
+ case QAction::SelectSoftKey:
+ return QAction::tr("Select");
+ case QAction::BackSoftKey:
+ return QAction::tr("Back");
+ case QAction::NextSoftKey:
+ return QAction::tr("Next");
+ case QAction::PreviousSoftKey:
+ return QAction::tr("Previous");
+ case QAction::OkSoftKey:
+ return QAction::tr("Ok");
+ case QAction::CancelSoftKey:
+ return QAction::tr("Cancel");
+ case QAction::EditSoftKey:
+ return QAction::tr("Edit");
+ case QAction::ViewSoftKey:
+ return QAction::tr("View");
+ default:
+ return QString();
+ };
+}
+void QActionToKeyEventMapper::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget)
+{
+ QAction *action = new QAction(actionWidget);
+ action->setSoftKeyRole(standardRole);
+ action->setText(roleText(standardRole));
+ QActionToKeyEventMapper *softKey = new QActionToKeyEventMapper(action, key, actionWidget);
+ connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent()));
+ connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater()));
+ actionWidget->setSoftKey(action);
+}
+
+void QActionToKeyEventMapper::removeSoftkey(QWidget *focussedWidget)
+{
+ focussedWidget->setSoftKey(0);
+}
+
+void QActionToKeyEventMapper::sendKeyEvent()
+{
+ QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier));
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/widgets/qactiontokeyeventmapper_p.h b/src/gui/widgets/qactiontokeyeventmapper_p.h
new file mode 100644
index 0000000..c54e612
--- /dev/null
+++ b/src/gui/widgets/qactiontokeyeventmapper_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACTIONTOKEYEVENTMAPPER_P_H
+#define QACTIONTOKEYEVENTMAPPER_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/qobject.h>
+#include "QtGui/qaction.h"
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QActionToKeyEventMapper : public QObject
+{
+ Q_OBJECT
+public:
+ QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent);
+ static QString roleText(QAction::SoftKeyRole role);
+ static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget);
+ static void removeSoftkey(QWidget *focussedWidget);
+private:
+ QAction *m_softKeyAction;
+ Qt::Key m_key;
+private Q_SLOTS:
+ void sendKeyEvent();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QACTIONTOKEYEVENTMAPPER_P_H
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/gui/widgets/qcalendarwidget.cpp
index 92c12a5..4436c04 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/gui/widgets/qcalendarwidget.cpp
@@ -2791,7 +2791,7 @@ QTextCharFormat QCalendarWidget::dateTextFormat(const QDate &date) const
void QCalendarWidget::setDateTextFormat(const QDate &date, const QTextCharFormat &format)
{
Q_D(QCalendarWidget);
- if ( date.isNull() && !format.isValid() )
+ if (date.isNull())
d->m_model->m_dateFormats.clear();
else
d->m_model->m_dateFormats[date] = format;
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index e9884bb..a6a5e08 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -63,7 +63,7 @@
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
#include <qdebug.h>
-
+#include <private/qactiontokeyeventmapper_p.h>
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
#endif
@@ -628,6 +628,9 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Select:
#endif
if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) {
+#ifdef QT_KEYPAD_NAVIGATION
+ QActionToKeyEventMapper::removeSoftkey(this);
+#endif
combo->hidePopup();
emit itemSelected(view->currentIndex());
}
@@ -640,7 +643,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
case Qt::Key_Escape:
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, KEYPAD_NAVIGATION_HACK when softkey support is there
+ QActionToKeyEventMapper::removeSoftkey(this);
#endif
combo->hidePopup();
return true;
@@ -948,7 +951,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q);
container->itemView()->setModel(model);
container->itemView()->setTextElideMode(Qt::ElideMiddle);
- updateDelegate();
+ updateDelegate(true);
updateLayoutDirection();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
@@ -1568,15 +1571,25 @@ bool QComboBox::isEditable() const
return d->lineEdit != 0;
}
-void QComboBoxPrivate::updateDelegate()
+/*! \internal
+ update the default delegate
+ depending on the style's SH_ComboBox_Popup hint, we use a different default delegate.
+
+ but we do not change the delegate is the combobox use a custom delegate,
+ unless \a force is set to true.
+ */
+void QComboBoxPrivate::updateDelegate(bool force)
{
Q_Q(QComboBox);
QStyleOptionComboBox opt;
q->initStyleOption(&opt);
- if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q))
- q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
- else
- q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ if (force || qobject_cast<QComboBoxDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
+ } else {
+ if (force || qobject_cast<QComboMenuDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ }
}
QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const
@@ -2425,6 +2438,7 @@ void QComboBox::showPopup()
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
view()->setEditFocus(true);
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view());
#endif
}
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index c39a231..a55b439 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -256,7 +256,7 @@ private:
};
class QComboMenuDelegate : public QAbstractItemDelegate
-{
+{ Q_OBJECT
public:
QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
@@ -285,7 +285,7 @@ private:
// Vista does not use the new theme for combo boxes and there might
// be other side effects from using the new class
class QComboBoxDelegate : public QItemDelegate
-{
+{ Q_OBJECT
public:
QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
@@ -367,7 +367,7 @@ public:
int itemRole() const;
void updateLayoutDirection();
void setCurrentIndex(const QModelIndex &index);
- void updateDelegate();
+ void updateDelegate(bool force = false);
void keyboardSearchString(const QString &text);
void modelChanged();
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp
index 83bec68..4d34691 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/gui/widgets/qdatetimeedit.cpp
@@ -2390,6 +2390,7 @@ void QDateTimeEditPrivate::init(const QVariant &var)
q->setCalendarPopup(true);
#endif
updateTimeSpec();
+ q->setInputMethodHints(Qt::ImhPreferNumbers);
setLayoutItemMargins(QStyle::SE_DateTimeEditLayoutItem);
}
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/gui/widgets/qlcdnumber.cpp
index 0136f1a..af80963 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/gui/widgets/qlcdnumber.cpp
@@ -1271,7 +1271,7 @@ bool QLCDNumber::event(QEvent *e)
/*!
\fn int QLCDNumber::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 116d000..a95d2f2 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -2274,8 +2274,16 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
}
#endif
- int priorState = d->undoState;
- d->removeSelectedText();
+ int priorState = 0;
+ bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty()
+ || e->replacementLength() > 0;
+ bool cursorPositionChanged = false;
+
+ if (isGettingInput) {
+ // If any text is being input, remove selected text.
+ priorState = d->undoState;
+ d->removeSelectedText();
+ }
int c = d->cursor; // cursor position after insertion of commit string
if (e->replacementStart() <= 0)
@@ -2289,11 +2297,30 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
d->selend = d->selstart + e->replacementLength();
d->removeSelectedText();
}
- if (!e->commitString().isEmpty())
+ if (!e->commitString().isEmpty()) {
d->insert(e->commitString());
+ cursorPositionChanged = true;
+ }
d->cursor = qMin(c, d->text.length());
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ d->cursor = qBound(0, a.start + a.length, d->text.length());
+ if (a.length) {
+ d->selstart = qMax(0, qMin(a.start, d->text.length()));
+ d->selend = d->cursor;
+ if (d->selend < d->selstart) {
+ qSwap(d->selstart, d->selend);
+ }
+ } else {
+ d->selstart = d->selend = 0;
+ }
+ cursorPositionChanged = true;
+ }
+ }
+
d->textLayout.setPreeditArea(d->cursor, e->preeditString());
d->preeditCursor = e->preeditString().length();
d->hideCursor = false;
@@ -2317,9 +2344,12 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e)
d->textLayout.setAdditionalFormats(formats);
d->updateTextLayout();
update();
- if (!e->commitString().isEmpty())
+ if (cursorPositionChanged)
d->emitCursorPositionChanged();
- d->finishChange(priorState);
+
+ if (isGettingInput)
+ d->finishChange(priorState);
+
#ifndef QT_NO_COMPLETER
if (!e->commitString().isEmpty())
d->complete(Qt::Key_unknown);
@@ -2337,13 +2367,20 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const
case Qt::ImFont:
return font();
case Qt::ImCursorPosition:
- return QVariant((d->selend - d->selstart == 0) ? d->cursor : d->selend);
+ return QVariant(d->cursor);
case Qt::ImSurroundingText:
return QVariant(d->text);
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
return QVariant(maxLength());
+ case Qt::ImAnchorPosition:
+ if (d->selstart == d->selend)
+ return QVariant(d->cursor);
+ else if (d->selstart == d->cursor)
+ return QVariant(d->selend);
+ else
+ return QVariant(d->selstart);
default:
return QVariant();
}
@@ -3690,7 +3727,7 @@ void QLineEditPrivate::redo() {
/*!
\fn int QLineEdit::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qmacnativewidget_mac.h b/src/gui/widgets/qmacnativewidget_mac.h
index 4db65e0..d36d74f 100644
--- a/src/gui/widgets/qmacnativewidget_mac.h
+++ b/src/gui/widgets/qmacnativewidget_mac.h
@@ -64,7 +64,7 @@ protected:
bool event(QEvent *ev);
private:
- Q_DECLARE_PRIVATE_D(QWidget::d_ptr, QMacNativeWidget)
+ Q_DECLARE_PRIVATE(QMacNativeWidget)
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 558ba42..2f3b412 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -481,6 +481,11 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
d->layout->setMenuBar(menuBar);
+ if (menuBar) {
+ QAction* menu = new QAction(QString::fromLatin1("Menu"), this);
+ menu->setSoftKeyRole(QAction::MenuSoftKey);
+ setSoftKey(menu);
+ }
}
/*!
diff --git a/src/gui/widgets/qmdiarea.cpp b/src/gui/widgets/qmdiarea.cpp
index 598d3b5..6acd977 100644
--- a/src/gui/widgets/qmdiarea.cpp
+++ b/src/gui/widgets/qmdiarea.cpp
@@ -81,7 +81,7 @@
subwindows. This information could be used in a popup menu
containing a list of windows, for example.
- The subwindows are sorted by the the current
+ The subwindows are sorted by the current
\l{QMdiArea::}{WindowOrder}. This is used for the subWindowList()
and for activateNextSubWindow() and acivatePreviousSubWindow().
Also, it is used when cascading or tiling the windows with
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 6be0f19..6d4dcf2 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -60,6 +60,7 @@
#ifndef QT_NO_WHATSTHIS
# include <qwhatsthis.h>
#endif
+#include <private/qactiontokeyeventmapper_p.h>
#include "qmenu_p.h"
#include "qmenubar_p.h"
@@ -578,8 +579,14 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
//when the action has no QWidget, the QMenu itself should
// get the focus
// Since the menu is a pop-up, it uses the popup reason.
- if (!q->hasFocus())
+ if (!q->hasFocus()) {
q->setFocus(Qt::PopupFocusReason);
+#ifdef QT_KEYPAD_NAVIGATION
+ // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey stack
+ // handles focus related and user related actions separately...
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, q);
+#endif
+ }
}
}
} else { //action is a separator
@@ -1937,6 +1944,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart);
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this);
+#endif
}
/*!
@@ -2587,7 +2597,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
case Qt::Key_Escape:
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Back:
- case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there
+ QActionToKeyEventMapper::removeSoftkey(this);
#endif
key_consumed = true;
if (d->tornoff) {
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
index 1676eb8..bf1c39f 100644
--- a/src/gui/widgets/qmenu.h
+++ b/src/gui/widgets/qmenu.h
@@ -184,9 +184,6 @@ protected:
#ifdef Q_OS_WINCE
QAction* wceCommands(uint command);
#endif
-#ifdef Q_OS_SYMBIAN
- void symbianCommands(int command);
-#endif
private Q_SLOTS:
void internalSetSloppyAction();
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index ad848c9..2560cfa 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -871,8 +871,6 @@ static NSMenuItem *qt_mac_menu_merge_action(OSMenuRef merge, QMacMenuAction *act
}
}
- if ([ret tag] != 0)
- ret = 0; // already taken
#endif
return ret;
}
@@ -1131,15 +1129,15 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction
GetMenuItemAttributes(action->menu, itemCount , &testattr);
if (mergedItems.contains(action->command)
&& (testattr & kMenuItemAttrSeparator)) {
- InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command);
- index = itemCount;
- } else {
- MenuItemIndex tmpIndex;
- AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex);
- index = tmpIndex;
- if (mergedItems.contains(action->command))
- AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex);
- }
+ InsertMenuItemTextWithCFString(action->menu, 0, qMax(itemCount - 1, 0), attr, action->command);
+ index = itemCount;
+ } else {
+ MenuItemIndex tmpIndex;
+ AppendMenuItemTextWithCFString(action->menu, 0, attr, action->command, &tmpIndex);
+ index = tmpIndex;
+ if (mergedItems.contains(action->command))
+ AppendMenuItemTextWithCFString(action->menu, 0, kMenuItemAttrSeparator, 0, &tmpIndex);
+ }
#else
[menu addItem:newItem];
#endif
@@ -1477,11 +1475,18 @@ QMenuPrivate::QMacMenuPrivate::removeAction(QMacMenuAction *action)
DeleteMenuItem(action->menu, qt_mac_menu_find_action(action->menu, action));
#else
QMacCocoaAutoReleasePool pool;
- QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
- if (action->menuItem == [loader quitMenuItem] || action->menuItem == [loader preferencesMenuItem])
- [action->menuItem setEnabled:false];
- else
+ if (action->merged) {
+ if (reinterpret_cast<QAction *>([action->menuItem tag]) == action->action) {
+ QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader();
+ [action->menuItem setEnabled:false];
+ if (action->menuItem != [loader quitMenuItem]
+ && action->menuItem != [loader preferencesMenuItem]) {
+ [[action->menuItem menu] removeItem:action->menuItem];
+ }
+ }
+ } else {
[[action->menuItem menu] removeItem:action->menuItem];
+ }
#endif
actionItems.removeAll(action);
}
@@ -1934,6 +1939,23 @@ bool QMenuBar::macUpdateMenuBar()
[loader ensureAppMenuInMenu:menu];
[NSApp setMainMenu:menu];
syncMenuBarItemsVisiblity(mb->d_func()->mac_menubar);
+
+ if (OSMenuRef tmpMerge = QMenuPrivate::mergeMenuHash.value(menu)) {
+ if (QMenuMergeList *mergeList
+ = QMenuPrivate::mergeMenuItemsHash.value(tmpMerge)) {
+ const int mergeListSize = mergeList->size();
+
+ for (int i = 0; i < mergeListSize; ++i) {
+ const QMenuMergeItem &mergeItem = mergeList->at(i);
+ // Ideally we would call QMenuPrivate::syncAction, but that requires finding
+ // the original QMen and likely doing more work than we need.
+ // For example, enabled is handled below.
+ [mergeItem.menuItem setTag:reinterpret_cast<long>(
+ static_cast<QAction *>(mergeItem.action->action))];
+ [mergeItem.menuItem setHidden:!(mergeItem.action->action->isVisible())];
+ }
+ }
+ }
#endif
QWidget *modalWidget = qApp->activeModalWidget();
if (mb != menubars()->value(modalWidget)) {
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index d47749f..aafc945 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -227,7 +227,7 @@ public:
QString searchBuffer;
QBasicTimer searchBufferTimer;
- //passing of mouse events up the parent heirarchy
+ //passing of mouse events up the parent hierarchy
QPointer<QMenu> activeMenu;
bool mouseEventTaken(QMouseEvent *);
@@ -358,7 +358,6 @@ public:
return 0;
}
} *symbian_menu;
- bool symbianCommands(int command);
#endif
QPointer<QWidget> noReplayFor;
};
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp
index 86affe3..69ce981 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/gui/widgets/qmenu_symbian.cpp
@@ -4,14 +4,42 @@
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmenu.h"
#include "qapplication.h"
-#include "qmainwindow.h"
-#include "qtoolbar.h"
#include "qevent.h"
#include "qstyle.h"
#include "qdebug.h"
@@ -26,12 +54,10 @@
#include <eikbtgpc.h>
#include <QtCore/qlibrary.h>
#include <avkon.rsg>
-
#ifndef QT_NO_MENUBAR
QT_BEGIN_NAMESPACE
-// ### FIX/Document this, we need some safe range of menu id's for Qt that don't clash with AIW ones
typedef QMultiHash<QWidget *, QMenuBarPrivate *> MenuBarHash;
Q_GLOBAL_STATIC(MenuBarHash, menubars)
@@ -48,6 +74,10 @@ struct SymbianMenuItem
static QList<SymbianMenuItem*> symbianMenus;
static QList<QMenuBar*> nativeMenuBars;
static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
+static QPointer<QWidget> widgetWithContextMenu;
+static QList<QAction*> contextMenuActionList;
+static QAction contextAction(0);
+static int contexMenuCommand=0;
bool menuExists()
{
@@ -58,6 +88,16 @@ bool menuExists()
return true;
}
+static bool hasContextMenu(QWidget* widget)
+{
+ if (!widget)
+ return false;
+ const Qt::ContextMenuPolicy policy = widget->contextMenuPolicy();
+ if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) {
+ return true;
+ }
+ return false;
+}
// ### FIX THIS, copy/paste of original (faulty) stripped text implementation.
// Implementation should be removed from QAction implementation to some generic place
static QString qt_strippedText_copy_from_qaction(QString s)
@@ -119,14 +159,14 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
// ### FIX THIS, the qt_strippedText2 doesn't work perfectly for stripping & marks. Same bug is in QAction
// New really working method is needed in a place where the implementation isn't copy/pasted
QString text = qt_strippedText_copy_from_qaction(action->action->text());
- HBufC* menuItemText = qt_QString2HBufCNewL(text);
+ TPtrC menuItemText(qt_QString2TPtrC(text));
if (action->action->menu()) {
SymbianMenuItem* menuItem = new SymbianMenuItem();
menuItem->menuItemData.iCascadeId = action->command;
menuItem->menuItemData.iCommandId = action->command;
menuItem->menuItemData.iFlags = 0;
- menuItem->menuItemData.iText = *menuItemText;
+ menuItem->menuItemData.iText = menuItemText;
menuItem->action = action->action;
if (action->action->menu()->actions().size() == 0 || !action->action->isEnabled() )
menuItem->menuItemData.iFlags |= EEikMenuItemDimmed;
@@ -147,7 +187,7 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
menuItem->menuItemData.iCascadeId = 0;
menuItem->menuItemData.iCommandId = action->command;
menuItem->menuItemData.iFlags = 0;
- menuItem->menuItemData.iText = *menuItemText;
+ menuItem->menuItemData.iText = menuItemText;
menuItem->action = action->action;
if (!action->action->isEnabled()){
menuItem->menuItemData.iFlags += EEikMenuItemDimmed;
@@ -161,7 +201,6 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QList<SymbianMe
}
parent->append(menuItem);
}
- delete menuItemText;
}
}
@@ -174,24 +213,18 @@ void deleteAll(QList<SymbianMenuItem*> *items)
}
}
-static void setSoftkeys()
-{
- CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba();
- if (cba){
- if (menuExists())
- cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
- else
- cba->SetCommandSetL(R_AVKON_SOFTKEYS_EXIT);
- }
-}
-
static void rebuildMenu()
{
+ widgetWithContextMenu = 0;
QMenuBarPrivate *mb = 0;
- setSoftkeys();
QWidget *w = qApp->activeWindow();
- if (w)
- {
+ QWidget* focusWidget = QApplication::focusWidget();
+ if (focusWidget) {
+ if (hasContextMenu(focusWidget))
+ widgetWithContextMenu = focusWidget;
+ }
+
+ if (w) {
mb = menubars()->value(w);
qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
deleteAll( &symbianMenus );
@@ -199,7 +232,7 @@ static void rebuildMenu()
return;
mb->symbian_menubar->rebuild();
}
- }
+}
Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane)
{
@@ -219,42 +252,23 @@ Q_GUI_EXPORT void qt_symbian_show_submenu( CEikMenuPane* menuPane, int id)
}
}
-void QMenu::symbianCommands(int command)
-{
- Q_D(QMenu);
- d->symbianCommands(command);
-}
-
-void QMenuBar::symbianCommands(int command)
+void QMenuBarPrivate::symbianCommands(int command)
{
+ if (command == contexMenuCommand && !widgetWithContextMenu.isNull()) {
+ QContextMenuEvent* event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(0,0));
+ QCoreApplication::postEvent(widgetWithContextMenu, event);
+ }
+
int size = nativeMenuBars.size();
for (int i = 0; i < nativeMenuBars.size(); ++i) {
- bool result = nativeMenuBars.at(i)->d_func()->symbianCommands(command);
- if (result)
- return;
- }
-}
-
-bool QMenuBarPrivate::symbianCommands(int command)
-{
SymbianMenuItem* menu = qt_symbian_find_menu_item(command, symbianMenus);
if (!menu)
- return false;
-
- emit q_func()->triggered(menu->action);
- menu->action->activate(QAction::Trigger);
- return true;
-}
-
-bool QMenuPrivate::symbianCommands(int command)
-{
- SymbianMenuItem* menu = qt_symbian_find_menu_item(command, symbianMenus);
- if (!menu)
- return false;
+ continue;
- emit q_func()->triggered(menu->action);
+ emit nativeMenuBars.at(i)->triggered(menu->action);
menu->action->activate(QAction::Trigger);
- return true;
+ break;
+ }
}
void QMenuBarPrivate::symbianCreateMenuBar(QWidget *parent)
@@ -289,7 +303,7 @@ QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate()
deleteAll( &symbianMenus );
symbianMenus.clear();
d = 0;
- rebuild();
+ rebuild();
}
QMenuPrivate::QSymbianMenuPrivate::QSymbianMenuPrivate()
@@ -371,22 +385,35 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a
rebuild();
}
-void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild()
+void QMenuBarPrivate::QSymbianMenuBarPrivate::insertNativeMenuItems(const QList<QAction*> &actions)
{
- setSoftkeys();
- qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
- deleteAll( &symbianMenus );
- if (!d)
- return;
- for (int i = 0; i < d->actions.size(); ++i) {
+ for (int i = 0; i <actions.size(); ++i) {
QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction;
- symbianActionTopLevel->action = d->actions.at(i);
+ symbianActionTopLevel->action = actions.at(i);
symbianActionTopLevel->parent = 0;
symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++;
qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus);
}
}
+
+
+void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild()
+{
+ contexMenuCommand = 0;
+ qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM;
+ deleteAll( &symbianMenus );
+ if (d)
+ insertNativeMenuItems(d->actions);
+
+ contextMenuActionList.clear();
+ if (widgetWithContextMenu) {
+ contexMenuCommand = qt_symbian_menu_static_cmd_id;
+ contextAction.setText(QMenuBar::tr("Actions"));
+ contextMenuActionList.append(&contextAction);
+ insertNativeMenuItems(contextMenuActionList);
+ }
+}
QT_END_NAMESPACE
#endif //QT_NO_MENUBAR
diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp
index d05323d..fb8a69b 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -2417,7 +2417,7 @@ int QMenuBar::findIdForAction(QAction *act) const
/*!
\fn int QMenuBar::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
index 36c983b..42f0c0c 100644
--- a/src/gui/widgets/qmenubar.h
+++ b/src/gui/widgets/qmenubar.h
@@ -118,10 +118,6 @@ public:
static void wceRefresh();
#endif
-#ifdef Q_OS_SYMBIAN
- static void symbianCommands(int command);
-#endif
-
public Q_SLOTS:
virtual void setVisible(bool visible);
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
index d562cd9..9e7d511 100644
--- a/src/gui/widgets/qmenubar_p.h
+++ b/src/gui/widgets/qmenubar_p.h
@@ -257,9 +257,10 @@ public:
}
return 0;
}
+ void insertNativeMenuItems(const QList<QAction*> &actions);
} *symbian_menubar;
- bool symbianCommands(int command);
+ static void symbianCommands(int command);
#endif
};
diff --git a/src/gui/widgets/qmenudata.h b/src/gui/widgets/qmenudata.h
index 24d960a..d570f20 100644
--- a/src/gui/widgets/qmenudata.h
+++ b/src/gui/widgets/qmenudata.h
@@ -67,6 +67,8 @@ private:
friend class QMenuBar;
void setId(int);
void setSignalValue(int);
+
+ Q_DISABLE_COPY(QMenuItem);
};
QT_END_NAMESPACE
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index e563fa1..3d2c4f5 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -72,6 +72,11 @@
QT_BEGIN_NAMESPACE
+static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit)
+{
+ return !plaintextedit->isReadOnly();
+}
+
class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivate
{
Q_DECLARE_PUBLIC(QPlainTextDocumentLayout)
@@ -705,7 +710,8 @@ QPlainTextEditPrivate::QPlainTextEditPrivate()
tabChangesFocus(false),
lineWrap(QPlainTextEdit::WidgetWidth),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere),
- topLine(0), pageUpDownLastCursorYIsValid(false)
+ clickCausedFocus(0),topLine(0),
+ pageUpDownLastCursorYIsValid(false)
{
showCursorOnInitialShow = true;
backgroundVisible = false;
@@ -1905,6 +1911,13 @@ void QPlainTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop();
d->ensureCursorVisible();
}
+
+ if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(this, &event);
+ }
+ d->clickCausedFocus = 0;
}
/*! \reimp
@@ -2038,6 +2051,9 @@ QVariant QPlainTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
void QPlainTextEdit::focusInEvent(QFocusEvent *e)
{
Q_D(QPlainTextEdit);
+ if (e->reason() == Qt::MouseFocusReason) {
+ d->clickCausedFocus = 1;
+ }
QAbstractScrollArea::focusInEvent(e);
d->sendControlEvent(e);
}
@@ -2304,7 +2320,7 @@ void QPlainTextEdit::setReadOnly(bool ro)
} else {
flags = Qt::TextEditorInteraction;
}
- setAttribute(Qt::WA_InputMethodEnabled, !ro);
+ setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this));
d->control->setTextInteractionFlags(flags);
}
diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h
index 0739d53..56a3aa9 100644
--- a/src/gui/widgets/qplaintextedit_p.h
+++ b/src/gui/widgets/qplaintextedit_p.h
@@ -91,7 +91,10 @@ public:
return r;
}
inline QRectF cursorRect() { return cursorRect(textCursor()); }
- void ensureCursorVisible() { textEdit->ensureCursorVisible(); }
+ void ensureCursorVisible() {
+ textEdit->ensureCursorVisible();
+ emit microFocusChanged();
+ }
QPlainTextEdit *textEdit;
@@ -148,6 +151,7 @@ public:
uint backgroundVisible : 1;
uint centerOnScroll : 1;
uint inDrag : 1;
+ uint clickCausedFocus : 1;
int topLine;
diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp
index 16334b8..80c1271 100644
--- a/src/gui/widgets/qprintpreviewwidget.cpp
+++ b/src/gui/widgets/qprintpreviewwidget.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprintpreviewwidget.h"
+#include "private/qwidget_p.h"
#include <private/qprinter_p.h>
#include <QtCore/qmath.h>
@@ -170,12 +171,12 @@ protected:
} // anonymous namespace
-class QPrintPreviewWidgetPrivate
+class QPrintPreviewWidgetPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QPrintPreviewWidget)
public:
- QPrintPreviewWidgetPrivate(QPrintPreviewWidget *q)
- : q_ptr(q), scene(0), curPage(1),
+ QPrintPreviewWidgetPrivate()
+ : scene(0), curPage(1),
viewMode(QPrintPreviewWidget::SinglePageView),
zoomMode(QPrintPreviewWidget::FitInView),
zoomFactor(1), initialized(false), fitting(true)
@@ -194,7 +195,6 @@ public:
void setZoomFactor(qreal zoomFactor);
int calcCurrentPage();
- QPrintPreviewWidget *q_ptr;
GraphicsView *graphicsView;
QGraphicsScene *scene;
@@ -518,7 +518,7 @@ void QPrintPreviewWidgetPrivate::setZoomFactor(qreal _zoomFactor)
\sa QWidget::setWindowFlags()
*/
QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), d_ptr(new QPrintPreviewWidgetPrivate(this))
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
{
Q_D(QPrintPreviewWidget);
d->printer = printer;
@@ -534,7 +534,7 @@ QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt:
preview.
*/
QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(parent, flags), d_ptr(new QPrintPreviewWidgetPrivate(this))
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
{
Q_D(QPrintPreviewWidget);
d->printer = new QPrinter;
@@ -551,7 +551,6 @@ QPrintPreviewWidget::~QPrintPreviewWidget()
Q_D(QPrintPreviewWidget);
if (d->ownPrinter)
delete d->printer;
- delete d_ptr;
}
/*!
diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h
index 27110a4..9f7ea6e 100644
--- a/src/gui/widgets/qprintpreviewwidget.h
+++ b/src/gui/widgets/qprintpreviewwidget.h
@@ -111,7 +111,7 @@ Q_SIGNALS:
void previewChanged();
private:
- QPrintPreviewWidgetPrivate *d_ptr;
+ void *dummy; // ### remove in Qt 5.0
Q_PRIVATE_SLOT(d_func(), void _q_fit())
Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentPage())
};
diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp
index cdb3836..1a7f878 100644
--- a/src/gui/widgets/qprogressbar.cpp
+++ b/src/gui/widgets/qprogressbar.cpp
@@ -349,6 +349,8 @@ void QProgressBar::setRange(int minimum, int maximum)
\property QProgressBar::textVisible
\brief whether the current completed percentage should be displayed
+ This property may be ignored by the style (e.g., QMacStyle never draws the text).
+
\sa textDirection
*/
void QProgressBar::setTextVisible(bool visible)
diff --git a/src/gui/widgets/qscrollarea.cpp b/src/gui/widgets/qscrollarea.cpp
index 6aca7d3..8b01453 100644
--- a/src/gui/widgets/qscrollarea.cpp
+++ b/src/gui/widgets/qscrollarea.cpp
@@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE
setting the layout's \l{QLayout::sizeConstraint}{size constraint}
property to one which provides constraints on the minimum and/or
maximum size of the layout (e.g., QLayout::SetMinAndMaxSize) will
- cause the size of the the scroll area to be updated whenever the
+ cause the size of the scroll area to be updated whenever the
contents of the layout changes.
For a complete example using the QScrollArea class, see the \l
diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp
index c691eaf..295bf48 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/gui/widgets/qspinbox.cpp
@@ -77,6 +77,8 @@ public:
QChar thousand;
inline void init() {
+ Q_Q(QSpinBox);
+ q->setInputMethodHints(Qt::ImhDigitsOnly);
setLayoutItemMargins(QStyle::SE_SpinBoxLayoutItem);
}
};
@@ -97,6 +99,11 @@ public:
// variables
int decimals;
QChar delimiter, thousand;
+
+ inline void init() {
+ Q_Q(QDoubleSpinBox);
+ q->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
+ }
};
@@ -592,6 +599,8 @@ void QSpinBox::fixup(QString &input) const
QDoubleSpinBox::QDoubleSpinBox(QWidget *parent)
: QAbstractSpinBox(*new QDoubleSpinBoxPrivate(parent), parent)
{
+ Q_D(QDoubleSpinBox);
+ d->init();
}
/*!
diff --git a/src/gui/widgets/qsplitter.cpp b/src/gui/widgets/qsplitter.cpp
index bf8af35..45e838f 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/gui/widgets/qsplitter.cpp
@@ -1517,7 +1517,7 @@ void QSplitter::setOpaqueResize(bool on)
/*!
\fn int QSplitter::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 69221ba..785d772 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1536,9 +1536,10 @@ void QTabBar::paintEvent(QPaintEvent *)
}
if (!d->dragInProgress)
p.drawControl(QStyle::CE_TabBarTab, tab);
- else
- d->movingTab->setGeometry(tab.rect);
-
+ else {
+ int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);
+ d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0));
+ }
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1805,7 +1806,9 @@ void QTabBarPrivate::setupMovableTab()
if (!movingTab)
movingTab = new QWidget(q);
+ int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
QRect grabRect = q->tabRect(pressedIndex);
+ grabRect.adjust(-taboverlap, 0, taboverlap, 0);
QPixmap grabImage(grabRect.size());
grabImage.fill(Qt::transparent);
@@ -1813,7 +1816,7 @@ void QTabBarPrivate::setupMovableTab()
QStyleOptionTabV3 tab;
q->initStyleOption(&tab, pressedIndex);
- tab.rect.moveTopLeft(QPoint(0, 0));
+ tab.rect.moveTopLeft(QPoint(taboverlap, 0));
p.drawControl(QStyle::CE_TabBarTab, tab);
p.end();
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp
index c16e000..43b2f54 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/gui/widgets/qtabwidget.cpp
@@ -504,7 +504,7 @@ QIcon QTabWidget::tabIcon(int index) const
}
/*!
- Returns true if the the page at position \a index is enabled; otherwise returns false.
+ Returns true if the page at position \a index is enabled; otherwise returns false.
\sa setTabEnabled(), QWidget::isEnabled()
*/
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 1c4df93..c1ec5c2 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -74,6 +74,10 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_TEXTEDIT
+static inline bool shouldEnableInputMethod(QTextEdit *textedit)
+{
+ return !textedit->isReadOnly();
+}
class QTextEditControl : public QTextControl
{
@@ -104,7 +108,7 @@ public:
QTextEditPrivate::QTextEditPrivate()
: control(0),
autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false),
- lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0),
+ lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), clickCausedFocus(0),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), textFormat(Qt::AutoText)
{
ignoreAutomaticScrollbarAdjustment = false;
@@ -1559,6 +1563,12 @@ void QTextEdit::mouseReleaseEvent(QMouseEvent *e)
d->autoScrollTimer.stop();
ensureCursorVisible();
}
+ if (e->button() == Qt::LeftButton && qApp->autoSipEnabled()
+ && (!d->clickCausedFocus || qApp->autoSipOnMouseFocus())) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(this, &event);
+ }
+ d->clickCausedFocus = 0;
}
/*! \reimp
@@ -1694,6 +1704,9 @@ QVariant QTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
void QTextEdit::focusInEvent(QFocusEvent *e)
{
Q_D(QTextEdit);
+ if (e->reason() == Qt::MouseFocusReason) {
+ d->clickCausedFocus = 1;
+ }
QAbstractScrollArea::focusInEvent(e);
d->sendControlEvent(e);
}
@@ -2058,7 +2071,7 @@ void QTextEdit::setReadOnly(bool ro)
} else {
flags = Qt::TextEditorInteraction;
}
- setAttribute(Qt::WA_InputMethodEnabled, !ro);
+ setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this));
d->control->setTextInteractionFlags(flags);
}
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
index 3c37868..594174a 100644
--- a/src/gui/widgets/qtextedit_p.h
+++ b/src/gui/widgets/qtextedit_p.h
@@ -123,6 +123,7 @@ public:
uint preferRichText : 1;
uint showCursorOnInitialShow : 1;
uint inDrag : 1;
+ uint clickCausedFocus : 1;
// Qt3 COMPAT only, for setText
Qt::TextFormat textFormat;
diff --git a/src/gui/widgets/qtoolbox.cpp b/src/gui/widgets/qtoolbox.cpp
index 81935a5..271130a 100644
--- a/src/gui/widgets/qtoolbox.cpp
+++ b/src/gui/widgets/qtoolbox.cpp
@@ -802,7 +802,7 @@ void QToolBox::itemRemoved(int index)
/*!
\fn int QToolBox::margin() const
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
Use QWidget::getContentsMargins() instead.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
index fc57944..9e226e2 100644
--- a/src/gui/widgets/widgets.pri
+++ b/src/gui/widgets/widgets.pri
@@ -78,8 +78,8 @@ HEADERS += \
widgets/qtoolbararealayout_p.h \
widgets/qplaintextedit.h \
widgets/qplaintextedit_p.h \
- widgets/qprintpreviewwidget.h
-
+ widgets/qprintpreviewwidget.h \
+ widgets/qactiontokeyeventmapper_p.h
SOURCES += \
widgets/qabstractbutton.cpp \
widgets/qabstractslider.cpp \
@@ -138,8 +138,8 @@ SOURCES += \
widgets/qwidgetanimator.cpp \
widgets/qtoolbararealayout.cpp \
widgets/qplaintextedit.cpp \
- widgets/qprintpreviewwidget.cpp
-
+ widgets/qprintpreviewwidget.cpp \
+ widgets/qactiontokeyeventmapper.cpp
!embedded:mac {
HEADERS += widgets/qmacnativewidget_mac.h \
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 569d2fd..c54c420 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -314,8 +314,10 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port)
{
bytesFromSocket.clear();
- if (socket)
+ if (socket) {
delete socket;
+ socket = 0;
+ }
socket = new QTcpSocket(this);
socket->setObjectName(QLatin1String("QFtpDTP Passive state socket"));
connect(socket, SIGNAL(connected()), SLOT(socketConnected()));
@@ -1658,11 +1660,12 @@ QFtp::QFtp(QObject *parent, const char *name)
*/
int QFtp::connectToHost(const QString &host, quint16 port)
{
- d_func()->pi.transferConnectionExtended = true;
QStringList cmds;
cmds << host;
cmds << QString::number((uint)port);
- return d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds));
+ int id = d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds));
+ d_func()->pi.transferConnectionExtended = true;
+ return id;
}
/*!
@@ -1721,9 +1724,10 @@ int QFtp::close()
*/
int QFtp::setTransferMode(TransferMode mode)
{
+ int id = d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList()));
d_func()->pi.transferConnectionExtended = true;
d_func()->transferMode = mode;
- return d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList()));
+ return id;
}
/*!
diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp
index 96ccc91..332c67b 100644
--- a/src/network/access/qhttp.cpp
+++ b/src/network/access/qhttp.cpp
@@ -64,10 +64,10 @@
# include "qtimer.h"
#endif
-QT_BEGIN_NAMESPACE
-
#ifndef QT_NO_HTTP
+QT_BEGIN_NAMESPACE
+
class QHttpNormalRequest;
class QHttpRequest
{
@@ -624,7 +624,6 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
*/
QHttpHeader::~QHttpHeader()
{
- delete d_ptr;
}
/*!
@@ -950,7 +949,7 @@ void QHttpHeader::setContentLength(int len)
}
/*!
- Returns true if the header has an entry for the the special HTTP
+ Returns true if the header has an entry for the special HTTP
header field \c content-type; otherwise returns false.
\sa contentType() setContentType()
diff --git a/src/network/access/qhttp.h b/src/network/access/qhttp.h
index 771176a..d575644 100644
--- a/src/network/access/qhttp.h
+++ b/src/network/access/qhttp.h
@@ -46,6 +46,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -108,7 +109,7 @@ protected:
QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
- QHttpHeaderPrivate *d_ptr;
+ QScopedPointer<QHttpHeaderPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QHttpHeader)
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index ae518df..cec9c87 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -77,8 +77,10 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate()
{
for (int i = 0; i < channelCount; ++i) {
- channels[i].socket->close();
- delete channels[i].socket;
+ if (channels[i].socket) {
+ channels[i].socket->close();
+ delete channels[i].socket;
+ }
}
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 09bd459..0f80bd9 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -244,8 +244,8 @@ public:
#ifndef QT_NO_OPENSSL
bool ignoreSSLErrors;
#endif
- Channel() :state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false), reconnectAttempts(2),
- authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None)
+ Channel() : socket(0), state(IdleState), reply(0), written(0), bytesTotal(0), resendCurrent(false),
+ reconnectAttempts(2), authMehtod(QAuthenticatorPrivate::None), proxyAuthMehtod(QAuthenticatorPrivate::None)
#ifndef QT_NO_OPENSSL
, ignoreSSLErrors(false)
#endif
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index f214699..4874d9d 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -605,6 +605,7 @@ void QNetworkAccessHttpBackend::open()
QNetworkAccessCache *cache = QNetworkAccessManagerPrivate::getCache(this);
if ((http = static_cast<QNetworkAccessHttpBackendCache *>(cache->requestEntryNow(cacheKey))) == 0) {
// no entry in cache; create an object
+ //### thiago: can we try/catch/ignore this????
http = new QNetworkAccessHttpBackendCache(url.host(), url.port(), encrypt);
#ifndef QT_NO_NETWORKPROXY
@@ -732,10 +733,15 @@ void QNetworkAccessHttpBackend::replyFinished()
// store the SSL configuration now
// once we call finished(), we won't have access to httpReply anymore
QSslConfiguration sslConfig = httpReply->sslConfiguration();
- if (pendingSslConfiguration)
+ if (pendingSslConfiguration) {
*pendingSslConfiguration = sslConfig;
- else if (!sslConfig.isNull())
- pendingSslConfiguration = new QSslConfiguration(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();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index bcbeef1..38e8af9 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -748,8 +748,8 @@ void QNetworkAccessManagerPrivate::createCookieJar() const
if (!cookieJarCreated) {
// keep the ugly hack in here
QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this);
- that->cookieJarCreated = true;
that->cookieJar = new QNetworkCookieJar(that->q_func());
+ that->cookieJarCreated = true;
}
}
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 892929e..daa2335 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -43,6 +43,7 @@
#include "qnetworkdiskcache.h"
#include "qnetworkdiskcache_p.h"
+#include "QtCore/qscopedpointer.h"
#include <qfile.h>
#include <qdir.h>
@@ -180,8 +181,7 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
break;
}
}
-
- QCacheItem *cacheItem = new QCacheItem;
+ QScopedPointer<QCacheItem> cacheItem(new QCacheItem);
cacheItem->metaData = metaData;
QIODevice *device = 0;
@@ -190,16 +190,20 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
device = &(cacheItem->data);
} else {
QString templateName = d->tmpCacheFileName();
- cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);
- if (!cacheItem->file->open()) {
+ QT_TRY {
+ cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);
+ } QT_CATCH(...) {
+ cacheItem->file = 0;
+ }
+ if (!cacheItem->file || !cacheItem->file->open()) {
qWarning() << "QNetworkDiskCache::prepare() unable to open temporary file";
- delete cacheItem;
+ cacheItem.reset();
return 0;
}
cacheItem->writeHeader(cacheItem->file);
device = cacheItem->file;
}
- d->inserting[device] = cacheItem;
+ d->inserting[device] = cacheItem.take();
return device;
}
@@ -358,31 +362,28 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
qDebug() << "QNetworkDiskCache::data()" << url;
#endif
Q_D(QNetworkDiskCache);
- QBuffer *buffer = 0;
+ QScopedPointer<QBuffer> buffer;
if (!url.isValid())
- return buffer;
+ return 0;
if (d->lastItem.metaData.url() == url && d->lastItem.data.isOpen()) {
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
buffer->setData(d->lastItem.data.data());
} else {
- QFile *file = new QFile(d->cacheFileName(url));
- if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered)) {
- delete file;
+ QScopedPointer<QFile> file(new QFile(d->cacheFileName(url)));
+ if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered))
return 0;
- }
- if (!d->lastItem.read(file, true)) {
+
+ if (!d->lastItem.read(file.data(), true)) {
file->close();
remove(url);
- delete file;
return 0;
}
if (d->lastItem.data.isOpen()) {
// compressed
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
buffer->setData(d->lastItem.data.data());
- delete file;
} else {
- buffer = new QBuffer;
+ buffer.reset(new QBuffer);
// ### verify that QFile uses the fd size and not the file name
qint64 size = file->size() - file->pos();
const uchar *p = 0;
@@ -390,16 +391,15 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
p = file->map(file->pos(), size);
#endif
if (p) {
- file->setParent(buffer);
buffer->setData((const char *)p, size);
+ file.take()->setParent(buffer.data());
} else {
buffer->setData(file->readAll());
- delete file;
}
}
}
buffer->open(QBuffer::ReadOnly);
- return buffer;
+ return buffer.take();
}
/*!
@@ -494,21 +494,21 @@ qint64 QNetworkDiskCache::expire()
QDir::Filters filters = QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot;
QDirIterator it(cacheDirectory(), filters, QDirIterator::Subdirectories);
- QMap<QDateTime, QString> cacheItems;
+ QMultiMap<QDateTime, QString> cacheItems;
qint64 totalSize = 0;
while (it.hasNext()) {
QString path = it.next();
QFileInfo info = it.fileInfo();
QString fileName = info.fileName();
if (fileName.endsWith(CACHE_POSTFIX) && fileName.startsWith(CACHE_PREFIX)) {
- cacheItems[info.created()] = path;
+ cacheItems.insert(info.created(), path);
totalSize += info.size();
}
}
int removedFiles = 0;
qint64 goal = (maximumCacheSize() * 9) / 10;
- QMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin();
+ QMultiMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin();
while (i != cacheItems.constEnd()) {
if (totalSize < goal)
break;
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 79c3d1a..6f715e5 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -382,7 +382,8 @@ void QNetworkReplyImplPrivate::feed(const QByteArray &data)
void QNetworkReplyImplPrivate::feed(QIODevice *data)
{
Q_Q(QNetworkReplyImpl);
- Q_ASSERT(q->isOpen());
+ if (!q->isOpen())
+ return;
// read until EOF from data
if (copyDevice) {
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 4f9ea52..2ff561a 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -216,10 +216,9 @@ public:
url = other.url;
#ifndef QT_NO_OPENSSL
+ sslConfiguration = 0;
if (other.sslConfiguration)
sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
- else
- sslConfiguration = 0;
#endif
}
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index b225c17..a3634ce 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -523,7 +523,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
Constructs a copy of the given \a address.
*/
QHostAddress::QHostAddress(const QHostAddress &address)
- : d(new QHostAddressPrivate(*address.d))
+ : d(new QHostAddressPrivate(*address.d.data()))
{
}
@@ -559,7 +559,6 @@ QHostAddress::QHostAddress(SpecialAddress address)
*/
QHostAddress::~QHostAddress()
{
- delete d;
}
/*!
@@ -568,7 +567,7 @@ QHostAddress::~QHostAddress()
*/
QHostAddress &QHostAddress::operator=(const QHostAddress &address)
{
- *d = *address.d;
+ *d.data() = *address.d.data();
return *this;
}
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 02a6f97..857b4af 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -44,6 +44,7 @@
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qabstractsocket.h>
struct sockaddr;
@@ -130,7 +131,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
protected:
- QHostAddressPrivate *d;
+ QScopedPointer<QHostAddressPrivate> d;
};
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp
index ca4124d..1858e02 100644
--- a/src/network/kernel/qhostinfo.cpp
+++ b/src/network/kernel/qhostinfo.cpp
@@ -42,6 +42,7 @@
#include "qhostinfo.h"
#include "qhostinfo_p.h"
+#include "QtCore/qscopedpointer.h"
#include <qabstracteventdispatcher.h>
#include <private/qunicodetables_p.h>
#include <qcoreapplication.h>
@@ -165,24 +166,24 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver,
// Support for IDNA
QString lookup = QString::fromLatin1(QUrl::toAce(name));
- QHostInfoResult *result = new QHostInfoResult;
- result->autoDelete = false;
- QObject::connect(result, SIGNAL(resultsReady(QHostInfo)),
+ QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
+ result.data()->autoDelete = false;
+ QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
receiver, member);
- int id = result->lookupId = theIdCounter.fetchAndAddRelaxed(1);
+ int id = result.data()->lookupId = theIdCounter.fetchAndAddRelaxed(1);
if (lookup.isEmpty()) {
QHostInfo info(id);
info.setError(QHostInfo::HostNotFound);
info.setErrorString(QObject::tr("No host name given"));
- QMetaObject::invokeMethod(result, "emitResultsReady", Qt::QueuedConnection,
+ QMetaObject::invokeMethod(result.data(), "emitResultsReady", Qt::QueuedConnection,
Q_ARG(QHostInfo, info));
- result->autoDelete = true;
+ result.take()->autoDelete = true;
return id;
}
QHostInfoAgent *agent = theAgent();
- agent->addHostName(lookup, result);
+ agent->addHostName(lookup, result.take());
#if !defined QT_NO_THREAD
if (!agent->isRunning())
@@ -327,7 +328,7 @@ QHostInfo::QHostInfo(int id)
Constructs a copy of \a other.
*/
QHostInfo::QHostInfo(const QHostInfo &other)
- : d(new QHostInfoPrivate(*other.d))
+ : d(new QHostInfoPrivate(*other.d.data()))
{
}
@@ -337,7 +338,7 @@ QHostInfo::QHostInfo(const QHostInfo &other)
*/
QHostInfo &QHostInfo::operator=(const QHostInfo &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
@@ -346,7 +347,6 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other)
*/
QHostInfo::~QHostInfo()
{
- delete d;
}
/*!
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 084ec89..c68b111 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -43,6 +43,7 @@
#define QHOSTINFO_H
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
QT_BEGIN_HEADER
@@ -91,7 +92,7 @@ public:
static QString localDomainName();
private:
- QHostInfoPrivate *d;
+ QScopedPointer<QHostInfoPrivate> d;
};
QT_END_NAMESPACE
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 3271deb..f5d7166 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -320,6 +320,8 @@ QString QHostInfo::localDomainName()
if (local_res_ninit) {
// using thread-safe version
res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
+ if (!state)
+ qBadAlloc();
memset(state, 0, sizeof(*state));
local_res_ninit(state);
QString domainName = QUrl::fromAce(state->defdname);
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index 0a34e2b..472bc4b 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -72,21 +72,6 @@ struct qt_addrinfo
qt_addrinfo *ai_next;
};
-// sockaddr_in6 size changed between old and new SDK
-// Only the new version is the correct one, so always
-// use this structure.
-struct qt_in6_addr {
- uchar qt_s6_addr[16];
-};
-
-struct qt_sockaddr_in6 {
- short sin6_family; /* AF_INET6 */
- u_short sin6_port; /* Transport level port number */
- u_long sin6_flowinfo; /* IPv6 flow information */
- struct qt_in6_addr sin6_addr; /* IPv6 address */
- u_long sin6_scope_id; /* set of interfaces for a scope */
-};
-
//###
#define QT_SOCKLEN_T int
#ifndef NI_MAXHOST // already defined to 1025 in ws2tcpip.h?
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index a339388..f8fff88 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -170,7 +170,7 @@ QNetworkAddressEntry::QNetworkAddressEntry()
object \a other.
*/
QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
- : d(new QNetworkAddressEntryPrivate(*other.d))
+ : d(new QNetworkAddressEntryPrivate(*other.d.data()))
{
}
@@ -179,7 +179,7 @@ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other)
*/
QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
@@ -188,7 +188,6 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry
*/
QNetworkAddressEntry::~QNetworkAddressEntry()
{
- delete d;
}
/*!
@@ -397,7 +396,7 @@ QNetworkInterface::~QNetworkInterface()
}
/*!
- Creates a copy of the the QNetworkInterface object contained in \a
+ Creates a copy of the QNetworkInterface object contained in \a
other.
*/
QNetworkInterface::QNetworkInterface(const QNetworkInterface &other)
diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h
index 09fbd0f..dd16550 100644
--- a/src/network/kernel/qnetworkinterface.h
+++ b/src/network/kernel/qnetworkinterface.h
@@ -43,6 +43,7 @@
#define QNETWORKINTERFACE_H
#include <QtCore/qshareddata.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
#ifndef QT_NO_NETWORKINTERFACE
@@ -79,7 +80,7 @@ public:
void setBroadcast(const QHostAddress &newBroadcast);
private:
- QNetworkAddressEntryPrivate *d;
+ QScopedPointer<QNetworkAddressEntryPrivate> d;
};
class QNetworkInterfacePrivate;
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp
index 82c673f..59f1c02 100644
--- a/src/network/kernel/qnetworkinterface_symbian.cpp
+++ b/src/network/kernel/qnetworkinterface_symbian.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index de97629..c783c33 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -115,6 +115,8 @@ static QHash<QHostAddress, QHostAddress> ipv4Netmasks()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
+ if (!pAdapter)
+ return ipv4netmasks;
// try again
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -156,7 +158,8 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_ADDRESSES *)qMalloc(bufSize);
-
+ if (!pAdapter)
+ return interfaces;
// try again
if (ptrGetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -236,7 +239,8 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWin2k()
if (retval == ERROR_BUFFER_OVERFLOW) {
// need more memory
pAdapter = (IP_ADAPTER_INFO *)qMalloc(bufSize);
-
+ if (!pAdapter)
+ return interfaces;
// try again
if (ptrGetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
qFree(pAdapter);
@@ -306,7 +310,8 @@ QString QHostInfo::localDomainName()
pinfo = &info;
if (ptrGetNetworkParams(pinfo, &bufSize) == ERROR_BUFFER_OVERFLOW) {
pinfo = (FIXED_INFO *)qMalloc(bufSize);
-
+ if (!pinfo)
+ return QString();
// try again
if (ptrGetNetworkParams(pinfo, &bufSize) != ERROR_SUCCESS) {
qFree(pinfo);
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 62bdfc7..fd3a85a 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -1258,6 +1258,6 @@ QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuer
return globalNetworkProxy()->proxyForQuery(query);
}
-#endif // QT_NO_NETWORKPROXY
-
QT_END_NAMESPACE
+
+#endif // QT_NO_NETWORKPROXY
diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp
index 255c9ea..d90c480 100644
--- a/src/network/kernel/qurlinfo.cpp
+++ b/src/network/kernel/qurlinfo.cpp
@@ -726,6 +726,6 @@ bool QUrlInfo::isValid() const
return d != 0;
}
-#endif // QT_NO_URLINFO
-
QT_END_NAMESPACE
+
+#endif // QT_NO_URLINFO
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 67e32fe..b6f91e4 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -99,7 +99,7 @@
the client has read the data). Note that Qt does not limit the
write buffer size. You can monitor its size by listening to this
signal.
-
+
The readyRead() signal is emitted every time a new chunk of data
has arrived. bytesAvailable() then returns the number of bytes
that are available for reading. Typically, you would connect the
@@ -199,9 +199,10 @@
parameter describes the type of error that occurred.
QAbstractSocket::SocketError is not a registered metatype, so for queued
- connections, you will have to register it with Q_REGISTER_METATYPE.
+ connections, you will have to register it with Q_DECLARE_METATYPE() and
+ qRegisterMetaType().
- \sa error(), errorString()
+ \sa error(), errorString(), {Creating Custom Qt Types}
*/
/*!
@@ -211,9 +212,10 @@
The \a socketState parameter is the new state.
QAbstractSocket::SocketState is not a registered metatype, so for queued
- connections, you will have to register it with Q_REGISTER_METATYPE.
+ connections, you will have to register it with Q_REGISTER_METATYPE() and
+ qRegisterMetaType().
- \sa state()
+ \sa state(), {Creating Custom Qt Types}
*/
/*!
@@ -1128,7 +1130,7 @@ bool QAbstractSocketPrivate::readFromSocket()
/*! \internal
- Sets up the the internal state after the connection has succeeded.
+ Sets up the internal state after the connection has succeeded.
*/
void QAbstractSocketPrivate::fetchConnectionParameters()
{
@@ -1865,9 +1867,9 @@ bool QAbstractSocket::waitForDisconnected(int msecs)
}
/*!
- Aborts the current connection and resets the socket. Unlike
- disconnectFromHost(), this function immediately closes the socket, discarding
- any pending data in the write buffer.
+ Aborts the current connection and resets the socket. Unlike disconnectFromHost(),
+ this function immediately closes the socket, discarding any pending data in the
+ write buffer.
\sa disconnectFromHost(), close()
*/
@@ -2164,7 +2166,12 @@ void QAbstractSocket::setPeerName(const QString &name)
}
/*!
- Disconnects the socket's connection with the host.
+ Closes the I/O device for the socket, disconnects the socket's connection with the
+ host, closes the socket, and resets the name, address, port number and underlying
+ socket descriptor.
+
+ See QIODevice::close() for a description of the actions that occur when an I/O
+ device is closed.
\sa abort()
*/
@@ -2457,7 +2464,8 @@ QNetworkProxy QAbstractSocket::proxy() const
#endif // QT_NO_NETWORKPROXY
#ifdef QT3_SUPPORT
-/*! \enum QAbstractSocket::Error
+/*!
+ \enum QAbstractSocket::Error
\compat
Use QAbstractSocket::SocketError instead.
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index 540c443..5a2a746 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -768,6 +768,6 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(int, QObject
return 0;
}
-#endif
-
QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index d6b1507..35701a7 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -276,6 +276,10 @@ QLocalSocket *QLocalServer::nextPendingConnection()
if (d->pendingConnections.isEmpty())
return 0;
QLocalSocket *nextSocket = d->pendingConnections.dequeue();
+#ifdef Q_OS_SYMBIAN
+ if(!d->socketNotifier)
+ return nextSocket;
+#endif
#ifndef Q_OS_WIN
d->socketNotifier->setEnabled(d->pendingConnections.size()
<= d->maxPendingConnections);
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 2471043..03723cf 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -237,7 +237,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
QLatin1String("QLocalSocket::connectToServer"));
return;
}
-
+#ifndef Q_OS_SYMBIAN
// set non blocking so we can try to connect and it wont wait
int flags = fcntl(d->connectingSocket, F_GETFL, 0);
if (-1 == flags
@@ -246,6 +246,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
QLatin1String("QLocalSocket::connectToServer"));
return;
}
+#endif
// _q_connectToSocket does the actual connecting
d->connectingName = name;
@@ -304,7 +305,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
case EAGAIN:
// Try again later, all of the sockets listening are full
if (!delayConnect) {
- delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write);
+ delayConnect = new QSocketNotifier(connectingSocket, QSocketNotifier::Write, q);
q->connect(delayConnect, SIGNAL(activated(int)), q, SLOT(_q_connectToSocket()));
}
if (!connectTimer) {
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 39c9284..ace3bc5 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -144,7 +144,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
- 0, // default attributes
+ FILE_FLAG_OVERLAPPED,
NULL); // no template file
}, {
localSocket = CreateFileA(
@@ -153,7 +153,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
- 0, // default attributes
+ FILE_FLAG_OVERLAPPED,
NULL); // no template file
});
if (localSocket != INVALID_HANDLE_VALUE)
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 515ad84..95ffba5 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -55,9 +55,9 @@
#include "QtNetwork/qhostaddress.h"
#include "private/qabstractsocketengine_p.h"
#ifndef Q_OS_WIN
-#include "qplatformdefs.h"
+# include "qplatformdefs.h"
#else
-#include <Winsock2.h> // sockaddr_storage, sockaddr_in
+# include <winsock2.h>
#endif
#ifdef Q_OS_SYMBIAN
@@ -227,6 +227,39 @@ static inline int qt_socket_socket(int domain, int type, int protocol)
#endif
+// Use our own defines and structs which we know are correct
+# define QT_SS_MAXSIZE 128
+# define QT_SS_ALIGNSIZE (sizeof(qint64))
+# define QT_SS_PAD1SIZE (QT_SS_ALIGNSIZE - sizeof (short))
+# define QT_SS_PAD2SIZE (QT_SS_MAXSIZE - (sizeof (short) + QT_SS_PAD1SIZE + QT_SS_ALIGNSIZE))
+struct qt_sockaddr_storage {
+ short ss_family;
+ char __ss_pad1[QT_SS_PAD1SIZE];
+ qint64 __ss_align;
+ char __ss_pad2[QT_SS_PAD2SIZE];
+};
+
+// sockaddr_in6 size changed between old and new SDK
+// Only the new version is the correct one, so always
+// use this structure.
+struct qt_in6_addr {
+ quint8 qt_s6_addr[16];
+};
+struct qt_sockaddr_in6 {
+ short sin6_family; /* AF_INET6 */
+ quint16 sin6_port; /* Transport level port number */
+ quint32 sin6_flowinfo; /* IPv6 flow information */
+ struct qt_in6_addr sin6_addr; /* IPv6 address */
+ quint32 sin6_scope_id; /* set of interfaces for a scope */
+};
+
+union qt_sockaddr {
+ sockaddr a;
+ sockaddr_in a4;
+ qt_sockaddr_in6 a6;
+ qt_sockaddr_storage storage;
+};
+
class QNativeSocketEnginePrivate;
class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index a3f62db..5136978 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -122,36 +122,34 @@ static void qt_ignore_sigpipe()
Extracts the port and address from a sockaddr, and stores them in
\a port and \a addr if they are non-null.
*/
-static inline void qt_socket_getPortAndAddress(struct sockaddr *sa, quint16 *port, QHostAddress *addr)
+static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *port, QHostAddress *addr)
{
#if !defined(QT_NO_IPV6)
- if (sa->sa_family == AF_INET6) {
- struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
+ if (s->a.sa_family == AF_INET6) {
Q_IPV6ADDR tmp;
- memcpy(&tmp, &sa6->sin6_addr.s6_addr, sizeof(tmp));
+ memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp));
if (addr) {
QHostAddress tmpAddress;
tmpAddress.setAddress(tmp);
*addr = tmpAddress;
#ifndef QT_NO_IPV6IFNAME
char scopeid[IFNAMSIZ];
- if (::if_indextoname(sa6->sin6_scope_id, scopeid)) {
+ if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
addr->setScopeId(QLatin1String(scopeid));
} else
#endif
- addr->setScopeId(QString::number(sa6->sin6_scope_id));
+ addr->setScopeId(QString::number(s->a6.sin6_scope_id));
}
if (port)
- *port = ntohs(sa6->sin6_port);
+ *port = ntohs(s->a6.sin6_port);
return;
}
#endif
- struct sockaddr_in *sa4 = (struct sockaddr_in *)sa;
if (port)
- *port = ntohs(sa4->sin_port);
+ *port = ntohs(s->a4.sin_port);
if (addr) {
QHostAddress tmpAddress;
- tmpAddress.setAddress(ntohl(sa4->sin_addr.s_addr));
+ tmpAddress.setAddress(ntohl(s->a4.sin_addr.s_addr));
*addr = tmpAddress;
}
}
@@ -547,26 +545,16 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
{
// Create a sockaddr struct and reset its port number.
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage storage;
- sockaddr_in6 *storagePtrIPv6 = reinterpret_cast<sockaddr_in6 *>(&storage);
- storagePtrIPv6->sin6_port = 0;
-#else
- struct sockaddr storage;
-#endif
- sockaddr *storagePtr = reinterpret_cast<sockaddr *>(&storage);
- storagePtr->sa_family = 0;
-
- sockaddr_in *storagePtrIPv4 = reinterpret_cast<sockaddr_in *>(&storage);
- storagePtrIPv4->sin_port = 0;
+ qt_sockaddr storage;
QT_SOCKLEN_T storageSize = sizeof(storage);
+ memset(&storage, 0, storageSize);
// Peek 0 bytes into the next message. The size of the message may
// well be 0, so we can't check recvfrom's return value.
ssize_t readBytes;
do {
char c;
- readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, storagePtr, &storageSize);
+ readBytes = qt_socket_recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
} while (readBytes == -1 && errno == EINTR);
// If there's no error, or if our buffer was too small, there must be a
@@ -618,11 +606,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize,
QHostAddress *address, quint16 *port)
{
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage aa;
-#else
- struct sockaddr_in aa;
-#endif
+ qt_sockaddr aa;
memset(&aa, 0, sizeof(aa));
QT_SOCKLEN_T sz;
sz = sizeof(aa);
@@ -631,13 +615,13 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
do {
char c;
recvFromResult = qt_socket_recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
- 0, (struct sockaddr *)&aa, &sz);
+ 0, &aa.a, &sz);
} while (recvFromResult == -1 && errno == EINTR);
if (recvFromResult == -1) {
setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
} else if (port || address) {
- qt_socket_getPortAndAddress((struct sockaddr *) &aa, port, address);
+ qt_socket_getPortAndAddress(&aa, port, address);
}
#if defined (QNATIVESOCKETENGINE_DEBUG)
@@ -716,21 +700,16 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
if (socketDescriptor == -1)
return false;
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage sa;
-#else
- struct sockaddr_in sa;
-#endif
- struct sockaddr *sockAddrPtr = (struct sockaddr *) &sa;
+ qt_sockaddr sa;
QT_SOCKLEN_T sockAddrSize = sizeof(sa);
// Determine local address
memset(&sa, 0, sizeof(sa));
- if (qt_socket_getsockname(socketDescriptor, sockAddrPtr, &sockAddrSize) == 0) {
- qt_socket_getPortAndAddress(sockAddrPtr, &localPort, &localAddress);
+ if (qt_socket_getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
+ qt_socket_getPortAndAddress(&sa, &localPort, &localAddress);
// Determine protocol family
- switch (sockAddrPtr->sa_family) {
+ switch (sa.a.sa_family) {
case AF_INET:
socketProtocol = QAbstractSocket::IPv4Protocol;
break;
@@ -750,8 +729,8 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
}
// Determine the remote address
- if (!qt_socket_getpeername(socketDescriptor, sockAddrPtr, &sockAddrSize))
- qt_socket_getPortAndAddress(sockAddrPtr, &peerPort, &peerAddress);
+ if (!qt_socket_getpeername(socketDescriptor, &sa.a, &sockAddrSize))
+ qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
// Determine the socket type (UDP/TCP)
int value = 0;
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index d140be2..8c6cd31 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -149,41 +149,6 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength)
#endif
-#if !defined (QT_NO_IPV6)
-
-// Use our own defines and structs which we know are correct
-# define QT_SS_MAXSIZE 128
-# define QT_SS_ALIGNSIZE (sizeof(__int64))
-# define QT_SS_PAD1SIZE (QT_SS_ALIGNSIZE - sizeof (short))
-# define QT_SS_PAD2SIZE (QT_SS_MAXSIZE - (sizeof (short) + QT_SS_PAD1SIZE + QT_SS_ALIGNSIZE))
-struct qt_sockaddr_storage {
- short ss_family;
- char __ss_pad1[QT_SS_PAD1SIZE];
- __int64 __ss_align;
- char __ss_pad2[QT_SS_PAD2SIZE];
-};
-
-// sockaddr_in6 size changed between old and new SDK
-// Only the new version is the correct one, so always
-// use this structure.
-struct qt_in6_addr {
- u_char qt_s6_addr[16];
-};
-typedef struct {
- short sin6_family; /* AF_INET6 */
- u_short sin6_port; /* Transport level port number */
- u_long sin6_flowinfo; /* IPv6 flow information */
- struct qt_in6_addr sin6_addr; /* IPv6 address */
- u_long sin6_scope_id; /* set of interfaces for a scope */
-} qt_sockaddr_in6;
-
-#else
-
-typedef void * qt_sockaddr_in6 ;
-
-
-#endif
-
#ifndef AF_INET6
#define AF_INET6 23 /* Internetwork Version 6 */
#endif
@@ -605,6 +570,11 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
socketState = QAbstractSocket::UnconnectedState;
break;
}
+ if (value == WSAEHOSTUNREACH) {
+ setError(QAbstractSocket::NetworkError, HostUnreachableErrorString);
+ socketState = QAbstractSocket::UnconnectedState;
+ break;
+ }
}
// fall through
}
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index b6b0e89..98666c2 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -1834,9 +1834,9 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
QSOCKS5_DEBUG << "not proxying";
return 0;
}
- QSocks5SocketEngine *engine = new QSocks5SocketEngine(parent);
+ QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent));
engine->setProxy(proxy);
- return engine;
+ return engine.take();
}
QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(int socketDescriptor, QObject *parent)
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index c1fedc3..1978ee2 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -354,7 +354,12 @@ void QTcpServer::close()
if (d->socketEngine) {
d->socketEngine->close();
- d->socketEngine->deleteLater();
+ QT_TRY {
+ d->socketEngine->deleteLater();
+ } QT_CATCH(const std::bad_alloc &) {
+ // in out of memory situations, the socketEngine
+ // will be deleted in ~QTcpServer (it's a child-object of this)
+ }
d->socketEngine = 0;
}
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index a2ba644..c4aa43e 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -155,7 +155,7 @@ QSslCertificate::QSslCertificate(const QByteArray &data, QSsl::EncodingFormat fo
/*!
Constructs an identical copy of \a other.
*/
-QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
+QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -165,8 +165,6 @@ QSslCertificate::QSslCertificate(const QSslCertificate &other) : d(other.d)
*/
QSslCertificate::~QSslCertificate()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -175,7 +173,7 @@ QSslCertificate::~QSslCertificate()
*/
QSslCertificate &QSslCertificate::operator=(const QSslCertificate &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -241,12 +239,7 @@ void QSslCertificate::clear()
{
if (isNull())
return;
- if (d->ref == 1)
- delete d;
- else
- d->ref.deref();
-
- d = new QSslCertificatePrivate;
+ d.reset(new QSslCertificatePrivate);
}
/*!
@@ -267,7 +260,7 @@ QByteArray QSslCertificate::serialNumber() const
/*!
Returns a cryptographic digest of this certificate. By default,
- and MD5 digest will be generated, but you can also specify a
+ an MD5 digest will be generated, but you can also specify a
custom \a algorithm.
*/
QByteArray QSslCertificate::digest(QCryptographicHash::Algorithm algorithm) const
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index d4597cd..19152fb 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -118,7 +118,7 @@ public:
Qt::HANDLE handle() const;
private:
- QSslCertificatePrivate *d;
+ QScopedSharedPointer<QSslCertificatePrivate> d;
friend class QSslCertificatePrivate;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp
index 7fec2df..a72879d 100644
--- a/src/network/ssl/qsslcipher.cpp
+++ b/src/network/ssl/qsslcipher.cpp
@@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
QSslCipher::QSslCipher(const QSslCipher &other)
: d(new QSslCipherPrivate)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
}
/*!
@@ -111,7 +111,6 @@ QSslCipher::QSslCipher(const QSslCipher &other)
*/
QSslCipher::~QSslCipher()
{
- delete d;
}
/*!
@@ -120,7 +119,7 @@ QSslCipher::~QSslCipher()
*/
QSslCipher &QSslCipher::operator=(const QSslCipher &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index 404dc3d..d9ac7a9 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -44,6 +44,7 @@
#define QSSLCIPHER_H
#include <QtCore/qstring.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -78,7 +79,7 @@ public:
QSsl::SslProtocol protocol() const;
private:
- QSslCipherPrivate *d;
+ QScopedPointer<QSslCipherPrivate> d;
friend class QSslSocketBackendPrivate;
};
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 3096fee..280c659 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -140,7 +140,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
}
/*!
@@ -148,7 +148,6 @@ QSslError::QSslError(const QSslError &other)
*/
QSslError::~QSslError()
{
- delete d;
}
/*!
@@ -158,7 +157,7 @@ QSslError::~QSslError()
*/
QSslError &QSslError::operator=(const QSslError &other)
{
- *d = *other.d;
+ *d.data() = *other.d.data();
return *this;
}
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index 50cc142..8b8ebff 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -105,7 +105,7 @@ public:
QSslCertificate certificate() const;
private:
- QSslErrorPrivate *d;
+ QScopedPointer<QSslErrorPrivate> d;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/network/ssl/qsslkey.cpp b/src/network/ssl/qsslkey.cpp
index 8d550c0..d076112 100644
--- a/src/network/ssl/qsslkey.cpp
+++ b/src/network/ssl/qsslkey.cpp
@@ -269,7 +269,7 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding
/*!
Constructs an identical copy of \a other.
*/
-QSslKey::QSslKey(const QSslKey &other) : d(other.d)
+QSslKey::QSslKey(const QSslKey &other) : d(other.d.data())
{
d->ref.ref();
}
@@ -279,8 +279,6 @@ QSslKey::QSslKey(const QSslKey &other) : d(other.d)
*/
QSslKey::~QSslKey()
{
- if (!d->ref.deref())
- delete d;
}
/*!
@@ -291,7 +289,7 @@ QSslKey::~QSslKey()
*/
QSslKey &QSslKey::operator=(const QSslKey &other)
{
- qAtomicAssign(d, other.d);
+ d.assign(other.d.data());
return *this;
}
@@ -312,10 +310,13 @@ bool QSslKey::isNull() const
*/
void QSslKey::clear()
{
- if (!d->ref.deref()) {
- delete d;
- d = new QSslKeyPrivate;
- }
+ d.reset(new QSslKeyPrivate);
+
+ //### old code: is this really correct???
+ //if (!d->ref.deref()) {
+ // delete d;
+ // d = new QSslKeyPrivate;
+ //}
}
/*!
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index 45d03f7..d5d60a6 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -45,6 +45,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qbytearray.h>
+#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
QT_BEGIN_HEADER
@@ -92,7 +93,7 @@ public:
inline bool operator!=(const QSslKey &key) const { return !operator==(key); }
private:
- QSslKeyPrivate *d;
+ QScopedSharedPointer<QSslKeyPrivate> d;
friend class QSslCertificate;
};
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 6f8cf42..cb101af 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -482,30 +482,7 @@ void QSslSocketPrivate::resetDefaultCiphers()
QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
{
-#ifdef QQ_OS_UNIX
- // Check known locations for the system's default bundle. ### On Windows,
- // we should use CAPI to find the bundle, and not rely on default unix
- // locations.
- const char *standardLocations[] = {"/etc/ssl/certs/",
-#if 0
- // KDE uses KConfig for its SSL store,
- // but it also stores the bundle at
- // this location
- "$HOME/.kde/share/apps/kssl/ca-bundle.crt",
-#endif
- 0};
- const char **it = standardLocations;
- QStringList nameFilter;
- nameFilter << QLatin1String("*.pem") << QLatin1String("*.crt");
- while (*it) {
- if (QDirIterator(QLatin1String(*it), nameFilter).hasNext())
- return certificatesFromPath(QLatin1String(*it));
- ++it;
- }
-#endif
-
- // Qt provides a default bundle when we cannot detect the system's default
- // bundle.
+ // Qt provides a default bundle of certificates
QFile caBundle(QLatin1String(":/trolltech/network/ssl/qt-ca-bundle.crt"));
if (caBundle.open(QIODevice::ReadOnly | QIODevice::Text))
return QSslCertificate::fromDevice(&caBundle);
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 42c09f5..0723822 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -231,10 +231,16 @@ DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c,
DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
+#ifdef Q_OS_SYMBIAN
+#define RESOLVEFUNC(func, ordinal, lib) \
+ if (!(_q_##func = _q_PTR_##func(lib->resolve(#ordinal)))) \
+ qWarning("QSslSocket: cannot resolve "#func);
+#else
#define RESOLVEFUNC(func) \
if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \
&& !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
qWarning("QSslSocket: cannot resolve "#func);
+#endif
#if !defined QT_LINKED_OPENSSL
@@ -335,7 +341,24 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
pair.first = ssleay32;
pair.second = libeay32;
return pair;
+# elif defined(Q_OS_SYMBIAN)
+ QLibrary *libssl = new QLibrary(QLatin1String("libssl"));
+ if (!libssl->load()) {
+ // Cannot find ssleay32.dll
+ delete libssl;
+ return pair;
+ }
+ QLibrary *libcrypto = new QLibrary(QLatin1String("libcrypto"));
+ if (!libcrypto->load()) {
+ delete libcrypto;
+ delete libssl;
+ return pair;
+ }
+
+ pair.first = libssl;
+ pair.second = libcrypto;
+ return pair;
# elif defined(Q_OS_UNIX)
QLibrary *&libssl = pair.first;
QLibrary *&libcrypto = pair.second;
@@ -437,6 +460,127 @@ bool q_resolveOpenSslSymbols()
// failed to load them
return false;
+#ifdef Q_OS_SYMBIAN
+#ifdef SSLEAY_MACROS
+ RESOLVEFUNC(ASN1_dup, 125, libs.second )
+#endif
+ RESOLVEFUNC(ASN1_STRING_data, 71, libs.second )
+ RESOLVEFUNC(ASN1_STRING_length, 76, libs.second )
+ RESOLVEFUNC(BIO_ctrl, 184, libs.second )
+ RESOLVEFUNC(BIO_free, 209, libs.second )
+ RESOLVEFUNC(BIO_new, 222, libs.second )
+ RESOLVEFUNC(BIO_new_mem_buf, 230, libs.second )
+ RESOLVEFUNC(BIO_read, 244, libs.second )
+ RESOLVEFUNC(BIO_s_mem, 251, libs.second )
+ RESOLVEFUNC(BIO_write, 269, libs.second )
+ RESOLVEFUNC(BN_num_bits, 387, libs.second )
+ RESOLVEFUNC(CRYPTO_free, 469, libs.second )
+ RESOLVEFUNC(CRYPTO_num_locks, 500, libs.second )
+ RESOLVEFUNC(CRYPTO_set_id_callback, 513, libs.second )
+ RESOLVEFUNC(CRYPTO_set_locking_callback, 516, libs.second )
+ RESOLVEFUNC(DSA_free, 594, libs.second )
+ RESOLVEFUNC(ERR_error_string, 744, libs.second )
+ RESOLVEFUNC(ERR_get_error, 749, libs.second )
+ RESOLVEFUNC(EVP_des_ede3_cbc, 919, libs.second )
+ RESOLVEFUNC(EVP_PKEY_assign, 859, libs.second )
+ RESOLVEFUNC(EVP_PKEY_free, 867, libs.second )
+ RESOLVEFUNC(EVP_PKEY_get1_DSA, 869, libs.second )
+ RESOLVEFUNC(EVP_PKEY_get1_RSA, 870, libs.second )
+ RESOLVEFUNC(EVP_PKEY_new, 876, libs.second )
+ RESOLVEFUNC(EVP_PKEY_type, 882, libs.second )
+ RESOLVEFUNC(OBJ_nid2sn, 1036, libs.second )
+ RESOLVEFUNC(OBJ_obj2nid, 1037, libs.second )
+#ifdef SSLEAY_MACROS // ### verify
+ RESOLVEFUNC(PEM_ASN1_read_bio, 1180, libs.second )
+#else
+ RESOLVEFUNC(PEM_read_bio_DSAPrivateKey, 1219, libs.second )
+ RESOLVEFUNC(PEM_read_bio_RSAPrivateKey, 1228, libs.second )
+ RESOLVEFUNC(PEM_write_bio_DSAPrivateKey, 1260, libs.second )
+ RESOLVEFUNC(PEM_write_bio_RSAPrivateKey, 1271, libs.second )
+#endif
+ RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY, 1220, libs.second )
+ RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY, 1230, libs.second )
+ RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY, 1261, libs.second )
+ RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY, 1273, libs.second )
+ RESOLVEFUNC(RAND_seed, 1426, libs.second )
+ RESOLVEFUNC(RAND_status, 1429, libs.second )
+ RESOLVEFUNC(RSA_free, 1450, libs.second )
+ RESOLVEFUNC(sk_free, 2571, libs.second )
+ RESOLVEFUNC(sk_num, 2576, libs.second )
+ RESOLVEFUNC(sk_value, 2585, libs.second )
+ RESOLVEFUNC(SSL_CIPHER_description, 11, libs.first )
+ RESOLVEFUNC(SSL_CTX_check_private_key, 21, libs.first )
+ RESOLVEFUNC(SSL_CTX_ctrl, 22, libs.first )
+ RESOLVEFUNC(SSL_CTX_free, 24, libs.first )
+ RESOLVEFUNC(SSL_CTX_new, 35, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_cipher_list, 40, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_default_verify_paths, 44, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_verify, 56, libs.first )
+ RESOLVEFUNC(SSL_CTX_set_verify_depth, 57, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_certificate, 64, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_certificate_file, 67, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey, 58, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey, 61, libs.first )
+ RESOLVEFUNC(SSL_CTX_use_PrivateKey_file, 60, libs.first )
+ RESOLVEFUNC(SSL_accept, 82, libs.first )
+ RESOLVEFUNC(SSL_clear, 92, libs.first )
+ RESOLVEFUNC(SSL_connect, 93, libs.first )
+ RESOLVEFUNC(SSL_free, 99, libs.first )
+ RESOLVEFUNC(SSL_get_ciphers, 104, libs.first )
+ RESOLVEFUNC(SSL_get_current_cipher, 106, libs.first )
+ RESOLVEFUNC(SSL_get_error, 110, libs.first )
+ RESOLVEFUNC(SSL_get_peer_cert_chain, 117, libs.first )
+ RESOLVEFUNC(SSL_get_peer_certificate, 118, libs.first )
+ RESOLVEFUNC(SSL_get_verify_result, 132, libs.first )
+ RESOLVEFUNC(SSL_library_init, 137, libs.first )
+ RESOLVEFUNC(SSL_load_error_strings, 139, libs.first )
+ RESOLVEFUNC(SSL_new, 140, libs.first )
+ RESOLVEFUNC(SSL_read, 143, libs.first )
+ RESOLVEFUNC(SSL_set_accept_state, 148, libs.first )
+ RESOLVEFUNC(SSL_set_bio, 149, libs.first )
+ RESOLVEFUNC(SSL_set_connect_state, 152, libs.first )
+ RESOLVEFUNC(SSL_shutdown, 173, libs.first )
+ RESOLVEFUNC(SSL_write, 188, libs.first )
+ RESOLVEFUNC(SSLv2_client_method, 192, libs.first )
+ RESOLVEFUNC(SSLv3_client_method, 195, libs.first )
+ RESOLVEFUNC(SSLv23_client_method, 189, libs.first )
+ RESOLVEFUNC(TLSv1_client_method, 198, libs.first )
+ RESOLVEFUNC(SSLv2_server_method, 194, libs.first )
+ RESOLVEFUNC(SSLv3_server_method, 197, libs.first )
+ RESOLVEFUNC(SSLv23_server_method, 191, libs.first )
+ RESOLVEFUNC(TLSv1_server_method, 200, libs.first )
+ RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second )
+ RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second )
+ RESOLVEFUNC(X509_STORE_free, 1939, libs.second )
+ RESOLVEFUNC(X509_STORE_new, 1942, libs.second )
+ RESOLVEFUNC(X509_STORE_add_cert, 1936, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_free, 1907, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_init, 1919, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_new, 1920, libs.second )
+ RESOLVEFUNC(X509_STORE_CTX_set_purpose, 1931, libs.second )
+ RESOLVEFUNC(X509_cmp, 1992, libs.second )
+#ifndef SSLEAY_MACROS
+ RESOLVEFUNC(X509_dup, 1997, libs.second )
+#endif
+ RESOLVEFUNC(X509_EXTENSION_get_object, 1785, libs.second )
+ RESOLVEFUNC(X509_free, 2001, libs.second )
+ RESOLVEFUNC(X509_get_ext, 2012, libs.second )
+ RESOLVEFUNC(X509_get_ext_count, 2016, libs.second )
+ RESOLVEFUNC(X509_get_ext_d2i, 2017, libs.second )
+ RESOLVEFUNC(X509_get_issuer_name, 2018, libs.second )
+ RESOLVEFUNC(X509_get_subject_name, 2022, libs.second )
+ RESOLVEFUNC(X509_verify_cert, 2069, libs.second )
+ RESOLVEFUNC(d2i_X509, 2309, libs.second )
+ RESOLVEFUNC(i2d_X509, 2489, libs.second )
+#ifdef SSLEAY_MACROS
+ RESOLVEFUNC(i2d_DSAPrivateKey, 2395, libs.second )
+ RESOLVEFUNC(i2d_RSAPrivateKey, 2476, libs.second )
+ RESOLVEFUNC(d2i_DSAPrivateKey, 2220, libs.second )
+ RESOLVEFUNC(d2i_RSAPrivateKey, 2296, libs.second )
+#endif
+ RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf, 1153, libs.second )
+ RESOLVEFUNC(OPENSSL_add_all_algorithms_conf, 1152, libs.second )
+#else // Q_OS_SYMBIAN
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
#endif
@@ -556,6 +700,7 @@ bool q_resolveOpenSslSymbols()
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
+#endif // Q_OS_SYMBIAN
symbolsResolved = true;
delete libs.first;
delete libs.second;
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index 5427370..6021d5d 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -3,11 +3,7 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
symbian {
- TRY_INCLUDEPATHS = $${EPOCROOT}epoc32/include $${EPOCROOT}epoc32/include/stdapis $${EPOCROOT}epoc32/include/stdapis/sys $$OS_LAYER_LIBC_SYSTEMINCLUDE
- for(p, TRY_INCLUDEPATHS) {
- pp = $$join(p, "", "", "/openssl")
- exists($$pp):INCLUDEPATH *= $$pp
- }
+ INCLUDEPATH *= $$OS_LAYER_SSL_SYSTEMINCLUDE
} else {
include($$QT_SOURCE_TREE/config.tests/unix/openssl/openssl.pri)
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index a74f044..beb4da6 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -926,6 +926,9 @@ void QGL2PaintEngineEx::drawCachedGlyphs(const QPointF &p, const QTextItemInt &t
const QImage &image = cache->image();
int margin = cache->glyphMargin();
+ if (image.isNull())
+ return;
+
glActiveTexture(QT_BRUSH_TEXTURE_UNIT);
d->ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true);
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 04bc611..cd7a7f0 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1484,8 +1484,8 @@ Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg()
*/
QGLContext::QGLContext(const QGLFormat &format, QPaintDevice *device)
+ : d_ptr(new QGLContextPrivate(this))
{
- d_ptr = new QGLContextPrivate(this);
Q_D(QGLContext);
d->init(device, format);
}
@@ -1507,8 +1507,8 @@ QGLContext::QGLContext(const QGLFormat &format, QPaintDevice *device)
\sa format(), isValid()
*/
QGLContext::QGLContext(const QGLFormat &format)
+ : d_ptr(new QGLContextPrivate(this))
{
- d_ptr = new QGLContextPrivate(this);
Q_D(QGLContext);
d->init(0, format);
}
@@ -1539,7 +1539,6 @@ QGLContext::~QGLContext()
QGLSignalProxy::instance()->emitAboutToDestroyContext(this);
reset();
- delete d;
}
void QGLContextPrivate::cleanup()
@@ -2504,6 +2503,42 @@ const QGLContext* QGLContext::currentContext()
visual. On other platforms it may work differently.
*/
+/*! \fn int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc)
+
+ \bold{Win32 only:} This virtual function chooses a pixel format
+ that matches the OpenGL \link setFormat() format\endlink.
+ Reimplement this function in a subclass if you need a custom
+ context.
+
+ \warning The \a dummyPfd pointer and \a pdc are used as a \c
+ PIXELFORMATDESCRIPTOR*. We use \c void to avoid using
+ Windows-specific types in our header files.
+
+ \sa chooseContext()
+*/
+
+/*! \fn void *QGLContext::chooseVisual()
+
+ \bold{X11 only:} This virtual function tries to find a visual that
+ matches the format, reducing the demands if the original request
+ cannot be met.
+
+ The algorithm for reducing the demands of the format is quite
+ simple-minded, so override this method in your subclass if your
+ application has spcific requirements on visual selection.
+
+ \sa chooseContext()
+*/
+
+/*! \fn void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth)
+ \internal
+
+ \bold{X11 only:} This virtual function chooses a visual that matches
+ the OpenGL \link format() format\endlink. Reimplement this function
+ in a subclass if you need a custom visual.
+
+ \sa chooseContext()
+*/
/*!
\fn void QGLContext::reset()
@@ -2588,7 +2623,7 @@ const QGLContext* QGLContext::currentContext()
\i paintGL() - Renders the OpenGL scene. Gets called whenever the widget
needs to be updated.
\i resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets
- called whenever the the widget has been resized (and also when it
+ called whenever the widget has been resized (and also when it
is shown for the first time because all newly created widgets get a
resize event automatically).
\i initializeGL() - Sets up the OpenGL rendering context, defines display
@@ -3020,11 +3055,10 @@ void QGLWidget::setFormat(const QGLFormat &format)
*/
/*
- \obsolete
-
\fn void QGLWidget::setContext(QGLContext *context,
- const QGLContext* shareContext,
- bool deleteOldContext)
+ const QGLContext* shareContext,
+ bool deleteOldContext)
+ \obsolete
Sets a new context for this widget. The QGLContext \a context must
be created using \e new. QGLWidget will delete \a context when
@@ -3174,9 +3208,10 @@ void QGLWidget::resizeOverlayGL(int, int)
{
}
-
+/*! \fn bool QGLWidget::event(QEvent *e)
+ \reimp
+*/
#if !defined(Q_OS_WINCE) && !defined(Q_WS_QWS)
-/*! \reimp */
bool QGLWidget::event(QEvent *e)
{
Q_D(QGLWidget);
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 01b1d6f..b7b2f36 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -45,6 +45,7 @@
#include <QtGui/qwidget.h>
#include <QtOpenGL/qglcolormap.h>
#include <QtCore/qmap.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -348,7 +349,7 @@ protected:
static QGLContext* currentCtx;
private:
- QGLContextPrivate* d_ptr;
+ QScopedPointer<QGLContextPrivate> d_ptr;
friend class QGLPixelBuffer;
friend class QGLPixelBufferPrivate;
diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp
index bd8569a..217b0fc 100644
--- a/src/opengl/qgl_win.cpp
+++ b/src/opengl/qgl_win.cpp
@@ -884,19 +884,9 @@ static bool qLogEq(bool a, bool b)
return (((!a) && (!b)) || (a && b));
}
-/*!
- \bold{Win32 only:} This virtual function chooses a pixel
- format that matches the OpenGL \link setFormat() format\endlink.
- Reimplement this function in a subclass if you need a custom
- context.
-
- \warning The \a dummyPfd pointer and \a pdc are used as a \c
- PIXELFORMATDESCRIPTOR*. We use \c void to avoid using
- Windows-specific types in our header files.
-
- \sa chooseContext()
-*/
-
+/*
+ See qgl.cpp for qdoc comment.
+ */
int QGLContext::choosePixelFormat(void* dummyPfd, HDC pdc)
{
Q_D(QGLContext);
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index cb51598..7429071 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -552,9 +552,6 @@ void QGLWidgetPrivate::updateColormap()
ReleaseDC(q->winId(), hdc);
}
-/*!
- \reimp
-\*/
bool QGLWidget::event(QEvent *e)
{
Q_D(QGLWidget);
diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp
index 28c34de..7ed7a23 100644
--- a/src/opengl/qgl_x11.cpp
+++ b/src/opengl/qgl_x11.cpp
@@ -443,19 +443,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
return true;
}
-
-/*!
- \bold{X11 only:} This virtual function tries to find a
- visual that matches the format, reducing the demands if the original
- request cannot be met.
-
- The algorithm for reducing the demands of the format is quite
- simple-minded, so override this method in your subclass if your
- application has spcific requirements on visual selection.
-
- \sa chooseContext()
-*/
-
+/*
+ See qgl.cpp for qdoc comment.
+ */
void *QGLContext::chooseVisual()
{
Q_D(QGLContext);
@@ -519,17 +509,9 @@ void *QGLContext::chooseVisual()
return vis;
}
-
-/*!
- \internal
-
- \bold{X11 only:} This virtual function chooses a visual
- that matches the OpenGL \link format() format\endlink. Reimplement this
- function in a subclass if you need a custom visual.
-
- \sa chooseContext()
-*/
-
+/*
+ See qgl.cpp for qdoc comment.
+ */
void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth)
{
Q_D(QGLContext);
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index c362b7e..6e908e2 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -448,7 +448,6 @@ QGLFramebufferObject::~QGLFramebufferObject()
glDeleteRenderbuffersEXT(1, &d->depth_stencil_buffer);
glDeleteFramebuffersEXT(1, &d->fbo);
}
- delete d_ptr;
}
/*!
diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h
index a9e1b2f..fea8920 100644
--- a/src/opengl/qglframebufferobject.h
+++ b/src/opengl/qglframebufferobject.h
@@ -116,7 +116,7 @@ protected:
private:
Q_DISABLE_COPY(QGLFramebufferObject)
- QGLFramebufferObjectPrivate *d_ptr;
+ QScopedPointer<QGLFramebufferObjectPrivate> d_ptr;
friend class QGLDrawable;
};
diff --git a/src/opengl/qglpaintdevice_qws.cpp b/src/opengl/qglpaintdevice_qws.cpp
index 18905ab..60a1238 100644
--- a/src/opengl/qglpaintdevice_qws.cpp
+++ b/src/opengl/qglpaintdevice_qws.cpp
@@ -68,8 +68,6 @@ QWSGLPaintDevice::QWSGLPaintDevice(QWidget *widget) :
QWSGLPaintDevice::~QWSGLPaintDevice()
{
- Q_D(QWSGLPaintDevice);
- delete d;
}
QPaintEngine* QWSGLPaintDevice::paintEngine() const
diff --git a/src/opengl/qglpaintdevice_qws_p.h b/src/opengl/qglpaintdevice_qws_p.h
index 369de7f..a471b1b 100644
--- a/src/opengl/qglpaintdevice_qws_p.h
+++ b/src/opengl/qglpaintdevice_qws_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include <QtCore/qscopedpointer.h>
#include <QPaintDevice>
QT_BEGIN_NAMESPACE
@@ -76,7 +77,7 @@ public:
private:
friend class QWSGLWindowSurface;
- QWSGLPaintDevicePrivate *d_ptr;
+ QScopedPointer<QWSGLPaintDevicePrivate> d_ptr;
};
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index 5f74f26..8ff2e1d 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -186,7 +186,6 @@ QGLPixelBuffer::~QGLPixelBuffer()
delete d->qctx;
if (current && current != d->qctx)
current->makeCurrent();
- delete d_ptr;
}
/*! \fn bool QGLPixelBuffer::makeCurrent()
diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h
index 0131570..8264c22 100644
--- a/src/opengl/qglpixelbuffer.h
+++ b/src/opengl/qglpixelbuffer.h
@@ -107,7 +107,7 @@ protected:
private:
Q_DISABLE_COPY(QGLPixelBuffer)
- QGLPixelBufferPrivate *d_ptr;
+ QScopedPointer<QGLPixelBufferPrivate> d_ptr;
friend class QGLDrawable;
friend class QGLWindowSurface;
};
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 5a212f5..c9fbc7e 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -5625,7 +5625,7 @@ void QOpenGLPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
QPainter *p = painter();
QBrush oldBrush = p->brush();
p->setBrush(brush);
- qt_draw_helper(p->d_ptr, painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
+ qt_draw_helper(p->d_ptr.data(), painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
p->setBrush(oldBrush);
return;
}
diff --git a/src/phonon/phonon.pro b/src/phonon/phonon.pro
index 679a1b0..221304d 100644
--- a/src/phonon/phonon.pro
+++ b/src/phonon/phonon.pro
@@ -13,13 +13,6 @@ PHONON_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/phonon
unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtNetwork
-# Phonon depends on numeric_limits. Enabling STL support in Qt
-# would bring in link dependencies, and we don't need that for
-# numeric_limits, hence we here merely ensure we bring in the necessary
-# header.
-symbian:INCLUDEPATH += $${EPOCROOT}epoc32/include/stdapis/stlport \
- $$OS_LAYER_STDCPP_SYSTEMINCLUDE
-
# Input
HEADERS += $$PHONON_DIR/abstractaudiooutput.h \
$$PHONON_DIR/abstractaudiooutput_p.h \
@@ -122,7 +115,15 @@ contains(QT_CONFIG, dbus) {
contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols
symbian: {
+ # Phonon depends on numeric_limits. Enabling STL support in Qt
+ # would bring in link dependencies, and we don't need that for
+ # numeric_limits, hence we here merely ensure we bring in the necessary
+ # header.
+ INCLUDEPATH *= $$OS_LAYER_STDCPP_SYSTEMINCLUDE
+
# Without this setting, code using numeric_limits will fail
# for winscw, although armv5 works fine no matter what.
- MMP_RULES += "option cw -wchar_t on"
+ QMAKE_CXXFLAGS.CW *= $$STLLIB_USAGE_CW_FLAGS
+
+ TARGET.UID3 = 0x2001E624
}
diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h
index aea91e1..57073ee 100644
--- a/src/plugins/accessible/widgets/rangecontrols.h
+++ b/src/plugins/accessible/widgets/rangecontrols.h
@@ -60,6 +60,7 @@ class QDial;
#ifndef QT_NO_SPINBOX
class QAccessibleAbstractSpinBox: public QAccessibleWidgetEx, public QAccessibleValueInterface
{
+ Q_ACCESSIBLE_OBJECT
public:
explicit QAccessibleAbstractSpinBox(QWidget *w);
@@ -132,6 +133,7 @@ protected:
class QAccessibleAbstractSlider: public QAccessibleWidgetEx, public QAccessibleValueInterface
{
+ Q_ACCESSIBLE_OBJECT
public:
explicit QAccessibleAbstractSlider(QWidget *w, Role r = Slider);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index 13f0a8f..180acaf 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -61,8 +61,6 @@ public:
void lockDirectFB(uint flags);
void unlockDirectFB();
- inline bool forceRasterPrimitives() const { return forceRaster; }
-
// Reimplemented from QCustomRasterPaintDevice:
void* memory() const;
QImage::Format format() const;
@@ -77,7 +75,6 @@ protected:
dfbSurface(0),
lockedImage(0),
screen(scr),
- forceRaster(false),
lock(0),
mem(0)
{}
@@ -95,7 +92,6 @@ protected:
QImage *lockedImage;
QDirectFBScreen *screen;
int bpl;
- bool forceRaster;
uint lock;
uchar *mem;
private:
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 989a37a..2fb533a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -81,7 +81,7 @@ template <> inline const bool* ptr<bool>(const bool &) { return 0; }
template <typename device, typename T1, typename T2, typename T3>
static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
int scale, bool matrixRotShear, bool simplePen,
- bool dfbHandledClip, bool forceRasterPrimitives,
+ bool dfbHandledClip,
const char *nameOne, const T1 &one,
const char *nameTwo, const T2 &two,
const char *nameThree, const T3 &three)
@@ -98,8 +98,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
dbg << "scale" << scale
<< "matrixRotShear" << matrixRotShear
<< "simplePen" << simplePen
- << "dfbHandledClip" << dfbHandledClip
- << "forceRasterPrimitives" << forceRasterPrimitives;
+ << "dfbHandledClip" << dfbHandledClip;
const T1 *t1 = ptr(one);
const T2 *t2 = ptr(two);
@@ -125,7 +124,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
__FUNCTION__, state()->painter->device(), \
d_func()->scale, d_func()->matrixRotShear, \
d_func()->simplePen, d_func()->dfbCanHandleClip(), \
- d_func()->forceRasterPrimitives, \
#one, one, #two, two, #three, three); \
if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \
return;
@@ -140,7 +138,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
__FUNCTION__, state()->painter->device(), \
d_func()->scale, d_func()->matrixRotShear, \
d_func()->simplePen, d_func()->dfbCanHandleClip(), \
- d_func()->forceRasterPrimitives, \
#one, one, #two, two, #three, three);
#else
#define RASTERFALLBACK(op, one, two, three)
@@ -218,8 +215,8 @@ public:
void setTransform(const QTransform &m);
void setPen(const QPen &pen);
- void setCompositionMode(QPainter::CompositionMode mode);
- void setOpacity(quint8 value);
+ inline void setCompositionMode(QPainter::CompositionMode mode);
+ inline void setOpacity(quint8 value);
void setRenderHints(QPainter::RenderHints hints);
inline void setDFBColor(const QColor &color);
@@ -263,7 +260,6 @@ private:
QPen pen;
bool antialiased;
- bool forceRasterPrimitives;
bool simplePen;
@@ -280,14 +276,12 @@ private:
quint8 opacity;
- quint32 drawFlagsFromCompositionMode, blitFlagsFromCompositionMode;
- DFBSurfacePorterDuffRule porterDuffRule;
-
bool dirtyClip;
bool dfbHandledClip;
bool ignoreSystemClip;
QDirectFBPaintDevice *dfbDevice;
void *lockedMemory;
+ bool unsupportedCompositionMode;
QDirectFBPaintEngine *q;
friend class QDirectFBPaintEngine;
@@ -383,7 +377,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
{
Q_D(QDirectFBPaintEngine);
d->dirtyClip = true;
- const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2));
+ const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().y2)));
if (bottom.y() >= d->lastLockedHeight)
d->lock();
QRasterPaintEngine::clip(path, op);
@@ -407,9 +401,8 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
Q_D(QDirectFBPaintEngine);
d->updateClip();
const QBrush &brush = state()->brush;
- if (!d->dfbCanHandleClip() || d->matrixRotShear
- || !d->simplePen || d->forceRasterPrimitives
- || !d->isSimpleBrush(brush)) {
+ if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear
+ || !d->simplePen || !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
@@ -433,9 +426,8 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
Q_D(QDirectFBPaintEngine);
d->updateClip();
const QBrush &brush = state()->brush;
- if (!d->dfbCanHandleClip() || d->matrixRotShear
- || !d->simplePen || d->forceRasterPrimitives
- || !d->isSimpleBrush(brush)) {
+ if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear
+ || !d->simplePen || !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
@@ -458,7 +450,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) {
+ if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -476,7 +468,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) {
+ if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -516,7 +508,8 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
d->updateClip();
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- if (d->matrixRotShear
+ if (d->unsupportedCompositionMode
+ || d->matrixRotShear
|| d->scale == QDirectFBPaintEnginePrivate::NegativeScale
|| !d->dfbCanHandleClip(r)
#ifndef QT_DIRECTFB_IMAGECACHE
@@ -560,7 +553,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
d->lock();
QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear
+ } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear
|| d->scale == QDirectFBPaintEnginePrivate::NegativeScale) {
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
@@ -592,7 +585,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp);
d->lock();
QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp);
- } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()
+ } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()
|| d->scale == QDirectFBPaintEnginePrivate::NegativeScale) {
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), sp);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
@@ -688,11 +681,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) {
+ if (!d->unsupportedCompositionMode && d->dfbCanHandleClip(rect) && !d->matrixRotShear) {
switch (brush.style()) {
case Qt::SolidPattern: {
- if (d->forceRasterPrimitives)
- break;
d->unlock();
d->setDFBColor(brush.color());
const QRect r = d->transform.mapRect(rect).toRect();
@@ -720,7 +711,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) {
+ if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear) {
RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG());
d->lock();
QRasterPaintEngine::fillRect(rect, color);
@@ -737,38 +728,32 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count,
uint color)
{
Q_D(QDirectFBPaintEngine);
- if (d->forceRasterPrimitives) {
- RASTERFALLBACK(DRAW_COLORSPANS, count, color, VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawColorSpans(spans, count, color);
- } else {
- color = INV_PREMUL(color);
-
- QVarLengthArray<DFBRegion> lines(count);
- int j = 0;
- for (int i = 0; i < count; ++i) {
- if (spans[i].coverage == 255) {
- lines[j].x1 = spans[i].x;
- lines[j].y1 = spans[i].y;
- lines[j].x2 = spans[i].x + spans[i].len - 1;
- lines[j].y2 = spans[i].y;
- ++j;
- } else {
- DFBSpan span = { spans[i].x, spans[i].len };
- uint c = BYTE_MUL(color, spans[i].coverage);
- // ### how does this play with setDFBColor
- d->surface->SetColor(d->surface,
- qRed(c), qGreen(c), qBlue(c), qAlpha(c));
- d->surface->FillSpans(d->surface, spans[i].y, &span, 1);
- }
- }
- if (j > 0) {
+ color = INV_PREMUL(color);
+
+ QVarLengthArray<DFBRegion> lines(count);
+ int j = 0;
+ for (int i = 0; i < count; ++i) {
+ if (spans[i].coverage == 255) {
+ lines[j].x1 = spans[i].x;
+ lines[j].y1 = spans[i].y;
+ lines[j].x2 = spans[i].x + spans[i].len - 1;
+ lines[j].y2 = spans[i].y;
+ ++j;
+ } else {
+ DFBSpan span = { spans[i].x, spans[i].len };
+ uint c = BYTE_MUL(color, spans[i].coverage);
+ // ### how does this play with setDFBColor
d->surface->SetColor(d->surface,
- qRed(color), qGreen(color), qBlue(color),
- qAlpha(color));
- d->surface->DrawLines(d->surface, lines.data(), j);
+ qRed(c), qGreen(c), qBlue(c), qAlpha(c));
+ d->surface->FillSpans(d->surface, spans[i].y, &span, 1);
}
}
+ if (j > 0) {
+ d->surface->SetColor(d->surface,
+ qRed(color), qGreen(color), qBlue(color),
+ qAlpha(color));
+ d->surface->DrawLines(d->surface, lines.data(), j);
+ }
}
void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
@@ -803,11 +788,11 @@ void QDirectFBPaintEngine::initImageCache(int size)
QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
- : surface(0), antialiased(false), forceRasterPrimitives(false), simplePen(false),
+ : surface(0), antialiased(false), simplePen(false),
matrixRotShear(false), scale(NoScale), lastLockedHeight(-1),
- fbWidth(-1), fbHeight(-1), opacity(255), drawFlagsFromCompositionMode(0),
- blitFlagsFromCompositionMode(0), porterDuffRule(DSPD_SRC_OVER), dirtyClip(true),
- dfbHandledClip(false), dfbDevice(0), lockedMemory(0), q(p)
+ fbWidth(-1), fbHeight(-1), opacity(255), dirtyClip(true),
+ dfbHandledClip(false), dfbDevice(0), lockedMemory(0),
+ unsupportedCompositionMode(false), q(p)
{
fb = QDirectFBScreen::instance()->dfb();
ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip;
@@ -896,13 +881,12 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device)
device->devType());
}
lockedMemory = 0;
- forceRasterPrimitives = dfbDevice->forceRasterPrimitives();
surface->GetSize(surface, &fbWidth, &fbHeight);
setTransform(QTransform());
antialiased = false;
- opacity = 255;
+ setOpacity(255);
setCompositionMode(q->state()->compositionMode());
dirtyClip = true;
setPen(q->state()->pen);
@@ -930,72 +914,13 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p)
void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
{
- blitFlagsFromCompositionMode = DSBLIT_NOFX;
- drawFlagsFromCompositionMode = DSDRAW_NOFX;
-
- bool blend = true;
- switch (mode) {
- case QPainter::CompositionMode_SourceOver:
- porterDuffRule = DSPD_SRC_OVER;
- break;
- case QPainter::CompositionMode_DestinationOver:
- porterDuffRule = DSPD_DST_OVER;
- break;
- case QPainter::CompositionMode_Clear:
- porterDuffRule = DSPD_CLEAR;
- blend = false;
- break;
- case QPainter::CompositionMode_Source:
- porterDuffRule = DSPD_SRC;
- blend = false;
- break;
- case QPainter::CompositionMode_Destination:
- porterDuffRule = DSPD_NONE; // ### need to double check this
- blend = false;
- return;
- case QPainter::CompositionMode_SourceIn:
- porterDuffRule = DSPD_SRC_IN;
- break;
- case QPainter::CompositionMode_DestinationIn:
- porterDuffRule = DSPD_DST_IN;
- break;
- case QPainter::CompositionMode_SourceOut:
- porterDuffRule = DSPD_SRC_OUT;
- break;
- case QPainter::CompositionMode_DestinationOut:
- porterDuffRule = DSPD_DST_OUT;
- break;
- case QPainter::CompositionMode_Xor:
- porterDuffRule = DSPD_XOR;
- blitFlagsFromCompositionMode |= DSBLIT_XOR;
- drawFlagsFromCompositionMode |= DSDRAW_XOR;
- break;
-// case QPainter::CompositionMode_Plus: // ???
-// porterDuffRule = DSPD_ADD;
-// break;
- default:
- qWarning("QDirectFBPaintEnginePrivate::setCompositionMode(): "
- "mode %d not implemented", mode);
- return;
- }
- // intentially not comparing with current porterDuffRule. surface might have changed.
- if (blend) {
- blitFlagsFromCompositionMode |= DSBLIT_BLEND_ALPHACHANNEL;
- drawFlagsFromCompositionMode |= DSDRAW_BLEND;
- }
- if (opacity != 255) {
- setOpacity(opacity);
- }
+ unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver);
}
+
void QDirectFBPaintEnginePrivate::setOpacity(quint8 op)
{
opacity = op;
- if (opacity == 255) {
- blitFlagsFromCompositionMode &= ~DSBLIT_BLEND_COLORALPHA;
- } else {
- blitFlagsFromCompositionMode |= DSBLIT_BLEND_COLORALPHA;
- }
}
void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
@@ -1009,15 +934,9 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha)
{
- quint32 blittingFlags = blitFlagsFromCompositionMode;
- if (alpha) {
- surface->SetPorterDuff(surface,
- (blittingFlags & DSBLIT_BLEND_COLORALPHA)
- ? DSPD_NONE
- : porterDuffRule);
- } else {
- blittingFlags &= ~DSBLIT_BLEND_ALPHACHANNEL;
- surface->SetPorterDuff(surface, DSPD_NONE);
+ quint32 blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX;
+ if (opacity != 255) {
+ blittingFlags |= DSBLIT_BLEND_COLORALPHA;
}
surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags));
@@ -1028,15 +947,9 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color)
Q_ASSERT(surface);
const quint8 alpha = (opacity == 255 ?
color.alpha() : ALPHA_MUL(color.alpha(), opacity));
- surface->SetColor(surface,
- color.red(), color.green(), color.blue(), alpha);
- quint32 drawingFlags = drawFlagsFromCompositionMode;
- if (alpha == 255) {
- drawingFlags &= ~DSDRAW_BLEND;
- }
+ surface->SetColor(surface, color.red(), color.green(), color.blue(), alpha);
surface->SetPorterDuff(surface, DSPD_NONE);
- // PorterDuff messes up alpha values for primitives
- surface->SetDrawingFlags(surface, DFBSurfaceDrawingFlags(drawingFlags));
+ surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND);
}
void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n)
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index c9b676a..18754f5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -76,7 +76,6 @@ void QDirectFBPixmapData::resize(int width, int height)
format,
QDirectFBScreen::TrackSurface);
alpha = false;
- forceRaster = (format == QImage::Format_RGB32);
if (!dfbSurface) {
invalidate();
qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface");
@@ -187,7 +186,6 @@ void QDirectFBPixmapData::fromImage(const QImage &i,
}
dfbSurface = screen->copyToDFBSurface(img, format,
QDirectFBScreen::TrackSurface);
- forceRaster = (format == QImage::Format_RGB32);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
invalidate();
@@ -204,11 +202,12 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
}
IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFBSurface();
- const bool hasAlpha = data->hasAlphaChannel();
- format = (hasAlpha
+ alpha = data->hasAlphaChannel();
+ format = (alpha
? QDirectFBScreen::instance()->alphaPixmapFormat()
: QDirectFBScreen::instance()->pixelFormat());
+
dfbSurface = screen->createDFBSurface(rect.size(), format,
QDirectFBScreen::TrackSurface);
if (!dfbSurface) {
@@ -216,9 +215,8 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
invalidate();
return;
}
- forceRaster = (format == QImage::Format_RGB32);
- if (hasAlpha) {
+ if (alpha) {
dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
} else {
@@ -268,7 +266,6 @@ void QDirectFBPixmapData::fill(const QColor &color)
screen->releaseDFBSurface(dfbSurface);
format = screen->alphaPixmapFormat();
dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface);
- forceRaster = false;
setSerialNumber(++global_ser_no);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fill()");
@@ -277,24 +274,7 @@ void QDirectFBPixmapData::fill(const QColor &color)
}
}
- if (forceRaster) {
- // in DSPF_RGB32 all dfb drawing causes the Alpha byte to be
- // set to 0. This causes issues for the raster engine.
- uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl);
- if (mem) {
- const int h = QPixmapData::height();
- const int w = QPixmapData::width() * 4; // 4 bytes per 32 bit pixel
- const int c = color.rgba();
- for (int i = 0; i < h; ++i) {
- memset(mem, c, w);
- mem += bpl;
- }
- dfbSurface->Unlock(dfbSurface);
- }
- } else {
- dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(),
- color.alpha());
- }
+ dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), color.alpha());
}
QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 98e32ed..9e35a66 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -958,9 +958,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
return false;
}
- if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive))
- printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface);
-
// Work out what format we're going to use for surfaces with an alpha channel
d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->dfbSurface);
setPixelFormat(d_ptr->alphaPixmapFormat);
@@ -971,12 +968,17 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
case QImage::Format_RGB444:
d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied;
break;
+ case QImage::Format_RGB32:
+ qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the RGB32 pixelformat. "
+ "We recommmend using ARGB instead");
+ return false;
+ case QImage::Format_Indexed8:
+ qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the LUT8 pixelformat.");
+ return false;
case QImage::NImageFormats:
case QImage::Format_Invalid:
case QImage::Format_Mono:
case QImage::Format_MonoLSB:
- case QImage::Format_Indexed8:
- case QImage::Format_RGB32:
case QImage::Format_RGB888:
case QImage::Format_RGB16:
case QImage::Format_RGB555:
@@ -1037,6 +1039,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
setGraphicsSystem(d_ptr);
+ if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive))
+ printDirectFBInfo(d_ptr->dfb, d_ptr->dfbSurface);
+
return true;
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index cd8796b..330eb88 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -127,7 +127,6 @@ void QDirectFBWindowSurface::createWindow()
dfbSurface->Release(dfbSurface);
dfbWindow->GetSurface(dfbWindow, &dfbSurface);
- forceRaster = (format == QImage::Format_RGB32);
#endif
}
#endif // QT_NO_DIRECTFB_WM
@@ -164,7 +163,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect, const QRegion &mask)
rect.width(), rect.height() };
result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
}
- forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32);
} else {
const bool isResize = rect.size() != geometry().size();
#ifdef QT_NO_DIRECTFB_WM
@@ -179,7 +177,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect, const QRegion &mask)
}
dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface);
- forceRaster = (dfbSurface && QDirectFBScreen::getImageFormat(dfbSurface) == QImage::Format_RGB32);
} else {
Q_ASSERT(dfbSurface);
}
@@ -242,31 +239,28 @@ void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
#endif
}
-bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
+static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
{
- if (!dfbSurface || !(flipFlags & DSFLIP_BLIT))
- return false;
-
- const QVector<QRect> rects = region.rects();
- const int n = rects.size();
-
- QVarLengthArray<DFBRectangle, 8> dfbRects(n);
- QVarLengthArray<DFBPoint, 8> dfbPoints(n);
+ surface->SetBlittingFlags(surface, DSBLIT_NOFX);
+ const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
+ surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy);
+}
- for (int i = 0; i < n; ++i) {
- const QRect r = rects.at(i);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
- dfbPoints[i].x = r.x() + dx;
- dfbPoints[i].y = r.y() + dy;
- }
+bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
+{
+ if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty())
+ return false;
dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- dfbSurface->BatchBlit(dfbSurface, dfbSurface,
- dfbRects.data(), dfbPoints.data(), n);
- dfbSurface->ReleaseSource(dfbSurface);
+ if (region.numRects() == 1) {
+ ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy);
+ } else {
+ const QVector<QRect> rects = region.rects();
+ const int n = rects.size();
+ for (int i=0; i<n; ++i) {
+ ::scrollSurface(dfbSurface, rects.at(i), dx, dy);
+ }
+ }
return true;
}
diff --git a/src/plugins/imageformats/mng/qmnghandler.cpp b/src/plugins/imageformats/mng/qmnghandler.cpp
index 19cc16d..7fabcd9 100644
--- a/src/plugins/imageformats/mng/qmnghandler.cpp
+++ b/src/plugins/imageformats/mng/qmnghandler.cpp
@@ -375,8 +375,6 @@ QMngHandler::QMngHandler()
QMngHandler::~QMngHandler()
{
- Q_D(QMngHandler);
- delete d;
}
/*! \reimp */
diff --git a/src/plugins/imageformats/mng/qmnghandler.h b/src/plugins/imageformats/mng/qmnghandler.h
index 909be2d..ce2ec6f 100644
--- a/src/plugins/imageformats/mng/qmnghandler.h
+++ b/src/plugins/imageformats/mng/qmnghandler.h
@@ -42,6 +42,7 @@
#ifndef QMNGHANDLER_H
#define QMNGHANDLER_H
+#include <QtCore/qscopedpointer.h>
#include <QtGui/qimageiohandler.h>
QT_BEGIN_NAMESPACE
@@ -74,7 +75,7 @@ class QMngHandler : public QImageIOHandler
private:
Q_DECLARE_PRIVATE(QMngHandler)
- QMngHandlerPrivate *d_ptr;
+ QScopedPointer<QMngHandlerPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/plugins/s60/src/qdesktopservices_3_1.cpp b/src/plugins/s60/src/qdesktopservices_3_1.cpp
index 1b7edbd..0551a74 100644
--- a/src/plugins/s60/src/qdesktopservices_3_1.cpp
+++ b/src/plugins/s60/src/qdesktopservices_3_1.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/plugins/s60/src/qdesktopservices_3_2.cpp b/src/plugins/s60/src/qdesktopservices_3_2.cpp
index e563c14..7695f00 100644
--- a/src/plugins/s60/src/qdesktopservices_3_2.cpp
+++ b/src/plugins/s60/src/qdesktopservices_3_2.cpp
@@ -5,15 +5,47 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
#include <private/qcore_symbian_p.h>
-#include <cdirectorylocalizer.h> // CDirectoryLocalizer
#include <qstring.h>
#include <qdir.h>
+#include <e32base.h> // CBase -> Required by cdirectorylocalizer.h
+#include <cdirectorylocalizer.h> // CDirectoryLocalizer
+
EXPORT_C QString localizedDirectoryName(QString& rawPath)
{
QString ret;
diff --git a/src/plugins/s60/src/qlocale_3_1.cpp b/src/plugins/s60/src/qlocale_3_1.cpp
index 95cf244..b2e6a5d 100644
--- a/src/plugins/s60/src/qlocale_3_1.cpp
+++ b/src/plugins/s60/src/qlocale_3_1.cpp
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/plugins/s60/src/qlocale_3_2.cpp b/src/plugins/s60/src/qlocale_3_2.cpp
index 027eefc..7a3a7e5 100644
--- a/src/plugins/s60/src/qlocale_3_2.cpp
+++ b/src/plugins/s60/src/qlocale_3_2.cpp
@@ -5,11 +5,43 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
+#include <exception>
#include <e32std.h>
+#include <e32base.h>
EXPORT_C TPtrC defaultGetLongDateFormatSpec(TExtendedLocale& locale)
{
diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
index bacf23b..0574341 100644
--- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
+++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro
@@ -2,7 +2,5 @@
TEMPLATE = subdirs
# We just want to extract the zip file containing sqlite binaries for Symbian
-!exists($${EPOCROOT}epoc32/release/armv5/urel/sqlite3.dll): {
- BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip"
-}
+BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip"
diff --git a/src/qt3support/itemviews/q3table.cpp b/src/qt3support/itemviews/q3table.cpp
index 658b0ad..458f5a5 100644
--- a/src/qt3support/itemviews/q3table.cpp
+++ b/src/qt3support/itemviews/q3table.cpp
@@ -166,6 +166,7 @@ private:
QTimer *stretchTimer, *widgetStretchTimer;
Q3TableHeaderPrivate *d;
+ Q_DISABLE_COPY(Q3TableHeader)
};
#ifdef _WS_QWS_
diff --git a/src/qt3support/network/q3http.cpp b/src/qt3support/network/q3http.cpp
index f1590a6..591b381 100644
--- a/src/qt3support/network/q3http.cpp
+++ b/src/qt3support/network/q3http.cpp
@@ -626,7 +626,7 @@ void Q3HttpHeader::setContentLength( int len )
}
/*!
- Returns true if the header has an entry for the the special HTTP
+ Returns true if the header has an entry for the special HTTP
header field \c content-type; otherwise returns false.
\sa contentType() setContentType()
diff --git a/src/qt3support/network/q3urloperator.cpp b/src/qt3support/network/q3urloperator.cpp
index 3f334a8..b415e12 100644
--- a/src/qt3support/network/q3urloperator.cpp
+++ b/src/qt3support/network/q3urloperator.cpp
@@ -543,7 +543,7 @@ const Q3NetworkOperation *Q3UrlOperator::rename( const QString &oldname, const Q
in mind that the get() and put() operations emit this signal
through the Q3UrlOperator. The number of transferred bytes and the
total bytes that you receive as arguments in this signal do not
- relate to the the whole copy operation; they relate first to the
+ relate to the whole copy operation; they relate first to the
get() and then to the put() operation. Always check what type of
operation the signal comes from; this is given in the signal's
last argument.
diff --git a/src/qt3support/other/q3accel.cpp b/src/qt3support/other/q3accel.cpp
index a570a70..2358092 100644
--- a/src/qt3support/other/q3accel.cpp
+++ b/src/qt3support/other/q3accel.cpp
@@ -206,7 +206,7 @@ bool Q_COMPAT_EXPORT qt_tryComposeUnicode(QWidget* w, QKeyEvent* e){
void Q3AccelManager::setFuncPtr() {
if (qApp->d_func()->qt_compat_used)
return;
- QApplicationPrivate *data = static_cast<QApplicationPrivate*>(qApp->d_ptr);
+ QApplicationPrivate *data = static_cast<QApplicationPrivate*>(qApp->d_ptr.data());
data->qt_tryAccelEvent = qt_tryAccelEvent;
data->qt_tryComposeUnicode = qt_tryComposeUnicode;
data->qt_dispatchAccelEvent = qt_dispatchAccelEvent;
diff --git a/src/qt3support/painting/q3painter.h b/src/qt3support/painting/q3painter.h
index 6fd17cb..c301ee7 100644
--- a/src/qt3support/painting/q3painter.h
+++ b/src/qt3support/painting/q3painter.h
@@ -82,6 +82,8 @@ public:
private:
QRect adjustedRectangle(const QRect &r);
+
+ Q_DISABLE_COPY(Q3Painter)
};
void inline Q3Painter::drawRect(const QRect &r)
diff --git a/src/qt3support/widgets/q3action.cpp b/src/qt3support/widgets/q3action.cpp
index 4e1a1bf..311212a 100644
--- a/src/qt3support/widgets/q3action.cpp
+++ b/src/qt3support/widgets/q3action.cpp
@@ -497,7 +497,7 @@ Q3Action::Q3Action(const QIcon& icon, const QString& menuText, QKeySequence acce
}
/*!
- This constructor results in an icon-less action with the the menu
+ This constructor results in an icon-less action with the menu
text \a menuText and keyboard accelerator \a accel. It is a child
of \a parent and called \a name.
diff --git a/src/qt3support/widgets/q3groupbox.cpp b/src/qt3support/widgets/q3groupbox.cpp
index 1fa7e7c..e0b609a 100644
--- a/src/qt3support/widgets/q3groupbox.cpp
+++ b/src/qt3support/widgets/q3groupbox.cpp
@@ -382,7 +382,7 @@ int Q3GroupBox::insideSpacing() const
}
/*!
- Sets the the width of the inside margin to \a m pixels.
+ Sets the width of the inside margin to \a m pixels.
\sa insideMargin()
*/
@@ -954,7 +954,7 @@ int Q3GroupBox::frameWidth() const
\fn int Q3GroupBox::margin() const
\since 4.2
- Returns the width of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
This function uses QWidget::getContentsMargins() to get the margin.
diff --git a/src/qt3support/widgets/q3popupmenu.cpp b/src/qt3support/widgets/q3popupmenu.cpp
index 7f890b5..0b3a524 100644
--- a/src/qt3support/widgets/q3popupmenu.cpp
+++ b/src/qt3support/widgets/q3popupmenu.cpp
@@ -134,7 +134,7 @@ QT_BEGIN_NAMESPACE
\fn int Q3PopupMenu::margin() const
\since 4.2
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
This function uses QWidget::getContentsMargins() to get the margin.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/qt3support/widgets/q3progressbar.cpp b/src/qt3support/widgets/q3progressbar.cpp
index caae460..81f0dbf 100644
--- a/src/qt3support/widgets/q3progressbar.cpp
+++ b/src/qt3support/widgets/q3progressbar.cpp
@@ -455,7 +455,7 @@ void Q3ProgressBar::paintEvent(QPaintEvent *)
\fn int Q3ProgressBar::margin() const
\since 4.2
- Returns the with of the the margin around the contents of the widget.
+ Returns the width of the margin around the contents of the widget.
This function uses QWidget::getContentsMargins() to get the margin.
\sa setMargin(), QWidget::getContentsMargins()
diff --git a/src/qt3support/widgets/q3scrollview.cpp b/src/qt3support/widgets/q3scrollview.cpp
index 91a9203..5a91027 100644
--- a/src/qt3support/widgets/q3scrollview.cpp
+++ b/src/qt3support/widgets/q3scrollview.cpp
@@ -2038,7 +2038,7 @@ void Q3ScrollView::center(int x, int y)
\list
\i Margin 0.0 allows (x, y) to be on the edge of the visible area.
\i Margin 0.5 ensures that (x, y) is in middle 50% of the visible area.
- \i Margin 1.0 ensures that (x, y) is in the center of the the visible area.
+ \i Margin 1.0 ensures that (x, y) is in the center of the visible area.
\endlist
*/
void Q3ScrollView::center(int x, int y, float xmargin, float ymargin)
diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro
index 9aadfc0..e9da90d 100644
--- a/src/s60installs/qt_libs.pro
+++ b/src/s60installs/qt_libs.pro
@@ -41,7 +41,7 @@ symbian: {
contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
qtlibraries.depends += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}"
}
- contains(QT_CONFIG, stl) {
+ contains(CONFIG, stl) {
qtlibraries.depends += "(0x2000F866), 1, 0, 0, {\"Standard C++ Library Common\"}"
}
diff --git a/src/s60main/qts60main.cpp b/src/s60main/qts60main.cpp
index 1d19cc6..d7daf4a 100644
--- a/src/s60main/qts60main.cpp
+++ b/src/s60main/qts60main.cpp
@@ -5,11 +5,42 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
// INCLUDE FILES
+#include <exception>
#include <eikstart.h>
#include "qts60mainapplication.h"
diff --git a/src/s60main/qts60main_mcrt0.cpp b/src/s60main/qts60main_mcrt0.cpp
index 10a784a..49a47bd 100644
--- a/src/s60main/qts60main_mcrt0.cpp
+++ b/src/s60main/qts60main_mcrt0.cpp
@@ -2,7 +2,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_3RDPARTY_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,7 +79,15 @@ GLDEF_C TInt QtMainWrapper()
CleanupArrayDelete<char*>::PushL(argv);
CleanupArrayDelete<char*>::PushL(envp);
//Call user(application)'s main
- int ret = CALLMAIN(argc,argv,envp);
+ int ret = 0;
+ try
+ {
+ ret = CALLMAIN(argc, argv, envp);
+ }
+ catch (...)
+ {
+ User::Leave(KErrGeneral);
+ }
CleanupStack::PopAndDestroy(2,argv);
return ret;
}
diff --git a/src/s60main/qts60mainapplication.cpp b/src/s60main/qts60mainapplication.cpp
index 807b5af..2fada3d 100644
--- a/src/s60main/qts60mainapplication.cpp
+++ b/src/s60main/qts60mainapplication.cpp
@@ -5,11 +5,42 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
// INCLUDE FILES
+#include <exception>
#include "qts60maindocument.h"
#include "qts60mainapplication.h"
#include <bautils.h>
diff --git a/src/s60main/qts60mainapplication.h b/src/s60main/qts60mainapplication.h
index 318f83b..70b6909 100644
--- a/src/s60main/qts60mainapplication.h
+++ b/src/s60main/qts60mainapplication.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/s60main/qts60mainappui.cpp b/src/s60main/qts60mainappui.cpp
index dafbe96..1ac4f5a 100644
--- a/src/s60main/qts60mainappui.cpp
+++ b/src/s60main/qts60mainappui.cpp
@@ -5,11 +5,42 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
// INCLUDE FILES
+#include <exception>
#include <avkon.hrh>
#include <eikmenub.h>
#include <eikmenup.h>
@@ -38,6 +69,9 @@ void CQtS60MainAppUi::ConstructL()
// even these flags are defined
BaseConstructL(CAknAppUi::EAknEnableSkin);
+ CEikButtonGroupContainer* nativeContainer = Cba();
+ nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+
// Create async callback to call Qt main,
// this is required to give S60 app FW to finish starting correctly
TCallBack callBack( OpenCMainStaticCallBack, this );
@@ -73,14 +107,29 @@ CQtS60MainAppUi::~CQtS60MainAppUi()
void CQtS60MainAppUi::HandleCommandL( TInt aCommand )
{
if (qApp)
- qApp->s60HandleCommandL(aCommand);
+ qApp->symbianHandleCommand(aCommand);
+}
+
+// -----------------------------------------------------------------------------
+// CQtS60MainAppUi::HandleResourceChangeL()
+// Takes care of event handling.
+// -----------------------------------------------------------------------------
+//
+void CQtS60MainAppUi::HandleResourceChangeL(TInt aType)
+{
+ CAknAppUi::HandleResourceChangeL(aType);
+
+ if (qApp)
+ qApp->symbianResourceChange(aType);
}
void CQtS60MainAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl *control)
{
int result = 0;
if (qApp)
- result = qApp->s60ProcessEvent(const_cast<TWsEvent*>(&aEvent));
+ QT_TRANSLATE_EXCEPTION_TO_SYMBIAN_LEAVE(
+ result = qApp->s60ProcessEvent(const_cast<TWsEvent*>(&aEvent))
+ );
if (result <= 0)
CAknAppUi::HandleWsEventL(aEvent, control);
@@ -119,7 +168,8 @@ TInt CQtS60MainAppUi::OpenCMainStaticCallBack( TAny* aObject )
//
void CQtS60MainAppUi::OpenCMainCallBack()
{
- TInt ret = QtMainWrapper();
+ TInt ret;
+ TRAPD(err, ret = QtMainWrapper());
Exit();
}
diff --git a/src/s60main/qts60mainappui.h b/src/s60main/qts60mainappui.h
index 3addb0c..6bdeb2e 100644
--- a/src/s60main/qts60mainappui.h
+++ b/src/s60main/qts60mainappui.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
@@ -61,6 +91,13 @@ class CQtS60MainAppUi : public CAknAppUi
void HandleCommandL( TInt aCommand );
/**
+ * From CAknAppUi, HandleResourceChangeL
+ * Handles resource change events such as layout switches in global level.
+ * @param aType event type.
+ */
+ void HandleResourceChangeL(TInt aType);
+
+ /**
* HandleStatusPaneSizeChange.
* Called by the framework when the application status pane
* size is changed.
diff --git a/src/s60main/qts60maindocument.cpp b/src/s60main/qts60maindocument.cpp
index 9ab426d..eb7ea42 100644
--- a/src/s60main/qts60maindocument.cpp
+++ b/src/s60main/qts60maindocument.cpp
@@ -5,11 +5,42 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
// INCLUDE FILES
+#include <exception>
#include "qts60mainappui.h"
#include "qts60maindocument.h"
diff --git a/src/s60main/qts60maindocument.h b/src/s60main/qts60maindocument.h
index 4979e7f..a95e620 100644
--- a/src/s60main/qts60maindocument.h
+++ b/src/s60main/qts60maindocument.h
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/s60main/s60main.rss b/src/s60main/s60main.rss
index 569f59e..6e8004c 100644
--- a/src/s60main/s60main.rss
+++ b/src/s60main/s60main.rss
@@ -5,7 +5,37 @@
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
-** $TROLLTECH_DUAL_EMBEDDED_LICENSE$
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
**
****************************************************************************/
diff --git a/src/script/qscriptable.cpp b/src/script/qscriptable.cpp
index a6401d6..56291d8 100644
--- a/src/script/qscriptable.cpp
+++ b/src/script/qscriptable.cpp
@@ -118,8 +118,6 @@ QScriptable::QScriptable()
*/
QScriptable::~QScriptable()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/script/qscriptable.h b/src/script/qscriptable.h
index f990db2..d09b945 100644
--- a/src/script/qscriptable.h
+++ b/src/script/qscriptable.h
@@ -46,6 +46,8 @@
#ifndef QT_NO_SCRIPT
+#include <QtCore/qscopedpointer.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -73,7 +75,7 @@ public:
QScriptValue argument(int index) const;
private:
- QScriptablePrivate *d_ptr;
+ QScopedPointer<QScriptablePrivate> d_ptr;
Q_DISABLE_COPY(QScriptable)
Q_DECLARE_PRIVATE(QScriptable)
diff --git a/src/script/qscriptclass.cpp b/src/script/qscriptclass.cpp
index 14b8add..535a530 100644
--- a/src/script/qscriptclass.cpp
+++ b/src/script/qscriptclass.cpp
@@ -457,8 +457,6 @@ QScriptClass::QScriptClass(QScriptEngine *engine, QScriptClassPrivate &dd)
*/
QScriptClass::~QScriptClass()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/script/qscriptclass.h b/src/script/qscriptclass.h
index 9c06ea2..77e9b08 100644
--- a/src/script/qscriptclass.h
+++ b/src/script/qscriptclass.h
@@ -47,6 +47,7 @@
#ifndef QT_NO_SCRIPT
#include <QtCore/qvariant.h>
+#include <QtCore/qscopedpointer.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
@@ -103,7 +104,7 @@ public:
protected:
QScriptClass(QScriptEngine *engine, QScriptClassPrivate &dd);
- QScriptClassPrivate *d_ptr;
+ QScopedPointer<QScriptClassPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptClass)
diff --git a/src/script/qscriptclasspropertyiterator.cpp b/src/script/qscriptclasspropertyiterator.cpp
index 96f34d5..f328e14 100644
--- a/src/script/qscriptclasspropertyiterator.cpp
+++ b/src/script/qscriptclasspropertyiterator.cpp
@@ -111,8 +111,6 @@ QScriptClassPropertyIterator::QScriptClassPropertyIterator(const QScriptValue &o
*/
QScriptClassPropertyIterator::~QScriptClassPropertyIterator()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/script/qscriptclasspropertyiterator.h b/src/script/qscriptclasspropertyiterator.h
index 2041a65..05d49d8 100644
--- a/src/script/qscriptclasspropertyiterator.h
+++ b/src/script/qscriptclasspropertyiterator.h
@@ -46,6 +46,7 @@
#ifndef QT_NO_SCRIPT
+#include <QtCore/qscopedpointer.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
@@ -80,7 +81,7 @@ public:
protected:
QScriptClassPropertyIterator(const QScriptValue &object, QScriptClassPropertyIteratorPrivate &dd);
- QScriptClassPropertyIteratorPrivate *d_ptr;
+ QScopedPointer<QScriptClassPropertyIteratorPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptClassPropertyIterator)
diff --git a/src/script/qscriptcontext.cpp b/src/script/qscriptcontext.cpp
index 020601b..0b72342 100644
--- a/src/script/qscriptcontext.cpp
+++ b/src/script/qscriptcontext.cpp
@@ -219,8 +219,6 @@ QScriptContext::QScriptContext():
*/
QScriptContext::~QScriptContext()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/script/qscriptcontext.h b/src/script/qscriptcontext.h
index 1e1f987..25a2198 100644
--- a/src/script/qscriptcontext.h
+++ b/src/script/qscriptcontext.h
@@ -46,6 +46,7 @@
#ifndef QT_NO_SCRIPT
+#include <QtCore/qscopedpointer.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
@@ -111,7 +112,7 @@ public:
private:
QScriptContext();
- QScriptContextPrivate *d_ptr;
+ QScopedPointer<QScriptContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptContext)
Q_DISABLE_COPY(QScriptContext)
diff --git a/src/script/qscriptcontextinfo.cpp b/src/script/qscriptcontextinfo.cpp
index 260d19f..0fa5c62 100644
--- a/src/script/qscriptcontextinfo.cpp
+++ b/src/script/qscriptcontextinfo.cpp
@@ -204,13 +204,12 @@ QScriptContextInfoPrivate::~QScriptContextInfoPrivate()
previously created QScriptContextInfo.
*/
QScriptContextInfo::QScriptContextInfo(const QScriptContext *context)
+ : d_ptr(0)
{
if (context) {
- d_ptr = new QScriptContextInfoPrivate(context);
+ d_ptr.data_ptr() = new QScriptContextInfoPrivate(context);
d_ptr->q_ptr = this;
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -218,7 +217,7 @@ QScriptContextInfo::QScriptContextInfo(const QScriptContext *context)
Constructs a new QScriptContextInfo from the \a other info.
*/
QScriptContextInfo::QScriptContextInfo(const QScriptContextInfo &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -239,10 +238,6 @@ QScriptContextInfo::QScriptContextInfo()
*/
QScriptContextInfo::~QScriptContextInfo()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
/*!
@@ -251,15 +246,7 @@ QScriptContextInfo::~QScriptContextInfo()
*/
QScriptContextInfo &QScriptContextInfo::operator=(const QScriptContextInfo &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
@@ -510,7 +497,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptContextInfo &info)
Q_SCRIPT_EXPORT QDataStream &operator>>(QDataStream &in, QScriptContextInfo &info)
{
if (!info.d_ptr) {
- info.d_ptr = new QScriptContextInfoPrivate();
+ info.d_ptr.data_ptr() = new QScriptContextInfoPrivate();
info.d_ptr->ref.ref();
}
diff --git a/src/script/qscriptcontextinfo.h b/src/script/qscriptcontextinfo.h
index a683733..20b6607 100644
--- a/src/script/qscriptcontextinfo.h
+++ b/src/script/qscriptcontextinfo.h
@@ -48,6 +48,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qstringlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -104,7 +105,7 @@ public:
bool operator!=(const QScriptContextInfo &other) const;
private:
- QScriptContextInfoPrivate *d_ptr;
+ QScopedSharedPointer<QScriptContextInfoPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptContextInfo)
};
diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp
index d8908ed..2a36104 100644
--- a/src/script/qscriptengine.cpp
+++ b/src/script/qscriptengine.cpp
@@ -330,10 +330,6 @@ QScriptEngine::~QScriptEngine()
Q_D(QScriptEngine);
d->m_frameRepository.release(currentContext());
d->objectAllocator.destruct();
-#ifdef QT_NO_QOBJECT
- delete d_ptr;
- d_ptr = 0;
-#endif
}
/*!
@@ -1777,7 +1773,7 @@ QScriptValue QScriptEngine::objectById(qint64 id) const
Constructs a new QScriptSyntaxCheckResult from the \a other result.
*/
QScriptSyntaxCheckResult::QScriptSyntaxCheckResult(const QScriptSyntaxCheckResult &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -1806,10 +1802,6 @@ QScriptSyntaxCheckResult::QScriptSyntaxCheckResult()
*/
QScriptSyntaxCheckResult::~QScriptSyntaxCheckResult()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
/*!
@@ -1863,15 +1855,7 @@ QString QScriptSyntaxCheckResult::errorMessage() const
*/
QScriptSyntaxCheckResult &QScriptSyntaxCheckResult::operator=(const QScriptSyntaxCheckResult &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
diff --git a/src/script/qscriptengine.h b/src/script/qscriptengine.h
index afd551b..c55caac 100644
--- a/src/script/qscriptengine.h
+++ b/src/script/qscriptengine.h
@@ -47,6 +47,7 @@
#ifndef QT_NO_SCRIPT
#include <QtCore/qvariant.h>
+#include <QtCore/qscopedpointer.h>
#ifndef QT_NO_QOBJECT
#include <QtCore/qobject.h>
@@ -114,7 +115,7 @@ public:
private:
QScriptSyntaxCheckResult();
QScriptSyntaxCheckResult(QScriptSyntaxCheckResultPrivate *d);
- QScriptSyntaxCheckResultPrivate *d_ptr;
+ QScopedSharedPointer<QScriptSyntaxCheckResultPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptSyntaxCheckResult)
friend class QScriptEnginePrivate;
@@ -282,7 +283,7 @@ private:
protected:
#ifdef QT_NO_QOBJECT
- QScriptEnginePrivate *d_ptr;
+ QScopedPointer<QScriptEnginePrivate> d_ptr;
QScriptEngine(QScriptEnginePrivate &dd);
#else
diff --git a/src/script/qscriptengineagent.cpp b/src/script/qscriptengineagent.cpp
index bda94ae..c3eaf96 100644
--- a/src/script/qscriptengineagent.cpp
+++ b/src/script/qscriptengineagent.cpp
@@ -173,8 +173,6 @@ QScriptEngineAgent::QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEng
*/
QScriptEngineAgent::~QScriptEngineAgent()
{
- delete d_ptr;
- d_ptr = 0;
}
/*!
diff --git a/src/script/qscriptengineagent.h b/src/script/qscriptengineagent.h
index 3334bc0..461d756 100644
--- a/src/script/qscriptengineagent.h
+++ b/src/script/qscriptengineagent.h
@@ -47,6 +47,7 @@
#ifndef QT_NO_SCRIPT
#include <QtCore/qvariant.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -96,7 +97,7 @@ public:
protected:
QScriptEngineAgent(QScriptEngineAgentPrivate &dd, QScriptEngine *engine);
- QScriptEngineAgentPrivate *d_ptr;
+ QScopedPointer<QScriptEngineAgentPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptEngineAgent)
diff --git a/src/script/qscriptstring.cpp b/src/script/qscriptstring.cpp
index 69b0796..e7591e1 100644
--- a/src/script/qscriptstring.cpp
+++ b/src/script/qscriptstring.cpp
@@ -54,6 +54,29 @@
QT_BEGIN_NAMESPACE
+/*! \internal */
+struct QScriptStringPrivatePointerHandler
+{
+ static inline void cleanup(QScriptStringPrivate *d)
+ {
+ if (!d || d->ref.deref())
+ return;
+
+ if (d->nameId) {
+ d->engine->uninternString(d);
+ } else {
+ // the engine has already been deleted
+ delete d;
+ }
+ }
+
+ static inline void reset(QScriptStringPrivate *&d, QScriptStringPrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/*!
\since 4.4
\class QScriptString
@@ -108,8 +131,8 @@ QScriptStringPrivate *QScriptStringPrivate::get(const QScriptString &q)
void QScriptStringPrivate::init(QScriptString &q, QScriptStringPrivate *d)
{
Q_ASSERT(q.d_ptr == 0);
- q.d_ptr = d;
- q.d_ptr->ref.ref();
+ q.d_ptr.data_ptr() = d;
+ d->ref.ref();
}
/*!
@@ -124,7 +147,7 @@ QScriptString::QScriptString()
Constructs a new QScriptString that is a copy of \a other.
*/
QScriptString::QScriptString(const QScriptString &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -135,15 +158,6 @@ QScriptString::QScriptString(const QScriptString &other)
*/
QScriptString::~QScriptString()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- if (isValid()) {
- d_ptr->engine->uninternString(d_ptr);
- } else {
- // the engine has already been deleted
- delete d_ptr;
- }
- d_ptr = 0;
- }
}
/*!
@@ -153,15 +167,7 @@ QScriptString &QScriptString::operator=(const QScriptString &other)
{
if (d_ptr == other.d_ptr)
return *this;
- if (d_ptr && !d_ptr->ref.deref()) {
- if (isValid()) {
- d_ptr->engine->uninternString(d_ptr);
- } else {
- // the engine has already been deleted
- delete d_ptr;
- }
- }
- d_ptr = other.d_ptr;
+ d_ptr.reset(other.d_ptr.data());
if (d_ptr)
d_ptr->ref.ref();
return *this;
diff --git a/src/script/qscriptstring.h b/src/script/qscriptstring.h
index d2fecd8..f68be0c 100644
--- a/src/script/qscriptstring.h
+++ b/src/script/qscriptstring.h
@@ -46,6 +46,8 @@
#ifndef QT_NO_SCRIPT
+#include <QtCore/qscopedpointer.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -54,6 +56,7 @@ QT_MODULE(Script)
class QScriptEngine;
class QScriptStringPrivate;
+struct QScriptStringPrivatePointerHandler;
class Q_SCRIPT_EXPORT QScriptString
{
@@ -73,7 +76,7 @@ public:
operator QString() const;
private:
- QScriptStringPrivate *d_ptr;
+ QScopedCustomPointer<QScriptStringPrivate, QScriptStringPrivatePointerHandler> d_ptr;
Q_DECLARE_PRIVATE(QScriptString)
};
diff --git a/src/script/qscriptvalue.cpp b/src/script/qscriptvalue.cpp
index a253985..4282248 100644
--- a/src/script/qscriptvalue.cpp
+++ b/src/script/qscriptvalue.cpp
@@ -57,6 +57,28 @@
QT_BEGIN_NAMESPACE
+/*! \internal
+ */
+struct QScriptValuePrivatePointerHandler
+{
+ static inline void cleanup(QScriptValuePrivate *d)
+ {
+ if (!d || d->ref.deref())
+ return;
+ if (d->engine) {
+ QScriptEnginePrivate::get(d->engine)->unregisterValue(d);
+ } else {
+ delete d;
+ }
+ }
+
+ static inline void reset(QScriptValuePrivate *&d, QScriptValuePrivate *other)
+ {
+ cleanup(d);
+ d = other;
+ }
+};
+
/*!
\since 4.3
\class QScriptValue
@@ -194,14 +216,6 @@ QScriptValue::QScriptValue()
*/
QScriptValue::~QScriptValue()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- if (engine()) {
- QScriptEnginePrivate::get(engine())->unregisterValue(d_ptr);
- } else {
- delete d_ptr;
- }
- d_ptr = 0;
- }
}
/*!
@@ -212,7 +226,7 @@ QScriptValue::~QScriptValue()
the new script value (i.e., the object itself is not copied).
*/
QScriptValue::QScriptValue(const QScriptValue &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -225,13 +239,12 @@ QScriptValue::QScriptValue(const QScriptValue &other)
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, QScriptValue::SpecialValue value)
+ : d_ptr(0)
{
if (engine) {
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
- d_ptr = eng_p->registerValue(QScriptValueImpl(value));
+ d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(value));
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -244,13 +257,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, QScriptValue::SpecialValue val
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, bool val)
+ : d_ptr(0)
{
if (engine) {
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
- d_ptr = eng_p->registerValue(QScriptValueImpl(val));
+ d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val));
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -262,13 +274,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, bool val)
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, int val)
+ : d_ptr(0)
{
if (engine) {
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
- d_ptr = eng_p->registerValue(QScriptValueImpl(val));
+ d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val));
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -280,13 +291,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, int val)
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, uint val)
+ : d_ptr(0)
{
if (engine) {
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
- d_ptr = eng_p->registerValue(QScriptValueImpl(val));
+ d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val));
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -298,13 +308,12 @@ QScriptValue::QScriptValue(QScriptEngine *engine, uint val)
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, qsreal val)
+ : d_ptr(0)
{
if (engine) {
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
- d_ptr = eng_p->registerValue(QScriptValueImpl(val));
+ d_ptr.data_ptr() = eng_p->registerValue(QScriptValueImpl(val));
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -316,15 +325,14 @@ QScriptValue::QScriptValue(QScriptEngine *engine, qsreal val)
registers it with the script \a engine.
*/
QScriptValue::QScriptValue(QScriptEngine *engine, const QString &val)
+ : d_ptr(0)
{
if (engine) {
QScriptValueImpl v;
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
eng_p->newString(&v, val);
- d_ptr = eng_p->registerValue(v);
+ d_ptr.data_ptr() = eng_p->registerValue(v);
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
@@ -338,15 +346,14 @@ QScriptValue::QScriptValue(QScriptEngine *engine, const QString &val)
#ifndef QT_NO_CAST_FROM_ASCII
QScriptValue::QScriptValue(QScriptEngine *engine, const char *val)
+ : d_ptr(0)
{
if (engine) {
QScriptValueImpl v;
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
eng_p->newString(&v, QString::fromAscii(val));
- d_ptr = eng_p->registerValue(v);
+ d_ptr.data_ptr() = eng_p->registerValue(v);
d_ptr->ref.ref();
- } else {
- d_ptr = 0;
}
}
#endif
@@ -464,14 +471,7 @@ QScriptValue &QScriptValue::operator=(const QScriptValue &other)
{
if (d_ptr == other.d_ptr)
return *this;
- if (d_ptr && !d_ptr->ref.deref()) {
- if (engine()) {
- QScriptEnginePrivate::get(engine())->unregisterValue(d_ptr);
- } else {
- delete d_ptr;
- }
- }
- d_ptr = other.d_ptr;
+ d_ptr.reset(other.d_ptr.data());
if (d_ptr)
d_ptr->ref.ref();
return *this;
diff --git a/src/script/qscriptvalue.h b/src/script/qscriptvalue.h
index 306da53..76b1186 100644
--- a/src/script/qscriptvalue.h
+++ b/src/script/qscriptvalue.h
@@ -47,6 +47,7 @@
#ifndef QT_NO_SCRIPT
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -71,6 +72,7 @@ typedef QList<QScriptValue> QScriptValueList;
typedef double qsreal;
class QScriptValuePrivate;
+struct QScriptValuePrivatePointerHandler;
class Q_SCRIPT_EXPORT QScriptValue
{
public:
@@ -216,12 +218,12 @@ public:
private:
// force compile error, prevent QScriptValue(bool) to be called
- inline QScriptValue(void *) { Q_ASSERT(false); }
+ inline QScriptValue(void *);
// force compile error, prevent QScriptValue(QScriptEngine*, bool) to be called
- inline QScriptValue(QScriptEngine *, void *) { Q_ASSERT(false); }
+ inline QScriptValue(QScriptEngine *, void *);
private:
- QScriptValuePrivate *d_ptr;
+ QScopedCustomPointer<QScriptValuePrivate, QScriptValuePrivatePointerHandler> d_ptr;
Q_DECLARE_PRIVATE(QScriptValue)
};
diff --git a/src/script/qscriptvalue_p.h b/src/script/qscriptvalue_p.h
index 8463ed2..6528464 100644
--- a/src/script/qscriptvalue_p.h
+++ b/src/script/qscriptvalue_p.h
@@ -91,7 +91,7 @@ inline QScriptValueImpl QScriptValuePrivate::valueOf(const QScriptValue &value)
inline void QScriptValuePrivate::init(QScriptValue &value, QScriptValuePrivate *p)
{
- value.d_ptr = p;
+ value.d_ptr.data_ptr() = p;
value.d_ptr->ref.ref();
}
diff --git a/src/script/qscriptvalueiterator.cpp b/src/script/qscriptvalueiterator.cpp
index 1a60632..2cf5575 100644
--- a/src/script/qscriptvalueiterator.cpp
+++ b/src/script/qscriptvalueiterator.cpp
@@ -115,12 +115,11 @@ QScriptValueIteratorPrivate::~QScriptValueIteratorPrivate()
first property).
*/
QScriptValueIterator::QScriptValueIterator(const QScriptValue &object)
+ : d_ptr(0)
{
QScriptValueImpl val = QScriptValuePrivate::valueOf(object);
- if (!val.isObject()) {
- d_ptr = 0;
- } else {
- d_ptr = new QScriptValueIteratorPrivate();
+ if (val.isObject()) {
+ d_ptr.reset(new QScriptValueIteratorPrivate());
d_ptr->it = new QScriptValueIteratorImpl(val);
}
}
@@ -130,10 +129,6 @@ QScriptValueIterator::QScriptValueIterator(const QScriptValue &object)
*/
QScriptValueIterator::~QScriptValueIterator()
{
- if (d_ptr) {
- delete d_ptr;
- d_ptr = 0;
- }
}
/*!
@@ -311,13 +306,10 @@ void QScriptValueIterator::remove()
*/
QScriptValueIterator& QScriptValueIterator::operator=(QScriptValue &object)
{
- if (d_ptr) {
- delete d_ptr;
- d_ptr = 0;
- }
+ d_ptr.reset();
QScriptValueImpl val = QScriptValuePrivate::valueOf(object);
if (val.isObject()) {
- d_ptr = new QScriptValueIteratorPrivate();
+ d_ptr.reset(new QScriptValueIteratorPrivate());
d_ptr->it = new QScriptValueIteratorImpl(val);
}
return *this;
diff --git a/src/script/qscriptvalueiterator.h b/src/script/qscriptvalueiterator.h
index 91561e8..082158d 100644
--- a/src/script/qscriptvalueiterator.h
+++ b/src/script/qscriptvalueiterator.h
@@ -46,6 +46,8 @@
#ifndef QT_NO_SCRIPT
+#include <QtCore/qscopedpointer.h>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -84,7 +86,7 @@ public:
QScriptValueIterator& operator=(QScriptValue &value);
private:
- QScriptValueIteratorPrivate *d_ptr;
+ QScopedPointer<QScriptValueIteratorPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptValueIterator)
Q_DISABLE_COPY(QScriptValueIterator)
diff --git a/src/scripttools/debugging/qscriptbreakpointdata.cpp b/src/scripttools/debugging/qscriptbreakpointdata.cpp
index 9762ca4..50e597e 100644
--- a/src/scripttools/debugging/qscriptbreakpointdata.cpp
+++ b/src/scripttools/debugging/qscriptbreakpointdata.cpp
@@ -136,7 +136,6 @@ QScriptBreakpointData::QScriptBreakpointData(const QScriptBreakpointData &other)
*/
QScriptBreakpointData::~QScriptBreakpointData()
{
- delete d_ptr;
}
/*!
@@ -355,7 +354,7 @@ bool QScriptBreakpointData::operator!=(const QScriptBreakpointData &other) const
*/
QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data)
{
- const QScriptBreakpointDataPrivate *d = data.d_ptr;
+ const QScriptBreakpointDataPrivate *d = data.d_ptr.data();
out << d->scriptId;
out << d->fileName;
out << d->lineNumber;
@@ -377,7 +376,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptBreakpointData &data)
*/
QDataStream &operator>>(QDataStream &in, QScriptBreakpointData &data)
{
- QScriptBreakpointDataPrivate *d = data.d_ptr;
+ QScriptBreakpointDataPrivate *d = data.d_ptr.data();
in >> d->scriptId;
in >> d->fileName;
in >> d->lineNumber;
diff --git a/src/scripttools/debugging/qscriptbreakpointdata_p.h b/src/scripttools/debugging/qscriptbreakpointdata_p.h
index c1ff033..6cfceed 100644
--- a/src/scripttools/debugging/qscriptbreakpointdata_p.h
+++ b/src/scripttools/debugging/qscriptbreakpointdata_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
@@ -114,7 +114,7 @@ public:
bool operator!=(const QScriptBreakpointData &other) const;
private:
- QScriptBreakpointDataPrivate *d_ptr;
+ QScopedPointer<QScriptBreakpointDataPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptBreakpointData)
};
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
index 3c29130..46d8497 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp
@@ -385,7 +385,6 @@ QScriptDebuggerBackend::QScriptDebuggerBackend()
QScriptDebuggerBackend::~QScriptDebuggerBackend()
{
detach();
- delete d_ptr;
}
/*!
diff --git a/src/scripttools/debugging/qscriptdebuggerbackend_p.h b/src/scripttools/debugging/qscriptdebuggerbackend_p.h
index 6d593a6..d9ec307 100644
--- a/src/scripttools/debugging/qscriptdebuggerbackend_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerbackend_p.h
@@ -144,7 +144,7 @@ protected:
protected:
QScriptDebuggerBackend(QScriptDebuggerBackendPrivate &dd);
- QScriptDebuggerBackendPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerBackendPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerBackend)
diff --git a/src/scripttools/debugging/qscriptdebuggercommand.cpp b/src/scripttools/debugging/qscriptdebuggercommand.cpp
index c40bfc4..98bb3b3 100644
--- a/src/scripttools/debugging/qscriptdebuggercommand.cpp
+++ b/src/scripttools/debugging/qscriptdebuggercommand.cpp
@@ -118,7 +118,6 @@ QScriptDebuggerCommand::QScriptDebuggerCommand(const QScriptDebuggerCommand &oth
*/
QScriptDebuggerCommand::~QScriptDebuggerCommand()
{
- delete d_ptr;
}
/*!
@@ -646,7 +645,7 @@ QScriptDebuggerCommand QScriptDebuggerCommand::clearExceptionsCommand()
*/
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command)
{
- const QScriptDebuggerCommandPrivate *d = command.d_ptr;
+ const QScriptDebuggerCommandPrivate *d = command.d_ptr.data();
out << (quint32)d->type;
out << (qint32)d->attributes.size();
QHash<QScriptDebuggerCommand::Attribute, QVariant>::const_iterator it;
@@ -666,7 +665,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerCommand &command)
*/
QDataStream &operator>>(QDataStream &in, QScriptDebuggerCommand &command)
{
- QScriptDebuggerCommandPrivate *d = command.d_ptr;
+ QScriptDebuggerCommandPrivate *d = command.d_ptr.data();
quint32 type;
in >> type;
diff --git a/src/scripttools/debugging/qscriptdebuggercommand_p.h b/src/scripttools/debugging/qscriptdebuggercommand_p.h
index 260e3ec..363738f 100644
--- a/src/scripttools/debugging/qscriptdebuggercommand_p.h
+++ b/src/scripttools/debugging/qscriptdebuggercommand_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qhash.h>
#include <QtCore/qvariant.h>
@@ -250,7 +250,7 @@ public:
static QScriptDebuggerCommand clearExceptionsCommand();
private:
- QScriptDebuggerCommandPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerCommandPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerCommand)
};
diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
index 1be8c5f..e75ff99 100644
--- a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
+++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp
@@ -98,7 +98,6 @@ QScriptDebuggerCommandExecutor::QScriptDebuggerCommandExecutor()
QScriptDebuggerCommandExecutor::~QScriptDebuggerCommandExecutor()
{
- delete d_ptr;
}
/*!
diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h b/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h
index 8fff5e5..da7de76 100644
--- a/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h
+++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h
@@ -54,6 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
@@ -74,7 +75,7 @@ public:
protected:
QScriptDebuggerCommandExecutor(QScriptDebuggerCommandExecutorPrivate &dd);
- QScriptDebuggerCommandExecutorPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerCommandExecutorPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerCommandExecutor)
diff --git a/src/scripttools/debugging/qscriptdebuggerconsole.cpp b/src/scripttools/debugging/qscriptdebuggerconsole.cpp
index 70bb8b1..09a32db 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsole.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsole.cpp
@@ -199,7 +199,6 @@ QScriptDebuggerConsole::QScriptDebuggerConsole()
QScriptDebuggerConsole::~QScriptDebuggerConsole()
{
- delete d_ptr;
}
void QScriptDebuggerConsole::loadScriptedCommands(const QString &scriptsPath,
diff --git a/src/scripttools/debugging/qscriptdebuggerconsole_p.h b/src/scripttools/debugging/qscriptdebuggerconsole_p.h
index b5ebf44..a8c4163 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsole_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerconsole_p.h
@@ -54,6 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
#include "qscriptdebuggerconsolehistorianinterface_p.h"
@@ -109,7 +110,7 @@ public:
void bumpSessionId();
private:
- QScriptDebuggerConsolePrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerConsolePrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerConsole)
Q_DISABLE_COPY(QScriptDebuggerConsole)
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp
index 6cbf58c..8e4bc06 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp
@@ -72,7 +72,6 @@ QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand()
QScriptDebuggerConsoleCommand::~QScriptDebuggerConsoleCommand()
{
- delete d_ptr;
}
QScriptDebuggerConsoleCommand::QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd)
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h
index fbf285f..2ce3315 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
@@ -91,7 +91,7 @@ public:
protected:
QScriptDebuggerConsoleCommand(QScriptDebuggerConsoleCommandPrivate &dd);
- QScriptDebuggerConsoleCommandPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerConsoleCommandPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommand)
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp
index 9cfac97..1d43dd0 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp
@@ -90,7 +90,7 @@ QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData(
QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData(
const QScriptDebuggerConsoleCommandGroupData &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -98,22 +98,12 @@ QScriptDebuggerConsoleCommandGroupData::QScriptDebuggerConsoleCommandGroupData(
QScriptDebuggerConsoleCommandGroupData::~QScriptDebuggerConsoleCommandGroupData()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
QScriptDebuggerConsoleCommandGroupData &QScriptDebuggerConsoleCommandGroupData::operator=(
const QScriptDebuggerConsoleCommandGroupData &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
index c32277f..9b0e281 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
@@ -82,7 +82,7 @@ public:
const QScriptDebuggerConsoleCommandGroupData &other);
private:
- QScriptDebuggerConsoleCommandGroupDataPrivate *d_ptr;
+ QScopedSharedPointer<QScriptDebuggerConsoleCommandGroupDataPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommandGroupData)
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp
index ef9687e..f22efc5 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp
@@ -105,7 +105,6 @@ QScriptDebuggerConsoleCommandManager::QScriptDebuggerConsoleCommandManager()
QScriptDebuggerConsoleCommandManager::~QScriptDebuggerConsoleCommandManager()
{
- delete d_ptr;
}
/*!
diff --git a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h
index b5c9842..cebb999 100644
--- a/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qmap.h>
#include <QtCore/qlist.h>
@@ -86,7 +86,7 @@ public:
QStringList completions(const QString &prefix) const;
private:
- QScriptDebuggerConsoleCommandManagerPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerConsoleCommandManagerPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerConsoleCommandManager)
};
diff --git a/src/scripttools/debugging/qscriptdebuggerevent.cpp b/src/scripttools/debugging/qscriptdebuggerevent.cpp
index 9d971a9..418e8fa 100644
--- a/src/scripttools/debugging/qscriptdebuggerevent.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerevent.cpp
@@ -97,7 +97,6 @@ QScriptDebuggerEvent::QScriptDebuggerEvent(const QScriptDebuggerEvent &other)
QScriptDebuggerEvent::~QScriptDebuggerEvent()
{
- delete d_ptr;
}
QScriptDebuggerEvent &QScriptDebuggerEvent::operator=(const QScriptDebuggerEvent &other)
@@ -276,7 +275,7 @@ bool QScriptDebuggerEvent::operator!=(const QScriptDebuggerEvent &other) const
*/
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerEvent &event)
{
- const QScriptDebuggerEventPrivate *d = event.d_ptr;
+ const QScriptDebuggerEventPrivate *d = event.d_ptr.data();
out << (quint32)d->type;
out << (qint32)d->attributes.size();
QHash<QScriptDebuggerEvent::Attribute, QVariant>::const_iterator it;
@@ -296,7 +295,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerEvent &event)
*/
QDataStream &operator>>(QDataStream &in, QScriptDebuggerEvent &event)
{
- QScriptDebuggerEventPrivate *d = event.d_ptr;
+ QScriptDebuggerEventPrivate *d = event.d_ptr.data();
quint32 type;
in >> type;
diff --git a/src/scripttools/debugging/qscriptdebuggerevent_p.h b/src/scripttools/debugging/qscriptdebuggerevent_p.h
index d9c073c..0cfde4f 100644
--- a/src/scripttools/debugging/qscriptdebuggerevent_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerevent_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qhash.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
@@ -137,7 +138,7 @@ public:
bool operator!=(const QScriptDebuggerEvent &other) const;
private:
- QScriptDebuggerEventPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerEventPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerEvent)
};
diff --git a/src/scripttools/debugging/qscriptdebuggerfrontend.cpp b/src/scripttools/debugging/qscriptdebuggerfrontend.cpp
index ced20b1..4d0a8b4 100644
--- a/src/scripttools/debugging/qscriptdebuggerfrontend.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerfrontend.cpp
@@ -143,7 +143,6 @@ QScriptDebuggerFrontend::QScriptDebuggerFrontend()
QScriptDebuggerFrontend::~QScriptDebuggerFrontend()
{
- delete d_ptr;
}
QScriptDebuggerFrontend::QScriptDebuggerFrontend(QScriptDebuggerFrontendPrivate &dd)
diff --git a/src/scripttools/debugging/qscriptdebuggerfrontend_p.h b/src/scripttools/debugging/qscriptdebuggerfrontend_p.h
index a763463..bed0f85 100644
--- a/src/scripttools/debugging/qscriptdebuggerfrontend_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerfrontend_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qstring.h>
#include "qscriptdebuggercommandschedulerinterface_p.h"
@@ -90,7 +90,7 @@ protected:
protected:
QScriptDebuggerFrontend(QScriptDebuggerFrontendPrivate &dd);
- QScriptDebuggerFrontendPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerFrontendPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerFrontend)
diff --git a/src/scripttools/debugging/qscriptdebuggerjob.cpp b/src/scripttools/debugging/qscriptdebuggerjob.cpp
index 109c805..20d17bb 100644
--- a/src/scripttools/debugging/qscriptdebuggerjob.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerjob.cpp
@@ -85,7 +85,6 @@ QScriptDebuggerJob::QScriptDebuggerJob(QScriptDebuggerJobPrivate &dd)
QScriptDebuggerJob::~QScriptDebuggerJob()
{
- delete d_ptr;
}
void QScriptDebuggerJob::finish()
diff --git a/src/scripttools/debugging/qscriptdebuggerjob_p.h b/src/scripttools/debugging/qscriptdebuggerjob_p.h
index e84d6d5..2f7305f 100644
--- a/src/scripttools/debugging/qscriptdebuggerjob_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerjob_p.h
@@ -54,6 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
@@ -76,7 +77,7 @@ public:
protected:
QScriptDebuggerJob(QScriptDebuggerJobPrivate &dd);
- QScriptDebuggerJobPrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerJobPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptDebuggerJob)
diff --git a/src/scripttools/debugging/qscriptdebuggerresponse.cpp b/src/scripttools/debugging/qscriptdebuggerresponse.cpp
index 82bfff2..bf24846 100644
--- a/src/scripttools/debugging/qscriptdebuggerresponse.cpp
+++ b/src/scripttools/debugging/qscriptdebuggerresponse.cpp
@@ -101,7 +101,6 @@ QScriptDebuggerResponse::QScriptDebuggerResponse(const QScriptDebuggerResponse &
QScriptDebuggerResponse::~QScriptDebuggerResponse()
{
- delete d_ptr;
}
QScriptDebuggerResponse &QScriptDebuggerResponse::operator=(const QScriptDebuggerResponse &other)
@@ -320,7 +319,7 @@ bool QScriptDebuggerResponse::operator!=(const QScriptDebuggerResponse &other) c
*/
QDataStream &operator<<(QDataStream &out, const QScriptDebuggerResponse &response)
{
- const QScriptDebuggerResponsePrivate *d = response.d_ptr;
+ const QScriptDebuggerResponsePrivate *d = response.d_ptr.data();
out << (quint32)d->error;
out << d->result;
out << d->async;
@@ -336,7 +335,7 @@ QDataStream &operator<<(QDataStream &out, const QScriptDebuggerResponse &respons
*/
QDataStream &operator>>(QDataStream &in, QScriptDebuggerResponse &response)
{
- QScriptDebuggerResponsePrivate *d = response.d_ptr;
+ QScriptDebuggerResponsePrivate *d = response.d_ptr.data();
quint32 error;
in >> error;
diff --git a/src/scripttools/debugging/qscriptdebuggerresponse_p.h b/src/scripttools/debugging/qscriptdebuggerresponse_p.h
index dd65ffd..4fa1731 100644
--- a/src/scripttools/debugging/qscriptdebuggerresponse_p.h
+++ b/src/scripttools/debugging/qscriptdebuggerresponse_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qmap.h>
#include <QtCore/qvariant.h>
@@ -127,7 +127,7 @@ public:
bool operator!=(const QScriptDebuggerResponse &other) const;
private:
- QScriptDebuggerResponsePrivate *d_ptr;
+ QScopedPointer<QScriptDebuggerResponsePrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerResponse)
};
diff --git a/src/scripttools/debugging/qscriptdebuggervalue.cpp b/src/scripttools/debugging/qscriptdebuggervalue.cpp
index bb41ee8..b92cbd2 100644
--- a/src/scripttools/debugging/qscriptdebuggervalue.cpp
+++ b/src/scripttools/debugging/qscriptdebuggervalue.cpp
@@ -94,7 +94,7 @@ QScriptDebuggerValue::QScriptDebuggerValue(const QScriptValue &value)
: d_ptr(0)
{
if (value.isValid()) {
- d_ptr = new QScriptDebuggerValuePrivate;
+ d_ptr.reset(new QScriptDebuggerValuePrivate);
if (value.isUndefined())
d_ptr->type = UndefinedValue;
else if (value.isNull())
@@ -157,7 +157,7 @@ QScriptDebuggerValue::QScriptDebuggerValue(ValueType type)
}
QScriptDebuggerValue::QScriptDebuggerValue(const QScriptDebuggerValue &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -165,21 +165,11 @@ QScriptDebuggerValue::QScriptDebuggerValue(const QScriptDebuggerValue &other)
QScriptDebuggerValue::~QScriptDebuggerValue()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
QScriptDebuggerValue &QScriptDebuggerValue::operator=(const QScriptDebuggerValue &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
diff --git a/src/scripttools/debugging/qscriptdebuggervalue_p.h b/src/scripttools/debugging/qscriptdebuggervalue_p.h
index 0142de0..c082bf3 100644
--- a/src/scripttools/debugging/qscriptdebuggervalue_p.h
+++ b/src/scripttools/debugging/qscriptdebuggervalue_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qlist.h>
QT_BEGIN_NAMESPACE
@@ -103,7 +103,7 @@ public:
bool operator!=(const QScriptDebuggerValue &other) const;
private:
- QScriptDebuggerValuePrivate *d_ptr;
+ QScopedSharedPointer<QScriptDebuggerValuePrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerValue)
};
diff --git a/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp b/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp
index 723e304..63f820b 100644
--- a/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp
+++ b/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp
@@ -105,7 +105,7 @@ QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QString &name,
Constructs a QScriptDebuggerValueProperty that is a copy of the \a other property.
*/
QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebuggerValueProperty &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -116,10 +116,6 @@ QScriptDebuggerValueProperty::QScriptDebuggerValueProperty(const QScriptDebugger
*/
QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
/*!
@@ -127,13 +123,7 @@ QScriptDebuggerValueProperty::~QScriptDebuggerValueProperty()
*/
QScriptDebuggerValueProperty &QScriptDebuggerValueProperty::operator=(const QScriptDebuggerValueProperty &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
diff --git a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
index f67bafd..be27ebd 100644
--- a/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
+++ b/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h
@@ -55,6 +55,7 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_NAMESPACE
@@ -85,7 +86,7 @@ public:
bool isValid() const;
private:
- QScriptDebuggerValuePropertyPrivate *d_ptr;
+ QScopedSharedPointer<QScriptDebuggerValuePropertyPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptDebuggerValueProperty)
};
diff --git a/src/scripttools/debugging/qscriptenginedebugger.cpp b/src/scripttools/debugging/qscriptenginedebugger.cpp
index e35bd1d..0f8b600 100644
--- a/src/scripttools/debugging/qscriptenginedebugger.cpp
+++ b/src/scripttools/debugging/qscriptenginedebugger.cpp
@@ -63,16 +63,23 @@
#include <QtGui/qtoolbar.h>
#include <QtGui/qboxlayout.h>
+// this has to be outside the namespace
+static void initScriptEngineDebuggerResources()
+{
+ Q_INIT_RESOURCE(scripttools_debugging);
+}
+
+QT_BEGIN_NAMESPACE
+
class QtScriptDebuggerResourceInitializer
{
public:
QtScriptDebuggerResourceInitializer() {
- Q_INIT_RESOURCE(scripttools_debugging);
+ // call outside-the-namespace function
+ initScriptEngineDebuggerResources();
}
};
-QT_BEGIN_NAMESPACE
-
/*!
\since 4.5
\class QScriptEngineDebugger
diff --git a/src/scripttools/debugging/qscriptscriptdata.cpp b/src/scripttools/debugging/qscriptscriptdata.cpp
index 068748f..a4f8cd7 100644
--- a/src/scripttools/debugging/qscriptscriptdata.cpp
+++ b/src/scripttools/debugging/qscriptscriptdata.cpp
@@ -98,7 +98,7 @@ QScriptScriptData::QScriptScriptData(const QString &contents, const QString &fil
}
QScriptScriptData::QScriptScriptData(const QScriptScriptData &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -106,21 +106,11 @@ QScriptScriptData::QScriptScriptData(const QScriptScriptData &other)
QScriptScriptData::~QScriptScriptData()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
QScriptScriptData &QScriptScriptData::operator=(const QScriptScriptData &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
@@ -191,7 +181,7 @@ bool QScriptScriptData::operator!=(const QScriptScriptData &other) const
QDataStream &operator<<(QDataStream &out, const QScriptScriptData &data)
{
- const QScriptScriptDataPrivate *d = data.d_ptr;
+ const QScriptScriptDataPrivate *d = data.d_ptr.data();
if (d) {
out << d->contents;
out << d->fileName;
@@ -207,10 +197,10 @@ QDataStream &operator<<(QDataStream &out, const QScriptScriptData &data)
QDataStream &operator>>(QDataStream &in, QScriptScriptData &data)
{
if (!data.d_ptr) {
- data.d_ptr = new QScriptScriptDataPrivate();
+ data.d_ptr.reset(new QScriptScriptDataPrivate());
data.d_ptr->ref.ref();
}
- QScriptScriptDataPrivate *d = data.d_ptr;
+ QScriptScriptDataPrivate *d = data.d_ptr.data();
in >> d->contents;
in >> d->fileName;
qint32 ln;
diff --git a/src/scripttools/debugging/qscriptscriptdata_p.h b/src/scripttools/debugging/qscriptscriptdata_p.h
index 50cad32..e871c2c 100644
--- a/src/scripttools/debugging/qscriptscriptdata_p.h
+++ b/src/scripttools/debugging/qscriptscriptdata_p.h
@@ -54,7 +54,7 @@
//
#include <QtCore/qobjectdefs.h>
-
+#include <QtCore/qscopedpointer.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qmap.h>
@@ -91,7 +91,7 @@ public:
bool operator!=(const QScriptScriptData &other) const;
private:
- QScriptScriptDataPrivate *d_ptr;
+ QScopedSharedPointer<QScriptScriptDataPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptScriptData)
};
diff --git a/src/scripttools/debugging/qscriptstdmessagehandler.cpp b/src/scripttools/debugging/qscriptstdmessagehandler.cpp
index 4e0f12c..6742554 100644
--- a/src/scripttools/debugging/qscriptstdmessagehandler.cpp
+++ b/src/scripttools/debugging/qscriptstdmessagehandler.cpp
@@ -66,7 +66,6 @@ QScriptStdMessageHandler::QScriptStdMessageHandler()
QScriptStdMessageHandler::~QScriptStdMessageHandler()
{
- delete d_ptr;
}
void QScriptStdMessageHandler::message(QtMsgType type, const QString &text,
diff --git a/src/scripttools/debugging/qscriptstdmessagehandler_p.h b/src/scripttools/debugging/qscriptstdmessagehandler_p.h
index 8b75f6a..06d680b 100644
--- a/src/scripttools/debugging/qscriptstdmessagehandler_p.h
+++ b/src/scripttools/debugging/qscriptstdmessagehandler_p.h
@@ -53,6 +53,8 @@
// We mean it.
//
+#include <QtCore/qscopedpointer.h>
+
#include "qscriptmessagehandlerinterface_p.h"
QT_BEGIN_NAMESPACE
@@ -71,7 +73,7 @@ public:
const QVariant &data = QVariant());
private:
- QScriptStdMessageHandlerPrivate *d_ptr;
+ QScopedPointer<QScriptStdMessageHandlerPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(QScriptStdMessageHandler)
diff --git a/src/scripttools/debugging/qscriptvalueproperty.cpp b/src/scripttools/debugging/qscriptvalueproperty.cpp
index 245edc3..75cfdd7 100644
--- a/src/scripttools/debugging/qscriptvalueproperty.cpp
+++ b/src/scripttools/debugging/qscriptvalueproperty.cpp
@@ -95,7 +95,7 @@ QScriptValueProperty::QScriptValueProperty(const QString &name,
Constructs a QScriptValueProperty that is a copy of the \a other property.
*/
QScriptValueProperty::QScriptValueProperty(const QScriptValueProperty &other)
- : d_ptr(other.d_ptr)
+ : d_ptr(other.d_ptr.data())
{
if (d_ptr)
d_ptr->ref.ref();
@@ -106,10 +106,6 @@ QScriptValueProperty::QScriptValueProperty(const QScriptValueProperty &other)
*/
QScriptValueProperty::~QScriptValueProperty()
{
- if (d_ptr && !d_ptr->ref.deref()) {
- delete d_ptr;
- d_ptr = 0;
- }
}
/*!
@@ -117,13 +113,7 @@ QScriptValueProperty::~QScriptValueProperty()
*/
QScriptValueProperty &QScriptValueProperty::operator=(const QScriptValueProperty &other)
{
- if (d_ptr == other.d_ptr)
- return *this;
- if (d_ptr && !d_ptr->ref.deref())
- delete d_ptr;
- d_ptr = other.d_ptr;
- if (d_ptr)
- d_ptr->ref.ref();
+ d_ptr.assign(other.d_ptr.data());
return *this;
}
diff --git a/src/scripttools/debugging/qscriptvalueproperty_p.h b/src/scripttools/debugging/qscriptvalueproperty_p.h
index 938ab83..ca6980f 100644
--- a/src/scripttools/debugging/qscriptvalueproperty_p.h
+++ b/src/scripttools/debugging/qscriptvalueproperty_p.h
@@ -55,6 +55,7 @@
#include <QtCore/qobjectdefs.h>
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_NAMESPACE
@@ -81,7 +82,7 @@ public:
bool isValid() const;
private:
- QScriptValuePropertyPrivate *d_ptr;
+ QScopedSharedPointer<QScriptValuePropertyPrivate> d_ptr;
Q_DECLARE_PRIVATE(QScriptValueProperty)
};
diff --git a/src/scripttools/scripttools.pro b/src/scripttools/scripttools.pro
index faf0936a..5878db2 100644
--- a/src/scripttools/scripttools.pro
+++ b/src/scripttools/scripttools.pro
@@ -10,3 +10,5 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui QtScript
include(../qbase.pri)
include(debugging/debugging.pri)
+
+symbian:TARGET.UID3=0x2001E625
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 4f3d79d..1645555 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -55,6 +55,7 @@
#include <limits.h>
#include <math.h>
#include <qdebug.h>
+#include <QVarLengthArray>
QT_BEGIN_NAMESPACE
@@ -583,7 +584,7 @@ QVariant QIBaseResultPrivate::fetchArray(int pos, ISC_QUAD *arr)
int arraySize = 1, subArraySize;
short dimensions = desc.array_desc_dimensions;
- short *numElements = new short[dimensions];
+ QVarLengthArray<short> numElements(dimensions);
for(int i = 0; i < dimensions; ++i) {
subArraySize = (desc.array_desc_bounds[i].array_bound_upper -
@@ -612,9 +613,7 @@ QVariant QIBaseResultPrivate::fetchArray(int pos, ISC_QUAD *arr)
QSqlError::StatementError))
return list;
- readArrayBuffer(list, ba.data(), 0, numElements, &desc, tc);
-
- delete[] numElements;
+ readArrayBuffer(list, ba.data(), 0, numElements.data(), &desc, tc);
return QVariant(list);
}
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index fbefa0c..53645c9 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -927,6 +927,7 @@ bool QMYSQLResult::exec()
nullVector[i] = static_cast<my_bool>(val.isNull());
currBind->is_null = &nullVector[i];
currBind->length = 0;
+ currBind->is_unsigned = 0;
switch (val.type()) {
case QVariant::ByteArray:
@@ -973,7 +974,6 @@ bool QMYSQLResult::exec()
currBind->buffer_type = MYSQL_TYPE_DOUBLE;
currBind->buffer = data;
currBind->buffer_length = sizeof(double);
- currBind->is_unsigned = 0;
break;
case QVariant::LongLong:
case QVariant::ULongLong:
@@ -989,7 +989,6 @@ bool QMYSQLResult::exec()
currBind->buffer_type = MYSQL_TYPE_STRING;
currBind->buffer = const_cast<char *>(ba.constData());
currBind->buffer_length = ba.length();
- currBind->is_unsigned = 0;
break; }
}
}
@@ -1279,6 +1278,11 @@ bool QMYSQLDriver::open(const QString& db,
d->preparedQuerysEnabled = false;
#endif
+#ifndef QT_NO_THREAD
+ mysql_thread_init();
+#endif
+
+
setOpen(true);
setOpenError(false);
return true;
@@ -1287,6 +1291,9 @@ bool QMYSQLDriver::open(const QString& db,
void QMYSQLDriver::close()
{
if (isOpen()) {
+#ifndef QT_NO_THREAD
+ mysql_thread_end();
+#endif
mysql_close(d->mysql);
d->mysql = NULL;
setOpen(false);
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index d63c482..a7031b1 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -1789,7 +1789,7 @@ bool QOCIResult::prepare(const QString& query)
bool QOCIResult::exec()
{
int r = 0;
- ub2 stmtType;
+ ub2 stmtType=0;
ub4 iters;
ub4 mode;
QList<QByteArray> tmpStorage;
@@ -1803,6 +1803,16 @@ bool QOCIResult::exec()
OCI_ATTR_STMT_TYPE,
d->err);
+ if (r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO) {
+ qOraWarning("QOCIResult::exec: Unable to get statement type:", d->err);
+ setLastError(qMakeError(QCoreApplication::translate("QOCIResult",
+ "Unable to get statement type"), QSqlError::StatementError, d->err));
+#ifdef QOCI_DEBUG
+ qDebug() << "lastQuery()" << lastQuery();
+#endif
+ return false;
+ }
+
if (stmtType == OCI_STMT_SELECT) {
iters = 0;
mode = OCI_DEFAULT;
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index e6729a5..2a07e28 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -1195,7 +1195,7 @@ void QSqlQuery::finish()
The query will be repositioned on an \e invalid record in the new
result set and must be navigated to a valid record before data
values can be retrieved. If a new result set isn't available the
- function returns false and the the query is set to inactive. In any
+ function returns false and the query is set to inactive. In any
case the old result set will be discarded.
When one of the statements is a non-select statement a count of
diff --git a/src/src.pro b/src/src.pro
index 3e63e6e..f131e4f 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -23,6 +23,9 @@ win32:{
!wince*: SRC_SUBDIRS += src_tools_idc
}
+# TODO the following line should be between opengl and webkit when the 'symbian' block is removed
+contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon
+
!symbian {
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl
contains(QT_CONFIG, xmlpatterns): SRC_SUBDIRS += src_xmlpatterns
@@ -35,8 +38,6 @@ contains(QT_CONFIG, scripttools): SRC_SUBDIRS += src_scripttools
SRC_SUBDIRS += src_plugins
}
-contains(QT_CONFIG, phonon): SRC_SUBDIRS += src_phonon
-
src_s60main.subdir = $$QT_SOURCE_TREE/src/s60main
src_s60main.target = sub-s60main
src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain
diff --git a/src/svg/qgraphicssvgitem.h b/src/svg/qgraphicssvgitem.h
index c6ab0f7..940ce9b 100644
--- a/src/svg/qgraphicssvgitem.h
+++ b/src/svg/qgraphicssvgitem.h
@@ -41,8 +41,8 @@
#ifndef QGRAPHICSSVGITEM_H
#define QGRAPHICSSVGITEM_H
-#include <QtGui/qgraphicsitem.h>
#include <QtCore/qobject.h>
+#include <QtGui/qgraphicsitem.h>
#ifndef QT_NO_GRAPHICSSVGITEM
@@ -89,9 +89,9 @@ private:
// Q_DECLARE_PRIVATE_WITH_BASE(QGraphicsSvgItem, QObject)
inline QGraphicsSvgItemPrivate *d_func()
- { return reinterpret_cast<QGraphicsSvgItemPrivate *>(QObject::d_ptr); }
+ { return reinterpret_cast<QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); }
inline const QGraphicsSvgItemPrivate *d_func() const
- { return reinterpret_cast<const QGraphicsSvgItemPrivate *>(QObject::d_ptr); }
+ { return reinterpret_cast<const QGraphicsSvgItemPrivate *>(QObject::d_ptr.data()); }
friend class QGraphicsSvgItemPrivate;
Q_PRIVATE_SLOT(d_func(), void _q_repaintItem())
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index e822da5..5052ec7 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -261,7 +261,7 @@ public:
constantAlpha &= (stops.at(i).second.alpha() == alpha);
if (!constantAlpha) {
- const qreal spacing = 0.02;
+ const qreal spacing = qreal(0.02);
QGradientStops newStops;
QRgb fromColor = PREMUL(stops.at(0).second.rgba());
QRgb toColor;
@@ -567,7 +567,6 @@ QSvgGenerator::~QSvgGenerator()
if (d->owns_iodevice)
delete d->engine->outputDevice();
delete d->engine;
- delete d_ptr;
}
/*!
diff --git a/src/svg/qsvggenerator.h b/src/svg/qsvggenerator.h
index 723a220..1d24324 100644
--- a/src/svg/qsvggenerator.h
+++ b/src/svg/qsvggenerator.h
@@ -49,6 +49,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qobjectdefs.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -100,7 +101,7 @@ protected:
int metric(QPaintDevice::PaintDeviceMetric metric) const;
private:
- QSvgGeneratorPrivate *d_ptr;
+ QScopedPointer<QSvgGeneratorPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/testlib/3rdparty/cycle_p.h b/src/testlib/3rdparty/cycle_p.h
index 547fdc1..a292423 100644
--- a/src/testlib/3rdparty/cycle_p.h
+++ b/src/testlib/3rdparty/cycle_p.h
@@ -190,6 +190,7 @@ INLINE_ELAPSED(__inline__)
#endif
/* Visual C++ -- thanks to Morten Nissov for his help with this */
+#if defined(_MSC_VER)
#if _MSC_VER >= 1200 && (_M_IX86 >= 500 || (defined(_WIN32_WCE) && defined(_X86_))) && !defined(HAVE_TICK_COUNTER)
#include <windows.h>
typedef LARGE_INTEGER CycleCounterTicks;
@@ -215,6 +216,7 @@ static __inline double elapsed(CycleCounterTicks t1, CycleCounterTicks t0)
#define HAVE_TICK_COUNTER
#define TIME_MIN 5000.0 /* unreliable pentium IV cycle counter */
#endif
+#endif
#if _MSC_VER >= 1400 && defined(_WIN32_WCE) && !defined(HAVE_TICK_COUNTER)
#include <windows.h>
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 6ea38f7..15319ce 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -226,10 +226,17 @@ int main(int argc, char *argv[]) \
#include <QtTest/qtest_gui.h>
+#ifdef QT_KEYPAD_NAVIGATION
+# define QTEST_DISABLE_KEYPAD_NAVIGATION QApplication::setKeypadNavigationEnabled(false);
+#else
+# define QTEST_DISABLE_KEYPAD_NAVIGATION
+#endif
+
#define QTEST_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
QApplication app(argc, argv); \
+ QTEST_DISABLE_KEYPAD_NAVIGATION \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 27ba6da..38e63cf 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -300,10 +300,15 @@ QT_BEGIN_NAMESPACE
the \a TestClass, and executes all tests in the order they were defined.
Use this macro to build stand-alone executables.
+ \bold {Note:} On platforms that have keypad navigation enabled by default (eg: Symbian),
+ this macro will forcfully disable it to simplify the usage of key events when writing
+ autotests. If you wish to write a test case that uses keypad navigation, you should
+ enable it either in the \c {initTestCase()} or \c {init()} functions of your test case.
+
Example:
\snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 11
- \sa QTEST_APPLESS_MAIN(), QTest::qExec()
+ \sa QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setKeypadNavigationEnabled()
*/
/*! \macro QTEST_APPLESS_MAIN(TestClass)
@@ -1432,7 +1437,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
}
#endif
- #ifndef QT_NO_EXCEPTIONS
+#ifndef QT_NO_EXCEPTIONS
} catch (...) {
QTestResult::addFailure("Caught unhandled exception", __FILE__, __LINE__);
if (QTestResult::currentTestFunction()) {
@@ -1446,13 +1451,13 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
IOPMAssertionRelease(powerID);
}
#endif
- #ifdef Q_OS_WIN
+//# ifdef Q_OS_WIN
// rethrow exception to make debugging easier
throw;
- #endif
- return -1;
+//# endif
+ return 1;
}
- #endif
+# endif
currentTestObject = 0;
#ifdef QT_MAC_USE_COCOA
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 550abc9..5e2c74b 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -512,8 +512,8 @@ public:
bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn);
// Attributes
- QDomDocumentTypePrivate* doctype() { return type; };
- QDomImplementationPrivate* implementation() { return impl; };
+ QDomDocumentTypePrivate* doctype() { return type.data(); };
+ QDomImplementationPrivate* implementation() { return impl.data(); };
QDomElementPrivate* documentElement();
// Factories
@@ -537,8 +537,8 @@ public:
void clear();
// Variables
- QDomImplementationPrivate* impl;
- QDomDocumentTypePrivate* type;
+ QScopedSharedPointer<QDomImplementationPrivate> impl;
+ QScopedSharedPointer<QDomDocumentTypePrivate> type;
void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const;
@@ -3060,7 +3060,7 @@ QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
{
- QDomNamedNodeMapPrivate* m = new QDomNamedNodeMapPrivate(p);
+ QScopedPointer<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));
m->readonly = readonly;
m->appendToParent = appendToParent;
@@ -3073,7 +3073,7 @@ QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)
// we are no longer interested in ownership
m->ref.deref();
- return m;
+ return m.take();
}
void QDomNamedNodeMapPrivate::clearMap()
@@ -3499,13 +3499,18 @@ QDomDocumentTypePrivate::~QDomDocumentTypePrivate()
void QDomDocumentTypePrivate::init()
{
entities = new QDomNamedNodeMapPrivate(this);
- notations = new QDomNamedNodeMapPrivate(this);
- publicId.clear();
- systemId.clear();
- internalSubset.clear();
-
- entities->setAppendToParent(true);
- notations->setAppendToParent(true);
+ QT_TRY {
+ notations = new QDomNamedNodeMapPrivate(this);
+ publicId.clear();
+ systemId.clear();
+ internalSubset.clear();
+
+ entities->setAppendToParent(true);
+ notations->setAppendToParent(true);
+ } QT_CATCH(...) {
+ delete entities;
+ QT_RETHROW;
+ }
}
QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(bool deep)
@@ -6148,8 +6153,8 @@ QDomDocumentPrivate::QDomDocumentPrivate()
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
name = QLatin1String("#document");
}
@@ -6158,8 +6163,8 @@ QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname)
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
type->name = aname;
name = QLatin1String("#document");
@@ -6169,12 +6174,11 @@ QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
: QDomNodePrivate(0),
nodeListTime(1)
{
- impl = new QDomImplementationPrivate;
+ impl.reset(new QDomImplementationPrivate);
if (dt != 0) {
- type = dt;
- type->ref.ref();
+ type.assign(dt);
} else {
- type = new QDomDocumentTypePrivate(this, this);
+ type.reset(new QDomDocumentTypePrivate(this, this));
}
name = QLatin1String("#document");
@@ -6184,31 +6188,19 @@ QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep)
: QDomNodePrivate(n, deep),
nodeListTime(1)
{
- impl = n->impl->clone();
- // Reference count is down to 0, so we set it to 1 here.
- impl->ref.ref();
- type = (QDomDocumentTypePrivate*)n->type->cloneNode();
+ impl.assign(n->impl->clone());
+ type.assign((QDomDocumentTypePrivate*)n->type->cloneNode());
type->setParent(this);
- // Reference count is down to 0, so we set it to 1 here.
- type->ref.ref();
}
QDomDocumentPrivate::~QDomDocumentPrivate()
{
- if (!impl->ref.deref())
- delete impl;
- if (!type->ref.deref())
- delete type;
}
void QDomDocumentPrivate::clear()
{
- if (!impl->ref.deref())
- delete impl;
- if (!type->ref.deref())
- delete type;
- impl = 0;
- type = 0;
+ impl.assign(0);
+ type.assign(0);
QDomNodePrivate::clear();
}
@@ -6229,8 +6221,8 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProc
bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn)
{
clear();
- impl = new QDomImplementationPrivate;
- type = new QDomDocumentTypePrivate(this, this);
+ impl.reset(new QDomImplementationPrivate);
+ type.reset(new QDomDocumentTypePrivate(this, this));
bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))
&& !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));
@@ -7448,20 +7440,22 @@ bool QDomHandler::characters(const QString& ch)
if (node == doc)
return false;
- QDomNodePrivate *n;
+ QScopedPointer<QDomNodePrivate> n;
if (cdata) {
- n = doc->createCDATASection(ch);
+ n.reset(doc->createCDATASection(ch));
} else if (!entityName.isEmpty()) {
- QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, entityName,
- QString(), QString(), QString());
+ QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,
+ QString(), QString(), QString()));
e->value = ch;
- doc->doctype()->appendChild(e);
- n = doc->createEntityReference(entityName);
+ doc->doctype()->appendChild(e.data());
+ e.take();
+ n.reset(doc->createEntityReference(entityName));
} else {
- n = doc->createTextNode(ch);
+ n.reset(doc->createTextNode(ch));
}
n->setLocation(locator->lineNumber(), locator->columnNumber());
- node->appendChild(n);
+ node->appendChild(n.data());
+ n.take();
return true;
}
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index b94d3fa..1655642 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -262,10 +262,11 @@ class QXmlDefaultHandlerPrivate
class QXmlSimpleReaderPrivate
{
+public:
+ ~QXmlSimpleReaderPrivate();
private:
// functions
- QXmlSimpleReaderPrivate();
- ~QXmlSimpleReaderPrivate();
+ QXmlSimpleReaderPrivate(QXmlSimpleReader *reader);
void initIncrementalParsing();
// used to determine if elements are correctly nested
@@ -350,7 +351,7 @@ private:
bool contentCharDataRead;
// helper classes
- QXmlLocator *locator;
+ QScopedPointer<QXmlLocator> locator;
QXmlNamespaceSupport namespaceSupport;
// error string
@@ -545,8 +546,8 @@ private:
QXmlParseException::QXmlParseException(const QString& name, int c, int l,
const QString& p, const QString& s)
+ : d(new QXmlParseExceptionPrivate)
{
- d = new QXmlParseExceptionPrivate;
d->msg = name;
d->column = c;
d->line = l;
@@ -559,7 +560,6 @@ QXmlParseException::QXmlParseException(const QString& name, int c, int l,
*/
QXmlParseException::~QXmlParseException()
{
- delete d;
}
/*!
@@ -928,8 +928,9 @@ void QXmlNamespaceSupport::popContext()
*/
void QXmlNamespaceSupport::reset()
{
+ QXmlNamespaceSupportPrivate *newD = new QXmlNamespaceSupportPrivate;
delete d;
- d = new QXmlNamespaceSupportPrivate;
+ d = newD;
}
@@ -1260,18 +1261,23 @@ void QXmlInputSource::init()
{
d = new QXmlInputSourcePrivate;
- d->inputDevice = 0;
- d->inputStream = 0;
+ QT_TRY {
+ d->inputDevice = 0;
+ d->inputStream = 0;
- setData(QString());
+ setData(QString());
#ifndef QT_NO_TEXTCODEC
- d->encMapper = 0;
+ d->encMapper = 0;
#endif
- d->nextReturnedEndOfData = true; // first call to next() will call fetchData()
+ d->nextReturnedEndOfData = true; // first call to next() will call fetchData()
- d->encodingDeclBytes.clear();
- d->encodingDeclChars.clear();
- d->lookingForEncodingDecl = true;
+ d->encodingDeclBytes.clear();
+ d->encodingDeclChars.clear();
+ d->lookingForEncodingDecl = true;
+ } QT_CATCH(...) {
+ delete(d);
+ QT_RETHROW;
+ }
}
/*!
@@ -2109,7 +2115,7 @@ events are reported.
You can set the lexical handler with
QXmlReader::setLexicalHandler().
- This interface's design is based on the the SAX2 extension
+ This interface's design is based on the SAX2 extension
LexicalHandler.
The interface provides the startDTD(), endDTD(), startEntity(),
@@ -2715,9 +2721,24 @@ inline void QXmlSimpleReaderPrivate::refClear()
refValueLen = 0; refArrayPos = 0;
}
-QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate()
+QXmlSimpleReaderPrivate::QXmlSimpleReaderPrivate(QXmlSimpleReader *reader)
{
+ q_ptr = reader;
parseStack = 0;
+
+ locator.reset(new QXmlSimpleReaderLocator(reader));
+ entityRes = 0;
+ dtdHnd = 0;
+ contentHnd = 0;
+ errorHnd = 0;
+ lexicalHnd = 0;
+ declHnd = 0;
+
+ // default feature settings
+ useNamespaces = true;
+ useNamespacePrefixes = false;
+ reportWhitespaceCharData = true;
+ reportEntities = false;
}
QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()
@@ -2727,8 +2748,10 @@ QXmlSimpleReaderPrivate::~QXmlSimpleReaderPrivate()
void QXmlSimpleReaderPrivate::initIncrementalParsing()
{
- delete parseStack;
- parseStack = new QStack<ParseState>;
+ if( parseStack )
+ parseStack->clear();
+ else
+ parseStack = new QStack<ParseState>;
}
/*********************************************
@@ -3101,25 +3124,8 @@ static NameChar determineNameChar(QChar ch)
*/
QXmlSimpleReader::QXmlSimpleReader()
+ : d_ptr(new QXmlSimpleReaderPrivate(this))
{
- d_ptr = new QXmlSimpleReaderPrivate();
- Q_D(QXmlSimpleReader);
- d->q_ptr = this;
-
- d->locator = new QXmlSimpleReaderLocator(this);
-
- d->entityRes = 0;
- d->dtdHnd = 0;
- d->contentHnd = 0;
- d->errorHnd = 0;
- d->lexicalHnd = 0;
- d->declHnd = 0;
-
- // default feature settings
- d->useNamespaces = true;
- d->useNamespacePrefixes = false;
- d->reportWhitespaceCharData = true;
- d->reportEntities = false;
}
/*!
@@ -3127,9 +3133,6 @@ QXmlSimpleReader::QXmlSimpleReader()
*/
QXmlSimpleReader::~QXmlSimpleReader()
{
- Q_D(QXmlSimpleReader);
- delete d->locator;
- delete d;
}
/*!
@@ -3412,7 +3415,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource *input, bool incremental)
// call the handler
if (d->contentHnd) {
- d->contentHnd->setDocumentLocator(d->locator);
+ d->contentHnd->setDocumentLocator(d->locator.data());
if (!d->contentHnd->startDocument()) {
d->reportParseError(d->contentHnd->errorString());
d->tags.clear();
diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h
index e0165d3..8e3eb25 100644
--- a/src/xml/sax/qxml.h
+++ b/src/xml/sax/qxml.h
@@ -47,6 +47,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qlist.h>
+#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER
@@ -202,7 +203,7 @@ public:
QString message() const;
private:
- QXmlParseExceptionPrivate *d;
+ QScopedPointer<QXmlParseExceptionPrivate> d;
};
@@ -271,7 +272,7 @@ public:
private:
Q_DISABLE_COPY(QXmlSimpleReader)
Q_DECLARE_PRIVATE(QXmlSimpleReader)
- QXmlSimpleReaderPrivate* d_ptr;
+ QScopedPointer<QXmlSimpleReaderPrivate> d_ptr;
friend class QXmlSimpleReaderLocator;
};
diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
index 0caa8c4..12ce6a7 100644
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
+++ b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
@@ -302,7 +302,6 @@ QAbstractXmlNodeModel::QAbstractXmlNodeModel(QAbstractXmlNodeModelPrivate *d) :
*/
QAbstractXmlNodeModel::~QAbstractXmlNodeModel()
{
- delete d_ptr;
}
/*!
diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.h b/src/xmlpatterns/api/qabstractxmlnodemodel.h
index 6c9574c..9b5b3dd 100644
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.h
+++ b/src/xmlpatterns/api/qabstractxmlnodemodel.h
@@ -44,6 +44,7 @@
#include <QtXmlPatterns/QXmlName>
#include <QtCore/QSharedData>
+#include <QtCore/QScopedPointer>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -339,7 +340,7 @@ protected:
return QXmlNodeModelIndex::create(data, this, additionalData);
}
- QAbstractXmlNodeModelPrivate *d_ptr;
+ QScopedPointer<QAbstractXmlNodeModelPrivate> d_ptr;
private:
friend class QPatternist::ItemMappingIterator<QXmlNodeModelIndex, QXmlNodeModelIndex, const QAbstractXmlNodeModel *, QExplicitlySharedDataPointer<QPatternist::DynamicContext> >;
friend class QPatternist::SequenceMappingIterator<QXmlNodeModelIndex, QXmlNodeModelIndex, const QAbstractXmlNodeModel *>;
diff --git a/src/xmlpatterns/api/qabstractxmlreceiver.cpp b/src/xmlpatterns/api/qabstractxmlreceiver.cpp
index ddd01e4..4253ce0 100644
--- a/src/xmlpatterns/api/qabstractxmlreceiver.cpp
+++ b/src/xmlpatterns/api/qabstractxmlreceiver.cpp
@@ -224,7 +224,6 @@ QAbstractXmlReceiver::QAbstractXmlReceiver() : d_ptr(0)
*/
QAbstractXmlReceiver::~QAbstractXmlReceiver()
{
- delete d_ptr;
}
/*!
diff --git a/src/xmlpatterns/api/qabstractxmlreceiver.h b/src/xmlpatterns/api/qabstractxmlreceiver.h
index 355576a..270b9da 100644
--- a/src/xmlpatterns/api/qabstractxmlreceiver.h
+++ b/src/xmlpatterns/api/qabstractxmlreceiver.h
@@ -43,6 +43,7 @@
#define QABSTRACTXMLRECEIVER_H
#include <QtCore/QVariant>
+#include <QtCore/QScopedPointer>
#include <QtXmlPatterns/QXmlNodeModelIndex>
QT_BEGIN_HEADER
@@ -90,7 +91,7 @@ public:
protected:
QAbstractXmlReceiver(QAbstractXmlReceiverPrivate *d);
- QAbstractXmlReceiverPrivate *d_ptr;
+ QScopedPointer<QAbstractXmlReceiverPrivate> d_ptr;
void sendAsNode(const QPatternist::Item &outputItem);
private:
diff --git a/src/xmlpatterns/api/qxmlresultitems.cpp b/src/xmlpatterns/api/qxmlresultitems.cpp
index a2253c9..652d931 100644
--- a/src/xmlpatterns/api/qxmlresultitems.cpp
+++ b/src/xmlpatterns/api/qxmlresultitems.cpp
@@ -85,7 +85,6 @@ QXmlResultItems::QXmlResultItems() : d_ptr(new QXmlResultItemsPrivate())
*/
QXmlResultItems::~QXmlResultItems()
{
- delete d_ptr;
}
/*!
diff --git a/src/xmlpatterns/api/qxmlresultitems.h b/src/xmlpatterns/api/qxmlresultitems.h
index aeb7d2c..5484616 100644
--- a/src/xmlpatterns/api/qxmlresultitems.h
+++ b/src/xmlpatterns/api/qxmlresultitems.h
@@ -43,6 +43,7 @@
#define QXMLRESULTITEMS
#include <QtCore/QString>
+#include <QtCore/QScopedPointer>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -66,7 +67,7 @@ public:
private:
friend class QXmlQuery;
Q_DECLARE_PRIVATE(QXmlResultItems)
- QXmlResultItemsPrivate *d_ptr;
+ QScopedPointer<QXmlResultItemsPrivate> d_ptr;
Q_DISABLE_COPY(QXmlResultItems)
};
diff --git a/src/xmlpatterns/expr/qpath.cpp b/src/xmlpatterns/expr/qpath.cpp
index 33bfa0f..a60f622 100644
--- a/src/xmlpatterns/expr/qpath.cpp
+++ b/src/xmlpatterns/expr/qpath.cpp
@@ -170,7 +170,7 @@ Expression::Ptr Path::compress(const StaticContext::Ptr &context)
/* We do this as late as we can, such that we pick up the most recent type
* from the operand. */
- if(m_isLast && !m_kind == XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item)
+ if(m_isLast && m_kind != XSLTForEach && m_operand2->staticType()->itemType() == BuiltinTypes::item)
m_checkXPTY0018 = true;
return me;