summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2012-01-16 17:52:29 +0100
committerJoão Abecasis <joao.abecasis@nokia.com>2012-01-16 17:53:41 +0100
commit5b250d497fd798c476765b22a2906e1c0ff1e432 (patch)
treefd4215ca375cc2402e536bf670c2977cf64ae2ef /src/corelib
parent2c52e9a5c1d6ef6cbf4577430e14027375465c96 (diff)
parent7a0099183a1c107126bda3b59a47651aac612426 (diff)
Merge remote-tracking branch 'gerrit/master' into containers
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in10
-rw-r--r--src/corelib/Qt5CoreMacros.cmake321
-rw-r--r--src/corelib/animation/qabstractanimation.cpp501
-rw-r--r--src/corelib/animation/qabstractanimation.h2
-rw-r--r--src/corelib/animation/qabstractanimation_p.h111
-rw-r--r--src/corelib/animation/qanimationgroup.cpp2
-rw-r--r--src/corelib/animation/qanimationgroup.h2
-rw-r--r--src/corelib/animation/qanimationgroup_p.h2
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp2
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h2
-rw-r--r--src/corelib/animation/qparallelanimationgroup_p.h2
-rw-r--r--src/corelib/animation/qpauseanimation.cpp2
-rw-r--r--src/corelib/animation/qpauseanimation.h2
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp2
-rw-r--r--src/corelib/animation/qpropertyanimation.h2
-rw-r--r--src/corelib/animation/qpropertyanimation_p.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h2
-rw-r--r--src/corelib/animation/qvariantanimation.cpp2
-rw-r--r--src/corelib/animation/qvariantanimation.h2
-rw-r--r--src/corelib/animation/qvariantanimation_p.h2
-rw-r--r--src/corelib/arch/alpha/qatomic_alpha.s2
-rw-r--r--src/corelib/arch/arm/qatomic_arm.cpp2
-rw-r--r--src/corelib/arch/generic/qatomic_generic_unix.cpp2
-rw-r--r--src/corelib/arch/generic/qatomic_generic_windows.cpp2
-rw-r--r--src/corelib/arch/ia64/qatomic_ia64.s2
-rw-r--r--src/corelib/arch/macosx/qatomic32_ppc.s2
-rw-r--r--src/corelib/arch/mips/qatomic_mips32.s2
-rw-r--r--src/corelib/arch/mips/qatomic_mips64.s2
-rw-r--r--src/corelib/arch/parisc/q_ldcw.s2
-rw-r--r--src/corelib/arch/parisc/qatomic_parisc.cpp2
-rw-r--r--src/corelib/arch/powerpc/qatomic32.s2
-rw-r--r--src/corelib/arch/powerpc/qatomic64.s2
-rw-r--r--src/corelib/arch/qatomic_alpha.h2
-rw-r--r--src/corelib/arch/qatomic_arch.h2
-rw-r--r--src/corelib/arch/qatomic_arm.h2
-rw-r--r--src/corelib/arch/qatomic_armv5.h2
-rw-r--r--src/corelib/arch/qatomic_armv6.h2
-rw-r--r--src/corelib/arch/qatomic_armv7.h2
-rw-r--r--src/corelib/arch/qatomic_avr32.h2
-rw-r--r--src/corelib/arch/qatomic_bfin.h2
-rw-r--r--src/corelib/arch/qatomic_bootstrap.h2
-rw-r--r--src/corelib/arch/qatomic_generic.h2
-rw-r--r--src/corelib/arch/qatomic_i386.h2
-rw-r--r--src/corelib/arch/qatomic_ia64.h2
-rw-r--r--src/corelib/arch/qatomic_integrity.h2
-rw-r--r--src/corelib/arch/qatomic_macosx.h2
-rw-r--r--src/corelib/arch/qatomic_mips.h2
-rw-r--r--src/corelib/arch/qatomic_parisc.h2
-rw-r--r--src/corelib/arch/qatomic_powerpc.h2
-rw-r--r--src/corelib/arch/qatomic_s390.h2
-rw-r--r--src/corelib/arch/qatomic_sh.h2
-rw-r--r--src/corelib/arch/qatomic_sh4a.h2
-rw-r--r--src/corelib/arch/qatomic_sparc.h2
-rw-r--r--src/corelib/arch/qatomic_symbian.h2
-rw-r--r--src/corelib/arch/qatomic_vxworks.h2
-rw-r--r--src/corelib/arch/qatomic_windows.h2
-rw-r--r--src/corelib/arch/qatomic_windowsce.h2
-rw-r--r--src/corelib/arch/qatomic_x86_64.h2
-rw-r--r--src/corelib/arch/sh/qatomic_sh.cpp2
-rw-r--r--src/corelib/arch/sparc/qatomic32.s2
-rw-r--r--src/corelib/arch/sparc/qatomic64.s2
-rw-r--r--src/corelib/arch/sparc/qatomic_sparc.cpp2
-rw-r--r--src/corelib/codecs/codecs.pri3
-rw-r--r--src/corelib/codecs/codecs.qdoc2
-rw-r--r--src/corelib/codecs/qfontlaocodec.cpp2
-rw-r--r--src/corelib/codecs/qfontlaocodec_p.h2
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp2
-rw-r--r--src/corelib/codecs/qiconvcodec_p.h2
-rw-r--r--src/corelib/codecs/qisciicodec.cpp2
-rw-r--r--src/corelib/codecs/qisciicodec_p.h2
-rw-r--r--src/corelib/codecs/qlatincodec.cpp2
-rw-r--r--src/corelib/codecs/qlatincodec_p.h2
-rw-r--r--src/corelib/codecs/qsimplecodec.cpp10
-rw-r--r--src/corelib/codecs/qsimplecodec_p.h6
-rw-r--r--src/corelib/codecs/qtextcodec.cpp68
-rw-r--r--src/corelib/codecs/qtextcodec.h9
-rw-r--r--src/corelib/codecs/qtextcodec_p.h2
-rw-r--r--src/corelib/codecs/qtextcodec_symbian.cpp689
-rw-r--r--src/corelib/codecs/qtextcodecplugin.cpp2
-rw-r--r--src/corelib/codecs/qtextcodecplugin.h2
-rw-r--r--src/corelib/codecs/qtsciicodec.cpp2
-rw-r--r--src/corelib/codecs/qtsciicodec_p.h2
-rw-r--r--src/corelib/codecs/qutfcodec.cpp2
-rw-r--r--src/corelib/codecs/qutfcodec_p.h2
-rw-r--r--src/corelib/concurrent/qfuture.cpp2
-rw-r--r--src/corelib/concurrent/qfuture.h2
-rw-r--r--src/corelib/concurrent/qfutureinterface.cpp2
-rw-r--r--src/corelib/concurrent/qfutureinterface.h2
-rw-r--r--src/corelib/concurrent/qfutureinterface_p.h2
-rw-r--r--src/corelib/concurrent/qfuturesynchronizer.cpp2
-rw-r--r--src/corelib/concurrent/qfuturesynchronizer.h2
-rw-r--r--src/corelib/concurrent/qfuturewatcher.cpp2
-rw-r--r--src/corelib/concurrent/qfuturewatcher.h2
-rw-r--r--src/corelib/concurrent/qfuturewatcher_p.h2
-rw-r--r--src/corelib/concurrent/qrunnable.cpp2
-rw-r--r--src/corelib/concurrent/qrunnable.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentcompilertest.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentexception.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentexception.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentfilter.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentfilter.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentfilterkernel.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentfunctionwrappers.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentiteratekernel.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentiteratekernel.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentmap.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentmap.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentmapkernel.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentmedian.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentreducekernel.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentresultstore.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentresultstore.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentrun.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentrun.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentrunbase.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentstoredfunctioncall.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.cpp2
-rw-r--r--src/corelib/concurrent/qtconcurrentthreadengine.h2
-rw-r--r--src/corelib/concurrent/qthreadpool.cpp2
-rw-r--r--src/corelib/concurrent/qthreadpool.h2
-rw-r--r--src/corelib/concurrent/qthreadpool_p.h2
-rw-r--r--src/corelib/corelib.pro1
-rw-r--r--src/corelib/global/qconfig-dist.h2
-rw-r--r--src/corelib/global/qconfig-large.h2
-rw-r--r--src/corelib/global/qconfig-medium.h2
-rw-r--r--src/corelib/global/qconfig-minimal.h5
-rw-r--r--src/corelib/global/qconfig-nacl.h2
-rw-r--r--src/corelib/global/qconfig-small.h5
-rw-r--r--src/corelib/global/qendian.h2
-rw-r--r--src/corelib/global/qendian.qdoc2
-rw-r--r--src/corelib/global/qfeatures.h17
-rw-r--r--src/corelib/global/qfeatures.txt7
-rw-r--r--src/corelib/global/qglobal.cpp392
-rw-r--r--src/corelib/global/qglobal.h276
-rw-r--r--src/corelib/global/qlibraryinfo.cpp4
-rw-r--r--src/corelib/global/qlibraryinfo.h2
-rw-r--r--src/corelib/global/qmalloc.cpp8
-rw-r--r--src/corelib/global/qnamespace.h51
-rw-r--r--src/corelib/global/qnamespace.qdoc46
-rw-r--r--src/corelib/global/qnumeric.cpp2
-rw-r--r--src/corelib/global/qnumeric.h2
-rw-r--r--src/corelib/global/qnumeric_p.h2
-rw-r--r--src/corelib/global/qt_pch.h2
-rw-r--r--src/corelib/global/qt_windows.h2
-rw-r--r--src/corelib/io/io.pri57
-rw-r--r--src/corelib/io/qabstractfileengine.cpp2
-rw-r--r--src/corelib/io/qabstractfileengine.h2
-rw-r--r--src/corelib/io/qabstractfileengine_p.h2
-rw-r--r--src/corelib/io/qbuffer.cpp10
-rw-r--r--src/corelib/io/qbuffer.h2
-rw-r--r--src/corelib/io/qdatastream.cpp2
-rw-r--r--src/corelib/io/qdatastream.h2
-rw-r--r--src/corelib/io/qdatastream_p.h2
-rw-r--r--src/corelib/io/qdataurl.cpp68
-rw-r--r--src/corelib/io/qdataurl_p.h4
-rw-r--r--src/corelib/io/qdebug.cpp2
-rw-r--r--src/corelib/io/qdebug.h21
-rw-r--r--src/corelib/io/qdir.cpp4
-rw-r--r--src/corelib/io/qdir.h2
-rw-r--r--src/corelib/io/qdir_p.h2
-rw-r--r--src/corelib/io/qdiriterator.cpp2
-rw-r--r--src/corelib/io/qdiriterator.h2
-rw-r--r--src/corelib/io/qfile.cpp2
-rw-r--r--src/corelib/io/qfile.h2
-rw-r--r--src/corelib/io/qfile_p.h2
-rw-r--r--src/corelib/io/qfileinfo.cpp2
-rw-r--r--src/corelib/io/qfileinfo.h2
-rw-r--r--src/corelib/io/qfileinfo_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_mac.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine_symbian.cpp406
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp63
-rw-r--r--src/corelib/io/qfilesystementry.cpp2
-rw-r--r--src/corelib/io/qfilesystementry_p.h2
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h2
-rw-r--r--src/corelib/io/qfilesystemiterator_symbian.cpp127
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp2
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp2
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h2
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp371
-rw-r--r--src/corelib/io/qfilesystemwatcher.h10
-rw-r--r--src/corelib/io/qfilesystemwatcher_dnotify.cpp461
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.cpp492
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents_p.h132
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp37
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify_p.h17
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue.cpp296
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue_p.h15
-rw-r--r--src/corelib/io/qfilesystemwatcher_p.h17
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling.cpp151
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling_p.h (renamed from src/corelib/io/qfilesystemwatcher_dnotify_p.h)113
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp273
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp35
-rw-r--r--src/corelib/io/qfilesystemwatcher_win_p.h10
-rw-r--r--src/corelib/io/qfsfileengine.cpp2
-rw-r--r--src/corelib/io/qfsfileengine.h2
-rw-r--r--src/corelib/io/qfsfileengine_iterator.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_iterator_p.h2
-rw-r--r--src/corelib/io/qfsfileengine_p.h2
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp5
-rw-r--r--src/corelib/io/qiodevice.cpp2
-rw-r--r--src/corelib/io/qiodevice.h2
-rw-r--r--src/corelib/io/qiodevice_p.h2
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp2
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice_p.h2
-rw-r--r--src/corelib/io/qprocess.cpp14
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qprocess_p.h2
-rw-r--r--src/corelib/io/qprocess_symbian.cpp1072
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qprocess_win.cpp125
-rw-r--r--src/corelib/io/qprocess_wince.cpp330
-rw-r--r--src/corelib/io/qresource.cpp4
-rw-r--r--src/corelib/io/qresource.h2
-rw-r--r--src/corelib/io/qresource_iterator.cpp2
-rw-r--r--src/corelib/io/qresource_iterator_p.h2
-rw-r--r--src/corelib/io/qresource_p.h2
-rw-r--r--src/corelib/io/qsettings.cpp2
-rw-r--r--src/corelib/io/qsettings.h2
-rw-r--r--src/corelib/io/qsettings_mac.cpp2
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qsettings_win.cpp2
-rw-r--r--src/corelib/io/qstandardpaths.cpp4
-rw-r--r--src/corelib/io/qstandardpaths.h5
-rw-r--r--src/corelib/io/qstandardpaths_mac.cpp6
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp13
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp5
-rw-r--r--src/corelib/io/qtemporarydir.cpp2
-rw-r--r--src/corelib/io/qtemporarydir.h2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp2
-rw-r--r--src/corelib/io/qtemporaryfile.h2
-rw-r--r--src/corelib/io/qtextstream.cpp2
-rw-r--r--src/corelib/io/qtextstream.h2
-rw-r--r--src/corelib/io/qtldurl.cpp2
-rw-r--r--src/corelib/io/qtldurl_p.h2
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/io/qurl.h2
-rw-r--r--src/corelib/io/qwindowspipereader.cpp315
-rw-r--r--src/corelib/io/qwindowspipereader_p.h (renamed from src/corelib/io/qfilesystemwatcher_symbian_p.h)106
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp2
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h2
-rw-r--r--src/corelib/itemmodels/itemmodels.pri20
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp (renamed from src/corelib/kernel/qabstractitemmodel.cpp)42
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h (renamed from src/corelib/kernel/qabstractitemmodel.h)23
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h (renamed from src/corelib/kernel/qabstractitemmodel_p.h)2
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp388
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.h113
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel_p.h76
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.cpp578
-rw-r--r--src/corelib/itemmodels/qidentityproxymodel.h120
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp1641
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h256
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel_p.h113
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp2703
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h205
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.cpp310
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.h91
-rw-r--r--src/corelib/kernel/kernel.pri76
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp42
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h24
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher_p.h2
-rw-r--r--src/corelib/kernel/qbasictimer.cpp54
-rw-r--r--src/corelib/kernel/qbasictimer.h4
-rw-r--r--src/corelib/kernel/qcore_mac.cpp2
-rw-r--r--src/corelib/kernel/qcore_mac_p.h2
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp317
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h282
-rw-r--r--src/corelib/kernel/qcore_unix.cpp2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp54
-rw-r--r--src/corelib/kernel/qcoreapplication.h8
-rw-r--r--src/corelib/kernel/qcoreapplication_mac.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp2
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h2
-rw-r--r--src/corelib/kernel/qcoreevent.cpp5
-rw-r--r--src/corelib/kernel/qcoreevent.h5
-rw-r--r--src/corelib/kernel/qcoreglobaldata.cpp2
-rw-r--r--src/corelib/kernel/qcoreglobaldata_p.h2
-rw-r--r--src/corelib/kernel/qcrashhandler.cpp2
-rw-r--r--src/corelib/kernel/qcrashhandler_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib_p.h4
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp1316
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h327
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp328
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h49
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp65
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h7
-rw-r--r--src/corelib/kernel/qeventloop.cpp2
-rw-r--r--src/corelib/kernel/qeventloop.h2
-rw-r--r--src/corelib/kernel/qfunctions_nacl.cpp2
-rw-r--r--src/corelib/kernel/qfunctions_nacl.h2
-rw-r--r--src/corelib/kernel/qfunctions_p.h2
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.cpp2
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.h2
-rw-r--r--src/corelib/kernel/qfunctions_wince.cpp2
-rw-r--r--src/corelib/kernel/qfunctions_wince.h2
-rw-r--r--src/corelib/kernel/qmath.cpp2
-rw-r--r--src/corelib/kernel/qmath.h2
-rw-r--r--src/corelib/kernel/qmath.qdoc2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp23
-rw-r--r--src/corelib/kernel/qmetaobject.h2
-rw-r--r--src/corelib/kernel/qmetaobject_moc_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject_p.h2
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp35
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h6
-rw-r--r--src/corelib/kernel/qmetatype.cpp158
-rw-r--r--src/corelib/kernel/qmetatype.h30
-rw-r--r--src/corelib/kernel/qmetatype_p.h85
-rw-r--r--src/corelib/kernel/qmetatypeswitcher_p.h2
-rw-r--r--src/corelib/kernel/qmimedata.cpp2
-rw-r--r--src/corelib/kernel/qmimedata.h2
-rw-r--r--src/corelib/kernel/qobject.cpp290
-rw-r--r--src/corelib/kernel/qobject.h38
-rw-r--r--src/corelib/kernel/qobject_impl.h38
-rw-r--r--src/corelib/kernel/qobject_p.h11
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.cpp2
-rw-r--r--src/corelib/kernel/qobjectcleanuphandler.h2
-rw-r--r--src/corelib/kernel/qobjectdefs.h20
-rw-r--r--src/corelib/kernel/qpointer.cpp22
-rw-r--r--src/corelib/kernel/qpointer.h39
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory.h2
-rw-r--r--src/corelib/kernel/qsharedmemory_p.h2
-rw-r--r--src/corelib/kernel/qsharedmemory_symbian.cpp173
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp2
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp2
-rw-r--r--src/corelib/kernel/qsignalmapper.cpp2
-rw-r--r--src/corelib/kernel/qsignalmapper.h2
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp4
-rw-r--r--src/corelib/kernel/qsocketnotifier.h6
-rw-r--r--src/corelib/kernel/qsystemerror.cpp60
-rw-r--r--src/corelib/kernel/qsystemerror_p.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_symbian.cpp138
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp2
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp2
-rw-r--r--src/corelib/kernel/qtcore_eval.cpp6
-rw-r--r--src/corelib/kernel/qtimer.cpp48
-rw-r--r--src/corelib/kernel/qtimer.h9
-rw-r--r--src/corelib/kernel/qtimerinfo_unix.cpp625
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h117
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qtranslator.h2
-rw-r--r--src/corelib/kernel/qtranslator_p.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp393
-rw-r--r--src/corelib/kernel/qvariant.h28
-rw-r--r--src/corelib/kernel/qvariant_p.h144
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp2
-rw-r--r--src/corelib/kernel/qwineventnotifier.h2
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp2
-rw-r--r--src/corelib/plugin/qelfparser_p.h2
-rw-r--r--src/corelib/plugin/qfactoryinterface.h2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp2
-rw-r--r--src/corelib/plugin/qfactoryloader_p.h2
-rw-r--r--src/corelib/plugin/qlibrary.cpp96
-rw-r--r--src/corelib/plugin/qlibrary.h2
-rw-r--r--src/corelib/plugin/qlibrary_p.h2
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp2
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp2
-rw-r--r--src/corelib/plugin/qplugin.h2
-rw-r--r--src/corelib/plugin/qplugin.qdoc2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp62
-rw-r--r--src/corelib/plugin/qpluginloader.h2
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp2
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h2
-rw-r--r--src/corelib/plugin/quuid.cpp85
-rw-r--r--src/corelib/plugin/quuid.h36
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp2
-rw-r--r--src/corelib/statemachine/qabstractstate.h2
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp2
-rw-r--r--src/corelib/statemachine/qabstracttransition.h2
-rw-r--r--src/corelib/statemachine/qabstracttransition_p.h2
-rw-r--r--src/corelib/statemachine/qeventtransition.cpp2
-rw-r--r--src/corelib/statemachine/qeventtransition.h2
-rw-r--r--src/corelib/statemachine/qeventtransition_p.h2
-rw-r--r--src/corelib/statemachine/qfinalstate.cpp2
-rw-r--r--src/corelib/statemachine/qfinalstate.h2
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp2
-rw-r--r--src/corelib/statemachine/qhistorystate.h2
-rw-r--r--src/corelib/statemachine/qhistorystate_p.h2
-rw-r--r--src/corelib/statemachine/qsignaleventgenerator_p.h2
-rw-r--r--src/corelib/statemachine/qsignaltransition.cpp2
-rw-r--r--src/corelib/statemachine/qsignaltransition.h2
-rw-r--r--src/corelib/statemachine/qsignaltransition_p.h2
-rw-r--r--src/corelib/statemachine/qstate.cpp2
-rw-r--r--src/corelib/statemachine/qstate.h2
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp2
-rw-r--r--src/corelib/statemachine/qstatemachine.h2
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
-rw-r--r--src/corelib/thread/qatomic.cpp2
-rw-r--r--src/corelib/thread/qatomic.h4
-rw-r--r--src/corelib/thread/qmutex.cpp2
-rw-r--r--src/corelib/thread/qmutex.h2
-rw-r--r--src/corelib/thread/qmutex_linux.cpp2
-rw-r--r--src/corelib/thread/qmutex_mac.cpp2
-rw-r--r--src/corelib/thread/qmutex_p.h2
-rw-r--r--src/corelib/thread/qmutex_unix.cpp2
-rw-r--r--src/corelib/thread/qmutex_win.cpp2
-rw-r--r--src/corelib/thread/qmutexpool.cpp2
-rw-r--r--src/corelib/thread/qmutexpool_p.h2
-rw-r--r--src/corelib/thread/qoldbasicatomic.h (renamed from src/corelib/thread/qbasicatomic.h)2
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h2
-rw-r--r--src/corelib/thread/qreadwritelock.cpp15
-rw-r--r--src/corelib/thread/qreadwritelock.h5
-rw-r--r--src/corelib/thread/qreadwritelock_p.h2
-rw-r--r--src/corelib/thread/qsemaphore.cpp2
-rw-r--r--src/corelib/thread/qsemaphore.h2
-rw-r--r--src/corelib/thread/qthread.cpp2
-rw-r--r--src/corelib/thread/qthread.h2
-rw-r--r--src/corelib/thread/qthread_p.h16
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/thread/qthreadstorage.cpp2
-rw-r--r--src/corelib/thread/qthreadstorage.h2
-rw-r--r--src/corelib/thread/qwaitcondition.h2
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc2
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp2
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp2
-rw-r--r--src/corelib/thread/thread.pri4
-rw-r--r--src/corelib/tools/qalgorithms.h2
-rw-r--r--src/corelib/tools/qalgorithms.qdoc2
-rw-r--r--src/corelib/tools/qbitarray.cpp20
-rw-r--r--src/corelib/tools/qbitarray.h6
-rw-r--r--src/corelib/tools/qbytearray.cpp32
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qbytearraymatcher.cpp2
-rw-r--r--src/corelib/tools/qbytearraymatcher.h2
-rw-r--r--src/corelib/tools/qbytedata_p.h2
-rw-r--r--src/corelib/tools/qcache.h5
-rw-r--r--src/corelib/tools/qcache.qdoc2
-rw-r--r--src/corelib/tools/qchar.cpp2
-rw-r--r--src/corelib/tools/qchar.h2
-rw-r--r--src/corelib/tools/qcontainerfwd.h2
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp2
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qcryptographichash.cpp25
-rw-r--r--src/corelib/tools/qcryptographichash.h4
-rw-r--r--src/corelib/tools/qdatetime.cpp83
-rw-r--r--src/corelib/tools/qdatetime.h19
-rw-r--r--src/corelib/tools/qdatetime_p.h2
-rw-r--r--src/corelib/tools/qeasingcurve.cpp2
-rw-r--r--src/corelib/tools/qeasingcurve.h2
-rw-r--r--src/corelib/tools/qelapsedtimer.cpp2
-rw-r--r--src/corelib/tools/qelapsedtimer.h2
-rw-r--r--src/corelib/tools/qelapsedtimer_generic.cpp2
-rw-r--r--src/corelib/tools/qelapsedtimer_mac.cpp2
-rw-r--r--src/corelib/tools/qelapsedtimer_symbian.cpp2
-rw-r--r--src/corelib/tools/qelapsedtimer_unix.cpp2
-rw-r--r--src/corelib/tools/qelapsedtimer_win.cpp2
-rw-r--r--src/corelib/tools/qfreelist.cpp2
-rw-r--r--src/corelib/tools/qfreelist_p.h2
-rw-r--r--src/corelib/tools/qharfbuzz.cpp2
-rw-r--r--src/corelib/tools/qharfbuzz_p.h2
-rw-r--r--src/corelib/tools/qhash.cpp6
-rw-r--r--src/corelib/tools/qhash.h2
-rw-r--r--src/corelib/tools/qiterator.h2
-rw-r--r--src/corelib/tools/qiterator.qdoc2
-rw-r--r--src/corelib/tools/qline.cpp2
-rw-r--r--src/corelib/tools/qline.h2
-rw-r--r--src/corelib/tools/qlinkedlist.cpp2
-rw-r--r--src/corelib/tools/qlinkedlist.h2
-rw-r--r--src/corelib/tools/qlist.cpp10
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qlocale.cpp22
-rw-r--r--src/corelib/tools/qlocale.h14
-rw-r--r--src/corelib/tools/qlocale.qdoc6
-rw-r--r--src/corelib/tools/qlocale_data_p.h2
-rw-r--r--src/corelib/tools/qlocale_icu.cpp2
-rw-r--r--src/corelib/tools/qlocale_mac.mm2
-rw-r--r--src/corelib/tools/qlocale_p.h2
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp2
-rw-r--r--src/corelib/tools/qlocale_tools.cpp6
-rw-r--r--src/corelib/tools/qlocale_tools_p.h2
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qlocale_win.cpp2
-rw-r--r--src/corelib/tools/qmap.cpp8
-rw-r--r--src/corelib/tools/qmap.h2
-rw-r--r--src/corelib/tools/qmargins.cpp2
-rw-r--r--src/corelib/tools/qmargins.h2
-rw-r--r--src/corelib/tools/qpair.h2
-rw-r--r--src/corelib/tools/qpair.qdoc2
-rw-r--r--src/corelib/tools/qpodlist_p.h2
-rw-r--r--src/corelib/tools/qpoint.cpp2
-rw-r--r--src/corelib/tools/qpoint.h2
-rw-r--r--src/corelib/tools/qqueue.cpp2
-rw-r--r--src/corelib/tools/qqueue.h2
-rw-r--r--src/corelib/tools/qrect.cpp2
-rw-r--r--src/corelib/tools/qrect.h53
-rw-r--r--src/corelib/tools/qrefcount.cpp2
-rw-r--r--src/corelib/tools/qrefcount.h2
-rw-r--r--src/corelib/tools/qregexp.cpp12
-rw-r--r--src/corelib/tools/qregexp.h6
-rw-r--r--src/corelib/tools/qringbuffer_p.h2
-rw-r--r--src/corelib/tools/qscopedpointer.cpp2
-rw-r--r--src/corelib/tools/qscopedpointer.h2
-rw-r--r--src/corelib/tools/qscopedpointer_p.h2
-rw-r--r--src/corelib/tools/qscopedvaluerollback.cpp2
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h2
-rw-r--r--src/corelib/tools/qset.h18
-rw-r--r--src/corelib/tools/qset.qdoc2
-rw-r--r--src/corelib/tools/qshareddata.cpp2
-rw-r--r--src/corelib/tools/qshareddata.h2
-rw-r--r--src/corelib/tools/qsharedpointer.cpp2
-rw-r--r--src/corelib/tools/qsharedpointer.h2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h2
-rw-r--r--src/corelib/tools/qsimd.cpp2
-rw-r--r--src/corelib/tools/qsimd_p.h2
-rw-r--r--src/corelib/tools/qsize.cpp2
-rw-r--r--src/corelib/tools/qsize.h2
-rw-r--r--src/corelib/tools/qstack.cpp2
-rw-r--r--src/corelib/tools/qstack.h2
-rw-r--r--src/corelib/tools/qstring.cpp93
-rw-r--r--src/corelib/tools/qstring.h105
-rw-r--r--src/corelib/tools/qstringbuilder.cpp2
-rw-r--r--src/corelib/tools/qstringbuilder.h2
-rw-r--r--src/corelib/tools/qstringlist.cpp2
-rw-r--r--src/corelib/tools/qstringlist.h2
-rw-r--r--src/corelib/tools/qstringmatcher.cpp2
-rw-r--r--src/corelib/tools/qstringmatcher.h2
-rw-r--r--src/corelib/tools/qtextboundaryfinder.cpp2
-rw-r--r--src/corelib/tools/qtextboundaryfinder.h2
-rw-r--r--src/corelib/tools/qtimeline.cpp2
-rw-r--r--src/corelib/tools/qtimeline.h2
-rw-r--r--src/corelib/tools/qtools_p.h2
-rw-r--r--src/corelib/tools/qunicodetables.cpp2
-rw-r--r--src/corelib/tools/qunicodetables_p.h2
-rw-r--r--src/corelib/tools/qvarlengtharray.h7
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc39
-rw-r--r--src/corelib/tools/qvector.cpp12
-rw-r--r--src/corelib/tools/qvector.h6
-rw-r--r--src/corelib/tools/qvsnprintf.cpp2
-rwxr-xr-xsrc/corelib/xml/make-parser.sh2
-rw-r--r--src/corelib/xml/qxmlstream.cpp10
-rw-r--r--src/corelib/xml/qxmlstream.g2
-rw-r--r--src/corelib/xml/qxmlstream.h2
-rw-r--r--src/corelib/xml/qxmlstream_p.h2
-rw-r--r--src/corelib/xml/qxmlutils.cpp2
-rw-r--r--src/corelib/xml/qxmlutils_p.h2
549 files changed, 11438 insertions, 10236 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 154069411a..e97493f65d 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -2,10 +2,6 @@
get_filename_component(_qt5_corelib_install_prefix ${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR} ABSOLUTE)
# Required by default:
-set(QT_QMAKE_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/qmake\")
-set(QT_MOC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/moc\")
-set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/rcc\")
-
-set(Qt5Core_PLUGIN_TYPES codecs)
-
-set(Qt5_CODECS_PLUGINS qcncodecs qjpcodecs qkrcodecs qtwcodecs )
+set(QT_QMAKE_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/qmake$$CMAKE_BIN_SUFFIX\")
+set(QT_MOC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/moc$$CMAKE_BIN_SUFFIX\")
+set(QT_RCC_EXECUTABLE \"${_qt5_corelib_install_prefix}/$$CMAKE_BIN_DIR/rcc$$CMAKE_BIN_SUFFIX\")
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index b7f785b716..abfe49ec84 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -39,167 +39,166 @@
include(CMakeParseArguments)
# macro used to create the names of output files preserving relative dirs
-MACRO (QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
- STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
- STRING(LENGTH ${infile} _infileLength)
- SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
- IF(_infileLength GREATER _binlength)
- STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
- IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
- FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
- ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
- FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
- ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
- ELSE(_infileLength GREATER _binlength)
- FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
- ENDIF(_infileLength GREATER _binlength)
- IF(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
- STRING(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
- ENDIF(WIN32 AND rel MATCHES "^[a-zA-Z]:")
- SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
- STRING(REPLACE ".." "__" _outfile ${_outfile})
- GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
- GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
- FILE(MAKE_DIRECTORY ${outpath})
- SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
-ENDMACRO (QT5_MAKE_OUTPUT_FILE )
-
-
-MACRO (QT5_GET_MOC_FLAGS _moc_flags)
- SET(${_moc_flags})
- GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
-
- FOREACH(_current ${_inc_DIRS})
- IF("${_current}" MATCHES "\\.framework/?$")
- STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
- SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
- ELSE("${_current}" MATCHES "\\.framework/?$")
- SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
- ENDIF("${_current}" MATCHES "\\.framework/?$")
- ENDFOREACH(_current ${_inc_DIRS})
-
- GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
- FOREACH(_current ${_defines})
- SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
- ENDFOREACH(_current ${_defines})
-
- IF(Q_WS_WIN)
- SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
- ENDIF(Q_WS_WIN)
-
-ENDMACRO(QT5_GET_MOC_FLAGS)
+macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
+ string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
+ string(LENGTH ${infile} _infileLength)
+ set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
+ if(_infileLength GREATER _binlength)
+ string(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
+ if(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
+ file(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
+ else()
+ file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
+ endif()
+ else()
+ file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
+ endif()
+ if(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
+ string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
+ endif()
+ set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
+ string(REPLACE ".." "__" _outfile ${_outfile})
+ get_filename_component(outpath ${_outfile} PATH)
+ get_filename_component(_outfile ${_outfile} NAME_WE)
+ file(MAKE_DIRECTORY ${outpath})
+ set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
+endmacro()
+
+
+macro(QT5_GET_MOC_FLAGS _moc_flags)
+ set(${_moc_flags})
+ get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
+
+ foreach(_current ${_inc_DIRS})
+ if("${_current}" MATCHES "\\.framework/?$")
+ string(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}")
+ set(${_moc_flags} ${${_moc_flags}} "-F${framework_path}")
+ else()
+ set(${_moc_flags} ${${_moc_flags}} "-I${_current}")
+ endif()
+ endforeach()
+
+ get_directory_property(_defines COMPILE_DEFINITIONS)
+ foreach(_current ${_defines})
+ set(${_moc_flags} ${${_moc_flags}} "-D${_current}")
+ endforeach()
+
+ if(Q_WS_WIN)
+ set(${_moc_flags} ${${_moc_flags}} -DWIN32)
+ endif()
+endmacro()
# helper macro to set up a moc rule
-MACRO (QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
- # For Windows, create a parameters file to work around command line length limit
- IF (WIN32)
- # Pass the parameters in a file. Set the working directory to
- # be that containing the parameters file and reference it by
- # just the file name. This is necessary because the moc tool on
- # MinGW builds does not seem to handle spaces in the path to the
- # file given with the @ syntax.
- GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
- GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
- IF(_moc_outfile_dir)
- SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
- ENDIF(_moc_outfile_dir)
- SET (_moc_parameters_file ${outfile}_parameters)
- SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
- STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
- FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}")
- ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
- COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
- DEPENDS ${infile}
- ${_moc_working_dir}
- VERBATIM)
- ELSE (WIN32)
- ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
- DEPENDS ${infile} VERBATIM)
- ENDIF (WIN32)
-ENDMACRO (QT5_CREATE_MOC_COMMAND)
-
-
-MACRO (QT5_GENERATE_MOC infile outfile )
-# get include dirs and flags
- QT5_GET_MOC_FLAGS(moc_flags)
- GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
- SET(_outfile "${outfile}")
- IF(NOT IS_ABSOLUTE "${outfile}")
- SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
- ENDIF(NOT IS_ABSOLUTE "${outfile}")
- QT5_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "")
- SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
-ENDMACRO (QT5_GENERATE_MOC)
-
-
-# QT5_WRAP_CPP(outfiles inputfile ... )
-
-MACRO (QT5_WRAP_CPP outfiles )
- # get include dirs
- QT5_GET_MOC_FLAGS(moc_flags)
-
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
- set(moc_options ${_WRAP_CPP_OPTIONS})
- FOREACH (it ${moc_files})
- GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
- QT5_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
- QT5_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}")
- SET(${outfiles} ${${outfiles}} ${outfile})
- ENDFOREACH(it)
-
-ENDMACRO (QT5_WRAP_CPP)
-
-
-# QT5_ADD_RESOURCES(outfiles inputfile ... )
-
-MACRO (QT5_ADD_RESOURCES outfiles )
-
- set(options)
- set(oneValueArgs)
- set(multiValueArgs OPTIONS)
-
- cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
- set(rcc_options ${_RCC_OPTIONS})
-
- FOREACH (it ${rcc_files})
- GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
- GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
- GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
- SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
- # parse file for dependencies
- # all files are absolute paths or relative to the location of the qrc file
- FILE(READ "${infile}" _RC_FILE_CONTENTS)
- STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
- SET(_RC_DEPENDS)
- FOREACH(_RC_FILE ${_RC_FILES})
- STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
- IF(NOT IS_ABSOLUTE "${_RC_FILE}")
- SET(_RC_FILE "${rc_path}/${_RC_FILE}")
- ENDIF(NOT IS_ABSOLUTE "${_RC_FILE}")
- SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
- ENDFOREACH(_RC_FILE)
- # Since this cmake macro is doing the dependency scanning for these files,
- # let's make a configured file and add it as a dependency so cmake is run
- # again when dependencies need to be recomputed.
- QT5_MAKE_OUTPUT_FILE("${infile}" "" "qrc.depends" out_depends)
- CONFIGURE_FILE("${infile}" "${out_depends}" COPY_ONLY)
- ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
- COMMAND ${QT_RCC_EXECUTABLE}
- ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
- MAIN_DEPENDENCY ${infile}
- DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
- SET(${outfiles} ${${outfiles}} ${outfile})
- ENDFOREACH (it)
-
-ENDMACRO (QT5_ADD_RESOURCES)
+macro(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
+ # For Windows, create a parameters file to work around command line length limit
+ if(WIN32)
+ # Pass the parameters in a file. Set the working directory to
+ # be that containing the parameters file and reference it by
+ # just the file name. This is necessary because the moc tool on
+ # MinGW builds does not seem to handle spaces in the path to the
+ # file given with the @ syntax.
+ get_filename_component(_moc_outfile_name "${outfile}" NAME)
+ get_filename_component(_moc_outfile_dir "${outfile}" PATH)
+ if(_moc_outfile_dir)
+ set(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
+ endif()
+ set(_moc_parameters_file ${outfile}_parameters)
+ set(_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
+ string(REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
+ file(WRITE ${_moc_parameters_file} "${_moc_parameters}")
+ add_custom_command(OUTPUT ${outfile}
+ COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
+ DEPENDS ${infile}
+ ${_moc_working_dir}
+ VERBATIM)
+ else()
+ add_custom_command(OUTPUT ${outfile}
+ COMMAND ${QT_MOC_EXECUTABLE}
+ ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
+ DEPENDS ${infile} VERBATIM)
+ endif()
+endmacro()
+
+
+function(QT5_GENERATE_MOC infile outfile )
+ # get include dirs and flags
+ qt5_get_moc_flags(moc_flags)
+ get_filename_component(abs_infile ${infile} ABSOLUTE)
+ set(_outfile "${outfile}")
+ if(NOT IS_ABSOLUTE "${outfile}")
+ set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
+ endif()
+ qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "")
+ set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
+endfunction()
+
+
+# qt5_wrap_cpp(outfiles inputfile ... )
+
+function(QT5_WRAP_CPP outfiles )
+ # get include dirs
+ qt5_get_moc_flags(moc_flags)
+
+ set(options)
+ set(oneValueArgs)
+ set(multiValueArgs OPTIONS)
+
+ cmake_parse_arguments(_WRAP_CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ set(moc_files ${_WRAP_CPP_UNPARSED_ARGUMENTS})
+ set(moc_options ${_WRAP_CPP_OPTIONS})
+ foreach(it ${moc_files})
+ get_filename_component(it ${it} ABSOLUTE)
+ qt5_make_output_file(${it} moc_ cxx outfile)
+ qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}")
+ list(APPEND ${outfiles} ${outfile})
+ endforeach()
+ set(${outfiles} ${${outfiles}} PARENT_SCOPE)
+endfunction()
+
+
+# qt5_add_resources(outfiles inputfile ... )
+
+function(QT5_ADD_RESOURCES outfiles )
+
+ set(options)
+ set(oneValueArgs)
+ set(multiValueArgs OPTIONS)
+
+ cmake_parse_arguments(_RCC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
+ set(rcc_options ${_RCC_OPTIONS})
+
+ foreach(it ${rcc_files})
+ get_filename_component(outfilename ${it} NAME_WE)
+ get_filename_component(infile ${it} ABSOLUTE)
+ get_filename_component(rc_path ${infile} PATH)
+ set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
+ # parse file for dependencies
+ # all files are absolute paths or relative to the location of the qrc file
+ file(READ "${infile}" _RC_FILE_CONTENTS)
+ string(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
+ set(_RC_DEPENDS)
+ foreach(_RC_FILE ${_RC_FILES})
+ string(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
+ if(NOT IS_ABSOLUTE "${_RC_FILE}")
+ set(_RC_FILE "${rc_path}/${_RC_FILE}")
+ endif()
+ set(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
+ endforeach()
+ # Since this cmake function is doing the dependency scanning for these files,
+ # let's make a configured file and add it as a dependency so cmake is run
+ # again when dependencies need to be recomputed.
+ qt5_make_output_file("${infile}" "" "qrc.depends" out_depends)
+ configure_file("${infile}" "${out_depends}" COPY_ONLY)
+ add_custom_command(OUTPUT ${outfile}
+ COMMAND ${QT_RCC_EXECUTABLE}
+ ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
+ MAIN_DEPENDENCY ${infile}
+ DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
+ list(APPEND ${outfiles} ${outfile})
+ endforeach()
+ set(${outfiles} ${${outfiles}} PARENT_SCOPE)
+endfunction()
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index b529359f71..040715f54a 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -157,18 +157,69 @@
#ifndef QT_NO_ANIMATION
#define DEFAULT_TIMER_INTERVAL 16
-#define STARTSTOP_TIMER_DELAY 0
+#define PAUSE_TIMER_COARSE_THRESHOLD 2000
QT_BEGIN_NAMESPACE
+/*!
+ \class QAbstractAnimationTimer
+ \brief QAbstractAnimationTimer is the base class for animation timers.
+ \internal
+
+ Subclass QAbstractAnimationTimer to provide an animation timer that is run by
+ QUnifiedTimer and can in turn be used to run any number of animations.
+
+ Currently two subclasses have been implemented: QAnimationTimer to drive the Qt C++
+ animation framework (QAbstractAnimation and subclasses) and QDeclarativeAnimationTimer
+ to drive the Qt QML animation framework.
+*/
+
+/*!
+ \fn virtual void QAbstractAnimationTimer::updateAnimationsTime(qint64 delta) = 0;
+ \internal
+
+ This pure virtual function is called when the animation timer needs to update
+ the current time for all animations it is running.
+*/
+
+/*!
+ \fn virtual void QAbstractAnimationTimer::restartAnimationTimer() = 0;
+ \internal
+
+ This pure virtual function restarts the animation timer as needed.
+
+ Classes implementing this function may choose to pause or resume the timer
+ as appropriate, or conditionally restart it.
+*/
+
+/*!
+ \fn virtual int QAbstractAnimationTimer::runningAnimationCount() = 0;
+ \internal
+
+ This pure virtual function returns the number of animations the timer is running.
+ This information is useful for profiling.
+*/
+
+/*!
+ \class QUnifiedTimer
+ \brief QUnifiedTimer provides a unified timing mechanism for animations in Qt C++ and QML.
+ \internal
+
+ QUnifiedTimer allows animations run by Qt to share a single timer. This keeps animations
+ visually in sync, as well as being more efficient than running numerous timers.
+
+ QUnifiedTimer drives animations indirectly, via QAbstractAnimationTimer.
+*/
+
#ifndef QT_NO_THREAD
Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
#endif
QUnifiedTimer::QUnifiedTimer() :
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
- currentAnimationIdx(0), insideTick(false), consistentTiming(false), slowMode(false),
- slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0), profilerCallback(0)
+ currentAnimationIdx(0), insideTick(false), insideRestart(false), consistentTiming(false), slowMode(false),
+ startTimersPending(false), stopTimerPending(false),
+ slowdownFactor(5.0f), profilerCallback(0)
{
time.invalidate();
driver = &defaultDriver;
@@ -183,7 +234,7 @@ QUnifiedTimer *QUnifiedTimer::instance(bool create)
inst = new QUnifiedTimer;
unifiedTimer()->setLocalData(inst);
} else {
- inst = unifiedTimer()->localData();
+ inst = unifiedTimer() ? unifiedTimer()->localData() : 0;
}
#else
static QUnifiedTimer unifiedTimer;
@@ -197,23 +248,16 @@ QUnifiedTimer *QUnifiedTimer::instance()
return instance(true);
}
-void QUnifiedTimer::ensureTimerUpdate()
-{
- QUnifiedTimer *inst = QUnifiedTimer::instance(false);
- if (inst && inst->isPauseTimerActive)
- inst->updateAnimationsTime(-1);
-}
-
-void QUnifiedTimer::updateAnimationsTime(qint64 timeStep)
+void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
{
//setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
if(insideTick)
return;
- qint64 totalElapsed = timeStep >= 0 ? timeStep : time.elapsed();
+ qint64 totalElapsed = currentTick >= 0 ? currentTick : time.elapsed();
// ignore consistentTiming in case the pause timer is active
- int delta = (consistentTiming && !isPauseTimerActive) ?
+ qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
timingInterval : totalElapsed - lastTick;
if (slowMode) {
if (slowdownFactor > 0)
@@ -229,177 +273,195 @@ void QUnifiedTimer::updateAnimationsTime(qint64 timeStep)
//when the CPU load is high
if (delta) {
insideTick = true;
- for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
- QAbstractAnimation *animation = animations.at(currentAnimationIdx);
- int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
- + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
- animation->setCurrentTime(elapsed);
-
- if (profilerCallback)
- profilerCallback(delta);
+ if (profilerCallback)
+ profilerCallback(delta);
+ for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) {
+ QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
+ animation->updateAnimationsTime(delta);
}
insideTick = false;
currentAnimationIdx = 0;
}
}
-void QUnifiedTimer::registerProfilerCallback(void (*cb)(qint64))
+int QUnifiedTimer::runningAnimationCount()
{
- profilerCallback = cb;
+ int count = 0;
+ for (int i = 0; i < animationTimers.count(); ++i)
+ count += animationTimers.at(i)->runningAnimationCount();
+ return count;
}
-void QUnifiedTimer::updateAnimationTimer()
+void QUnifiedTimer::registerProfilerCallback(void (*cb)(qint64))
{
- QUnifiedTimer *inst = QUnifiedTimer::instance(false);
- if (inst)
- inst->restartAnimationTimer();
+ profilerCallback = cb;
}
-void QUnifiedTimer::restartAnimationTimer()
+void QUnifiedTimer::localRestart()
{
- if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty()) {
- int closestTimeToFinish = closestPauseAnimationTimeToFinish();
- if (closestTimeToFinish < 0) {
- qDebug() << runningPauseAnimations;
- qDebug() << closestPauseAnimationTimeToFinish();
- }
+ if (insideRestart)
+ return;
+
+ if (!pausedAnimationTimers.isEmpty() && (animationTimers.count() + animationTimersToStart.count() == pausedAnimationTimers.count())) {
driver->stop();
- animationTimer.start(closestTimeToFinish, this);
- isPauseTimerActive = true;
- } else if (!driver->isRunning() || isPauseTimerActive) {
+ int closestTimeToFinish = closestPausedAnimationTimerTimeToFinish();
+ // use a precise timer if the pause will be short
+ Qt::TimerType timerType = closestTimeToFinish < PAUSE_TIMER_COARSE_THRESHOLD ? Qt::PreciseTimer : Qt::CoarseTimer;
+ pauseTimer.start(closestTimeToFinish, timerType, this);
+ } else if (!driver->isRunning()) {
+ if (pauseTimer.isActive())
+ pauseTimer.stop();
driver->start();
- isPauseTimerActive = false;
- } else if (runningLeafAnimations == 0)
- driver->stop();
+ }
+
+}
+
+void QUnifiedTimer::restart()
+{
+ insideRestart = true;
+ for (int i = 0; i < animationTimers.count(); ++i)
+ animationTimers.at(i)->restartAnimationTimer();
+ insideRestart = false;
+
+ localRestart();
}
void QUnifiedTimer::setTimingInterval(int interval)
{
timingInterval = interval;
- if (driver->isRunning() && !isPauseTimerActive) {
+ if (driver->isRunning() && !pauseTimer.isActive()) {
//we changed the timing interval
driver->stop();
driver->start();
}
}
+void QUnifiedTimer::startTimers()
+{
+ startTimersPending = false;
+ if (!animationTimers.isEmpty())
+ updateAnimationTimers(-1);
+
+ //we transfer the waiting animations into the "really running" state
+ animationTimers += animationTimersToStart;
+ animationTimersToStart.clear();
+ if (!animationTimers.isEmpty()) {
+ localRestart();
+ if (!time.isValid()) {
+ lastTick = 0;
+ time.start();
+ }
+ }
+}
+
+void QUnifiedTimer::stopTimer()
+{
+ stopTimerPending = false;
+ if (animationTimers.isEmpty()) {
+ driver->stop();
+ pauseTimer.stop();
+ // invalidate the start reference time
+ time.invalidate();
+ }
+}
void QUnifiedTimer::timerEvent(QTimerEvent *event)
{
- //in the case of consistent timing we make sure the orders in which events come is always the same
- //for that purpose we do as if the startstoptimer would always fire before the animation timer
- if ((consistentTiming && startStopAnimationTimer.isActive()) ||
- event->timerId() == startStopAnimationTimer.timerId()) {
- startStopAnimationTimer.stop();
-
- //we transfer the waiting animations into the "really running" state
- animations += animationsToStart;
- animationsToStart.clear();
- if (animations.isEmpty()) {
- animationTimer.stop();
- isPauseTimerActive = false;
- // invalidate the start reference time
- time.invalidate();
- } else {
- restartAnimationTimer();
- if (!time.isValid()) {
- lastTick = 0;
- time.start();
- }
- }
+ //in the case of consistent timing we make sure the order in which events come is always the same
+ //for that purpose we do as if the startstoptimer would always fire before the animation timer
+ if (consistentTiming) {
+ if (stopTimerPending)
+ stopTimer();
+ if (startTimersPending)
+ startTimers();
}
- if (event->timerId() == animationTimer.timerId()) {
- // update current time on all top level animations
- updateAnimationsTime(-1);
- restartAnimationTimer();
+ if (event->timerId() == pauseTimer.timerId()) {
+ // update current time on all timers
+ updateAnimationTimers(-1);
+ restart();
}
}
-void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
+void QUnifiedTimer::startAnimationTimer(QAbstractAnimationTimer *timer)
{
+ if (timer->isRegistered)
+ return;
+ timer->isRegistered = true;
+
QUnifiedTimer *inst = instance(true); //we create the instance if needed
- inst->registerRunningAnimation(animation);
- if (isTopLevel) {
- Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
- QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
- inst->animationsToStart << animation;
- if (!inst->startStopAnimationTimer.isActive())
- inst->startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, inst);
+ inst->animationTimersToStart << timer;
+ if (!inst->startTimersPending) {
+ inst->startTimersPending = true;
+ QMetaObject::invokeMethod(inst, "startTimers", Qt::QueuedConnection);
}
}
-void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
+void QUnifiedTimer::stopAnimationTimer(QAbstractAnimationTimer *timer)
{
QUnifiedTimer *inst = QUnifiedTimer::instance(false);
if (inst) {
//at this point the unified timer should have been created
//but it might also have been already destroyed in case the application is shutting down
- inst->unregisterRunningAnimation(animation);
-
- if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
+ if (!timer->isRegistered)
return;
+ timer->isRegistered = false;
- int idx = inst->animations.indexOf(animation);
+ int idx = inst->animationTimers.indexOf(timer);
if (idx != -1) {
- inst->animations.removeAt(idx);
+ inst->animationTimers.removeAt(idx);
// this is needed if we unregister an animation while its running
if (idx <= inst->currentAnimationIdx)
--inst->currentAnimationIdx;
- if (inst->animations.isEmpty() && !inst->startStopAnimationTimer.isActive())
- inst->startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, inst);
+ if (inst->animationTimers.isEmpty() && !inst->stopTimerPending) {
+ inst->stopTimerPending = true;
+ QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
+ }
} else {
- inst->animationsToStart.removeOne(animation);
+ inst->animationTimersToStart.removeOne(timer);
}
}
- QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false;
}
-void QUnifiedTimer::registerRunningAnimation(QAbstractAnimation *animation)
+void QUnifiedTimer::pauseAnimationTimer(QAbstractAnimationTimer *timer, int duration)
{
- if (QAbstractAnimationPrivate::get(animation)->isGroup)
- return;
-
- if (QAbstractAnimationPrivate::get(animation)->isPause) {
- runningPauseAnimations << animation;
- } else
- runningLeafAnimations++;
+ QUnifiedTimer *inst = QUnifiedTimer::instance();
+ if (!timer->isRegistered)
+ inst->startAnimationTimer(timer);
+
+ bool timerWasPaused = timer->isPaused;
+ timer->isPaused = true;
+ timer->pauseDuration = duration;
+ if (!timerWasPaused)
+ inst->pausedAnimationTimers << timer;
+ inst->localRestart();
}
-void QUnifiedTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
+void QUnifiedTimer::resumeAnimationTimer(QAbstractAnimationTimer *timer)
{
- if (QAbstractAnimationPrivate::get(animation)->isGroup)
+ if (!timer->isPaused)
return;
- if (QAbstractAnimationPrivate::get(animation)->isPause)
- runningPauseAnimations.removeOne(animation);
- else
- runningLeafAnimations--;
- Q_ASSERT(runningLeafAnimations >= 0);
+ timer->isPaused = false;
+ QUnifiedTimer *inst = QUnifiedTimer::instance();
+ inst->pausedAnimationTimers.removeOne(timer);
+ inst->localRestart();
}
-int QUnifiedTimer::closestPauseAnimationTimeToFinish()
+int QUnifiedTimer::closestPausedAnimationTimerTimeToFinish()
{
int closestTimeToFinish = INT_MAX;
- for (int i = 0; i < runningPauseAnimations.size(); ++i) {
- QAbstractAnimation *animation = runningPauseAnimations.at(i);
- int timeToFinish;
-
- if (animation->direction() == QAbstractAnimation::Forward)
- timeToFinish = animation->duration() - animation->currentLoopTime();
- else
- timeToFinish = animation->currentLoopTime();
-
+ for (int i = 0; i < pausedAnimationTimers.size(); ++i) {
+ int timeToFinish = pausedAnimationTimers.at(i)->pauseDuration;
if (timeToFinish < closestTimeToFinish)
closestTimeToFinish = timeToFinish;
}
return closestTimeToFinish;
}
-
void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
{
if (driver != &defaultDriver) {
@@ -416,7 +478,6 @@ void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
}
-
void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d)
{
if (driver != d) {
@@ -441,6 +502,199 @@ bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d)
return d == driver && driver != &defaultDriver;
}
+#ifndef QT_NO_THREAD
+Q_GLOBAL_STATIC(QThreadStorage<QAnimationTimer *>, animationTimer)
+#endif
+
+QAnimationTimer::QAnimationTimer() :
+ QAbstractAnimationTimer(), lastTick(0),
+ currentAnimationIdx(0), insideTick(false),
+ startAnimationPending(false), stopTimerPending(false),
+ runningLeafAnimations(0)
+{
+}
+
+QAnimationTimer *QAnimationTimer::instance(bool create)
+{
+ QAnimationTimer *inst;
+#ifndef QT_NO_THREAD
+ if (create && !animationTimer()->hasLocalData()) {
+ inst = new QAnimationTimer;
+ animationTimer()->setLocalData(inst);
+ } else {
+ inst = animationTimer() ? animationTimer()->localData() : 0;
+ }
+#else
+ static QAnimationTimer animationTimer;
+ inst = &animationTimer;
+#endif
+ return inst;
+}
+
+QAnimationTimer *QAnimationTimer::instance()
+{
+ return instance(true);
+}
+
+void QAnimationTimer::ensureTimerUpdate()
+{
+ QAnimationTimer *inst = QAnimationTimer::instance(false);
+ QUnifiedTimer *instU = QUnifiedTimer::instance(false);
+ if (instU && inst && inst->isPaused)
+ instU->updateAnimationTimers(-1);
+}
+
+void QAnimationTimer::updateAnimationsTime(qint64 delta)
+{
+ //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations
+ if (insideTick)
+ return;
+
+ lastTick += delta;
+
+ //we make sure we only call update time if the time has actually changed
+ //it might happen in some cases that the time doesn't change because events are delayed
+ //when the CPU load is high
+ if (delta) {
+ insideTick = true;
+ for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
+ QAbstractAnimation *animation = animations.at(currentAnimationIdx);
+ int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
+ + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
+ animation->setCurrentTime(elapsed);
+ }
+ insideTick = false;
+ currentAnimationIdx = 0;
+ }
+}
+
+void QAnimationTimer::updateAnimationTimer()
+{
+ QAnimationTimer *inst = QAnimationTimer::instance(false);
+ if (inst)
+ inst->restartAnimationTimer();
+}
+
+void QAnimationTimer::restartAnimationTimer()
+{
+ if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty())
+ QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish());
+ else if (isPaused)
+ QUnifiedTimer::resumeAnimationTimer(this);
+ else if (!isRegistered)
+ QUnifiedTimer::startAnimationTimer(this);
+}
+
+void QAnimationTimer::startAnimations()
+{
+ startAnimationPending = false;
+ //force timer to update, which prevents large deltas for our newly added animations
+ if (!animations.isEmpty())
+ QUnifiedTimer::instance()->updateAnimationTimers(-1);
+
+ //we transfer the waiting animations into the "really running" state
+ animations += animationsToStart;
+ animationsToStart.clear();
+ if (!animations.isEmpty())
+ restartAnimationTimer();
+}
+
+void QAnimationTimer::stopTimer()
+{
+ stopTimerPending = false;
+ if (animations.isEmpty()) {
+ QUnifiedTimer::resumeAnimationTimer(this);
+ QUnifiedTimer::stopAnimationTimer(this);
+ // invalidate the start reference time
+ lastTick = 0;
+ }
+}
+
+void QAnimationTimer::registerAnimation(QAbstractAnimation *animation, bool isTopLevel)
+{
+ QAnimationTimer *inst = instance(true); //we create the instance if needed
+ inst->registerRunningAnimation(animation);
+ if (isTopLevel) {
+ Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
+ QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
+ inst->animationsToStart << animation;
+ if (!inst->startAnimationPending) {
+ inst->startAnimationPending = true;
+ QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection);
+ }
+ }
+}
+
+void QAnimationTimer::unregisterAnimation(QAbstractAnimation *animation)
+{
+ QAnimationTimer *inst = QAnimationTimer::instance(false);
+ if (inst) {
+ //at this point the unified timer should have been created
+ //but it might also have been already destroyed in case the application is shutting down
+
+ inst->unregisterRunningAnimation(animation);
+
+ if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
+ return;
+
+ int idx = inst->animations.indexOf(animation);
+ if (idx != -1) {
+ inst->animations.removeAt(idx);
+ // this is needed if we unregister an animation while its running
+ if (idx <= inst->currentAnimationIdx)
+ --inst->currentAnimationIdx;
+
+ if (inst->animations.isEmpty() && !inst->stopTimerPending) {
+ inst->stopTimerPending = true;
+ QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection);
+ }
+ } else {
+ inst->animationsToStart.removeOne(animation);
+ }
+ }
+ QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = false;
+}
+
+void QAnimationTimer::registerRunningAnimation(QAbstractAnimation *animation)
+{
+ if (QAbstractAnimationPrivate::get(animation)->isGroup)
+ return;
+
+ if (QAbstractAnimationPrivate::get(animation)->isPause) {
+ runningPauseAnimations << animation;
+ } else
+ runningLeafAnimations++;
+}
+
+void QAnimationTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
+{
+ if (QAbstractAnimationPrivate::get(animation)->isGroup)
+ return;
+
+ if (QAbstractAnimationPrivate::get(animation)->isPause)
+ runningPauseAnimations.removeOne(animation);
+ else
+ runningLeafAnimations--;
+ Q_ASSERT(runningLeafAnimations >= 0);
+}
+
+int QAnimationTimer::closestPauseAnimationTimeToFinish()
+{
+ int closestTimeToFinish = INT_MAX;
+ for (int i = 0; i < runningPauseAnimations.size(); ++i) {
+ QAbstractAnimation *animation = runningPauseAnimations.at(i);
+ int timeToFinish;
+
+ if (animation->direction() == QAbstractAnimation::Forward)
+ timeToFinish = animation->duration() - animation->currentLoopTime();
+ else
+ timeToFinish = animation->currentLoopTime();
+
+ if (timeToFinish < closestTimeToFinish)
+ closestTimeToFinish = timeToFinish;
+ }
+ return closestTimeToFinish;
+}
/*!
\class QAnimationDriver
@@ -486,8 +740,8 @@ void QAnimationDriver::advanceAnimation(qint64 timeStep)
QUnifiedTimer *instance = QUnifiedTimer::instance();
// update current time on all top level animations
- instance->updateAnimationsTime(timeStep);
- instance->restartAnimationTimer();
+ instance->updateAnimationTimers(timeStep);
+ instance->restart();
}
@@ -601,7 +855,8 @@ void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
void QDefaultAnimationDriver::startTimer()
{
- m_timer.start(m_unified_timer->timingInterval, this);
+ // always use a precise timer to drive animations
+ m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer, this);
}
void QDefaultAnimationDriver::stopTimer()
@@ -643,11 +898,11 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
if (oldState == QAbstractAnimation::Running) {
if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
- QUnifiedTimer::ensureTimerUpdate();
+ QAnimationTimer::ensureTimerUpdate();
//the animation, is not running any more
- QUnifiedTimer::unregisterAnimation(q);
+ QAnimationTimer::unregisterAnimation(q);
} else if (newState == QAbstractAnimation::Running) {
- QUnifiedTimer::registerAnimation(q, isTopLevel);
+ QAnimationTimer::registerAnimation(q, isTopLevel);
}
q->updateState(newState, oldState);
@@ -669,7 +924,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (oldState == QAbstractAnimation::Stopped) {
if (isTopLevel) {
// currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::ensureTimerUpdate();
+ QAnimationTimer::ensureTimerUpdate();
q->setCurrentTime(totalCurrentTime);
}
}
@@ -728,7 +983,7 @@ QAbstractAnimation::~QAbstractAnimation()
d->state = Stopped;
emit stateChanged(oldState, d->state);
if (oldState == QAbstractAnimation::Running)
- QUnifiedTimer::unregisterAnimation(this);
+ QAnimationTimer::unregisterAnimation(this);
}
}
@@ -827,14 +1082,14 @@ void QAbstractAnimation::setDirection(Direction direction)
// the commands order below is important: first we need to setCurrentTime with the old direction,
// then update the direction on this and all children and finally restart the pauseTimer if needed
if (d->hasRegisteredTimer)
- QUnifiedTimer::ensureTimerUpdate();
+ QAnimationTimer::ensureTimerUpdate();
d->direction = direction;
updateDirection(direction);
if (d->hasRegisteredTimer)
// needed to update the timer interval in case of a pause animation
- QUnifiedTimer::updateAnimationTimer();
+ QAnimationTimer::updateAnimationTimer();
emit directionChanged(direction);
}
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index 456c017bba..4c20d25a53 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 7e7571bc58..2b2d5b8872 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -140,20 +140,36 @@ public:
bool running;
};
-typedef QElapsedTimer ElapsedTimer;
+class Q_CORE_EXPORT QAbstractAnimationTimer : public QObject
+{
+ Q_OBJECT
+public:
+ QAbstractAnimationTimer() : isRegistered(false), isPaused(false), pauseDuration(0) {}
+
+ virtual void updateAnimationsTime(qint64 delta) = 0;
+ virtual void restartAnimationTimer() = 0;
+ virtual int runningAnimationCount() = 0;
+
+ bool isRegistered;
+ bool isPaused;
+ int pauseDuration;
+};
class Q_CORE_EXPORT QUnifiedTimer : public QObject
{
+ Q_OBJECT
private:
QUnifiedTimer();
public:
- //XXX this is needed by dui
static QUnifiedTimer *instance();
static QUnifiedTimer *instance(bool create);
- static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
- static void unregisterAnimation(QAbstractAnimation *animation);
+ static void startAnimationTimer(QAbstractAnimationTimer *timer);
+ static void stopAnimationTimer(QAbstractAnimationTimer *timer);
+
+ static void pauseAnimationTimer(QAbstractAnimationTimer *timer, int duration);
+ static void resumeAnimationTimer(QAbstractAnimationTimer *timer);
//defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
void setTimingInterval(int interval);
@@ -168,32 +184,24 @@ public:
void setSlowModeEnabled(bool enabled) { slowMode = enabled; }
void setSlowdownFactor(qreal factor) { slowdownFactor = factor; }
- /*
- this is used for updating the currentTime of all animations in case the pause
- timer is active or, otherwise, only of the animation passed as parameter.
- */
- static void ensureTimerUpdate();
-
- /*
- this will evaluate the need of restarting the pause timer in case there is still
- some pause animations running.
- */
- static void updateAnimationTimer();
-
void installAnimationDriver(QAnimationDriver *driver);
void uninstallAnimationDriver(QAnimationDriver *driver);
bool canUninstallAnimationDriver(QAnimationDriver *driver);
- void restartAnimationTimer();
- void updateAnimationsTime(qint64 timeStep);
+ void restart();
+ void updateAnimationTimers(qint64 currentTick);
//useful for profiling/debugging
- int runningAnimationCount() { return animations.count(); }
+ int runningAnimationCount();
void registerProfilerCallback(void (*cb)(qint64));
protected:
void timerEvent(QTimerEvent *);
+private Q_SLOTS:
+ void startTimers();
+ void stopTimer();
+
private:
friend class QDefaultAnimationDriver;
friend class QAnimationDriver;
@@ -201,26 +209,75 @@ private:
QAnimationDriver *driver;
QDefaultAnimationDriver defaultDriver;
- QBasicTimer animationTimer;
- // timer used to delay the check if we should start/stop the animation timer
- QBasicTimer startStopAnimationTimer;
+ QBasicTimer pauseTimer;
- ElapsedTimer time;
+ QElapsedTimer time;
qint64 lastTick;
int timingInterval;
int currentAnimationIdx;
bool insideTick;
+ bool insideRestart;
bool consistentTiming;
bool slowMode;
+ bool startTimersPending;
+ bool stopTimerPending;
// This factor will be used to divide the DEFAULT_TIMER_INTERVAL at each tick
// when slowMode is enabled. Setting it to 0 or higher than DEFAULT_TIMER_INTERVAL (16)
// stops all animations.
qreal slowdownFactor;
- // bool to indicate that only pause animations are active
- bool isPauseTimerActive;
+ QList<QAbstractAnimationTimer*> animationTimers, animationTimersToStart;
+ QList<QAbstractAnimationTimer*> pausedAnimationTimers;
+
+ void localRestart();
+ int closestPausedAnimationTimerTimeToFinish();
+
+ void (*profilerCallback)(qint64);
+};
+
+class QAnimationTimer : public QAbstractAnimationTimer
+{
+ Q_OBJECT
+private:
+ QAnimationTimer();
+
+public:
+ static QAnimationTimer *instance();
+ static QAnimationTimer *instance(bool create);
+
+ static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
+ static void unregisterAnimation(QAbstractAnimation *animation);
+
+ /*
+ this is used for updating the currentTime of all animations in case the pause
+ timer is active or, otherwise, only of the animation passed as parameter.
+ */
+ static void ensureTimerUpdate();
+
+ /*
+ this will evaluate the need of restarting the pause timer in case there is still
+ some pause animations running.
+ */
+ static void updateAnimationTimer();
+
+ void restartAnimationTimer();
+ void updateAnimationsTime(qint64 delta);
+
+ //useful for profiling/debugging
+ int runningAnimationCount() { return animations.count(); }
+
+private Q_SLOTS:
+ void startAnimations();
+ void stopTimer();
+
+private:
+ qint64 lastTick;
+ int currentAnimationIdx;
+ bool insideTick;
+ bool startAnimationPending;
+ bool stopTimerPending;
QList<QAbstractAnimation*> animations, animationsToStart;
@@ -232,8 +289,6 @@ private:
void unregisterRunningAnimation(QAbstractAnimation *animation);
int closestPauseAnimationTimeToFinish();
-
- void (*profilerCallback)(qint64);
};
QT_END_NAMESPACE
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index 0d2eac2ebb..5993eda307 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h
index 7569671374..69a2686b69 100644
--- a/src/corelib/animation/qanimationgroup.h
+++ b/src/corelib/animation/qanimationgroup.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h
index d2e2498a87..8415610bdc 100644
--- a/src/corelib/animation/qanimationgroup_p.h
+++ b/src/corelib/animation/qanimationgroup_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp
index 6e942e0257..6e21efbc7f 100644
--- a/src/corelib/animation/qparallelanimationgroup.cpp
+++ b/src/corelib/animation/qparallelanimationgroup.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h
index 74eb36f4cd..b03163cfbb 100644
--- a/src/corelib/animation/qparallelanimationgroup.h
+++ b/src/corelib/animation/qparallelanimationgroup.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h
index cb8b3ae190..73fed5541c 100644
--- a/src/corelib/animation/qparallelanimationgroup_p.h
+++ b/src/corelib/animation/qparallelanimationgroup_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp
index 0f1e07e1f1..fe5bafa3bd 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h
index 827f1694ad..7f8a2ddf26 100644
--- a/src/corelib/animation/qpauseanimation.h
+++ b/src/corelib/animation/qpauseanimation.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 481b79d196..d34242739e 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h
index 28fc837f33..f41b96ce64 100644
--- a/src/corelib/animation/qpropertyanimation.h
+++ b/src/corelib/animation/qpropertyanimation.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h
index c8c69720e9..83f7c3f0fa 100644
--- a/src/corelib/animation/qpropertyanimation_p.h
+++ b/src/corelib/animation/qpropertyanimation_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 8b32d6b76d..a991a38823 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h
index 40201a9a32..07b2e3b8fc 100644
--- a/src/corelib/animation/qsequentialanimationgroup.h
+++ b/src/corelib/animation/qsequentialanimationgroup.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index 33af063bc9..87cdc044b2 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 7dfb4bddc1..8984abbe03 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index 3c92219b2a..4176b4f428 100644
--- a/src/corelib/animation/qvariantanimation.h
+++ b/src/corelib/animation/qvariantanimation.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index a8868d13ce..940cdbfe39 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/alpha/qatomic_alpha.s b/src/corelib/arch/alpha/qatomic_alpha.s
index 31f3925499..7dd09d4480 100644
--- a/src/corelib/arch/alpha/qatomic_alpha.s
+++ b/src/corelib/arch/alpha/qatomic_alpha.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/arm/qatomic_arm.cpp b/src/corelib/arch/arm/qatomic_arm.cpp
index 30612cef11..0eaeb5a15b 100644
--- a/src/corelib/arch/arm/qatomic_arm.cpp
+++ b/src/corelib/arch/arm/qatomic_arm.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/generic/qatomic_generic_unix.cpp b/src/corelib/arch/generic/qatomic_generic_unix.cpp
index e474a65642..78292e7e49 100644
--- a/src/corelib/arch/generic/qatomic_generic_unix.cpp
+++ b/src/corelib/arch/generic/qatomic_generic_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/generic/qatomic_generic_windows.cpp b/src/corelib/arch/generic/qatomic_generic_windows.cpp
index 7ce0eea076..94129cb106 100644
--- a/src/corelib/arch/generic/qatomic_generic_windows.cpp
+++ b/src/corelib/arch/generic/qatomic_generic_windows.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/ia64/qatomic_ia64.s b/src/corelib/arch/ia64/qatomic_ia64.s
index 26db10d994..f6b100c170 100644
--- a/src/corelib/arch/ia64/qatomic_ia64.s
+++ b/src/corelib/arch/ia64/qatomic_ia64.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/macosx/qatomic32_ppc.s b/src/corelib/arch/macosx/qatomic32_ppc.s
index edb80473e1..97d68cba70 100644
--- a/src/corelib/arch/macosx/qatomic32_ppc.s
+++ b/src/corelib/arch/macosx/qatomic32_ppc.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/mips/qatomic_mips32.s b/src/corelib/arch/mips/qatomic_mips32.s
index cd1585ecbc..b4013dfff5 100644
--- a/src/corelib/arch/mips/qatomic_mips32.s
+++ b/src/corelib/arch/mips/qatomic_mips32.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/mips/qatomic_mips64.s b/src/corelib/arch/mips/qatomic_mips64.s
index 60c9a83881..a66b785e30 100644
--- a/src/corelib/arch/mips/qatomic_mips64.s
+++ b/src/corelib/arch/mips/qatomic_mips64.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/parisc/q_ldcw.s b/src/corelib/arch/parisc/q_ldcw.s
index 86d50c79a5..0c1db6f394 100644
--- a/src/corelib/arch/parisc/q_ldcw.s
+++ b/src/corelib/arch/parisc/q_ldcw.s
@@ -1,6 +1,6 @@
;/****************************************************************************
;**
-;** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+;** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
;** All rights reserved.
;** Contact: Nokia Corporation (qt-info@nokia.com)
;**
diff --git a/src/corelib/arch/parisc/qatomic_parisc.cpp b/src/corelib/arch/parisc/qatomic_parisc.cpp
index aa2189162c..da8d480a4f 100644
--- a/src/corelib/arch/parisc/qatomic_parisc.cpp
+++ b/src/corelib/arch/parisc/qatomic_parisc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/powerpc/qatomic32.s b/src/corelib/arch/powerpc/qatomic32.s
index 794a397b77..dfc0605cff 100644
--- a/src/corelib/arch/powerpc/qatomic32.s
+++ b/src/corelib/arch/powerpc/qatomic32.s
@@ -1,6 +1,6 @@
############################################################################
##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation (qt-info@nokia.com)
##
diff --git a/src/corelib/arch/powerpc/qatomic64.s b/src/corelib/arch/powerpc/qatomic64.s
index 4a10b25012..9e81eb0bc0 100644
--- a/src/corelib/arch/powerpc/qatomic64.s
+++ b/src/corelib/arch/powerpc/qatomic64.s
@@ -1,6 +1,6 @@
############################################################################
##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation (qt-info@nokia.com)
##
diff --git a/src/corelib/arch/qatomic_alpha.h b/src/corelib/arch/qatomic_alpha.h
index a99a84b32a..b44b9f23f5 100644
--- a/src/corelib/arch/qatomic_alpha.h
+++ b/src/corelib/arch/qatomic_alpha.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_arch.h b/src/corelib/arch/qatomic_arch.h
index 905ccd7d99..66e12cc95b 100644
--- a/src/corelib/arch/qatomic_arch.h
+++ b/src/corelib/arch/qatomic_arch.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_arm.h b/src/corelib/arch/qatomic_arm.h
index 0f27009066..b5856102b2 100644
--- a/src/corelib/arch/qatomic_arm.h
+++ b/src/corelib/arch/qatomic_arm.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_armv5.h b/src/corelib/arch/qatomic_armv5.h
index 2a18042a26..d602e83e64 100644
--- a/src/corelib/arch/qatomic_armv5.h
+++ b/src/corelib/arch/qatomic_armv5.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index dd465db18b..260f48d563 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_armv7.h b/src/corelib/arch/qatomic_armv7.h
index 3554cd4301..814eefb376 100644
--- a/src/corelib/arch/qatomic_armv7.h
+++ b/src/corelib/arch/qatomic_armv7.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_avr32.h b/src/corelib/arch/qatomic_avr32.h
index 78d5fc7dd3..749cc0fd36 100644
--- a/src/corelib/arch/qatomic_avr32.h
+++ b/src/corelib/arch/qatomic_avr32.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_bfin.h b/src/corelib/arch/qatomic_bfin.h
index 21026ee440..4784b634fc 100644
--- a/src/corelib/arch/qatomic_bfin.h
+++ b/src/corelib/arch/qatomic_bfin.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_bootstrap.h b/src/corelib/arch/qatomic_bootstrap.h
index 74dc6cfbb2..86376062a2 100644
--- a/src/corelib/arch/qatomic_bootstrap.h
+++ b/src/corelib/arch/qatomic_bootstrap.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_generic.h b/src/corelib/arch/qatomic_generic.h
index 2565451a41..0abc29cdb0 100644
--- a/src/corelib/arch/qatomic_generic.h
+++ b/src/corelib/arch/qatomic_generic.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_i386.h b/src/corelib/arch/qatomic_i386.h
index 86230054b9..53a81864bf 100644
--- a/src/corelib/arch/qatomic_i386.h
+++ b/src/corelib/arch/qatomic_i386.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h
index e3cab66dc6..0782ab3f36 100644
--- a/src/corelib/arch/qatomic_ia64.h
+++ b/src/corelib/arch/qatomic_ia64.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_integrity.h b/src/corelib/arch/qatomic_integrity.h
index f957297769..e83124bf4e 100644
--- a/src/corelib/arch/qatomic_integrity.h
+++ b/src/corelib/arch/qatomic_integrity.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_macosx.h b/src/corelib/arch/qatomic_macosx.h
index e26cf65ecd..a973fe1b57 100644
--- a/src/corelib/arch/qatomic_macosx.h
+++ b/src/corelib/arch/qatomic_macosx.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h
index 8b025adfd5..97cef3c457 100644
--- a/src/corelib/arch/qatomic_mips.h
+++ b/src/corelib/arch/qatomic_mips.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_parisc.h b/src/corelib/arch/qatomic_parisc.h
index 8fbbb2e709..200ca14aee 100644
--- a/src/corelib/arch/qatomic_parisc.h
+++ b/src/corelib/arch/qatomic_parisc.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_powerpc.h b/src/corelib/arch/qatomic_powerpc.h
index c0f957b8ac..bb9afe38d7 100644
--- a/src/corelib/arch/qatomic_powerpc.h
+++ b/src/corelib/arch/qatomic_powerpc.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_s390.h b/src/corelib/arch/qatomic_s390.h
index 079dd2db16..e167c7c6e3 100644
--- a/src/corelib/arch/qatomic_s390.h
+++ b/src/corelib/arch/qatomic_s390.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_sh.h b/src/corelib/arch/qatomic_sh.h
index a764a31c71..ca50eb1bf0 100644
--- a/src/corelib/arch/qatomic_sh.h
+++ b/src/corelib/arch/qatomic_sh.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_sh4a.h b/src/corelib/arch/qatomic_sh4a.h
index 3ca1917863..14238a6f10 100644
--- a/src/corelib/arch/qatomic_sh4a.h
+++ b/src/corelib/arch/qatomic_sh4a.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_sparc.h b/src/corelib/arch/qatomic_sparc.h
index ab4386a675..feb172e68d 100644
--- a/src/corelib/arch/qatomic_sparc.h
+++ b/src/corelib/arch/qatomic_sparc.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h
index 0162ebccfd..6cb91f0788 100644
--- a/src/corelib/arch/qatomic_symbian.h
+++ b/src/corelib/arch/qatomic_symbian.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_vxworks.h b/src/corelib/arch/qatomic_vxworks.h
index 706dea6f4f..13d6764d36 100644
--- a/src/corelib/arch/qatomic_vxworks.h
+++ b/src/corelib/arch/qatomic_vxworks.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h
index 4807c69905..667e58124e 100644
--- a/src/corelib/arch/qatomic_windows.h
+++ b/src/corelib/arch/qatomic_windows.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_windowsce.h b/src/corelib/arch/qatomic_windowsce.h
index f58119ebdf..3681655285 100644
--- a/src/corelib/arch/qatomic_windowsce.h
+++ b/src/corelib/arch/qatomic_windowsce.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/qatomic_x86_64.h b/src/corelib/arch/qatomic_x86_64.h
index abbf0a932e..c2627c825f 100644
--- a/src/corelib/arch/qatomic_x86_64.h
+++ b/src/corelib/arch/qatomic_x86_64.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/sh/qatomic_sh.cpp b/src/corelib/arch/sh/qatomic_sh.cpp
index c1f0f332d6..b552392b64 100644
--- a/src/corelib/arch/sh/qatomic_sh.cpp
+++ b/src/corelib/arch/sh/qatomic_sh.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/arch/sparc/qatomic32.s b/src/corelib/arch/sparc/qatomic32.s
index 612093b81c..5f695a9093 100644
--- a/src/corelib/arch/sparc/qatomic32.s
+++ b/src/corelib/arch/sparc/qatomic32.s
@@ -1,6 +1,6 @@
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
-!! Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+!! Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
!! All rights reserved.
!! Contact: Nokia Corporation (qt-info@nokia.com)
!!
diff --git a/src/corelib/arch/sparc/qatomic64.s b/src/corelib/arch/sparc/qatomic64.s
index d78b5b628e..448afbd34e 100644
--- a/src/corelib/arch/sparc/qatomic64.s
+++ b/src/corelib/arch/sparc/qatomic64.s
@@ -1,6 +1,6 @@
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
-!! Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+!! Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
!! All rights reserved.
!! Contact: Nokia Corporation (qt-info@nokia.com)
!!
diff --git a/src/corelib/arch/sparc/qatomic_sparc.cpp b/src/corelib/arch/sparc/qatomic_sparc.cpp
index 71859aeaec..85848d04a0 100644
--- a/src/corelib/arch/sparc/qatomic_sparc.cpp
+++ b/src/corelib/arch/sparc/qatomic_sparc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index 46d7dd46da..96f4d7f111 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -35,7 +35,7 @@ unix {
HEADERS += codecs/qiconvcodec_p.h
SOURCES += codecs/qiconvcodec.cpp
DEFINES += GNU_LIBICONV
- } else:!symbian {
+ } else {
# no iconv, so we put all plugins in the library
HEADERS += \
../plugins/codecs/cn/qgb18030codec.h \
@@ -56,4 +56,3 @@ unix {
../plugins/codecs/jp/qfontjpcodec.cpp
}
}
-symbian:LIBS += -lcharconv
diff --git a/src/corelib/codecs/codecs.qdoc b/src/corelib/codecs/codecs.qdoc
index ff14e67c83..76c3f98b42 100644
--- a/src/corelib/codecs/codecs.qdoc
+++ b/src/corelib/codecs/codecs.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qfontlaocodec.cpp b/src/corelib/codecs/qfontlaocodec.cpp
index b852cf576c..ea21fa2898 100644
--- a/src/corelib/codecs/qfontlaocodec.cpp
+++ b/src/corelib/codecs/qfontlaocodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qfontlaocodec_p.h b/src/corelib/codecs/qfontlaocodec_p.h
index f81ac1d821..c61ac2181b 100644
--- a/src/corelib/codecs/qfontlaocodec_p.h
+++ b/src/corelib/codecs/qfontlaocodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index fb27f6ddfd..428e7d4bbe 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h
index 5a9742e192..fb2d89eeac 100644
--- a/src/corelib/codecs/qiconvcodec_p.h
+++ b/src/corelib/codecs/qiconvcodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp
index e66f424e43..e17b21a507 100644
--- a/src/corelib/codecs/qisciicodec.cpp
+++ b/src/corelib/codecs/qisciicodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qisciicodec_p.h b/src/corelib/codecs/qisciicodec_p.h
index 9ae450b848..d529be1215 100644
--- a/src/corelib/codecs/qisciicodec_p.h
+++ b/src/corelib/codecs/qisciicodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp
index 3c69ab0dd7..d95fcfc601 100644
--- a/src/corelib/codecs/qlatincodec.cpp
+++ b/src/corelib/codecs/qlatincodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qlatincodec_p.h b/src/corelib/codecs/qlatincodec_p.h
index f7930e72f6..71eded6d08 100644
--- a/src/corelib/codecs/qlatincodec_p.h
+++ b/src/corelib/codecs/qlatincodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp
index d24b4d4cfd..757351f196 100644
--- a/src/corelib/codecs/qsimplecodec.cpp
+++ b/src/corelib/codecs/qsimplecodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -54,7 +54,6 @@ static const struct {
int mib;
quint16 values[128];
} unicodevalues[QSimpleTextCodec::numSimpleCodecs] = {
-#ifndef Q_OS_SYMBIAN
// from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt
{ "KOI8-R", { "csKOI8R", 0 }, 2084,
{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
@@ -289,7 +288,6 @@ static const struct {
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} },
-#endif
{ "ISO-8859-16", { "iso-ir-226", "latin10", 0 }, 112,
{ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
@@ -311,7 +309,6 @@ static const struct {
// next bits generated again from tables on the Unicode 3.0 CD.
// $ for a in CP* ; do (awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a) | sort | sed -e 's/#UNDEF.*$/0xFFFD/' | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done
-#ifndef Q_OS_SYMBIAN
{ "IBM850", { "CP850", "csPC850Multilingual", 0 }, 2009,
{ 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
@@ -346,7 +343,6 @@ static const struct {
0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} },
-#endif //Q_OS_SYMBIAN
{ "IBM866", { "CP866", "csIBM866", 0 }, 2086,
{ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
@@ -365,7 +361,6 @@ static const struct {
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E,
0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} },
-#ifndef Q_OS_SYMBIAN
{ "windows-1250", { "CP1250", 0 }, 2250,
{ 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021,
0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
@@ -520,7 +515,6 @@ static const struct {
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} },
-#endif
{ "Apple Roman", { "macintosh", "MacRoman", 0 }, -168,
{ 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
@@ -560,7 +554,6 @@ static const struct {
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} },
-#ifndef Q_OS_SYMBIAN
// this one is generated from the charmap file located in /usr/share/i18n/charmaps
// on most Linux distributions. The thai character set tis620 is byte by byte equivalent
// to iso8859-11, so we name it 8859-11 here, but recognise the name tis620 too.
@@ -584,7 +577,6 @@ static const struct {
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD } },
-#endif
/*
Name: hp-roman8 [HP-PCL5,RFC1345,KXS2]
MIBenum: 2004
diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h
index fc28c97c67..6d0ceb3c95 100644
--- a/src/corelib/codecs/qsimplecodec_p.h
+++ b/src/corelib/codecs/qsimplecodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,11 +64,7 @@ template <typename T> class QAtomicPointer;
class QSimpleTextCodec: public QTextCodec
{
public:
-#ifdef Q_OS_SYMBIAN
- enum { numSimpleCodecs = 5 };
-#else
enum { numSimpleCodecs = 30 };
-#endif
explicit QSimpleTextCodec(int);
~QSimpleTextCodec();
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 42fac98a71..465caea62f 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,7 +64,7 @@
#ifndef QT_NO_CODECS
# include "qtsciicodec_p.h"
# include "qisciicodec_p.h"
-#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
+#if !defined(Q_OS_INTEGRITY)
# if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// no iconv(3) support, must build all codecs into the library
# include "../../plugins/codecs/cn/qgb18030codec.h"
@@ -78,7 +78,7 @@
# include "qfontlaocodec_p.h"
# include "../../plugins/codecs/jp/qfontjpcodec.h"
# endif
-#endif // QT_NO_SYMBIAN
+#endif // !Q_OS_INTEGRITY
#endif // QT_NO_CODECS
#include "qlocale.h"
#include "qmutex.h"
@@ -95,10 +95,6 @@
# define QT_NO_SETLOCALE
#endif
-#ifdef Q_OS_SYMBIAN
-#include "qtextcodec_symbian.cpp"
-#endif
-
// enabling this is not exception safe!
// #define Q_DEBUG_TEXTCODEC
@@ -231,14 +227,7 @@ Q_GLOBAL_STATIC(QTextCodecCleanup, createQTextCodecCleanup)
bool QTextCodec::validCodecs()
{
-#ifdef Q_OS_SYMBIAN
- // If we don't have a trap handler, we're outside of the main() function,
- // ie. in global constructors or destructors. Don't use codecs in this
- // case as it would lead to crashes because we don't have a cleanup stack on Symbian
- return (User::TrapHandler() != NULL);
-#else
return true;
-#endif
}
@@ -588,12 +577,6 @@ static QTextCodec *checkForCodec(const QByteArray &name) {
*/
static void setupLocaleMapper()
{
-#ifdef Q_OS_SYMBIAN
- localeMapper = QSymbianTextCodec::localeMapper;
- if (localeMapper)
- return;
-#endif
-
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
localeMapper = QTextCodec::codecForName("System");
#else
@@ -728,14 +711,6 @@ static void setup()
if (all)
return;
-#ifdef Q_OS_SYMBIAN
- // If we don't have a trap handler, we're outside of the main() function,
- // ie. in global constructors or destructors. Don't create codecs in this
- // case as it would lead to crashes because of a missing cleanup stack on Symbian
- if (User::TrapHandler() == NULL)
- return;
-#endif
-
#ifdef Q_DEBUG_TEXTCODEC
if (destroying_is_ok)
qWarning("QTextCodec: Creating new codec during codec cleanup");
@@ -752,10 +727,6 @@ static void setup()
for (int i = 0; i < QSimpleTextCodec::numSimpleCodecs; ++i)
(void)new QSimpleTextCodec(i);
-#ifdef Q_OS_SYMBIAN
- localeMapper = QSymbianTextCodec::init();
-#endif
-
# if defined(Q_OS_UNIX) && !defined(QT_BOOTSTRAPPED)
// no font codecs when bootstrapping
(void)new QFontLaoCodec;
@@ -773,7 +744,7 @@ static void setup()
# endif // Q_OS_UNIX
-#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
+#if !defined(Q_OS_INTEGRITY)
# if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// no asian codecs when bootstrapping, sorry
(void)new QGb18030Codec;
@@ -787,7 +758,7 @@ static void setup()
(void)new QBig5Codec;
(void)new QBig5hkscsCodec;
# endif // QT_NO_ICONV && !QT_BOOTSTRAPPED
-#endif //Q_OS_SYMBIAN
+#endif // !Q_OS_INTEGRITY
#endif // QT_NO_CODECS
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
@@ -800,13 +771,11 @@ static void setup()
(void)new QUtf32Codec;
(void)new QUtf32BECodec;
(void)new QUtf32LECodec;
-#ifndef Q_OS_SYMBIAN
(void)new QLatin15Codec;
-#endif
(void)new QLatin1Codec;
(void)new QUtf8Codec;
-#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
+#if !defined(Q_OS_INTEGRITY)
#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// QIconvCodec depends on the UTF-16 codec, so it needs to be created last
(void) new QIconvCodec();
@@ -842,7 +811,7 @@ QTextCodec::ConverterState::~ConverterState()
if (flags & FreeFunction)
(QTextCodecUnalignedPointer::decode(state_data))(this);
else if (d)
- qFree(d);
+ free(d);
}
/*!
@@ -1315,17 +1284,6 @@ QList<QByteArray> QTextCodec::aliases() const
*/
/*!
- Creates a QTextDecoder which stores enough state to decode chunks
- of \c{char *} data to create chunks of Unicode data.
-
- The caller is responsible for deleting the returned object.
-*/
-QTextDecoder* QTextCodec::makeDecoder() const
-{
- return new QTextDecoder(this);
-}
-
-/*!
Creates a QTextDecoder with a specified \a flags to decode chunks
of \c{char *} data to create chunks of Unicode data.
@@ -1338,18 +1296,6 @@ QTextDecoder* QTextCodec::makeDecoder(QTextCodec::ConversionFlags flags) const
return new QTextDecoder(this, flags);
}
-
-/*!
- Creates a QTextEncoder which stores enough state to encode chunks
- of Unicode data as \c{char *} data.
-
- The caller is responsible for deleting the returned object.
-*/
-QTextEncoder* QTextCodec::makeEncoder() const
-{
- return new QTextEncoder(this);
-}
-
/*!
Creates a QTextEncoder with a specified \a flags to encode chunks
of Unicode data as \c{char *} data.
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index 015c0941f2..c4f1a09726 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -117,11 +117,8 @@ public:
QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const
{ return convertFromUnicode(in, length, state); }
- // ### Qt 5: merge these functions.
- QTextDecoder* makeDecoder() const;
- QTextDecoder* makeDecoder(ConversionFlags flags) const;
- QTextEncoder* makeEncoder() const;
- QTextEncoder* makeEncoder(ConversionFlags flags) const;
+ QTextDecoder* makeDecoder(ConversionFlags flags = DefaultConversion) const;
+ QTextEncoder* makeEncoder(ConversionFlags flags = DefaultConversion) const;
virtual QByteArray name() const = 0;
virtual QList<QByteArray> aliases() const;
diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h
index ed09c4d1ac..03d9d3dfaf 100644
--- a/src/corelib/codecs/qtextcodec_p.h
+++ b/src/corelib/codecs/qtextcodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp
deleted file mode 100644
index c8a7357edc..0000000000
--- a/src/corelib/codecs/qtextcodec_symbian.cpp
+++ /dev/null
@@ -1,689 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtextcodec_p.h"
-
-#include <private/qcore_symbian_p.h>
-#include <QThreadStorage>
-#include <QScopedPointer>
-
-#include <charconv.h>
-
-struct QSymbianCodecInitData {
- uint charsetId;
- int mib;
- const char *aliases;
-};
-
-/* This table contains the known Symbian codecs aliases.
- It is required because symbian does not provide aliases for codecs.
- It is also faster to have a name here than asking the system.
- It is ordered by charsetId to allow binary search lookup
- */
-static const QSymbianCodecInitData codecsData[] = {
- { /*268439485*/ KCharacterSetIdentifierShiftJis, 17, "Shift_JIS\0MS_Kanji\0csShiftJIS\0SJIS\0" },
- { /*268439486*/ KCharacterSetIdentifierGb2312, 57, "GB2312\0csGB2312\0CN-GB\0EUC-CN\0" }, // Note: ConvertCharacterSetIdentifierToMibEnumL returns Mib 0 instaead of 57
- { /*268439487*/ KCharacterSetIdentifierBig5, 2026, "Big5\0csBig5\0Big5-ETen\0CP950\0BIG-FIVE\0CN-BIG5\0" },
- { /*268440246*/ KCharacterSetIdentifierCodePage1252, 2252, "windows-1252\0Code Page 1252\0CP1252\0MS-ANSI\0" },
-// { /*268450576*/ KCharacterSetIdentifierIso88591, 4, "ISO-8859-1\0ISO_8859-1:1987\0iso-ir-100\0ISO_8859-1\0latin1\0l1\0IBM819\0CP819\0csISOLatin1\0ISO-IR-100\0ISO8859-1\0L1\0LATIN1\0CSISOLATIN1\0" },
- { /*268451531*/ KCharacterSetIdentifierGbk, 113, "GBK\0MS936\0windows-936\0CP936\0" },
- { /*268451866*/ KCharacterSetIdentifierGb12345, 0, "GB12345\0" },
- { /*268455110*/ KCharacterSetIdentifierAscii, 3, "US-ASCII\0ANSI_X3.4-1968\0iso-ir-6\0ANSI_X3.4-1986\0ISO_646.irv:1991\0ASCII\0ISO646-US\0us\0IBM367\0cp367\0csASCII\0ISO-IR-6\0ISO_646.IRV:1991\0"},
- { /*268456062*/ KCharacterSetIdentifierIso88592, 5, "ISO-8859-2\0ISO_8859-2:1987\0iso-ir-101\0latin2\0l2\0csISOLatin2\0" },
- { /*268456063*/ KCharacterSetIdentifierIso88594, 7, "ISO-8859-4\0ISO_8859-4:1988\0iso-ir-110\0latin4\0l4\0csISOLatin4\0" },
- { /*268456064*/ KCharacterSetIdentifierIso88595, 8, "ISO-8859-5\0ISO_8859-5:1988\0iso-ir-144\0cyrillic\0csISOLatinCyrillic\0" },
- { /*268456065*/ KCharacterSetIdentifierIso88597, 10, "ISO-8859-7\0ISO_8859-7:1987\0iso-ir-126\0ELOT_928\0ECMA-118\0greek\0greek8\0csISOLatinGreek\0" },
- { /*268456066*/ KCharacterSetIdentifierIso88599, 12, "ISO-8859-9\0ISO_8859-9:1989\0iso-ir-148\0latin5\0l5\0csISOLatin5\0" },
- { /*268456875*/ KCharacterSetIdentifierSms7Bit, 0, "SMS 7-bit\0" },
- { /*268458028*/ KCharacterSetIdentifierUtf7, 103, "UTF-7\0UNICODE-1-1-UTF-7\0CSUNICODE11UTF7\0" },
-// { /*268458029*/ KCharacterSetIdentifierUtf8, 106, "UTF-8\0" },
- { /*268458030*/ KCharacterSetIdentifierImapUtf7, 0, "IMAP UTF-7\0" },
- { /*268458031*/ KCharacterSetIdentifierJavaConformantUtf8, 0, "JAVA UTF-8\0" },
- { /*268458454*/ 268458454, 2250, "Windows-1250\0CP1250\0MS-EE\0" },
- { /*268458455*/ 268458455, 2251, "Windows-1251\0CP1251\0MS-CYRL\0" },
- { /*268458456*/ 268458456, 2253, "Windows-1253\0CP1253\0MS-GREEK\0" },
- { /*268458457*/ 268458457, 2254, "Windows-1254\0CP1254\0MS-TURK\0" },
- { /*268458458*/ 268458458, 2257, "Windows-1257\0CP1257\0WINBALTRIM\0" },
- { /*268460133*/ KCharacterSetIdentifierHz, 2085, "HZ-GB-2312\0HZ\0" },
- { /*268460134*/ KCharacterSetIdentifierJis, 16, "JIS_Encoding\0JIS\0" },
- { /*268460135*/ KCharacterSetIdentifierEucJpPacked, 18, "EUC-JP\0Extended_UNIX_Code_Packed_Format_for_Japanese\0csEUCPkdFmtJapanese\0EUCJP_PACKED\0" },
- { /*268461728*/ KCharacterSetIdentifierIso2022Jp, 39, "ISO-2022-JP\0csISO2022JP\0JIS7\0" },
- { /*268461731*/ KCharacterSetIdentifierIso2022Jp1, 0, "ISO2022JP1\0" },
- { /*268470824*/ KCharacterSetIdentifierIso88593, 6, "ISO-8859-3\0ISO_8859-3:1988\0iso-ir-109\0latin3\0l3\0csISOLatin3\0" },
- { /*268470825*/ KCharacterSetIdentifierIso88596, 9, "ISO-8859-6\0ISO_8859-6:1987\0iso-ir-127\0ECMA-114\0ASMO-708\0arabic\0ISO88596\0csISOLatinArabic\0ARABIC\0" },
- { /*268470826*/ KCharacterSetIdentifierIso88598, 11, "ISO-8859-8\0ISO_8859-8:1988\0iso-ir-138\0hebrew\0csISOLatinHebrew\0" },
- { /*268470827*/ KCharacterSetIdentifierIso885910, 13, "ISO-8859-10\0iso-ir-157\0l6\0ISO_8859-10:1992\0csISOLatin6\0latin6\0" },
- { /*268470828*/ KCharacterSetIdentifierIso885913, 109, "ISO-8859-13\0ISO885913\0ISO-IR-179\0ISO8859-13\0L7\0LATIN7\0CSISOLATIN7\0" },
- { /*268470829*/ KCharacterSetIdentifierIso885914, 110, "ISO-8859-14\0iso-ir-199\0ISO_8859-14:1998\0latin8\0iso-celtic\0l8\0" },
- { /*268470830*/ KCharacterSetIdentifierIso885915, 111, "ISO-8859-15\0latin-9\0ISO-IR-203\0" },
-// { /*270483374*/ KCharacterSetIdentifierUnicodeLittle, 1014, "UTF-16LE\0Little-Endian UNICODE\0" },
-// { /*270483538*/ KCharacterSetIdentifierUnicodeBig, 1013, "UTF-16BE\0Big-Endian UNICODE\0" },
- { /*270501191*/ 270501191, 2255, "Windows-1255\0CP1255\0MS-HEBR\0" },
- { /*270501192*/ 270501192, 2256, "Windows-1256\0CP1256\0MS-ARAB\0" },
- { /*270501193*/ 270501193, 2259, "TIS-620\0ISO-IR-166\0TIS620-0\0TIS620.2529-1\0TIS620.2533-0\0TIS620.2533-1\0" },
- { /*270501194*/ 270501194, 0, "windows-874\0CP874\0IBM874\0" },
- { /*270501325*/ 270501325, 0, "SmsStrict\0" },
- { /*270501521*/ 270501521, 0, "ShiftJisDirectmap\0" },
- { /*270501542*/ 270501542, 0, "EucJpDirectmap\0" },
- /* 270501691 (duplicate) Windows-1252 | windows-1252 |Windows-1252 |Code Page 1252 |CP1252 |MS-ANSI |WINDOWS-1252 |2252 */
- { /*270501729*/ 270501729, 2088, "KOI8-U\0" },
- { /*270501752*/ 270501752, 2084, "KOI8-R\0csKOI8R\0" },
- { /*270529682*/ 270529682, 1000, "ISO-10646-UCS-2\0UCS-2\0CSUNICODE\0" },
- { /*270562232*/ 270562232, 2258, "Windows-1258\0CP1258\0WINDOWS-1258\0" },
- { /*270586888*/ 270586888, 0, "J5\0" },
- { /*271011982*/ 271011982, 0, "ISCII\0" },
- { /*271066541*/ 271066541, 2009, "CP850\0IBM850\0""850\0csPC850Multilingual\0" }, // Note: ConvertCharacterSetIdentifierToMibEnumL returns Mib 0 instead of 2009
- { /*271082493*/ 271082493, 0, "EXTENDED_SMS_7BIT\0" },
- { /*271082494*/ 271082494, 0, "gsm7_turkish_single\0" },
- { /*271082495*/ 271082495, 0, "turkish_locking_gsm7ext\0" },
- { /*271082496*/ 271082496, 0, "turkish_locking_single\0" },
- { /*271082503*/ 271082503, 0, "portuguese_gsm7_single\0" },
- { /*271082504*/ 271082504, 0, "portuguese_locking_gsm7ext\0" },
- { /*271082505*/ 271082505, 0, "portuguese_locking_single\0" },
- { /*271082506*/ 271082506, 0, "spanish_gsm7_single\0" },
- { /*271085624*/ 271085624, 114, "GB18030\0" },
- { /*536929574*/ 536929574, 38, "EUC-KR\0" },
- { /*536936703*/ 536936703, 0, "CP949\0" },
- { /*536936705*/ 536936705, 37, "ISO-2022-KR\0csISO2022KR\0" },
- { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" }
- };
-
-
-class QSymbianTextCodec : public QTextCodec
-{
-public:
- QString convertToUnicode(const char*, int, ConverterState*) const;
- QByteArray convertFromUnicode(const QChar*, int, ConverterState*) const;
- QList<QByteArray> aliases() const;
- QByteArray name() const;
- int mibEnum() const;
-
- explicit QSymbianTextCodec(uint charsetId, int staticIndex = -1) : m_charsetId(charsetId), m_staticIndex(staticIndex) { }
-
- static QSymbianTextCodec *init();
- static QSymbianTextCodec *localeMapper;
-private:
- static CCnvCharacterSetConverter *converter();
- static uint getLanguageDependentCharacterSet();
- uint m_charsetId;
- int m_staticIndex;
-};
-
-QSymbianTextCodec *QSymbianTextCodec::localeMapper = 0;
-
-class QSymbianTextCodecWithName : public QSymbianTextCodec
-{
-public:
- QSymbianTextCodecWithName(uint charsetId, const QByteArray &name)
- : QSymbianTextCodec(charsetId) , m_name(name) { }
- QByteArray name() const { return m_name; }
- QList<QByteArray> aliases() const { return QList<QByteArray>(); }
-private:
- QByteArray m_name;
-};
-
-Q_GLOBAL_STATIC(QThreadStorage<CCnvCharacterSetConverter *>,gs_converterStore);
-
-CCnvCharacterSetConverter *QSymbianTextCodec::converter()
-{
- CCnvCharacterSetConverter *&conv = gs_converterStore()->localData();
- if (!conv)
- QT_TRAP_THROWING(conv = CCnvCharacterSetConverter::NewL())
- return conv;
-}
-
-
-QByteArray QSymbianTextCodec::name() const
-{
- if (m_staticIndex >= 0)
- return QByteArray(codecsData[m_staticIndex].aliases);
- QScopedPointer<HBufC8> buf;
- QT_TRAP_THROWING(buf.reset(converter()->ConvertCharacterSetIdentifierToStandardNameL(m_charsetId, qt_s60GetRFs())))
- if (buf)
- return QByteArray(reinterpret_cast<const char *>(buf->Ptr()), buf->Length());
- return QByteArray();
-}
-
-int QSymbianTextCodec::mibEnum() const
-{
- if (m_staticIndex >= 0)
- return codecsData[m_staticIndex].mib;
- int mib;
- QT_TRAP_THROWING(mib = converter()->ConvertCharacterSetIdentifierToMibEnumL(m_charsetId, qt_s60GetRFs()))
- return mib;
-}
-
-QList<QByteArray> QSymbianTextCodec::aliases() const
-{
- QList<QByteArray> result;
- if (m_staticIndex >= 0) {
- const char *aliases = codecsData[m_staticIndex].aliases;
- aliases += strlen(aliases) + 1;
- while (*aliases) {
- int len = strlen(aliases);
- result += QByteArray(aliases, len);
- aliases += len + 1;
- }
- }
- return result;
-}
-
-
-QString QSymbianTextCodec::convertToUnicode(const char *str, int len, ConverterState *state) const
-{
- uint charsetId = m_charsetId;
-
- // no support for utf7 with state
- if (state && (charsetId == KCharacterSetIdentifierUtf7 ||
- charsetId == KCharacterSetIdentifierImapUtf7)) {
- return QString();
- }
- CCnvCharacterSetConverter *converter = QSymbianTextCodec::converter();
- if (!str) {
- return QString();
- }
-
- //Search the character set array containing all of the character sets for which conversion is available
- CCnvCharacterSetConverter::TAvailability av;
- QT_TRAP_THROWING(av = converter->PrepareToConvertToOrFromL(charsetId, qt_s60GetRFs()))
- if (av == CCnvCharacterSetConverter::ENotAvailable) {
- return QString();
- }
-
- char *str2;
- int len2;
- QByteArray helperBA;
- if (state && (state->remainingChars > 0)) {
- // we should prepare the input string ourselves
- // the real size
- len2 = len + state->remainingChars;
- helperBA.resize(len2);
- str2 = helperBA.data();
- if (state->remainingChars > 3) { // doesn't happen usually
- memcpy(str2, state->d, state->remainingChars);
- qFree(state->d);
- state->d = 0;
- } else {
- char charTbl[3];
- charTbl[0] = state->state_data[0];
- charTbl[1] = state->state_data[1];
- charTbl[2] = state->state_data[2];
- memcpy(str2, charTbl, state->remainingChars);
- }
- memcpy(str2+state->remainingChars, str, len);
- }
- else {
- len2 = len;
- str2 = const_cast<char*>(str);
- }
-
- QString UnicodeText(len2, Qt::Uninitialized);
- TPtrC8 remainderOfForeignText;
- remainderOfForeignText.Set(reinterpret_cast<const unsigned char *>(str2), len2);
-
- int numberOfUnconvertibleCharacters = 0;
- int indexOfFirstUnconvertibleCharacter;
-
- // Use null character as replacement, if it is asked
- bool convertToNull = (state && (state->flags & QTextCodec::ConvertInvalidToNull));
- if (convertToNull) {
- _LIT8(KReplacement, "\x00");
- QT_TRAP_THROWING(converter->SetReplacementForUnconvertibleUnicodeCharactersL(KReplacement))
- }
- // use state->invalidChars for keeping symbian state
- int sState = CCnvCharacterSetConverter::KStateDefault;
- if (state && (state->invalidChars != CCnvCharacterSetConverter::KStateDefault)) {
- sState = state->invalidChars;
- }
- //Convert text encoded in a non-Unicode character set into the Unicode character set (UCS-2).
- int remainingChars = -1;
- int initial_size=0;
- while (1) {
- TPtr16 UnicodePtr(reinterpret_cast<unsigned short *>(UnicodeText.data()+initial_size), UnicodeText.size());
- QT_TRAP_THROWING(remainingChars = converter->ConvertToUnicode(UnicodePtr,
- remainderOfForeignText,
- sState,
- numberOfUnconvertibleCharacters,
- indexOfFirstUnconvertibleCharacter))
-
- initial_size += UnicodePtr.Length();
- // replace 0xFFFD with 0x0000 and only if state set to convert to it
- if (numberOfUnconvertibleCharacters>0 && convertToNull) {
- int len2 = UnicodePtr.Length();
- for (int i = indexOfFirstUnconvertibleCharacter; i < len2; i++) {
- UnicodePtr[i] = 0x0000;
- }
- }
- // success
- if (remainingChars==KErrNone) {
- break;
- }
- // if ConvertToUnicode could not consume the foreign text at all
- // UTF-8: EErrorIllFormedInput = KErrCorrupt
- // UCS-2: KErrNotFound
- if (remainingChars == CCnvCharacterSetConverter::EErrorIllFormedInput ||
- remainingChars == KErrNotFound) {
- remainingChars = remainderOfForeignText.Size();
- break;
- }
- else {
- if (remainingChars < 0) {
- return QString();
- }
- }
- //
- UnicodeText.resize(UnicodeText.size() + remainingChars*2);
- remainderOfForeignText.Set(reinterpret_cast<const unsigned char *>(str2+len2-remainingChars), remainingChars);
- }
- // save symbian state
- if (state) {
- state->invalidChars = sState;
- }
-
- if (remainingChars > 0) {
- if (!state) {
- // No way to signal, if there is still remaining chars, for ex. UTF-8 still can have
- // some characters hanging around.
- return QString();
- }
- const unsigned char *charPtr = remainderOfForeignText.Right(remainingChars).Ptr();
- if (remainingChars > 3) { // doesn't happen usually
- state->d = (void*)qMalloc(remainingChars);
- if (!state->d)
- return QString();
- // copy characters there
- memcpy(state->d, charPtr, remainingChars);
- }
- else {
- // fallthru is correct
- switch (remainingChars) {
- case 3:
- state->state_data[2] = charPtr[2];
- case 2:
- state->state_data[1] = charPtr[1];
- case 1:
- state->state_data[0] = charPtr[0];
- }
- }
- state->remainingChars = remainingChars;
- }
- else {
- if (state) {
- // If we continued from an earlier iteration
- state->remainingChars = 0;
- }
- }
- // check if any ORIGINAL headers should be left
- if (initial_size > 0) {
- if (!state || (state && !(state->flags & QTextCodec::IgnoreHeader))) {
- // always skip headers on following state loops
- if (state) {
- state->flags |= QTextCodec::IgnoreHeader;
- }
- const TUint16 *ptr = reinterpret_cast<const TUint16 *>(UnicodeText.data());
- if (ptr[0] == QChar::ByteOrderMark || ptr[0] == QChar::ByteOrderSwapped) {
- return UnicodeText.mid(1, initial_size - 1);
- }
- }
- }
- if (initial_size >= 0) {
- UnicodeText.resize(initial_size);
- return UnicodeText;
- }
- else {
- return QString();
- }
-}
-
-
-QByteArray QSymbianTextCodec::convertFromUnicode(const QChar *str, int len, ConverterState *state) const
-{
- uint charsetId = m_charsetId;
- CCnvCharacterSetConverter *converter = QSymbianTextCodec::converter();
- if (!str)
- return QByteArray();
-
- if (len == 0)
- return QByteArray();
-
- // no support for utf7 with state
- if (state && (charsetId == KCharacterSetIdentifierUtf7 ||
- charsetId == KCharacterSetIdentifierImapUtf7))
- return QByteArray();
-
- //Get reference file session from backend
- RFs &fileSession = qt_s60GetRFs();
-
- //Search the character set array containing all of the character sets for which conversion is available
- CCnvCharacterSetConverter::TAvailability av = CCnvCharacterSetConverter::ENotAvailable;
- QT_TRAP_THROWING(av = converter->PrepareToConvertToOrFromL(charsetId, fileSession))
- if (av == CCnvCharacterSetConverter::ENotAvailable)
- return QByteArray();
-
- // Use null character as replacement, if it is asked
- if (state && (state->flags & QTextCodec::ConvertInvalidToNull)) {
- _LIT8(KReplacement, "\x00");
- QT_TRAP_THROWING(converter->SetReplacementForUnconvertibleUnicodeCharactersL(KReplacement))
- }
- else {
- _LIT8(KReplacement, "?");
- QT_TRAP_THROWING(converter->SetReplacementForUnconvertibleUnicodeCharactersL(KReplacement))
- }
- QByteArray outputBuffer;
-
- // add header if no state (one run), or if no ignoreheader (from first state)
- int bomofs = 0;
- if (!state || (state && !(state->flags & QTextCodec::IgnoreHeader))) {
-
- QChar bom(QChar::ByteOrderMark);
-
- if (state)
- state->flags |= QTextCodec::IgnoreHeader; // bom handling only on first state
-
- switch (charsetId) {
- case KCharacterSetIdentifierUcs2:
- outputBuffer.append(bom.row());
- outputBuffer.append(bom.cell());
- bomofs = 2;
- break;
-
- case KCharacterSetIdentifierUtf8: // we don't add bom for UTF-8
- case KCharacterSetIdentifierJavaConformantUtf8:
- /*outputBuffer.append("\xef\xbb\xbf");
- bomofs = 3;
- */
- break;
-
- case KCharacterSetIdentifierUnicodeLittle:
- outputBuffer.append(bom.cell());
- outputBuffer.append(bom.row());
- bomofs = 2;
- break;
-
- case KCharacterSetIdentifierUnicodeBig:
- outputBuffer.append(bom.row());
- outputBuffer.append(bom.cell());
- bomofs = 2;
- break;
-
- default:
- break;
- }
- }
-
- // len is 16bit chars, reserve 3 8bit chars for each input char
- // jsz - it could be differentiated, to allocate less
- outputBuffer.resize(len * 3 + bomofs);
-
- // loop for too short output buffer
- int unconverted;
- int numberOfUnconvertibleCharacters = len;
- int indexOfFirstUnconvertibleCharacter;
- int convertedSize;
- int lastUnconverted = 0;
- int initial_size=0;
- int remainderToConvert = len;
- while (1) {
- TPtr8 outputPtr(reinterpret_cast<unsigned char *>(outputBuffer.data() + bomofs + initial_size), outputBuffer.size() - bomofs);
-
- TPtrC16 UnicodeText(reinterpret_cast<const unsigned short *>(str+len-remainderToConvert), remainderToConvert);
-
- //Convert text encoded in the Unicode character set (UCS-2) into other character sets
- unconverted = -1;
- QT_TRAP_THROWING( unconverted = converter->ConvertFromUnicode(outputPtr,
- UnicodeText,
- numberOfUnconvertibleCharacters,
- indexOfFirstUnconvertibleCharacter))
- initial_size += outputPtr.Length();
- if (unconverted < 0) {
- return QByteArray();
- }
-
-
- if (unconverted == 0 ) {
- convertedSize = initial_size;
- break;
- }
-
- // check what means unconverted > 0
- if (indexOfFirstUnconvertibleCharacter<0) {
- // 8859-6 and 8859-8 break with certain input (string of \xc0 - \xd9 converted to unicode and back)
- if (unconverted == lastUnconverted) {
- return QByteArray();
- }
- lastUnconverted = unconverted;
- }
- else {
- // were some character not possible to convert
-
- }
- remainderToConvert = unconverted; // len - indexOfFirstUnconvertibleCharacter;
- // resize output buffer, use =op for the null check
- outputBuffer.resize(outputBuffer.size() + remainderToConvert * 3 + bomofs);
- };
-
- // shorten output
- outputBuffer.resize(convertedSize + bomofs);
-
- if (state) {
- state->invalidChars = numberOfUnconvertibleCharacters;
-
- // check if any Symbian CONVERTED headers should be removed
- if (state->flags & QTextCodec::IgnoreHeader && state->state_data[0] == 0) {
-
- state->state_data[0] = 0xff; // bom handling only on first state
-
- if (charsetId == KCharacterSetIdentifierUcs2 && outputBuffer.size() > 1) {
-
- QChar bom(QChar::ByteOrderMark);
- if (outputBuffer.at(0) == bom.row() && outputBuffer.at(1) == bom.cell()) {
- outputBuffer.remove(0, 2);
- } else if (outputBuffer.at(0) == bom.cell() && outputBuffer.at(1) == bom.row()) {
- outputBuffer.remove(0, 2);
- }
-
- } else if ((charsetId == KCharacterSetIdentifierUtf8 ||
- charsetId == KCharacterSetIdentifierJavaConformantUtf8) &&
- outputBuffer.size() > 2) {
- if (outputBuffer.at(0) == 0xef && outputBuffer.at(1) == 0xbb && outputBuffer.at(2) == 0xbf) {
- outputBuffer.remove(0, 3);
- }
-
- } else if (charsetId == KCharacterSetIdentifierUnicodeLittle &&
- outputBuffer.size() > 1) {
-
- QChar bom(QChar::ByteOrderMark);
- if (outputBuffer.at(0) == bom.row() && outputBuffer.at(1) == bom.cell()) {
- outputBuffer.remove(0, 2);
- }
-
- } else if (charsetId == KCharacterSetIdentifierUnicodeBig &&
- outputBuffer.size() > 1) {
-
- QChar bom(QChar::ByteOrderSwapped);
- if (outputBuffer.at(0) == bom.row() && outputBuffer.at(1) == bom.cell()) {
- outputBuffer.remove(0, 2);
- }
- }
-
- }
- }
-
- return outputBuffer;
-}
-
-
-uint QSymbianTextCodec::getLanguageDependentCharacterSet()
-{
- TLanguage lang = User::Language();
-
- uint langIndex = 0;
-
- switch (lang) {
- case 14: //ELangTurkish
- langIndex = KCharacterSetIdentifierIso88599; break;
- case 16: //ELangRussian
- langIndex = KCharacterSetIdentifierIso88595; break;
- case 17: //ELangHungarian
- langIndex = KCharacterSetIdentifierIso88592; break;
- case 25: //ELangCzec
- case 26: //ELangSlovak
- case 27: //ELangPolish
- case 28: //ELangSlovenian
- langIndex = KCharacterSetIdentifierIso88592; break;
- case 29: //ELangTaiwanChinese
- case 30: //ELangHongKongChinese
- langIndex = KCharacterSetIdentifierBig5; break;
- case 31: //ELangPrcChinese
- langIndex = KCharacterSetIdentifierGbk; break;
- case 32: //ELangJapanese
- langIndex = KCharacterSetIdentifierShiftJis; break;
- case 33: //ELangThai
- langIndex = 270501193 /*KCharacterSetIdentifierTis620*/; break;
- case 37: //ELangArabic
- langIndex = KCharacterSetIdentifierIso88596; break;
- case 40: //ELangBelarussian
- case 42: //ELangBulgarian
- langIndex = KCharacterSetIdentifierIso88595; break;
- case 45: //ELangCroatian
- langIndex = KCharacterSetIdentifierIso88592; break;
- case 49: //ELangEstonian
- langIndex = KCharacterSetIdentifierIso88594; break;
- case 54: //ELangGreek
- case 55: //ELangCyprusGreek
- langIndex = KCharacterSetIdentifierIso88597; break;
- case 57: //ELangHebrew
- langIndex = KCharacterSetIdentifierIso88598; break;
- case 58: //ELangHindi
- langIndex = 271011982/*KCharacterSetIdentifierIscii*/; break;
- case 67: //ELangLatvian
- case 68: //ELangLithuanian
- langIndex = KCharacterSetIdentifierIso88594; break;
- case 69: //ELangMacedonian
- langIndex = KCharacterSetIdentifierIso88595; break;
- case 78: //ELangRomanian
- langIndex = KCharacterSetIdentifierIso88592; break;
- case 79: //ELangSerbian
- langIndex = KCharacterSetIdentifierIso88592; break;
- case 91: //ELangCyprusTurkish
- langIndex = KCharacterSetIdentifierIso88599; break;
- case 93: //ELangUkrainian
- langIndex = KCharacterSetIdentifierIso88595; break;
- case 94: //ELangUrdu
- langIndex = KCharacterSetIdentifierIso88596; break;
- case 157: //ELangEnglish_Taiwan
- case 158: //ELangEnglish_HongKong
- langIndex = KCharacterSetIdentifierBig5; break;
- case 159: //ELangEnglish_Prc
- langIndex = KCharacterSetIdentifierGbk; break;
- case 160:
- langIndex = KCharacterSetIdentifierShiftJis; break;
- case 161: //ELangEnglish_Thailand
- langIndex = 270501193/*KCharacterSetIdentifierTis620*/; break;
- }
-
- if (langIndex > 0) {
- return langIndex;
- }
- return KCharacterSetIdentifierCodePage1252;
-}
-
-/* Create the codecs that have aliases and return the locale mapper*/
-QSymbianTextCodec *QSymbianTextCodec::init()
-{
- const uint localeMapperId = getLanguageDependentCharacterSet();
- QScopedPointer<CArrayFix<CCnvCharacterSetConverter::SCharacterSet> > array;
- QT_TRAP_THROWING(array.reset(CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableL(qt_s60GetRFs())))
- CCnvCharacterSetConverter *converter = QSymbianTextCodec::converter();
- int count = array->Count();
- for (int i = 0; i < count; i++) {
- int charsetId = array->At(i).Identifier();
-
- // skip builtin Qt codecs
- if (charsetId == KCharacterSetIdentifierUtf8 || charsetId == KCharacterSetIdentifierUnicodeLittle
- || charsetId == KCharacterSetIdentifierUnicodeLittle || charsetId == KCharacterSetIdentifierUnicodeBig
- || charsetId == KCharacterSetIdentifierIso88591
- || charsetId == 270501691 /* skip Windows-1252 duplicate*/) {
- continue;
- }
-
- int begin = 0;
- int n = sizeof(codecsData) / sizeof(codecsData[0]);
- int half;
-
- while (n > 0) {
- half = n >> 1;
- int middle = begin + half;
- if (codecsData[middle].charsetId < charsetId) {
- begin = middle + 1;
- n -= half + 1;
- } else {
- n = half;
- }
- }
- if (codecsData[begin].charsetId == charsetId) {
- QSymbianTextCodec *c = new QSymbianTextCodec(charsetId, begin);
- if (charsetId == localeMapperId)
- localeMapper = c;
- } else {
- // We did not find the charsetId in our codecsData[], therefore we ask
- // the OS for the codec name. We first try to get a "standard name" and fall
- // back to array->At(i).Name(), if really needed. array->At(i).Name() is not
- // guaranteed to be a correct name for QTextCodec::codecFromName().
- QScopedPointer<HBufC8> buf;
- QT_TRAP_THROWING(buf.reset(converter->ConvertCharacterSetIdentifierToStandardNameL(charsetId, qt_s60GetRFs())))
- QByteArray name;
- if (buf && buf->Length()) {
- name = QByteArray(reinterpret_cast<const char *>(buf->Ptr()), buf->Length());
- } else {
- TPtrC charSetName = array->At(i).NameIsFileName() ? TParsePtrC(array->At(i).Name()).Name() : array->At(i).Name();
- int len = charSetName.Length();
- QString str;
- str.setUnicode(reinterpret_cast<const QChar*>(charSetName.Ptr()), len);
- name = str.toLatin1();
- }
- if (!name.isEmpty())
- new QSymbianTextCodecWithName(charsetId, name);
- }
-
- }
- return localeMapper;
-}
diff --git a/src/corelib/codecs/qtextcodecplugin.cpp b/src/corelib/codecs/qtextcodecplugin.cpp
index 91b172d591..4eb075c5f2 100644
--- a/src/corelib/codecs/qtextcodecplugin.cpp
+++ b/src/corelib/codecs/qtextcodecplugin.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qtextcodecplugin.h b/src/corelib/codecs/qtextcodecplugin.h
index d80b173c8c..9a00bbc9fa 100644
--- a/src/corelib/codecs/qtextcodecplugin.h
+++ b/src/corelib/codecs/qtextcodecplugin.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qtsciicodec.cpp b/src/corelib/codecs/qtsciicodec.cpp
index 868136605e..c158ad2dc5 100644
--- a/src/corelib/codecs/qtsciicodec.cpp
+++ b/src/corelib/codecs/qtsciicodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qtsciicodec_p.h b/src/corelib/codecs/qtsciicodec_p.h
index b55d8bf288..b74b38c429 100644
--- a/src/corelib/codecs/qtsciicodec_p.h
+++ b/src/corelib/codecs/qtsciicodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 34e4695a26..d279f8591c 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h
index 982a3d198a..737697f5d6 100644
--- a/src/corelib/codecs/qutfcodec_p.h
+++ b/src/corelib/codecs/qutfcodec_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuture.cpp b/src/corelib/concurrent/qfuture.cpp
index 5bffd66fc3..81655502e9 100644
--- a/src/corelib/concurrent/qfuture.cpp
+++ b/src/corelib/concurrent/qfuture.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuture.h b/src/corelib/concurrent/qfuture.h
index 911fb7ecc5..6407fc39e7 100644
--- a/src/corelib/concurrent/qfuture.h
+++ b/src/corelib/concurrent/qfuture.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfutureinterface.cpp b/src/corelib/concurrent/qfutureinterface.cpp
index f54b335403..63033080a1 100644
--- a/src/corelib/concurrent/qfutureinterface.cpp
+++ b/src/corelib/concurrent/qfutureinterface.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfutureinterface.h b/src/corelib/concurrent/qfutureinterface.h
index b92a47a33d..2acd1f46fd 100644
--- a/src/corelib/concurrent/qfutureinterface.h
+++ b/src/corelib/concurrent/qfutureinterface.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfutureinterface_p.h b/src/corelib/concurrent/qfutureinterface_p.h
index 7b5275f5f8..96567c35eb 100644
--- a/src/corelib/concurrent/qfutureinterface_p.h
+++ b/src/corelib/concurrent/qfutureinterface_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuturesynchronizer.cpp b/src/corelib/concurrent/qfuturesynchronizer.cpp
index 18990ae2f0..d46aa3e7e7 100644
--- a/src/corelib/concurrent/qfuturesynchronizer.cpp
+++ b/src/corelib/concurrent/qfuturesynchronizer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuturesynchronizer.h b/src/corelib/concurrent/qfuturesynchronizer.h
index ba838a8b66..4fc1987f65 100644
--- a/src/corelib/concurrent/qfuturesynchronizer.h
+++ b/src/corelib/concurrent/qfuturesynchronizer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuturewatcher.cpp b/src/corelib/concurrent/qfuturewatcher.cpp
index e405896f0b..e0f197c7e7 100644
--- a/src/corelib/concurrent/qfuturewatcher.cpp
+++ b/src/corelib/concurrent/qfuturewatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuturewatcher.h b/src/corelib/concurrent/qfuturewatcher.h
index a5f723c100..efd7d94101 100644
--- a/src/corelib/concurrent/qfuturewatcher.h
+++ b/src/corelib/concurrent/qfuturewatcher.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qfuturewatcher_p.h b/src/corelib/concurrent/qfuturewatcher_p.h
index e90bff1e9b..4898779c33 100644
--- a/src/corelib/concurrent/qfuturewatcher_p.h
+++ b/src/corelib/concurrent/qfuturewatcher_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qrunnable.cpp b/src/corelib/concurrent/qrunnable.cpp
index 9ac335bc83..e5f7dc0efb 100644
--- a/src/corelib/concurrent/qrunnable.cpp
+++ b/src/corelib/concurrent/qrunnable.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qrunnable.h b/src/corelib/concurrent/qrunnable.h
index 34ef16bc10..d4b3bda956 100644
--- a/src/corelib/concurrent/qrunnable.h
+++ b/src/corelib/concurrent/qrunnable.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentcompilertest.h b/src/corelib/concurrent/qtconcurrentcompilertest.h
index c139c7a8b2..b6385b5a8f 100644
--- a/src/corelib/concurrent/qtconcurrentcompilertest.h
+++ b/src/corelib/concurrent/qtconcurrentcompilertest.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentexception.cpp b/src/corelib/concurrent/qtconcurrentexception.cpp
index 237152c0d3..3bc4c05684 100644
--- a/src/corelib/concurrent/qtconcurrentexception.cpp
+++ b/src/corelib/concurrent/qtconcurrentexception.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentexception.h b/src/corelib/concurrent/qtconcurrentexception.h
index 1c100a5206..c926d9ffe7 100644
--- a/src/corelib/concurrent/qtconcurrentexception.h
+++ b/src/corelib/concurrent/qtconcurrentexception.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentfilter.cpp b/src/corelib/concurrent/qtconcurrentfilter.cpp
index dff5e2e5ed..0b3ddd829d 100644
--- a/src/corelib/concurrent/qtconcurrentfilter.cpp
+++ b/src/corelib/concurrent/qtconcurrentfilter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentfilter.h b/src/corelib/concurrent/qtconcurrentfilter.h
index d8c5f43a48..c9ed9bbdfa 100644
--- a/src/corelib/concurrent/qtconcurrentfilter.h
+++ b/src/corelib/concurrent/qtconcurrentfilter.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentfilterkernel.h b/src/corelib/concurrent/qtconcurrentfilterkernel.h
index 95dc5b70be..61d13423a3 100644
--- a/src/corelib/concurrent/qtconcurrentfilterkernel.h
+++ b/src/corelib/concurrent/qtconcurrentfilterkernel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
index 1e09221cee..1468b4e4e6 100644
--- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
index c9ea79bd34..9b3b177ce8 100644
--- a/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
+++ b/src/corelib/concurrent/qtconcurrentiteratekernel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.h b/src/corelib/concurrent/qtconcurrentiteratekernel.h
index 49c053caf7..6adb05574b 100644
--- a/src/corelib/concurrent/qtconcurrentiteratekernel.h
+++ b/src/corelib/concurrent/qtconcurrentiteratekernel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentmap.cpp b/src/corelib/concurrent/qtconcurrentmap.cpp
index ebd0ccdcd8..f078a0646a 100644
--- a/src/corelib/concurrent/qtconcurrentmap.cpp
+++ b/src/corelib/concurrent/qtconcurrentmap.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentmap.h b/src/corelib/concurrent/qtconcurrentmap.h
index 166d5c8527..d735045173 100644
--- a/src/corelib/concurrent/qtconcurrentmap.h
+++ b/src/corelib/concurrent/qtconcurrentmap.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentmapkernel.h b/src/corelib/concurrent/qtconcurrentmapkernel.h
index 48f5b60de1..ed8a1543ce 100644
--- a/src/corelib/concurrent/qtconcurrentmapkernel.h
+++ b/src/corelib/concurrent/qtconcurrentmapkernel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentmedian.h b/src/corelib/concurrent/qtconcurrentmedian.h
index e563b3bd3a..13983fd2a4 100644
--- a/src/corelib/concurrent/qtconcurrentmedian.h
+++ b/src/corelib/concurrent/qtconcurrentmedian.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentreducekernel.h b/src/corelib/concurrent/qtconcurrentreducekernel.h
index ebc37e7936..1a30d2e3e3 100644
--- a/src/corelib/concurrent/qtconcurrentreducekernel.h
+++ b/src/corelib/concurrent/qtconcurrentreducekernel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentresultstore.cpp b/src/corelib/concurrent/qtconcurrentresultstore.cpp
index 89f561c2ac..e9d76448a7 100644
--- a/src/corelib/concurrent/qtconcurrentresultstore.cpp
+++ b/src/corelib/concurrent/qtconcurrentresultstore.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentresultstore.h b/src/corelib/concurrent/qtconcurrentresultstore.h
index 627aca27bd..c2a9f0a3e2 100644
--- a/src/corelib/concurrent/qtconcurrentresultstore.h
+++ b/src/corelib/concurrent/qtconcurrentresultstore.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentrun.cpp b/src/corelib/concurrent/qtconcurrentrun.cpp
index 87952da882..676a542471 100644
--- a/src/corelib/concurrent/qtconcurrentrun.cpp
+++ b/src/corelib/concurrent/qtconcurrentrun.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentrun.h b/src/corelib/concurrent/qtconcurrentrun.h
index ef51b2adcb..06da380430 100644
--- a/src/corelib/concurrent/qtconcurrentrun.h
+++ b/src/corelib/concurrent/qtconcurrentrun.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h
index c1270e953b..51390028b0 100644
--- a/src/corelib/concurrent/qtconcurrentrunbase.h
+++ b/src/corelib/concurrent/qtconcurrentrunbase.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h
index 9beb0b9c35..8a02497ddd 100644
--- a/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h
+++ b/src/corelib/concurrent/qtconcurrentstoredfunctioncall.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.cpp b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
index 71a47164d2..559e7bb490 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.cpp
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qtconcurrentthreadengine.h b/src/corelib/concurrent/qtconcurrentthreadengine.h
index 38d01ee11a..98edd2d9ec 100644
--- a/src/corelib/concurrent/qtconcurrentthreadengine.h
+++ b/src/corelib/concurrent/qtconcurrentthreadengine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qthreadpool.cpp b/src/corelib/concurrent/qthreadpool.cpp
index 91e77d9eff..2cc31b9943 100644
--- a/src/corelib/concurrent/qthreadpool.cpp
+++ b/src/corelib/concurrent/qthreadpool.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qthreadpool.h b/src/corelib/concurrent/qthreadpool.h
index d857073b42..1b5677b9fa 100644
--- a/src/corelib/concurrent/qthreadpool.h
+++ b/src/corelib/concurrent/qthreadpool.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/concurrent/qthreadpool_p.h b/src/corelib/concurrent/qthreadpool_p.h
index db50ec92c6..009dfcdee2 100644
--- a/src/corelib/concurrent/qthreadpool_p.h
+++ b/src/corelib/concurrent/qthreadpool_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index edb5ecb849..17c15d42b1 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -23,6 +23,7 @@ include(global/global.pri)
include(thread/thread.pri)
include(tools/tools.pri)
include(io/io.pri)
+include(itemmodels/itemmodels.pri)
include(plugin/plugin.pri)
include(kernel/kernel.pri)
include(codecs/codecs.pri)
diff --git a/src/corelib/global/qconfig-dist.h b/src/corelib/global/qconfig-dist.h
index bc3ab9a024..727eea0018 100644
--- a/src/corelib/global/qconfig-dist.h
+++ b/src/corelib/global/qconfig-dist.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qconfig-large.h b/src/corelib/global/qconfig-large.h
index 65367e9be1..8a2553a6a6 100644
--- a/src/corelib/global/qconfig-large.h
+++ b/src/corelib/global/qconfig-large.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
index f9ecf92388..96207d1cd8 100644
--- a/src/corelib/global/qconfig-medium.h
+++ b/src/corelib/global/qconfig-medium.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
index ace1eea508..30440243de 100644
--- a/src/corelib/global/qconfig-minimal.h
+++ b/src/corelib/global/qconfig-minimal.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -104,9 +104,6 @@
#ifndef QT_NO_TEMPORARYFILE
# define QT_NO_TEMPORARYFILE
#endif
-#ifndef QT_NO_TEXTSTREAM
-# define QT_NO_TEXTSTREAM
-#endif
#ifndef QT_NO_SETTINGS
# define QT_NO_SETTINGS
#endif
diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
index 18ae261809..6b943ab422 100644
--- a/src/corelib/global/qconfig-nacl.h
+++ b/src/corelib/global/qconfig-nacl.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
index 4f34169d75..84a5ec59d9 100644
--- a/src/corelib/global/qconfig-small.h
+++ b/src/corelib/global/qconfig-small.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -77,9 +77,6 @@
#endif
/* File I/O */
-#ifndef QT_NO_TEXTSTREAM
-# define QT_NO_TEXTSTREAM
-#endif
#ifndef QT_NO_SETTINGS
# define QT_NO_SETTINGS
#endif
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 8a17af55f2..66d66cb78f 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qendian.qdoc b/src/corelib/global/qendian.qdoc
index 307db59426..3133d3c252 100644
--- a/src/corelib/global/qendian.qdoc
+++ b/src/corelib/global/qendian.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index e0b8a8fb6d..5055414834 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -289,9 +289,6 @@
// HtmlParser
//#define QT_NO_TEXTHTMLPARSER
-// QTextStream
-//#define QT_NO_TEXTSTREAM
-
// QToolTip
//#define QT_NO_TOOLTIP
@@ -351,16 +348,6 @@
#define QT_NO_FILESYSTEMMODEL
#endif
-// QHostInfo
-#if !defined(QT_NO_HOSTINFO) && (defined(QT_NO_TEXTSTREAM))
-#define QT_NO_HOSTINFO
-#endif
-
-// XPM Image Format
-#if !defined(QT_NO_IMAGEFORMAT_XPM) && (defined(QT_NO_TEXTSTREAM))
-#define QT_NO_IMAGEFORMAT_XPM
-#endif
-
// QLibrary
#if !defined(QT_NO_LIBRARY) && (defined(QT_NO_SETTINGS))
#define QT_NO_LIBRARY
@@ -597,7 +584,7 @@
#endif
// QPrinter
-#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE))
+#if !defined(QT_NO_PRINTER) && (defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE))
#define QT_NO_PRINTER
#endif
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index 6b861d4d17..4eae2f50ec 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -192,13 +192,6 @@ Requires:
Name: QProcess
SeeAlso: ???
-Feature: TEXTSTREAM
-Description: Supports reading and writing of text.
-Section: File I/O
-Requires:
-Name: QTextStream
-SeeAlso: ???
-
Feature: TEMPORARYFILE
Description: Provides an I/O device that operates on temporary files.
Section: File I/O
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 615598b378..f8fc49ddbf 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -78,17 +78,6 @@
#include <CoreServices/CoreServices.h>
#endif
-#if defined(Q_OS_SYMBIAN)
-#include <e32def.h>
-#include <e32debug.h>
-#include <f32file.h>
-#include <e32math.h>
-# include "private/qcore_symbian_p.h"
-
-_LIT(qt_S60Filter, "Series60v?.*.sis");
-_LIT(qt_symbianSystemInstallDir, "z:\\system\\install\\");
-#endif
-
QT_BEGIN_NAMESPACE
@@ -970,22 +959,6 @@ bool qSharedBuild()
*/
/*!
- \fn QSysInfo::SymbianVersion QSysInfo::symbianVersion()
- \since 4.6
-
- Returns the version of the Symbian operating system on which the
- application is run (Symbian only).
-*/
-
-/*!
- \fn QSysInfo::S60Version QSysInfo::s60Version()
- \since 4.6
-
- Returns the version of the S60 SDK system on which the
- application is run (S60 only).
-*/
-
-/*!
\enum QSysInfo::Endian
\value BigEndian Big-endian byte order (also called Network byte order)
@@ -1041,7 +1014,7 @@ bool qSharedBuild()
\value WV_NT_based NT-based version of Windows
\value WV_CE_based CE-based version of Windows
- \sa MacVersion, SymbianVersion
+ \sa MacVersion
*/
/*!
@@ -1072,50 +1045,7 @@ bool qSharedBuild()
\value MV_SNOWLEOPARD Apple codename for MV_10_6
\value MV_LION Apple codename for MV_10_7
- \sa WinVersion, SymbianVersion
-*/
-
-/*!
- \enum QSysInfo::SymbianVersion
-
- This enum provides symbolic names for the various versions of the
- Symbian operating system. On Symbian, the
- QSysInfo::symbianVersion() function gives the version of the
- system on which the application is run.
-
- \value SV_9_2 Symbian OS v9.2
- \value SV_9_3 Symbian OS v9.3
- \value SV_9_4 Symbian OS v9.4
- \value SV_SF_1 S60 5th Edition (Symbian^1)
- \value SV_SF_2 Symbian^2
- \value SV_SF_3 Symbian^3 or Symbian Anna
- \value SV_SF_4 \e{This enum value is deprecated.}
- \value SV_API_5_3 Symbian/S60 API version 5.3 release
- \value SV_API_5_4 Symbian/S60 API version 5.4 release
- \value SV_Unknown An unknown and currently unsupported platform
-
- \sa S60Version, WinVersion, MacVersion
-*/
-
-/*!
- \enum QSysInfo::S60Version
-
- This enum provides symbolic names for the various versions of the
- S60 SDK. On S60, the
- QSysInfo::s60Version() function gives the version of the
- SDK on which the application is run.
-
- \value SV_S60_3_1 S60 3rd Edition Feature Pack 1
- \value SV_S60_3_2 S60 3rd Edition Feature Pack 2
- \value SV_S60_5_0 S60 5th Edition
- \value SV_S60_5_1 \e{This enum value is deprecated.}
- \value SV_S60_5_2 Symbian^3 and Symbian Anna
- \value SV_S60_5_3 Symbian/S60 API version 5.3 release
- \value SV_S60_5_4 Symbian/S60 API version 5.4 release
- \value SV_S60_Unknown An unknown and currently unsupported platform
- \omitvalue SV_S60_None
-
- \sa SymbianVersion, WinVersion, MacVersion
+ \sa WinVersion
*/
/*!
@@ -1625,108 +1555,6 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
#endif
-#ifdef Q_OS_SYMBIAN
-static QSysInfo::SymbianVersion cachedSymbianVersion = QSysInfo::SymbianVersion(-1);
-static QSysInfo::S60Version cachedS60Version = QSysInfo::S60Version(-1);
-
-static void symbianInitVersions()
-{
- // Use pure Symbian code, because if done using QDir, there will be a call back
- // to this method, resulting doing this expensive operation twice before the cache kicks in.
- // Pure Symbian code also makes this method ~10x faster, speeding up the application launch.
- RFs rfs = qt_s60GetRFs();
- TFindFile fileFinder(rfs);
- CDir* contents;
-
- // Check for platform version
- TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_symbianSystemInstallDir, contents);
- if (err == KErrNone) {
- QScopedPointer<CDir> contentsDeleter(contents);
- err = contents->Sort(EDescending|ESortByName);
- if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) {
- TInt major = (*contents)[0].iName[9] - '0';
- TInt minor = (*contents)[0].iName[11] - '0';
- if (major == 3) {
- if (minor == 1) {
- cachedS60Version = QSysInfo::SV_S60_3_1;
- cachedSymbianVersion = QSysInfo::SV_9_2;
- } else if (minor == 2) {
- cachedS60Version = QSysInfo::SV_S60_3_2;
- cachedSymbianVersion = QSysInfo::SV_9_3;
- }
- } else if (major == 5) {
- if (minor == 0) {
- cachedS60Version = QSysInfo::SV_S60_5_0;
- cachedSymbianVersion = QSysInfo::SV_9_4;
- } else if (minor == 1) {
- cachedS60Version = QSysInfo::SV_S60_5_1;
- cachedSymbianVersion = QSysInfo::SV_SF_2;
- } else if (minor == 2) {
- cachedS60Version = QSysInfo::SV_S60_5_2;
- cachedSymbianVersion = QSysInfo::SV_SF_3;
- } else if (minor == 3) {
- cachedS60Version = QSysInfo::SV_S60_5_3;
- cachedSymbianVersion = QSysInfo::SV_API_5_3;
- } else if (minor >= 4) {
- cachedS60Version = QSysInfo::SV_S60_5_4;
- cachedSymbianVersion = QSysInfo::SV_API_5_4;
- }
- }
- }
- }
-
-# ifdef Q_CC_NOKIAX86
- if (cachedS60Version == -1) {
- // Some emulator environments may not contain the version specific .sis files, so
- // simply hardcode the version on those environments. Note that can't use
- // S60_VERSION_* defines for S60 3.x/5.0 platforms, as they do not define them
- // right anyway in case .sis files are not found.
-# if defined(__SERIES60_31__)
- cachedS60Version = QSysInfo::SV_S60_3_1;
- cachedSymbianVersion = QSysInfo::SV_9_2;
-# elif defined(__S60_32__)
- cachedS60Version = QSysInfo::SV_S60_3_2;
- cachedSymbianVersion = QSysInfo::SV_9_3;
-# elif defined(__S60_50__)
- cachedS60Version = QSysInfo::SV_S60_5_0;
- cachedSymbianVersion = QSysInfo::SV_9_4;
-# elif defined(S60_VERSION_5_2)
- cachedS60Version = QSysInfo::SV_S60_5_2;
- cachedSymbianVersion = QSysInfo::SV_SF_3;
-# elif defined(S60_VERSION_5_3)
- cachedS60Version = QSysInfo::SV_S60_5_3;
- cachedSymbianVersion = QSysInfo::SV_API_5_3;
-# elif defined(S60_VERSION_5_4)
- cachedS60Version = QSysInfo::SV_S60_5_4;
- cachedSymbianVersion = QSysInfo::SV_API_5_4;
-# endif
- }
-# endif
-
- if (cachedS60Version == -1) {
- //If reaching here, it was not possible to determine the version
- cachedS60Version = QSysInfo::SV_S60_Unknown;
- cachedSymbianVersion = QSysInfo::SV_Unknown;
- }
-}
-
-QSysInfo::SymbianVersion QSysInfo::symbianVersion()
-{
- if (cachedSymbianVersion == -1)
- symbianInitVersions();
-
- return cachedSymbianVersion;
-}
-
-QSysInfo::S60Version QSysInfo::s60Version()
-{
- if (cachedS60Version == -1)
- symbianInitVersions();
-
- return cachedS60Version;
-}
-#endif // ifdef Q_OS_SYMBIAN
-
/*!
\macro void Q_ASSERT(bool test)
\relates <QtGlobal>
@@ -2037,18 +1865,6 @@ static void qDefaultMsgHandler(QtMsgType, const char *buf)
QString fstr = QString::fromLatin1(buf);
fstr += QLatin1Char('\n');
OutputDebugString(reinterpret_cast<const wchar_t *> (fstr.utf16()));
-#elif defined(Q_OS_SYMBIAN)
- // RDebug::Print has a cap of 256 characters so break it up
- _LIT(format, "[Qt Message] %S");
- const int maxBlockSize = 256 - ((const TDesC &)format).Length();
- const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
- HBufC* hbuffer = HBufC::New(qMin(maxBlockSize, ptr.Length()));
- Q_CHECK_PTR(hbuffer);
- for (int i = 0; i < ptr.Length(); i += hbuffer->Length()) {
- hbuffer->Des().Copy(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i)));
- RDebug::Print(format, hbuffer);
- }
- delete hbuffer;
#else
fprintf(stderr, "%s\n", buf);
fflush(stderr);
@@ -2099,15 +1915,7 @@ void qt_message_output(QtMsgType msgType, const char *buf)
_CrtDbgBreak();
#endif
-#if defined(Q_OS_SYMBIAN)
- __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));
- // Panic the current thread. We don't use real panic codes, so 0 has no special meaning.
- User::Panic(tmp, 0);
-#elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
+#if (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
@@ -2400,7 +2208,7 @@ bool qputenv(const char *varName, const QByteArray& value)
#endif
}
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD)
# if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500)
// older versions of INTEGRITY used a long instead of a uint for the seed.
@@ -2431,7 +2239,7 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
*/
void qsrand(uint seed)
{
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD)
SeedStorage *seedStorage = randTLS();
if (seedStorage) {
SeedStorageType *pseed = seedStorage->localData();
@@ -2446,7 +2254,7 @@ void qsrand(uint seed)
srand(seed);
}
#else
- // On Windows and Symbian srand() and rand() already use Thread-Local-Storage
+ // On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
// this is also valid for QT_NO_THREAD
srand(seed);
@@ -2470,7 +2278,7 @@ void qsrand(uint seed)
*/
int qrand()
{
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD)
SeedStorage *seedStorage = randTLS();
if (seedStorage) {
SeedStorageType *pseed = seedStorage->localData();
@@ -2487,7 +2295,7 @@ int qrand()
return rand();
}
#else
- // On Windows and Symbian srand() and rand() already use Thread-Local-Storage
+ // On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
// this is also valid for QT_NO_THREAD
return rand();
@@ -3160,185 +2968,15 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
\sa Q_DECL_EXPORT
*/
-#if defined(Q_OS_SYMBIAN)
-
-#include <typeinfo>
-
-/*! \macro QT_TRAP_THROWING(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_TRAP_THROWING(titlePane->SetTextL(captionPtr));
- }
- \endcode
-
- \sa QT_TRYCATCH_ERROR(), QT_TRYCATCH_LEAVING()
-*/
-
-/*! \macro QT_TRYCATCH_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_TRYCATCH_ERROR(err, name.Set(qt_QString2TPtrC(serverName)));
- if (err != KErrNone)
- return err;
- return iServer.Connect(name);
- }
- \endcode
-}
-
- \sa QT_TRYCATCH_LEAVING(), QT_TRAP_THROWING()
-*/
-
-/*! \macro QT_TRYCATCH_LEAVING(function)
+/*!
+ \macro Q_DECL_CONSTEXPR
\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_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled());
- }
- \endcode
-
- \sa QT_TRAP_THROWING(), QT_TRYCATCH_ERROR()
-*/
-#include <stdexcept>
+ This macro can be used to declare variable that should be constructed at compile-time,
+ or an inline function that can be computed at compile-time.
-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_symbian_exception2LeaveL(), qt_symbian_exception2Error()
+ It expands to "constexpr" if your compiler supports that C++11 keyword, or to nothing
+ otherwise.
*/
-void qt_symbian_throwIfError(int error)
-{
- if (error >= KErrNone)
- return; // do nothing - not an exception
- switch (error) {
- case KErrNoMemory:
- throw std::bad_alloc();
- case KErrArgument:
- throw std::invalid_argument("from Symbian error");
- case KErrOverflow:
- throw std::overflow_error("from Symbian error");
- case KErrUnderflow:
- throw std::underflow_error("from Symbian error");
- 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_symbian_throwIfError(), qt_symbian_exception2Error()
-*/
-void qt_symbian_exception2LeaveL(const std::exception& aThrow)
-{
- User::Leave(qt_symbian_exception2Error(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_symbian_throwIfError(), qt_symbian_exception2LeaveL()
-*/
-int qt_symbian_exception2Error(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;
- qWarning("translation from std exception \"%s\" to %d", aThrow.what(), err);
- }
-
- return err;
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e22d66628e..fd5c5d6315 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -76,8 +76,12 @@
# define QT_END_NAMESPACE
# define QT_BEGIN_INCLUDE_NAMESPACE
# define QT_END_INCLUDE_NAMESPACE
+#ifndef QT_BEGIN_MOC_NAMESPACE
# define QT_BEGIN_MOC_NAMESPACE
+#endif
+#ifndef QT_END_MOC_NAMESPACE
# define QT_END_MOC_NAMESPACE
+#endif
# define QT_FORWARD_DECLARE_CLASS(name) class name;
# define QT_FORWARD_DECLARE_STRUCT(name) struct name;
# define QT_MANGLE_NAMESPACE(name) name
@@ -90,8 +94,12 @@
# define QT_END_NAMESPACE }
# define QT_BEGIN_INCLUDE_NAMESPACE }
# define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE {
+#ifndef QT_BEGIN_MOC_NAMESPACE
# define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE
+#endif
+#ifndef QT_END_MOC_NAMESPACE
# define QT_END_MOC_NAMESPACE
+#endif
# define QT_FORWARD_DECLARE_CLASS(name) \
QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \
using QT_PREPEND_NAMESPACE(name);
@@ -450,7 +458,6 @@ namespace QT_NAMESPACE {}
/* GCC 2.95 knows "using" but does not support it correctly */
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 95
# define Q_NO_USING_KEYWORD
-# define QT_NO_STL_WCHAR
# endif
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
# define Q_ALIGNOF(type) __alignof__(type)
@@ -480,9 +487,13 @@ namespace QT_NAMESPACE {}
# define QT_NO_ARM_EABI
# endif
# endif
-# if defined(__GXX_EXPERIMENTAL_CXX0X__)
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+# define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# endif
+# if defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(__clang__) /* clang C++11 enablers are found below, don't do them here */
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
/* C++0x features supported in GCC 4.3: */
+# define Q_COMPILER_VARIADIC_MACROS
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_DECLTYPE
# define Q_COMPILER_STATIC_ASSERT
@@ -509,6 +520,11 @@ namespace QT_NAMESPACE {}
# define Q_COMPILER_UNRESTRICTED_UNIONS
# define Q_COMPILER_RANGE_FOR
# endif
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407
+ /* C++0x features supported in GCC 4.7: */
+# define Q_COMPILER_EXPLICIT_OVERRIDES
+# define Q_COMPILER_FINAL
+# endif
# endif
@@ -541,7 +557,6 @@ namespace QT_NAMESPACE {}
# define Q_NO_BOOL_TYPE
# define Q_NO_EXPLICIT_KEYWORD
# define Q_NO_USING_KEYWORD
-# define Q_TYPENAME
# define Q_OUTOFLINE_TEMPLATE inline
# define Q_BROKEN_TEMPLATE_SPECIALIZATION
# define Q_CANNOT_DELETE_CONSTANT
@@ -575,7 +590,6 @@ namespace QT_NAMESPACE {}
/* Apply to all versions prior to Compaq C++ V6.0-000 - observed on
DEC C++ V5.5-004. */
# if __DECCXX_VER < 60060000
-# define Q_TYPENAME
# define Q_BROKEN_TEMPLATE_SPECIALIZATION
# define Q_CANNOT_DELETE_CONSTANT
# endif
@@ -773,6 +787,45 @@ namespace QT_NAMESPACE {}
# endif
#endif
+#ifdef Q_CC_CLANG
+/* General C++ features */
+# if !__has_feature(cxx_exceptions)
+# define QT_NO_EXCEPTIONS
+# endif
+# if !__has_feature(cxx_rtti)
+# define QT_NO_RTTI
+# endif
+/* C++11 features, see http://clang.llvm.org/cxx_status.html */
+# if __cplusplus >= 201103L || __GXX_EXPERIMENTAL_CXX0X__
+# if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */
+# define Q_COMPILER_AUTO_TYPE
+# define Q_COMPILER_DECLTYPE
+# define Q_COMPILER_EXTERN_TEMPLATES
+# define Q_COMPILER_RVALUE_REFS
+# define Q_COMPILER_STATIC_ASSERT
+# define Q_COMPILER_VARIADIC_MACROS
+# define Q_COMPILER_VARIADIC_TEMPLATES
+# endif
+# if ((__clang_major__ * 100) + __clang_minor__) >= 300 /* since clang 3.0 */
+# define Q_COMPILER_CLASS_ENUM
+ /* defaulted members in 3.0, deleted members in 2.9 */
+# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
+# define Q_COMPILER_EXPLICIT_OVERRIDES
+# define Q_COMPILER_NULLPTR
+# define Q_COMPILER_RANGE_FOR
+# define Q_COMPILER_UNICODE_STRINGS
+# endif
+# if 0 /*) not implemented in clang */
+# define Q_COMPILER_ATOMICS
+# define Q_COMPILER_CONSTEXPR
+# define Q_COMPILER_FINAL
+# define Q_COMPILER_INITIALIZER_LISTS
+# define Q_COMPILER_LAMBDA
+# define Q_COMPILER_UNRESTRICTED_UNIONS
+# endif
+# endif
+#endif
+
#ifndef Q_PACKED
# define Q_PACKED
# undef Q_NO_PACKED_REFERENCE
@@ -785,6 +838,10 @@ namespace QT_NAMESPACE {}
# define Q_UNLIKELY(x) (x)
#endif
+#ifndef Q_ALLOC_SIZE
+# define Q_ALLOC_SIZE(x)
+#endif
+
#ifndef Q_CONSTRUCTOR_FUNCTION
# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
namespace { \
@@ -885,6 +942,7 @@ template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qin
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
+typedef qptrdiff qintptr;
/*
Useful type definitions for Qt
@@ -907,14 +965,6 @@ QT_END_INCLUDE_NAMESPACE
*/
#ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */
-/* Symbian OS defines TRUE = 1 and FALSE = 0,
-redefine to built-in booleans to make autotests work properly */
-#ifdef Q_OS_SYMBIAN
- #include <e32def.h> /* Symbian OS defines */
-
- #undef TRUE
- #undef FALSE
-#endif
# ifndef TRUE
# define TRUE true
# define FALSE false
@@ -1057,12 +1107,30 @@ redefine to built-in booleans to make autotests work properly */
# define Q_NULLPTR 0
#endif
+#ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
+# define Q_DECL_EQ_DELETE = delete
+#else
+# define Q_DECL_EQ_DELETE
+#endif
+
#ifdef Q_COMPILER_CONSTEXPR
# define Q_DECL_CONSTEXPR constexpr
#else
# define Q_DECL_CONSTEXPR
#endif
+#ifdef Q_COMPILER_EXPLICIT_OVERRIDES
+# define Q_DECL_OVERRIDE override
+#else
+# define Q_DECL_OVERRIDE
+#endif
+
+#ifdef Q_COMPILER_FINAL
+# define Q_DECL_FINAL final
+#else
+# define Q_DECL_FINAL
+#endif
+
//defines the type for the WNDPROC on windows
//the alignment needs to be forced for sse2 to not crash with mingw
#if defined(Q_OS_WIN)
@@ -1079,7 +1147,7 @@ typedef int QNoImplicitBoolCast;
// This logic must match the one in qmetatype.h
#if defined(QT_COORD_TYPE)
typedef QT_COORD_TYPE qreal;
-#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
+#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE)
typedef float qreal;
#else
typedef double qreal;
@@ -1175,10 +1243,10 @@ class QDataStream;
/*
- Create Qt DLL if QT_DLL is defined (Windows and Symbian only)
+ Create Qt DLL if QT_DLL is defined (Windows only)
*/
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_WIN)
# if defined(QT_NODLL)
# undef QT_MAKEDLL
# undef QT_DLL
@@ -1421,11 +1489,11 @@ class QDataStream;
for Qt's internal unit tests. If you want slower loading times and more
symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL.
*/
-#if defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_MAKEDLL)
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_MAKEDLL)
# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
-#elif defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_DLL)
+#elif defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && defined(QT_DLL)
# define Q_AUTOTEST_EXPORT Q_DECL_IMPORT
-#elif defined(QT_BUILD_INTERNAL) && !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_SHARED)
+#elif defined(QT_BUILD_INTERNAL) && !defined(Q_OS_WIN) && defined(QT_SHARED)
# define Q_AUTOTEST_EXPORT Q_DECL_EXPORT
#else
# define Q_AUTOTEST_EXPORT
@@ -1558,35 +1626,6 @@ public:
};
static const MacVersion MacintoshVersion;
#endif
-#ifdef Q_OS_SYMBIAN
- enum SymbianVersion {
- SV_Unknown = 1000000, // Assume unknown is something newer than what is supported
- //These are the Symbian Ltd versions 9.2-9.4
- SV_9_2 = 10,
- SV_9_3 = 20,
- SV_9_4 = 30,
- //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1
- SV_SF_1 = SV_9_4,
- SV_SF_2 = 40,
- SV_SF_3 = 50,
- SV_SF_4 = 60, // Deprecated
- SV_API_5_3 = 70,
- SV_API_5_4 = 80
- };
- static SymbianVersion symbianVersion();
- enum S60Version {
- SV_S60_None = 0,
- SV_S60_Unknown = SV_Unknown,
- SV_S60_3_1 = SV_9_2,
- SV_S60_3_2 = SV_9_3,
- SV_S60_5_0 = SV_9_4,
- SV_S60_5_1 = SV_SF_2, // Deprecated
- SV_S60_5_2 = SV_SF_3,
- SV_S60_5_3 = SV_API_5_3,
- SV_S60_5_4 = SV_API_5_4
- };
- static S60Version s60Version();
-#endif
};
Q_CORE_EXPORT const char *qVersion();
@@ -1603,10 +1642,6 @@ inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
# define Q_INLINE_TEMPLATE inline
#endif
-#ifndef Q_TYPENAME
-# define Q_TYPENAME typename
-#endif
-
/*
Avoid "unused parameter" warnings
*/
@@ -1623,15 +1658,6 @@ inline void qUnused(T &x) { (void)x; }
Debugging and error handling
*/
-/*
- On Symbian we do not know beforehand whether we are compiling in
- release or debug mode, so check the Symbian build define here,
- and set the QT_NO_DEBUG define appropriately.
-*/
-#if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG)
-# define QT_NO_DEBUG
-#endif
-
#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
# define QT_DEBUG
#endif
@@ -1668,10 +1694,6 @@ Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */
Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
-#if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
-#define QT_NO_DEBUG_STREAM
-#endif
-
/*
Forward declarations only.
@@ -1679,13 +1701,19 @@ Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
*/
class QDebug;
class QNoDebug;
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_OUTPUT) && !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT_INLINE QDebug qDebug();
-Q_CORE_EXPORT_INLINE QDebug qWarning();
-Q_CORE_EXPORT_INLINE QDebug qCritical();
#else
inline QNoDebug qDebug();
#endif
+#if !defined(QT_NO_WARNING_OUTPUT) && !defined(QT_NO_DEBUG_STREAM)
+Q_CORE_EXPORT_INLINE QDebug qWarning();
+#else
+inline QNoDebug qWarning();
+#endif
+#if !defined(QT_NO_DEBUG_STREAM)
+Q_CORE_EXPORT_INLINE QDebug qCritical();
+#endif
#define QT_NO_QDEBUG_MACRO while (false) qDebug
#ifdef QT_NO_DEBUG_OUTPUT
@@ -1714,10 +1742,10 @@ Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line);
Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line);
#if !defined(Q_ASSERT_X)
-# ifndef QT_NO_DEBUG
-# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
-# else
+# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
# define Q_ASSERT_X(cond, where, what) qt_noop()
+# else
+# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
# endif
#endif
@@ -1733,7 +1761,7 @@ template <> class QStaticAssertFailure<true> {};
#define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
#define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
#define Q_STATIC_ASSERT(Condition) \
- enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<(bool)(Condition)>)}
+ enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<(Condition)>)}
#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
#endif
@@ -1758,7 +1786,7 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
#elif defined(_MSC_VER)
# define Q_FUNC_INFO __FUNCSIG__
#else
-# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN)
+# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
# else
/* These two macros makes it possible to turn the builtin line expander into a
@@ -2027,6 +2055,19 @@ public:
};
};
+template<>
+class QTypeInfo<void>
+{
+public:
+ enum {
+ isPointer = false,
+ isComplex = false,
+ isStatic = false,
+ isLarge = false,
+ isDummy = false
+ };
+};
+
template <typename T>
class QTypeInfo<T*>
{
@@ -2140,11 +2181,11 @@ Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
These functions make it possible to use standard C++ functions with
a similar name from Qt header files (especially template classes).
*/
-Q_CORE_EXPORT void *qMalloc(size_t size);
+Q_CORE_EXPORT void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void qFree(void *ptr);
-Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);
-Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment);
-Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment);
+Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size) Q_ALLOC_SIZE(2);
+Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
+Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);
Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
@@ -2418,15 +2459,9 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
classes contains a private copy constructor and assignment
operator to disable copying (the compiler gives an error message).
*/
-#ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
#define Q_DISABLE_COPY(Class) \
- Class(const Class &) = delete;\
- Class &operator=(const Class &) = delete;
-#else
-#define Q_DISABLE_COPY(Class) \
- Class(const Class &); \
- Class &operator=(const Class &);
-#endif
+ Class(const Class &) Q_DECL_EQ_DELETE;\
+ Class &operator=(const Class &) Q_DECL_EQ_DELETE;
class QByteArray;
Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
@@ -2441,77 +2476,6 @@ inline int qIntCast(float f) { return int(f); }
Q_CORE_EXPORT void qsrand(uint seed);
Q_CORE_EXPORT int qrand();
-#if defined(Q_OS_SYMBIAN)
-
-#ifdef SYMBIAN_BUILD_GCE
-#define Q_SYMBIAN_SUPPORTS_SURFACES
-//RWsPointerCursor is fixed, so don't use low performance sprites
-#define Q_SYMBIAN_FIXED_POINTER_CURSORS
-#define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE
-#define Q_SYMBIAN_WINDOW_SIZE_CACHE
-#define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
-
-//enabling new graphics resources
-#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
-# define QT_SYMBIAN_SUPPORTS_SGIMAGE
-#endif
-
-#ifdef SYMBIAN_GRAPHICS_SET_SURFACE_TRANSPARENCY_AVAILABLE
-# define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
-#endif
-
-#ifdef SYMBIAN_GRAPHICS_TRANSITION_EFFECTS_SIGNALING_AVAILABLE
-# define Q_SYMBIAN_TRANSITION_EFFECTS
-#endif
-#endif
-
-#ifdef SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS
-#define Q_SYMBIAN_SUPPORTS_MULTIPLE_SCREENS
-#endif
-
-#ifdef SYMBIAN_GRAPHICS_FIXNATIVEORIENTATION
-#define Q_SYMBIAN_SUPPORTS_FIXNATIVEORIENTATION
-#endif
-
-//Symbian does not support data imports from a DLL
-#define Q_NO_DATA_RELOCATION
-
-QT_END_NAMESPACE
-// forward declare std::exception
-#ifdef __cplusplus
-namespace std { class exception; }
-#endif
-QT_BEGIN_NAMESPACE
-Q_CORE_EXPORT void qt_symbian_throwIfError(int error);
-Q_CORE_EXPORT void qt_symbian_exception2LeaveL(const std::exception& ex);
-Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
-
-#define QT_TRAP_THROWING(_f) \
- { \
- TInt ____error; \
- TRAP(____error, _f); \
- qt_symbian_throwIfError(____error); \
- }
-
-#define QT_TRYCATCH_ERROR(_err, _f) \
- { \
- _err = KErrNone; \
- try { \
- _f; \
- } catch (const std::exception &____ex) { \
- _err = qt_symbian_exception2Error(____ex); \
- } \
- }
-
-#define QT_TRYCATCH_LEAVING(_f) \
- { \
- TInt ____err; \
- QT_TRYCATCH_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.
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 7868d3db59..375349c18d 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -498,7 +498,7 @@ extern "C" void qt_core_boilerplate();
void qt_core_boilerplate()
{
printf("This is the QtCore library version " QT_VERSION_STR "\n"
- "Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).\n"
"Contact: Nokia Corporation (qt-info@nokia.com)\n"
"\n"
"Build date: %s\n"
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 8d1607d045..21fcdeb62c 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index 466f70614d..2ec6938f98 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -78,7 +78,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0;
if (alignment <= sizeof(void*)) {
// special, fast case
- void **newptr = static_cast<void **>(qRealloc(actualptr, newsize + sizeof(void*)));
+ void **newptr = static_cast<void **>(realloc(actualptr, newsize + sizeof(void*)));
if (!newptr)
return 0;
if (newptr == actualptr) {
@@ -90,7 +90,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
return newptr + 1;
}
- // qMalloc returns pointers aligned at least at sizeof(size_t) boundaries
+ // malloc returns pointers aligned at least at sizeof(size_t) boundaries
// but usually more (8- or 16-byte boundaries).
// So we overallocate by alignment-sizeof(size_t) bytes, so we're guaranteed to find a
// somewhere within the first alignment-sizeof(size_t) that is properly aligned.
@@ -98,7 +98,7 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
// However, we need to store the actual pointer, so we need to allocate actually size +
// alignment anyway.
- void *real = qRealloc(actualptr, newsize + alignment);
+ void *real = realloc(actualptr, newsize + alignment);
if (!real)
return 0;
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index b6e2384ea0..ee4000498f 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -61,7 +61,7 @@ Qt {
Q_OBJECT
#endif
-#if (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN))
+#if defined(Q_MOC_RUN)
// NOTE: Generally, do not add Q_ENUMS if a corresponding Q_FLAGS exists.
Q_ENUMS(ScrollBarPolicy FocusPolicy ContextMenuPolicy)
Q_ENUMS(ArrowType ToolButtonStyle PenStyle PenCapStyle PenJoinStyle BrushStyle)
@@ -97,7 +97,8 @@ Qt {
Q_ENUMS(GestureType)
#endif
Q_ENUMS(CursorMoveStyle)
-#endif // (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN))
+ Q_ENUMS(TimerType)
+#endif // defined(Q_MOC_RUN)
#if defined(Q_MOC_RUN)
public:
@@ -461,25 +462,8 @@ public:
WA_MergeSoftkeys = 124,
WA_MergeSoftkeysRecursively = 125,
-#if 0 // these values are reserved for Maemo5 - do not re-use them
- WA_Maemo5NonComposited = 126,
- WA_Maemo5StackedWindow = 127,
-#endif
-
- WA_LockPortraitOrientation = 128,
- WA_LockLandscapeOrientation = 129,
- WA_AutoOrientation = 130,
-
-#if 0 // these values are reserved for Maemo5 - do not re-use them
- WA_Maemo5PortraitOrientation = WA_LockPortraitOrientation,
- WA_Maemo5LandscapeOrientation = WA_LockLandscapeOrientation,
- WA_Maemo5AutoOrientation = WA_AutoOrientation,
- WA_Maemo5ShowProgressIndicator = 131,
-#endif
-
- WA_X11DoNotAcceptFocus = 132,
- WA_SymbianNoSystemRotation = 133,
- WA_MacNoShadow = 134,
+ WA_X11DoNotAcceptFocus = 126,
+ WA_MacNoShadow = 127,
// Add new attributes before this line
WA_AttributeCount
@@ -495,9 +479,10 @@ public:
AA_MacPluginApplication = 5,
AA_DontUseNativeMenuBar = 6,
AA_MacDontSwapCtrlAndMeta = 7,
- AA_S60DontConstructApplicationPanes = 8,
- AA_S60DisablePartialScreenInputMode = 9,
+ AA_Use96Dpi = 8,
AA_X11InitThreads = 10,
+ AA_SynthesizeTouchForUnhandledMouseEvents = 11,
+ AA_SynthesizeMouseForUnhandledTouchEvents = 12,
// Add new attributes before this line
AA_AttributeCount
@@ -1313,7 +1298,8 @@ public:
ImhDate = 0x80,
ImhTime = 0x100,
- ImhMultiLine = 0x200,
+
+ ImhPreferLatin = 0x200,
ImhDigitsOnly = 0x10000,
ImhFormattedNumbersOnly = 0x20000,
@@ -1322,6 +1308,7 @@ public:
ImhDialableCharactersOnly = 0x100000,
ImhEmailCharactersOnly = 0x200000,
ImhUrlCharactersOnly = 0x400000,
+ ImhLatinOnly = 0x800000,
ImhExclusiveInputMask = 0xffff0000
};
@@ -1400,7 +1387,7 @@ public:
StatusTipPropertyRole = 30,
WhatsThisPropertyRole = 31,
// Reserved
- UserRole = 32
+ UserRole = 0x0100
};
enum ItemFlag {
@@ -1495,10 +1482,7 @@ public:
TouchPointPressed = 0x01,
TouchPointMoved = 0x02,
TouchPointStationary = 0x04,
- TouchPointReleased = 0x08,
- TouchPointStateMask = 0x0f,
-
- TouchPointPrimary = 0x10
+ TouchPointReleased = 0x08
};
Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)
@@ -1547,6 +1531,12 @@ public:
LogicalMoveStyle,
VisualMoveStyle
};
+
+ enum TimerType {
+ PreciseTimer,
+ CoarseTimer,
+ VeryCoarseTimer
+ };
}
#ifdef Q_MOC_RUN
;
@@ -1566,6 +1556,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::DropActions)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::ItemFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodQueries)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates)
#ifndef QT_NO_GESTURES
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 63ac4a95be..3add1a48c7 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -167,6 +167,15 @@
construction in order to make Xlib calls thread-safe. This
attribute must be set before QApplication is constructed.
+ \value AA_SynthesizeTouchForUnhandledMouseEvents All mouse events
+ that are not accepted by the application will be translated
+ to touch events instead.
+
+ \value AA_SynthesizeMouseForUnhandledTouchEvents All touch events
+ that are not accepted by the application will be translated
+ to left button mouse events instead. This attribute is enabled
+ by default.
+
\omitvalue AA_AttributeCount
*/
@@ -1158,13 +1167,6 @@
to this top level window. This attribute has no effect on non-X11
platforms.
- \value WA_LockPortraitOrientation Locks the widget to a portrait orientation,
- ignoring changes to the display's orientation with respect to the user.
- \value WA_LockLandscapeOrientation Locks the widget to a landscape orientation,
- ignoring changes to the display's orientation with respect to the user.
- \value WA_AutoOrientation Causes the widget to change orientation whenever the
- display changes orientation with respect to the user.
-
\value WA_MacNoShadow Since Qt 4.8, this attribute disables drop shadows
for this top level window. Only affects Cocoa builds of Qt for Mac OS X.
@@ -1198,7 +1200,6 @@
\omitvalue WA_SetWindowModality
\omitvalue WA_WState_WindowOpacitySet
\omitvalue WA_WState_AcceptedTouchBeginEvent
- \omitvalue WA_SymbianNoSystemRotation
*/
/*! \typedef Qt::HANDLE
@@ -2437,7 +2438,7 @@
\value ImhDate The text editor functions as a date field.
\value ImhTime The text editor functions as a time field.
- \value ImhMultiLine The text editor accepts multi-line content.
+ \value ImhPreferLatin Latin characters are preferred (but not required).
Flags that restrict input (exclusive flags):
@@ -2448,6 +2449,7 @@
\value ImhDialableCharactersOnly Only characters suitable for phone dialing are allowed.
\value ImhEmailCharactersOnly Only characters suitable for email addresses are allowed.
\value ImhUrlCharactersOnly Only characters suitable for URLs are allowed.
+ \value ImhLatinOnly Only latin based input is allowed.
Masks:
@@ -2873,3 +2875,27 @@
\sa QApplication::setNavigationMode()
\sa QApplication::navigationMode()
*/
+
+/*!
+ \enum Qt::TimerType
+
+ The timer type indicates how accurate a timer can be.
+
+ \value PreciseTimer Precise timers try to keep millisecond accuracy
+ \value CoarseTimer Coarse timers try to keep accuracy within 5% of the desired interval
+ \value VeryCoarseTimer Very coarse timers only keep full second accuracy
+
+ On UNIX (including Linux and Mac OS X), Qt will keep millisecond accuracy
+ for Qt::PreciseTimer. For Qt::CoarseTimer, the interval will be adjusted up
+ to 5% to align the timer with other timers that are expected to fire at or
+ around the same time. The objective is to make most timers wake up at the
+ same time, thereby reducing CPU wakeups and power consumption.
+
+ On Windows, Qt will use Windows's Multimedia timer facility (if available)
+ for Qt::PreciseTimer and normal Windows timers for Qt::CoarseTimer and
+ Qt::VeryCoarseTimer.
+
+ On all platforms, the interval for Qt::VeryCoarseTimer is rounded to the
+ nearest full second (e.g. an interval of 23500ms will be rounded to
+ 24000ms, and 20300ms to 20000ms).
+*/
diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp
index 621b9885b0..7677d86db0 100644
--- a/src/corelib/global/qnumeric.cpp
+++ b/src/corelib/global/qnumeric.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qnumeric.h b/src/corelib/global/qnumeric.h
index bd8c2a4237..9f5ce691b1 100644
--- a/src/corelib/global/qnumeric.h
+++ b/src/corelib/global/qnumeric.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 336b348f3f..94d64409b3 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h
index 0926e02af1..a16e6be567 100644
--- a/src/corelib/global/qt_pch.h
+++ b/src/corelib/global/qt_pch.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index ba4041e765..3081645b6b 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index ef11621679..1d31e5d794 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -35,6 +35,7 @@ HEADERS += \
io/qfsfileengine_iterator_p.h \
io/qfilesystemwatcher.h \
io/qfilesystemwatcher_p.h \
+ io/qfilesystemwatcher_polling_p.h \
io/qfilesystementry_p.h \
io/qfilesystemengine_p.h \
io/qfilesystemmetadata_p.h \
@@ -65,36 +66,39 @@ SOURCES += \
io/qfsfileengine.cpp \
io/qfsfileengine_iterator.cpp \
io/qfilesystemwatcher.cpp \
+ io/qfilesystemwatcher_polling.cpp \
io/qfilesystementry.cpp \
io/qfilesystemengine.cpp
win32 {
SOURCES += io/qsettings_win.cpp
- SOURCES += io/qprocess_win.cpp
SOURCES += io/qfsfileengine_win.cpp
SOURCES += io/qfilesystemwatcher_win.cpp
HEADERS += io/qfilesystemwatcher_win_p.h
+ HEADERS += io/qwindowspipereader_p.h
+ SOURCES += io/qwindowspipereader.cpp
HEADERS += io/qwindowspipewriter_p.h
SOURCES += io/qwindowspipewriter.cpp
SOURCES += io/qfilesystemengine_win.cpp
SOURCES += io/qfilesystemiterator_win.cpp
SOURCES += io/qstandardpaths_win.cpp
-} else:unix {
- SOURCES += io/qfsfileengine_unix.cpp
- symbian {
- SOURCES += io/qfilesystemengine_symbian.cpp
- SOURCES += io/qprocess_symbian.cpp
- SOURCES += io/qfilesystemiterator_symbian.cpp
- } else {
- SOURCES += io/qfilesystemengine_unix.cpp
- SOURCES += io/qprocess_unix.cpp
- SOURCES += io/qfilesystemiterator_unix.cpp
- }
+
+ wince* {
+ SOURCES += io/qprocess_wince.cpp
+ } else {
+ SOURCES += io/qprocess_win.cpp
+ }
+} else:unix|integrity {
+ SOURCES += \
+ io/qfsfileengine_unix.cpp \
+ io/qfilesystemengine_unix.cpp \
+ io/qprocess_unix.cpp \
+ io/qfilesystemiterator_unix.cpp \
+
!nacl:macx-*: {
- HEADERS += io/qfilesystemwatcher_fsevents_p.h
SOURCES += io/qfilesystemengine_mac.cpp
- SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp
+ SOURCES += io/qsettings_mac.cpp
}
macx-*: {
SOURCES += io/qstandardpaths_mac.cpp
@@ -102,14 +106,9 @@ win32 {
SOURCES += io/qstandardpaths_unix.cpp
}
- linux-*:!symbian {
- SOURCES += \
- io/qfilesystemwatcher_inotify.cpp \
- io/qfilesystemwatcher_dnotify.cpp
-
- HEADERS += \
- io/qfilesystemwatcher_inotify_p.h \
- io/qfilesystemwatcher_dnotify_p.h
+ linux-* {
+ SOURCES += io/qfilesystemwatcher_inotify.cpp
+ HEADERS += io/qfilesystemwatcher_inotify_p.h
}
!nacl {
@@ -118,17 +117,5 @@ win32 {
HEADERS += io/qfilesystemwatcher_kqueue_p.h
}
}
-
- symbian {
- SOURCES += io/qfilesystemwatcher_symbian.cpp
- HEADERS += io/qfilesystemwatcher_symbian_p.h
- INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
- LIBS += -lplatformenv -lesock
- }
-}
-integrity {
- SOURCES += io/qfsfileengine_unix.cpp \
- io/qfsfileengine_iterator.cpp \
- io/qfilesystemengine_unix.cpp \
- io/qfilesystemiterator_unix.cpp
}
+
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index d2b250d336..c315d33606 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qabstractfileengine.h b/src/corelib/io/qabstractfileengine.h
index cc167a2aa6..c9bab7d435 100644
--- a/src/corelib/io/qabstractfileengine.h
+++ b/src/corelib/io/qabstractfileengine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h
index dd9a707316..72b8339e39 100644
--- a/src/corelib/io/qabstractfileengine_p.h
+++ b/src/corelib/io/qabstractfileengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index 35e7b6809c..a5e605b9d5 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -143,12 +143,8 @@ QByteArray QBufferPrivate::peek(qint64 maxSize)
QBuffer emits readyRead() when new data has arrived in the
buffer. By connecting to this signal, you can use QBuffer to
- store temporary data before processing it. For example, you can
- pass the buffer to QFtp when downloading a file from an FTP
- server. Whenever a new payload of data has been downloaded,
- readyRead() is emitted, and you can process the data that just
- arrived. QBuffer also emits bytesWritten() every time new data
- has been written to the buffer.
+ store temporary data before processing it. QBuffer also emits
+ bytesWritten() every time new data has been written to the buffer.
\sa QFile, QDataStream, QTextStream, QByteArray
*/
diff --git a/src/corelib/io/qbuffer.h b/src/corelib/io/qbuffer.h
index 9227a2f3dc..b222c7d6ca 100644
--- a/src/corelib/io/qbuffer.h
+++ b/src/corelib/io/qbuffer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 0e0a47267a..fb2528e45f 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 1ae0573f6c..30cf8417ad 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdatastream_p.h b/src/corelib/io/qdatastream_p.h
index d372d54e36..2501e98d1d 100644
--- a/src/corelib/io/qdatastream_p.h
+++ b/src/corelib/io/qdatastream_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdataurl.cpp b/src/corelib/io/qdataurl.cpp
index ed8abdd839..7e856ad647 100644
--- a/src/corelib/io/qdataurl.cpp
+++ b/src/corelib/io/qdataurl.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -51,51 +51,49 @@ QT_BEGIN_NAMESPACE
Decode a data: URL into its mimetype and payload. Returns a null string if
the URL could not be decoded.
*/
-Q_CORE_EXPORT QPair<QString, QByteArray> qDecodeDataUrl(const QUrl &uri)
+Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray &payload)
{
- QString mimeType;
- QByteArray payload;
+ if (uri.scheme() != QLatin1String("data") || !uri.host().isEmpty())
+ return false;
- if (uri.scheme() == QLatin1String("data") && uri.host().isEmpty()) {
- mimeType = QLatin1String("text/plain;charset=US-ASCII");
+ mimeType = QLatin1String("text/plain;charset=US-ASCII");
- // the following would have been the correct thing, but
- // reality often differs from the specification. People have
- // data: URIs with ? and #
- //QByteArray data = QByteArray::fromPercentEncoding(uri.encodedPath());
- QByteArray data = QByteArray::fromPercentEncoding(uri.toEncoded());
+ // the following would have been the correct thing, but
+ // reality often differs from the specification. People have
+ // data: URIs with ? and #
+ //QByteArray data = QByteArray::fromPercentEncoding(uri.encodedPath());
+ QByteArray data = QByteArray::fromPercentEncoding(uri.toEncoded());
- // remove the data: scheme
- data.remove(0, 5);
+ // remove the data: scheme
+ data.remove(0, 5);
- // parse it:
- int pos = data.indexOf(',');
- if (pos != -1) {
- payload = data.mid(pos + 1);
- data.truncate(pos);
- data = data.trimmed();
+ // parse it:
+ int pos = data.indexOf(',');
+ if (pos != -1) {
+ payload = data.mid(pos + 1);
+ data.truncate(pos);
+ data = data.trimmed();
- // find out if the payload is encoded in Base64
- if (data.endsWith(";base64")) {
- payload = QByteArray::fromBase64(payload);
- data.chop(7);
- }
+ // find out if the payload is encoded in Base64
+ if (data.endsWith(";base64")) {
+ payload = QByteArray::fromBase64(payload);
+ data.chop(7);
+ }
- if (data.toLower().startsWith("charset")) {
- int i = 7; // strlen("charset")
- while (data.at(i) == ' ')
- ++i;
- if (data.at(i) == '=')
- data.prepend("text/plain;");
- }
+ if (data.toLower().startsWith("charset")) {
+ int i = 7; // strlen("charset")
+ while (data.at(i) == ' ')
+ ++i;
+ if (data.at(i) == '=')
+ data.prepend("text/plain;");
+ }
- if (!data.isEmpty())
- mimeType = QLatin1String(data.trimmed());
+ if (!data.isEmpty())
+ mimeType = QLatin1String(data.trimmed());
- }
}
- return QPair<QString,QByteArray>(mimeType,payload);
+ return true;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qdataurl_p.h b/src/corelib/io/qdataurl_p.h
index d666d9e52a..b92f363e1d 100644
--- a/src/corelib/io/qdataurl_p.h
+++ b/src/corelib/io/qdataurl_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,7 +60,7 @@
QT_BEGIN_NAMESPACE
-Q_CORE_EXPORT QPair<QString, QByteArray> qDecodeDataUrl(const QUrl &url);
+Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &url, QString &mimeType, QByteArray &payload);
QT_END_NAMESPACE
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index a27716b8dc..8ca15b19ca 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 67221c7ce2..54663d5d65 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -129,10 +129,8 @@ public:
inline QNoDebug(){}
inline QNoDebug(const QDebug &){}
inline ~QNoDebug(){}
-#if !defined( QT_NO_TEXTSTREAM )
inline QNoDebug &operator<<(QTextStreamFunction) { return *this; }
inline QNoDebug &operator<<(QTextStreamManipulator) { return *this; }
-#endif
inline QNoDebug &space() { return *this; }
inline QNoDebug &nospace() { return *this; }
inline QNoDebug &maybeSpace() { return *this; }
@@ -141,8 +139,6 @@ public:
inline QNoDebug &operator<<(const T &) { return *this; }
};
-Q_CORE_EXPORT_INLINE QDebug qCritical() { return QDebug(QtCriticalMsg); }
-
inline QDebug &QDebug::operator=(const QDebug &other)
{
if (this != &other) {
@@ -161,7 +157,7 @@ inline QDebug operator<<(QDebug debug, const QList<T> &list)
#endif
{
debug.nospace() << '(';
- for (Q_TYPENAME QList<T>::size_type i = 0; i < list.count(); ++i) {
+ for (typename QList<T>::size_type i = 0; i < list.count(); ++i) {
if (i)
debug << ", ";
debug << list.at(i);
@@ -275,17 +271,15 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
return debug.space();
}
-#if !defined(QT_NO_DEBUG_STREAM)
+#if !defined(QT_NO_DEBUG_OUTPUT) && !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); }
-
-#else // QT_NO_DEBUG_STREAM
+#else
#undef qDebug
inline QNoDebug qDebug() { return QNoDebug(); }
#define qDebug QT_NO_QDEBUG_MACRO
-
#endif
-#if !defined(QT_NO_WARNING_OUTPUT)
+#if !defined(QT_NO_WARNING_OUTPUT) && !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT_INLINE QDebug qWarning() { return QDebug(QtWarningMsg); }
#else
#undef qWarning
@@ -293,6 +287,11 @@ inline QNoDebug qWarning() { return QNoDebug(); }
#define qWarning QT_NO_QWARNING_MACRO
#endif
+#if !defined(QT_NO_DEBUG_STREAM)
+Q_CORE_EXPORT_INLINE QDebug qCritical() { return QDebug(QtCriticalMsg); }
+#endif
+
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 44992fcd14..d6979bad57 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -1502,7 +1502,7 @@ bool QDir::removeRecursively()
di.next();
const QFileInfo& fi = di.fileInfo();
bool ok;
- if (fi.isDir())
+ if (fi.isDir() && !fi.isSymLink())
ok = QDir(di.filePath()).removeRecursively(); // recursive
else
ok = QFile::remove(di.filePath());
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e246f2f1aa..5b058272e7 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h
index a34427a716..7865c1d5a3 100644
--- a/src/corelib/io/qdir_p.h
+++ b/src/corelib/io/qdir_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 0b02adb4b6..28aa4a0f59 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qdiriterator.h b/src/corelib/io/qdiriterator.h
index 5ad8acb496..be03415372 100644
--- a/src/corelib/io/qdiriterator.h
+++ b/src/corelib/io/qdiriterator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index d5118525cf..95d842da42 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index 554b2954e1..903ba13963 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h
index 3072f5bc9e..24013c3c3d 100644
--- a/src/corelib/io/qfile_p.h
+++ b/src/corelib/io/qfile_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 1ea6c8d50a..226b5d3560 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index ef4573132c..6d6da3527a 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h
index 23ea0225f5..64e644f29f 100644
--- a/src/corelib/io/qfileinfo_p.h
+++ b/src/corelib/io/qfileinfo_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 72900ec033..ab10f30585 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp
index 0d1556522a..f5e61ff29f 100644
--- a/src/corelib/io/qfilesystemengine_mac.cpp
+++ b/src/corelib/io/qfilesystemengine_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h
index bbd4c4c020..af32a1c575 100644
--- a/src/corelib/io/qfilesystemengine_p.h
+++ b/src/corelib/io/qfilesystemengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp
deleted file mode 100644
index c8c1dfdc84..0000000000
--- a/src/corelib/io/qfilesystemengine_symbian.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfilesystemengine_p.h"
-#include "qfsfileengine.h"
-#include <QtCore/private/qcore_symbian_p.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <f32file.h>
-#include <pathinfo.h>
-#include <wchar.h>
-
-QT_BEGIN_NAMESPACE
-
-bool QFileSystemEngine::isCaseSensitive()
-{
- return false;
-}
-
-//TODO: resolve this with QDir::cleanPath, without breaking the behaviour of that
-//function which is documented only by autotest
-//input: a dirty absolute path, e.g. c:/../../foo/./
-//output: a clean absolute path, e.g. c:/foo/
-static QString symbianCleanAbsolutePath(const QString& path)
-{
- bool isDir = path.endsWith(QLatin1Char('/'));
- //using SkipEmptyParts flag to eliminate duplicated slashes
- QStringList components = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
- int cdups = 0;
- for(int i=components.count() - 1; i>=0; --i) {
- if(components.at(i) == QLatin1String("..")) {
- components.removeAt(i);
- cdups++;
- }
- else if(components.at(i) == QLatin1String(".")) {
- components.removeAt(i);
- }
- else if(cdups && i > 0) {
- --cdups;
- components.removeAt(i);
- }
- }
- QString result = components.join(QLatin1String("/"));
- if ((isDir&& !result.endsWith(QLatin1Char('/')))
- || (result.length() == 2 && result.at(1).unicode() == ':'))
- result.append(QLatin1Char('/'));
- return result;
-}
-
-//static
-QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
-{
- Q_UNUSED(data);
- return link;
-}
-
-//static
-QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
-{
- if (entry.isEmpty() || entry.isRoot())
- return entry;
-
- QFileSystemEntry result = absoluteName(entry);
- if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute))
- fillMetaData(result, data, QFileSystemMetaData::ExistsAttribute);
- if (!data.exists()) {
- // file doesn't exist
- return QFileSystemEntry();
- } else {
- return result;
- }
-}
-
-//static
-QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
-{
- QString orig = entry.filePath();
- const bool isAbsolute = entry.isAbsolute();
- const bool isDirty = !entry.isClean();
- if (isAbsolute && !isDirty)
- return entry;
-
- const bool isRelative = entry.isRelative();
- const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/');
- const bool isDriveLetter = !needsDrive && !isAbsolute && !isRelative && orig.length() == 2;
- const bool isDriveRelative = !needsDrive && !isAbsolute && !isRelative && orig.length() > 2;
-
- QString result;
- if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) {
- QFileSystemEntry cur(currentPath());
- if(needsDrive)
- result = cur.filePath().left(2);
- else if(isDriveRelative && cur.filePath().at(0) != orig.at(0))
- result = orig.left(2); // for BC, see tst_QFileInfo::absolutePath(<not current drive>:my.dll)
- else
- result = cur.filePath();
- if(isDriveLetter) {
- result[0] = orig.at(0); //copy drive letter
- orig.clear();
- }
- if(isDriveRelative) {
- orig = orig.mid(2); //discard the drive specifier from orig
- }
- }
- if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) {
- if (!result.isEmpty() && !result.endsWith(QLatin1Char('/')))
- result.append(QLatin1Char('/'));
- result.append(orig);
- }
-
- return QFileSystemEntry(symbianCleanAbsolutePath(result), QFileSystemEntry::FromInternalPath());
-}
-
-void QFileSystemMetaData::fillFromTEntry(const TEntry& entry)
-{
- entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
- knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags;
- //Symbian doesn't have unix type file permissions
- entryFlags |= QFileSystemMetaData::ReadPermissions;
- if(!entry.IsReadOnly()) {
- entryFlags |= QFileSystemMetaData::WritePermissions;
- }
- //set the type
- if(entry.IsDir())
- entryFlags |= (QFileSystemMetaData::DirectoryType | QFileSystemMetaData::ExecutePermissions);
- else
- entryFlags |= QFileSystemMetaData::FileType;
-
- //set the attributes
- entryFlags |= QFileSystemMetaData::ExistsAttribute;
- if(entry.IsHidden())
- entryFlags |= QFileSystemMetaData::HiddenAttribute;
-
-#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
- size_ = entry.FileSize();
-#else
- size_ = (TUint)(entry.iSize);
-#endif
-
- modificationTime_ = entry.iModified;
-}
-
-void QFileSystemMetaData::fillFromVolumeInfo(const TVolumeInfo& info)
-{
- entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
- knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags;
- entryFlags |= QFileSystemMetaData::ExistsAttribute;
- entryFlags |= QFileSystemMetaData::Permissions;
- if(info.iDrive.iDriveAtt & KDriveAttRom) {
- entryFlags &= ~(QFileSystemMetaData::WritePermissions);
- }
- entryFlags |= QFileSystemMetaData::DirectoryType;
- size_ = info.iSize;
- modificationTime_ = qt_symbian_time_t_To_TTime(0);
-}
-
-//static
-bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what)
-{
- if (what & QFileSystemMetaData::SymbianTEntryFlags) {
- RFs& fs(qt_s60GetRFs());
- TInt err;
- QFileSystemEntry absentry(absoluteName(entry));
- if (entry.isEmpty()) {
- err = KErrNotFound;
- } else if (absentry.isRoot()) {
- //Root directories don't have an entry, and Entry() returns KErrBadName.
- //Therefore get information about the volume instead.
- TInt drive;
- err = RFs::CharToDrive(TChar(absentry.nativeFilePath().at(0).unicode()), drive);
- if (!err) {
- TVolumeInfo info;
- err = fs.Volume(info, drive);
- if (!err)
- data.fillFromVolumeInfo(info);
- }
- } else {
- TEntry ent;
- err = fs.Entry(qt_QString2TPtrC(absentry.nativeFilePath()), ent);
- if (!err)
- data.fillFromTEntry(ent);
- }
- if (err) {
- data.size_ = 0;
- data.modificationTime_ = TTime(0);
- data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags);
- }
- //files in /sys/bin on any drive are executable, even though we don't normally have permission to check whether they exist or not
- if(absentry.filePath().midRef(1,10).compare(QLatin1String(":/sys/bin/"), Qt::CaseInsensitive) == 0)
- data.entryFlags |= QFileSystemMetaData::ExecutePermissions;
- }
- return data.hasFlags(what);
-}
-
-//static
-bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
-{
- QString abspath = absoluteName(entry).nativeFilePath();
- if (!abspath.endsWith(QLatin1Char('\\')))
- abspath.append(QLatin1Char('\\'));
- TInt r;
- if (createParents)
- r = qt_s60GetRFs().MkDirAll(qt_QString2TPtrC(abspath));
- else
- r = qt_s60GetRFs().MkDir(qt_QString2TPtrC(abspath));
- if (createParents && r == KErrAlreadyExists)
- return true; //# Qt5 - QDir::mkdir returns false for existing dir, QDir::mkpath returns true (should be made consistent in Qt 5)
- return (r == KErrNone);
-}
-
-//static
-bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
-{
- QString abspath = absoluteName(entry).nativeFilePath();
- if (!abspath.endsWith(QLatin1Char('\\')))
- abspath.append(QLatin1Char('\\'));
- TPtrC dir(qt_QString2TPtrC(abspath));
- RFs& fs = qt_s60GetRFs();
- bool ok = false;
- //behaviour of FS file engine:
- //returns true if the directory could be removed
- //success/failure of removing parent directories does not matter
- while (KErrNone == fs.RmDir(dir)) {
- ok = true;
- if (!removeEmptyParents)
- break;
- //RFs::RmDir treats "c:\foo\bar" and "c:\foo\" the same, so it is sufficient to remove the last \ to the end
- dir.Set(dir.Left(dir.LocateReverse(TChar('\\'))));
- }
- return ok;
-}
-
-//static
-bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
-{
- Q_UNUSED(source)
- Q_UNUSED(target)
- error = QSystemError(KErrNotSupported, QSystemError::NativeError);
- return false;
-}
-
-//static
-bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
-{
- //CFileMan is allocated each time because it is not thread-safe
- CFileMan *fm = 0;
- TRAPD(err, fm = CFileMan::NewL(qt_s60GetRFs()));
- if (err == KErrNone) {
- err = fm->Copy(qt_QString2TPtrC(absoluteName(source).nativeFilePath()), qt_QString2TPtrC(absoluteName(target).nativeFilePath()), 0);
- delete fm;
- }
- if (err == KErrNone)
- return true;
- error = QSystemError(err, QSystemError::NativeError);
- return false;
-}
-
-//static
-bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
-{
- QString sourcepath = absoluteName(source).nativeFilePath();
- QString targetpath = absoluteName(target).nativeFilePath();
- RFs& fs(qt_s60GetRFs());
- TInt err = fs.Rename(qt_QString2TPtrC(sourcepath), qt_QString2TPtrC(targetpath));
- if (err == KErrNone)
- return true;
- error = QSystemError(err, QSystemError::NativeError);
- return false;
-}
-
-//static
-bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error)
-{
- QString targetpath = absoluteName(entry).nativeFilePath();
- RFs& fs(qt_s60GetRFs());
- TInt err = fs.Delete(qt_QString2TPtrC(targetpath));
- if (err == KErrNone)
- return true;
- error = QSystemError(err, QSystemError::NativeError);
- return false;
-}
-
-//static
-bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data)
-{
- QString targetpath = absoluteName(entry).nativeFilePath();
- TUint setmask = 0;
- TUint clearmask = 0;
- RFs& fs(qt_s60GetRFs());
- if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther))
- clearmask = KEntryAttReadOnly; //if anyone can write, it's not read-only
- else
- setmask = KEntryAttReadOnly;
- TInt err = fs.SetAtt(qt_QString2TPtrC(targetpath), setmask, clearmask);
- if (data && !err) {
- data->entryFlags &= ~QFileSystemMetaData::Permissions;
- data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions));
- data->knownFlagsMask |= QFileSystemMetaData::Permissions;
- }
- if (err == KErrNone)
- return true;
- error = QSystemError(err, QSystemError::NativeError);
- return false;
-}
-
-QString QFileSystemEngine::homePath()
-{
- QString home = QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath()));
- if(home.endsWith(QLatin1Char('/')))
- home.chop(1);
- return home;
-}
-
-QString QFileSystemEngine::rootPath()
-{
- TChar drive;
- TInt err = RFs::DriveToChar(RFs::GetSystemDrive(), drive); //RFs::GetSystemDriveChar not supported on S60 3.1
- Q_ASSERT(err == KErrNone); //RFs::GetSystemDrive() shall always return a convertible drive number on a valid OS configuration
- return QString(QChar(drive)).append(QLatin1String(":/"));
-}
-
-QString QFileSystemEngine::tempPath()
-{
- return rootPath().append(QLatin1String("system/temp"));
-}
-
-//static
-bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
-{
- QFileSystemMetaData meta;
- QFileSystemEntry absname = absoluteName(entry);
- fillMetaData(absname, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType);
- if(!(meta.exists() && meta.isDirectory()))
- return false;
-
- RFs& fs = qt_s60GetRFs();
- QString abspath = absname.nativeFilePath();
- if(!abspath.endsWith(QLatin1Char('\\')))
- abspath.append(QLatin1Char('\\'));
- TInt r = fs.SetSessionPath(qt_QString2TPtrC(abspath));
- //SetSessionPath succeeds for non existent directory, which is why it's checked above
- if (r == KErrNone) {
- __ASSERT_COMPILE(sizeof(wchar_t) == sizeof(unsigned short));
- //attempt to set open C to the same path
- r = ::wchdir(reinterpret_cast<const wchar_t *>(absname.filePath().utf16()));
- if (r < 0)
- qWarning("failed to sync path to open C");
- return true;
- }
- return false;
-}
-
-//static
-QFileSystemEntry QFileSystemEngine::currentPath()
-{
- TFileName fn;
- QFileSystemEntry ret;
- TInt r = qt_s60GetRFs().SessionPath(fn);
- if(r == KErrNone) {
- //remove terminating slash from non root paths (session path is clean, absolute and always ends in a \)
- if(fn.Length() > 3 && fn[fn.Length() - 1] == '\\')
- fn.SetLength(fn.Length() - 1);
- ret = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath());
- }
- return ret;
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 9778b526ac..901aaf8f91 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 10ba95e97f..d724429f6b 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -160,6 +160,31 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
static TRUSTEE_W currentUserTrusteeW;
static TRUSTEE_W worldTrusteeW;
+static PSID currentUserSID = 0;
+static PSID worldSID = 0;
+
+/*
+ Deletes the allocated SIDs during global static cleanup
+*/
+class SidCleanup
+{
+public:
+ ~SidCleanup();
+};
+
+SidCleanup::~SidCleanup()
+{
+ qFree(currentUserSID);
+ currentUserSID = 0;
+
+ // worldSID was allocated with AllocateAndInitializeSid so it needs to be freed with FreeSid
+ if (worldSID) {
+ ::FreeSid(worldSID);
+ worldSID = 0;
+ }
+}
+
+Q_GLOBAL_STATIC(SidCleanup, initSidCleanup)
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
@@ -199,25 +224,35 @@ static void resolveLibs()
// Create TRUSTEE for current user
HANDLE hnd = ::GetCurrentProcess();
HANDLE token = 0;
+ initSidCleanup();
if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) {
- TOKEN_USER tu;
- DWORD retsize;
- if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize))
- ptrBuildTrusteeWithSidW(&currentUserTrusteeW, tu.User.Sid);
+ DWORD retsize = 0;
+ // GetTokenInformation requires a buffer big enough for the TOKEN_USER struct and
+ // the SID struct. Since the SID struct can have variable number of subauthorities
+ // tacked at the end, its size is variable. Obtain the required size by first
+ // doing a dummy GetTokenInformation call.
+ ::GetTokenInformation(token, TokenUser, 0, 0, &retsize);
+ if (retsize) {
+ void *tokenBuffer = qMalloc(retsize);
+ if (::GetTokenInformation(token, TokenUser, tokenBuffer, retsize, &retsize)) {
+ PSID tokenSid = reinterpret_cast<PTOKEN_USER>(tokenBuffer)->User.Sid;
+ DWORD sidLen = ::GetLengthSid(tokenSid);
+ currentUserSID = reinterpret_cast<PSID>(qMalloc(sidLen));
+ if (::CopySid(sidLen, currentUserSID, tokenSid))
+ ptrBuildTrusteeWithSidW(&currentUserTrusteeW, currentUserSID);
+ }
+ qFree(tokenBuffer);
+ }
::CloseHandle(token);
}
typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*);
PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid");
- typedef PVOID (WINAPI *PtrFreeSid)(PSID);
- PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid");
- if (ptrAllocateAndInitializeSid && ptrFreeSid) {
+ if (ptrAllocateAndInitializeSid) {
// Create TRUSTEE for Everyone (World)
SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY };
- PSID pWorld = 0;
- if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld))
- ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld);
- ptrFreeSid(pWorld);
+ if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &worldSID))
+ ptrBuildTrusteeWithSidW(&worldTrusteeW, worldSID);
}
}
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
@@ -278,7 +313,7 @@ static QString readSymLink(const QFileSystemEntry &link)
0);
if (handle != INVALID_HANDLE_VALUE) {
DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
- REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
+ REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)malloc(bufsize);
DWORD retsize = 0;
if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
@@ -296,7 +331,7 @@ static QString readSymLink(const QFileSystemEntry &link)
if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\'))
result = result.mid(4);
}
- qFree(rdb);
+ free(rdb);
CloseHandle(handle);
#if !defined(QT_NO_LIBRARY)
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index 2f37542f66..11b73dd745 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
index 8d524c087e..61902f77d0 100644
--- a/src/corelib/io/qfilesystementry_p.h
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index 6f2d1e1c6e..7df5988459 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemiterator_symbian.cpp b/src/corelib/io/qfilesystemiterator_symbian.cpp
deleted file mode 100644
index 4347f6acba..0000000000
--- a/src/corelib/io/qfilesystemiterator_symbian.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfilesystemiterator_p.h"
-#include "qfilesystemengine_p.h"
-#include <QtCore/private/qcore_symbian_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &path, QDir::Filters filters,
- const QStringList &nameFilters, QDirIterator::IteratorFlags iteratorFlags)
- : lastError(KErrNone), entryIndex(-1)
-{
- RFs& fs = qt_s60GetRFs();
-
- nativePath = path.nativeFilePath();
- if (!nativePath.endsWith(QLatin1Char('\\')))
- nativePath.append(QLatin1Char('\\'));
-
- QString absPath = QFileSystemEngine::absoluteName(path).nativeFilePath();
-
- if (!absPath.endsWith(QLatin1Char('\\')))
- absPath.append(QLatin1Char('\\'));
-
- int pathLen = absPath.length();
- if (pathLen > KMaxFileName) {
- lastError = KErrBadName;
- return;
- }
-
- //set up server side filtering to reduce IPCs
- //RDir won't accept all valid name filters e.g. "*. bar"
- if (nameFilters.count() == 1 && !(filters & QDir::AllDirs) && iteratorFlags
- == QDirIterator::NoIteratorFlags && pathLen + nameFilters[0].length()
- <= KMaxFileName) {
- //server side supports one mask - skip this for recursive mode or if only files should be filtered
- absPath.append(nameFilters[0]);
- }
-
- TUint symbianMask = 0;
- if ((filters & QDir::Dirs) || (filters & QDir::AllDirs) || (iteratorFlags
- & QDirIterator::Subdirectories))
- symbianMask |= KEntryAttDir; //include directories
- if (filters & QDir::Hidden)
- symbianMask |= KEntryAttHidden;
- if (filters & QDir::System)
- symbianMask |= KEntryAttSystem;
- if (((filters & QDir::Files) == 0) && symbianMask == KEntryAttDir)
- symbianMask |= KEntryAttMatchExclusive; //exclude non-directories
- else if (symbianMask == 0) {
- if ((filters & QDir::PermissionMask) == QDir::Writable)
- symbianMask = KEntryAttMatchExclude | KEntryAttReadOnly;
- }
-
- lastError = dirHandle.Open(fs, qt_QString2TPtrC(absPath), symbianMask);
-}
-
-QFileSystemIterator::~QFileSystemIterator()
-{
- dirHandle.Close();
-}
-
-bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData)
-{
- //1st time, lastError is result of dirHandle.Open(), entries.Count() is 0 and entryIndex is -1 so initial read is triggered
- //subsequent times, read is triggered each time we reach the end of the entry list
- //final time, lastError is KErrEof so we don't need to read anymore.
- ++entryIndex;
- if (lastError == KErrNone && entryIndex >= entries.Count()) {
- lastError = dirHandle.Read(entries);
- entryIndex = 0;
- }
-
- //each call to advance() gets the next entry from the entry list.
- //from the final (or only) read call, KErrEof is returned together with a full buffer so we still need to go through the list
- if ((lastError == KErrNone || lastError == KErrEof) && entryIndex < entries.Count()) {
- Q_ASSERT(entryIndex >= 0);
- const TEntry &entry(entries[entryIndex]);
- fileEntry = QFileSystemEntry(nativePath + qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath());
- metaData.fillFromTEntry(entry);
- return true;
- }
-
- //TODO: error reporting, to allow user to distinguish empty directory from error condition.
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 6987660ea3..d0eb04a145 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index 5fff4f82c6..1f5cf356a0 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 64749e3889..6ed5cec954 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 9739067c06..4abb4f3cc1 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -48,234 +48,45 @@
#include <qdebug.h>
#include <qdir.h>
#include <qfileinfo.h>
-#include <qmutex.h>
#include <qset.h>
#include <qtimer.h>
+
+#include "qfilesystemwatcher_polling_p.h"
#if defined(Q_OS_WIN)
# include "qfilesystemwatcher_win_p.h"
#elif defined(Q_OS_LINUX)
# include "qfilesystemwatcher_inotify_p.h"
-# include "qfilesystemwatcher_dnotify_p.h"
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
-# if (defined Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-# include "qfilesystemwatcher_fsevents_p.h"
-# endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
# include "qfilesystemwatcher_kqueue_p.h"
-#elif defined(Q_OS_SYMBIAN)
-# include "qfilesystemwatcher_symbian_p.h"
#endif
QT_BEGIN_NAMESPACE
-enum { PollingInterval = 1000 };
-
-class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine
-{
- Q_OBJECT
-
- class FileInfo
- {
- uint ownerId;
- uint groupId;
- QFile::Permissions permissions;
- QDateTime lastModified;
- QStringList entries;
-
- public:
- FileInfo(const QFileInfo &fileInfo)
- : ownerId(fileInfo.ownerId()),
- groupId(fileInfo.groupId()),
- permissions(fileInfo.permissions()),
- lastModified(fileInfo.lastModified())
- {
- if (fileInfo.isDir()) {
- entries = fileInfo.absoluteDir().entryList(QDir::AllEntries);
- }
- }
- FileInfo &operator=(const QFileInfo &fileInfo)
- {
- *this = FileInfo(fileInfo);
- return *this;
- }
-
- bool operator!=(const QFileInfo &fileInfo) const
- {
- if (fileInfo.isDir() && entries != fileInfo.absoluteDir().entryList(QDir::AllEntries))
- return true;
- return (ownerId != fileInfo.ownerId()
- || groupId != fileInfo.groupId()
- || permissions != fileInfo.permissions()
- || lastModified != fileInfo.lastModified());
- }
- };
-
- mutable QMutex mutex;
- QHash<QString, FileInfo> files, directories;
-
-public:
- QPollingFileSystemWatcherEngine();
-
- void run();
-
- QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
- QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
-
- void stop();
-
-private Q_SLOTS:
- void timeout();
-};
-
-QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine()
-{
-#ifndef QT_NO_THREAD
- moveToThread(this);
-#endif
-}
-
-void QPollingFileSystemWatcherEngine::run()
-{
- QTimer timer;
- connect(&timer, SIGNAL(timeout()), SLOT(timeout()));
- timer.start(PollingInterval);
- (void) exec();
-}
-
-QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,
- QStringList *files,
- QStringList *directories)
-{
- QMutexLocker locker(&mutex);
- QStringList p = paths;
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
- QFileInfo fi(path);
- if (!fi.exists())
- continue;
- if (fi.isDir()) {
- if (!directories->contains(path))
- directories->append(path);
- if (!path.endsWith(QLatin1Char('/')))
- fi = QFileInfo(path + QLatin1Char('/'));
- this->directories.insert(path, fi);
- } else {
- if (!files->contains(path))
- files->append(path);
- this->files.insert(path, fi);
- }
- it.remove();
- }
- start();
- return p;
-}
-
-QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &paths,
- QStringList *files,
- QStringList *directories)
-{
- QMutexLocker locker(&mutex);
- QStringList p = paths;
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
- if (this->directories.remove(path)) {
- directories->removeAll(path);
- it.remove();
- } else if (this->files.remove(path)) {
- files->removeAll(path);
- it.remove();
- }
- }
- if (this->files.isEmpty() && this->directories.isEmpty()) {
- locker.unlock();
- stop();
- wait();
- }
- return p;
-}
-
-void QPollingFileSystemWatcherEngine::stop()
-{
- quit();
-}
-
-void QPollingFileSystemWatcherEngine::timeout()
-{
- QMutexLocker locker(&mutex);
- QMutableHashIterator<QString, FileInfo> fit(files);
- while (fit.hasNext()) {
- QHash<QString, FileInfo>::iterator x = fit.next();
- QString path = x.key();
- QFileInfo fi(path);
- if (!fi.exists()) {
- fit.remove();
- emit fileChanged(path, true);
- } else if (x.value() != fi) {
- x.value() = fi;
- emit fileChanged(path, false);
- }
- }
- QMutableHashIterator<QString, FileInfo> dit(directories);
- while (dit.hasNext()) {
- QHash<QString, FileInfo>::iterator x = dit.next();
- QString path = x.key();
- QFileInfo fi(path);
- if (!path.endsWith(QLatin1Char('/')))
- fi = QFileInfo(path + QLatin1Char('/'));
- if (!fi.exists()) {
- dit.remove();
- emit directoryChanged(path, true);
- } else if (x.value() != fi) {
- fi.refresh();
- if (!fi.exists()) {
- dit.remove();
- emit directoryChanged(path, true);
- } else {
- x.value() = fi;
- emit directoryChanged(path, false);
- }
- }
-
- }
-}
-
-
-
-
-QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine()
+QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)
{
#if defined(Q_OS_WIN)
- return new QWindowsFileSystemWatcherEngine;
+ return new QWindowsFileSystemWatcherEngine(parent);
#elif defined(Q_OS_LINUX)
- QFileSystemWatcherEngine *eng = QInotifyFileSystemWatcherEngine::create();
- if(!eng)
- eng = QDnotifyFileSystemWatcherEngine::create();
- return eng;
+ // there is a chance that inotify may fail on Linux pre-2.6.13 (August
+ // 2005), so we can't just new inotify directly.
+ return QInotifyFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
-# if 0 && defined(Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
- return QFSEventsFileSystemWatcherEngine::create();
- else
-# endif
- return QKqueueFileSystemWatcherEngine::create();
-#elif defined(Q_OS_SYMBIAN)
- return new QSymbianFileSystemWatcherEngine;
+ return QKqueueFileSystemWatcherEngine::create(parent);
#else
return 0;
#endif
}
QFileSystemWatcherPrivate::QFileSystemWatcherPrivate()
- : native(0), poller(0), forced(0)
+ : native(0), poller(0)
{
}
void QFileSystemWatcherPrivate::init()
{
Q_Q(QFileSystemWatcher);
- native = createNativeEngine();
+ native = createNativeEngine(q);
if (native) {
QObject::connect(native,
SIGNAL(fileChanged(QString,bool)),
@@ -288,42 +99,13 @@ void QFileSystemWatcherPrivate::init()
}
}
-void QFileSystemWatcherPrivate::initForcedEngine(const QString &forceName)
-{
- if(forced)
- return;
-
- Q_Q(QFileSystemWatcher);
-
-#if defined(Q_OS_LINUX)
- if(forceName == QLatin1String("inotify")) {
- forced = QInotifyFileSystemWatcherEngine::create();
- } else if(forceName == QLatin1String("dnotify")) {
- forced = QDnotifyFileSystemWatcherEngine::create();
- }
-#else
- Q_UNUSED(forceName);
-#endif
-
- if(forced) {
- QObject::connect(forced,
- SIGNAL(fileChanged(QString,bool)),
- q,
- SLOT(_q_fileChanged(QString,bool)));
- QObject::connect(forced,
- SIGNAL(directoryChanged(QString,bool)),
- q,
- SLOT(_q_directoryChanged(QString,bool)));
- }
-}
-
void QFileSystemWatcherPrivate::initPollerEngine()
{
if(poller)
return;
Q_Q(QFileSystemWatcher);
- poller = new QPollingFileSystemWatcherEngine; // that was a mouthful
+ poller = new QPollingFileSystemWatcherEngine(q); // that was a mouthful
QObject::connect(poller,
SIGNAL(fileChanged(QString,bool)),
q,
@@ -434,27 +216,7 @@ QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent
Destroys the file system watcher.
*/
QFileSystemWatcher::~QFileSystemWatcher()
-{
- Q_D(QFileSystemWatcher);
- if (d->native) {
- d->native->stop();
- d->native->wait();
- delete d->native;
- d->native = 0;
- }
- if (d->poller) {
- d->poller->stop();
- d->poller->wait();
- delete d->poller;
- d->poller = 0;
- }
- if (d->forced) {
- d->forced->stop();
- d->forced->wait();
- delete d->forced;
- d->forced = 0;
- }
-}
+{ }
/*!
Adds \a path to the file system watcher if \a path exists. The
@@ -466,20 +228,28 @@ QFileSystemWatcher::~QFileSystemWatcher()
otherwise the fileChanged() signal is emitted when \a path is
modified, renamed or removed.
- \note There is a system dependent limit to the number of files and
- directories that can be monitored simultaneously. If this limit
- has been reached, \a path will not be added to the file system
- watcher, and a warning message will be printed to \e{stderr}.
+ If the watch was successful, true is returned.
+
+ Reasons for a watch failure are generally system-dependent, but
+ may include the resource not existing, access failures, or the
+ total watch count limit, if the platform has one.
+
+ \note There may be a system dependent limit to the number of
+ files and directories that can be monitored simultaneously.
+ If this limit is been reached, \a path will not be monitored,
+ and false is returned.
\sa addPaths(), removePath()
*/
-void QFileSystemWatcher::addPath(const QString &path)
+bool QFileSystemWatcher::addPath(const QString &path)
{
if (path.isEmpty()) {
qWarning("QFileSystemWatcher::addPath: path is empty");
- return;
+ return true;
}
- addPaths(QStringList(path));
+
+ QStringList paths = addPaths(QStringList(path));
+ return paths.isEmpty();
}
/*!
@@ -492,23 +262,37 @@ void QFileSystemWatcher::addPath(const QString &path)
otherwise the fileChanged() signal is emitted when the path is
modified, renamed, or removed.
- \note There is a system dependent limit to the number of files and
- directories that can be monitored simultaneously. If this limit
- has been reached, the excess \a paths will not be added to the
- file system watcher, and a warning message will be printed to
- \e{stderr} for each path that could not be added.
+ The return value is a list of paths that could not be watched.
+
+ Reasons for a watch failure are generally system-dependent, but
+ may include the resource not existing, access failures, or the
+ total watch count limit, if the platform has one.
+
+ \note There may be a system dependent limit to the number of
+ files and directories that can be monitored simultaneously.
+ If this limit has been reached, the excess \a paths will not
+ be monitored, and they will be added to the returned QStringList.
\sa addPath(), removePaths()
*/
-void QFileSystemWatcher::addPaths(const QStringList &paths)
+QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
{
Q_D(QFileSystemWatcher);
- if (paths.isEmpty()) {
+
+ QStringList p = paths;
+ QMutableListIterator<QString> it(p);
+
+ while (it.hasNext()) {
+ const QString &path = it.next();
+ if (path.isEmpty())
+ it.remove();
+ }
+
+ if (p.isEmpty()) {
qWarning("QFileSystemWatcher::addPaths: list is empty");
- return;
+ return QStringList();
}
- QStringList p = paths;
QFileSystemWatcherEngine *engine = 0;
if(!objectName().startsWith(QLatin1String("_qt_autotest_force_engine_"))) {
@@ -530,54 +314,71 @@ void QFileSystemWatcher::addPaths(const QStringList &paths)
} else if(forceName == QLatin1String("native")) {
qDebug() << "QFileSystemWatcher: skipping polling engine, using only native engine";
engine = d->native;
- } else {
- qDebug() << "QFileSystemWatcher: skipping polling and native engine, using only explicit" << forceName << "engine";
- d_func()->initForcedEngine(forceName);
- engine = d->forced;
}
}
if(engine)
p = engine->addPaths(p, &d->files, &d->directories);
- if (!p.isEmpty())
- qWarning("QFileSystemWatcher: failed to add paths: %s",
- qPrintable(p.join(QLatin1String(", "))));
+ return p;
}
/*!
Removes the specified \a path from the file system watcher.
+ If the watch is successfully removed, true is returned.
+
+ Reasons for watch removal failing are generally system-dependent,
+ but may be due to the path having already been deleted, for example.
+
\sa removePaths(), addPath()
*/
-void QFileSystemWatcher::removePath(const QString &path)
+bool QFileSystemWatcher::removePath(const QString &path)
{
if (path.isEmpty()) {
qWarning("QFileSystemWatcher::removePath: path is empty");
- return;
+ return true;
}
- removePaths(QStringList(path));
+
+ QStringList paths = removePaths(QStringList(path));
+ return paths.isEmpty();
}
/*!
Removes the specified \a paths from the file system watcher.
+ The return value is a list of paths which were not able to be
+ unwatched successfully.
+
+ Reasons for watch removal failing are generally system-dependent,
+ but may be due to the path having already been deleted, for example.
+
\sa removePath(), addPaths()
*/
-void QFileSystemWatcher::removePaths(const QStringList &paths)
+QStringList QFileSystemWatcher::removePaths(const QStringList &paths)
{
- if (paths.isEmpty()) {
- qWarning("QFileSystemWatcher::removePaths: list is empty");
- return;
- }
Q_D(QFileSystemWatcher);
+
QStringList p = paths;
+ QMutableListIterator<QString> it(p);
+
+ while (it.hasNext()) {
+ const QString &path = it.next();
+ if (path.isEmpty())
+ it.remove();
+ }
+
+ if (p.isEmpty()) {
+ qWarning("QFileSystemWatcher::removePaths: list is empty");
+ return QStringList();
+ }
+
if (d->native)
p = d->native->removePaths(p, &d->files, &d->directories);
if (d->poller)
p = d->poller->removePaths(p, &d->files, &d->directories);
- if (d->forced)
- p = d->forced->removePaths(p, &d->files, &d->directories);
+
+ return p;
}
/*!
@@ -634,7 +435,5 @@ QT_END_NAMESPACE
#include "moc_qfilesystemwatcher.cpp"
-#include "qfilesystemwatcher.moc"
-
#endif // QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher.h b/src/corelib/io/qfilesystemwatcher.h
index 763c8de0d6..7b7dbe98c5 100644
--- a/src/corelib/io/qfilesystemwatcher.h
+++ b/src/corelib/io/qfilesystemwatcher.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -64,10 +64,10 @@ public:
QFileSystemWatcher(const QStringList &paths, QObject *parent = 0);
~QFileSystemWatcher();
- void addPath(const QString &file);
- void addPaths(const QStringList &files);
- void removePath(const QString &file);
- void removePaths(const QStringList &files);
+ bool addPath(const QString &file);
+ QStringList addPaths(const QStringList &files);
+ bool removePath(const QString &file);
+ QStringList removePaths(const QStringList &files);
QStringList files() const;
QStringList directories() const;
diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp
deleted file mode 100644
index 46c3b46467..0000000000
--- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qfilesystemwatcher.h"
-#include "qfilesystemwatcher_dnotify_p.h"
-
-#ifndef QT_NO_FILESYSTEMWATCHER
-
-#include <qsocketnotifier.h>
-#include <qcoreapplication.h>
-#include <qfileinfo.h>
-#include <qtimer.h>
-#include <qwaitcondition.h>
-#include <qmutex.h>
-#include <dirent.h>
-#include <qdir.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-
-#include "private/qcore_unix_p.h"
-
-#ifdef QT_LINUXBASE
-
-/* LSB doesn't standardize these */
-#define F_NOTIFY 1026
-#define DN_ACCESS 0x00000001
-#define DN_MODIFY 0x00000002
-#define DN_CREATE 0x00000004
-#define DN_DELETE 0x00000008
-#define DN_RENAME 0x00000010
-#define DN_ATTRIB 0x00000020
-#define DN_MULTISHOT 0x80000000
-
-#endif
-
-QT_BEGIN_NAMESPACE
-
-static int qfswd_fileChanged_pipe[2];
-static void (*qfswd_old_sigio_handler)(int) = 0;
-static void (*qfswd_old_sigio_action)(int, siginfo_t *, void *) = 0;
-static void qfswd_sigio_monitor(int signum, siginfo_t *i, void *v)
-{
- qt_safe_write(qfswd_fileChanged_pipe[1], reinterpret_cast<char*>(&i->si_fd), sizeof(int));
-
- if (qfswd_old_sigio_handler && qfswd_old_sigio_handler != SIG_IGN)
- qfswd_old_sigio_handler(signum);
- if (qfswd_old_sigio_action)
- qfswd_old_sigio_action(signum, i, v);
-}
-
-class QDnotifySignalThread : public QThread
-{
-Q_OBJECT
-public:
- QDnotifySignalThread();
- virtual ~QDnotifySignalThread();
-
- void startNotify();
-
- virtual void run();
-
-signals:
- void fdChanged(int);
-
-protected:
- virtual bool event(QEvent *);
-
-private slots:
- void readFromDnotify();
-
-private:
- QMutex mutex;
- QWaitCondition wait;
- bool isExecing;
-};
-
-Q_GLOBAL_STATIC(QDnotifySignalThread, dnotifySignal)
-
-QDnotifySignalThread::QDnotifySignalThread()
-: isExecing(false)
-{
- moveToThread(this);
-
- qt_safe_pipe(qfswd_fileChanged_pipe, O_NONBLOCK);
-
- struct sigaction oldAction;
- struct sigaction action;
- memset(&action, 0, sizeof(action));
- action.sa_sigaction = qfswd_sigio_monitor;
- action.sa_flags = SA_SIGINFO;
- ::sigaction(SIGIO, &action, &oldAction);
- if (!(oldAction.sa_flags & SA_SIGINFO))
- qfswd_old_sigio_handler = oldAction.sa_handler;
- else
- qfswd_old_sigio_action = oldAction.sa_sigaction;
-}
-
-QDnotifySignalThread::~QDnotifySignalThread()
-{
- if(isRunning()) {
- quit();
- QThread::wait();
- }
-}
-
-bool QDnotifySignalThread::event(QEvent *e)
-{
- if(e->type() == QEvent::User) {
- QMutexLocker locker(&mutex);
- isExecing = true;
- wait.wakeAll();
- return true;
- } else {
- return QThread::event(e);
- }
-}
-
-void QDnotifySignalThread::startNotify()
-{
- // Note: All this fancy waiting for the thread to enter its event
- // loop is to avoid nasty messages at app shutdown when the
- // QDnotifySignalThread singleton is deleted
- start();
- mutex.lock();
- while(!isExecing)
- wait.wait(&mutex);
- mutex.unlock();
-}
-
-void QDnotifySignalThread::run()
-{
- QSocketNotifier sn(qfswd_fileChanged_pipe[0], QSocketNotifier::Read, this);
- connect(&sn, SIGNAL(activated(int)), SLOT(readFromDnotify()));
-
- QCoreApplication::instance()->postEvent(this, new QEvent(QEvent::User));
- (void) exec();
-}
-
-void QDnotifySignalThread::readFromDnotify()
-{
- int fd;
- int readrv = qt_safe_read(qfswd_fileChanged_pipe[0], reinterpret_cast<char*>(&fd), sizeof(int));
- // Only expect EAGAIN or EINTR. Other errors are assumed to be impossible.
- if(readrv != -1) {
- Q_ASSERT(readrv == sizeof(int));
- Q_UNUSED(readrv);
-
- if(0 == fd)
- quit();
- else
- emit fdChanged(fd);
- }
-}
-
-QDnotifyFileSystemWatcherEngine::QDnotifyFileSystemWatcherEngine()
-{
- QObject::connect(dnotifySignal(), SIGNAL(fdChanged(int)),
- this, SLOT(refresh(int)), Qt::DirectConnection);
-}
-
-QDnotifyFileSystemWatcherEngine::~QDnotifyFileSystemWatcherEngine()
-{
- QMutexLocker locker(&mutex);
-
- for(QHash<int, Directory>::ConstIterator iter = fdToDirectory.constBegin();
- iter != fdToDirectory.constEnd();
- ++iter) {
- qt_safe_close(iter->fd);
- if(iter->parentFd)
- qt_safe_close(iter->parentFd);
- }
-}
-
-QDnotifyFileSystemWatcherEngine *QDnotifyFileSystemWatcherEngine::create()
-{
- return new QDnotifyFileSystemWatcherEngine();
-}
-
-void QDnotifyFileSystemWatcherEngine::run()
-{
- qFatal("QDnotifyFileSystemWatcherEngine thread should not be run");
-}
-
-QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories)
-{
- QMutexLocker locker(&mutex);
-
- QStringList p = paths;
- QMutableListIterator<QString> it(p);
-
- while (it.hasNext()) {
- QString path = it.next();
-
- QFileInfo fi(path);
-
- if(!fi.exists()) {
- continue;
- }
-
- bool isDir = fi.isDir();
-
- if (isDir && directories->contains(path)) {
- continue; // Skip monitored directories
- } else if(!isDir && files->contains(path)) {
- continue; // Skip monitored files
- }
-
- if(!isDir)
- path = fi.canonicalPath();
-
- // Locate the directory entry (creating if needed)
- int fd = pathToFD[path];
-
- if(fd == 0) {
-
- QT_DIR *d = QT_OPENDIR(path.toUtf8().constData());
- if(!d) continue; // Could not open directory
- QT_DIR *parent = 0;
-
- QDir parentDir(path);
- if(!parentDir.isRoot()) {
- parentDir.cdUp();
- parent = QT_OPENDIR(parentDir.path().toUtf8().constData());
- if(!parent) {
- QT_CLOSEDIR(d);
- continue;
- }
- }
-
- fd = qt_safe_dup(::dirfd(d));
- int parentFd = parent ? qt_safe_dup(::dirfd(parent)) : 0;
-
- QT_CLOSEDIR(d);
- if(parent) QT_CLOSEDIR(parent);
-
- Q_ASSERT(fd);
- if(::fcntl(fd, F_SETSIG, SIGIO) ||
- ::fcntl(fd, F_NOTIFY, DN_MODIFY | DN_CREATE | DN_DELETE |
- DN_RENAME | DN_ATTRIB | DN_MULTISHOT) ||
- (parent && ::fcntl(parentFd, F_SETSIG, SIGIO)) ||
- (parent && ::fcntl(parentFd, F_NOTIFY, DN_DELETE | DN_RENAME |
- DN_MULTISHOT))) {
- continue; // Could not set appropriate flags
- }
-
- Directory dir;
- dir.path = path;
- dir.fd = fd;
- dir.parentFd = parentFd;
-
- fdToDirectory.insert(fd, dir);
- pathToFD.insert(path, fd);
- if(parentFd)
- parentToFD.insert(parentFd, fd);
- }
-
- Directory &directory = fdToDirectory[fd];
-
- if(isDir) {
- directory.isMonitored = true;
- } else {
- Directory::File file;
- file.path = fi.filePath();
- file.lastWrite = fi.lastModified();
- directory.files.append(file);
- pathToFD.insert(fi.filePath(), fd);
- }
-
- it.remove();
-
- if(isDir) {
- directories->append(path);
- } else {
- files->append(fi.filePath());
- }
- }
-
- dnotifySignal()->startNotify();
-
- return p;
-}
-
-QStringList QDnotifyFileSystemWatcherEngine::removePaths(const QStringList &paths, QStringList *files, QStringList *directories)
-{
- QMutexLocker locker(&mutex);
-
- QStringList p = paths;
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
-
- QString path = it.next();
- int fd = pathToFD.take(path);
-
- if(!fd)
- continue;
-
- Directory &directory = fdToDirectory[fd];
- bool isDir = false;
- if(directory.path == path) {
- isDir = true;
- directory.isMonitored = false;
- } else {
- for(int ii = 0; ii < directory.files.count(); ++ii) {
- if(directory.files.at(ii).path == path) {
- directory.files.removeAt(ii);
- break;
- }
- }
- }
-
- if(!directory.isMonitored && directory.files.isEmpty()) {
- // No longer needed
- qt_safe_close(directory.fd);
- pathToFD.remove(directory.path);
- fdToDirectory.remove(fd);
- }
-
- if(isDir) {
- directories->removeAll(path);
- } else {
- files->removeAll(path);
- }
-
- it.remove();
- }
-
- return p;
-}
-
-void QDnotifyFileSystemWatcherEngine::refresh(int fd)
-{
- QMutexLocker locker(&mutex);
-
- bool wasParent = false;
- QHash<int, Directory>::Iterator iter = fdToDirectory.find(fd);
- if(iter == fdToDirectory.end()) {
- QHash<int, int>::Iterator pIter = parentToFD.find(fd);
- if(pIter == parentToFD.end())
- return;
-
- iter = fdToDirectory.find(*pIter);
- if (iter == fdToDirectory.end())
- return;
- wasParent = true;
- }
-
- Directory &directory = *iter;
-
- if(!wasParent) {
- for(int ii = 0; ii < directory.files.count(); ++ii) {
- Directory::File &file = directory.files[ii];
- if(file.updateInfo()) {
- // Emit signal
- QString filePath = file.path;
- bool removed = !QFileInfo(filePath).exists();
-
- if(removed) {
- directory.files.removeAt(ii);
- --ii;
- }
-
- emit fileChanged(filePath, removed);
- }
- }
- }
-
- if(directory.isMonitored) {
- // Emit signal
- bool removed = !QFileInfo(directory.path).exists();
- QString path = directory.path;
-
- if(removed)
- directory.isMonitored = false;
-
- emit directoryChanged(path, removed);
- }
-
- if(!directory.isMonitored && directory.files.isEmpty()) {
- qt_safe_close(directory.fd);
- if(directory.parentFd) {
- qt_safe_close(directory.parentFd);
- parentToFD.remove(directory.parentFd);
- }
- fdToDirectory.erase(iter);
- }
-}
-
-void QDnotifyFileSystemWatcherEngine::stop()
-{
-}
-
-bool QDnotifyFileSystemWatcherEngine::Directory::File::updateInfo()
-{
- QFileInfo fi(path);
- QDateTime nLastWrite = fi.lastModified();
- uint nOwnerId = fi.ownerId();
- uint nGroupId = fi.groupId();
- QFile::Permissions nPermissions = fi.permissions();
-
- if(nLastWrite != lastWrite ||
- nOwnerId != ownerId ||
- nGroupId != groupId ||
- nPermissions != permissions) {
- ownerId = nOwnerId;
- groupId = nGroupId;
- permissions = nPermissions;
- lastWrite = nLastWrite;
- return true;
- } else {
- return false;
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qfilesystemwatcher_dnotify.moc"
-
-#endif // QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp
deleted file mode 100644
index 95da897974..0000000000
--- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp
+++ /dev/null
@@ -1,492 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#define _DARWIN_USE_64_BIT_INODE
-#include <qplatformdefs.h>
-
-#include "qfilesystemwatcher.h"
-#include "qfilesystemwatcher_fsevents_p.h"
-
-#ifndef QT_NO_FILESYSTEMWATCHER
-
-#include <qdebug.h>
-#include <qfile.h>
-#include <qdatetime.h>
-#include <qfileinfo.h>
-#include <qvarlengtharray.h>
-
-#include <mach/mach.h>
-#include <sys/types.h>
-#include <CoreFoundation/CFRunLoop.h>
-#include <CoreFoundation/CFUUID.h>
-#include <CoreServices/CoreServices.h>
-#include <AvailabilityMacros.h>
-#include <private/qcore_mac_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-// Static operator overloading so for the sake of some convieniece.
-// They only live in this compilation unit to avoid polluting Qt in general.
-static bool operator==(const struct ::timespec &left, const struct ::timespec &right)
-{
- return left.tv_sec == right.tv_sec
- && left.tv_nsec == right.tv_nsec;
-}
-
-static bool operator==(const struct ::stat &left, const struct ::stat &right)
-{
- return left.st_dev == right.st_dev
- && left.st_mode == right.st_mode
- && left.st_size == right.st_size
- && left.st_ino == right.st_ino
- && left.st_uid == right.st_uid
- && left.st_gid == right.st_gid
- && left.st_mtimespec == right.st_mtimespec
- && left.st_ctimespec == right.st_ctimespec
- && left.st_flags == right.st_flags;
-}
-
-static bool operator!=(const struct ::stat &left, const struct ::stat &right)
-{
- return !(operator==(left, right));
-}
-
-
-static void addPathToHash(PathHash &pathHash, const QString &key, const QFileInfo &fileInfo,
- const QString &path)
-{
- PathInfoList &list = pathHash[key];
- list.push_back(PathInfo(path,
- fileInfo.canonicalFilePath().normalized(QString::NormalizationForm_D).toUtf8()));
- pathHash.insert(key, list);
-}
-
-static void removePathFromHash(PathHash &pathHash, const QString &key, const QString &path)
-{
- PathInfoList &list = pathHash[key];
- // We make the assumption that the list contains unique paths
- PathInfoList::iterator End = list.end();
- PathInfoList::iterator it = list.begin();
- while (it != End) {
- if (it->originalPath == path) {
- list.erase(it);
- break;
- }
- ++it;
- }
- if (list.isEmpty())
- pathHash.remove(key);
-}
-
-static void stopFSStream(FSEventStreamRef stream)
-{
- if (stream) {
- FSEventStreamStop(stream);
- FSEventStreamInvalidate(stream);
- }
-}
-
-static QString createFSStreamPath(const QString &absolutePath)
-{
- // The path returned has a trailing slash, so ensure that here.
- QString string = absolutePath;
- string.reserve(string.size() + 1);
- string.append(QLatin1Char('/'));
- return string;
-}
-
-static void cleanupFSStream(FSEventStreamRef stream)
-{
- if (stream)
- FSEventStreamRelease(stream);
-}
-
-const FSEventStreamCreateFlags QtFSEventFlags = (kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagNoDefer /* | kFSEventStreamCreateFlagWatchRoot*/);
-
-const CFTimeInterval Latency = 0.033; // This will do updates 30 times a second which is probably more than you need.
-#endif
-
-QFSEventsFileSystemWatcherEngine::QFSEventsFileSystemWatcherEngine()
- : fsStream(0), pathsToWatch(0), threadsRunLoop(0)
-{
-}
-
-QFSEventsFileSystemWatcherEngine::~QFSEventsFileSystemWatcherEngine()
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- // I assume that at this point, QFileSystemWatcher has already called stop
- // on me, so I don't need to invalidate or stop my stream, simply
- // release it.
- cleanupFSStream(fsStream);
- if (pathsToWatch)
- CFRelease(pathsToWatch);
-#endif
-}
-
-QFSEventsFileSystemWatcherEngine *QFSEventsFileSystemWatcherEngine::create()
-{
- return new QFSEventsFileSystemWatcherEngine();
-}
-
-QStringList QFSEventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
- QStringList *files,
- QStringList *directories)
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- stop();
- wait();
- QMutexLocker locker(&mutex);
- QStringList failedToAdd;
- // if we have a running FSStreamEvent, we have to kill it, we'll re-add the stream soon.
- FSEventStreamEventId idToCheck;
- if (fsStream) {
- idToCheck = FSEventStreamGetLatestEventId(fsStream);
- cleanupFSStream(fsStream);
- } else {
- idToCheck = kFSEventStreamEventIdSinceNow;
- }
-
- // Brain-dead approach, but works. FSEvents actually can already read sub-trees, but since it's
- // work to figure out if we are doing a double register, we just register it twice as FSEvents
- // seems smart enough to only deliver one event. We also duplicate directory entries in here
- // (e.g., if you watch five files in the same directory, you get that directory included in the
- // array 5 times). This stupidity also makes remove work correctly though. I'll freely admit
- // that we could make this a bit smarter. If you do, check the auto-tests, they should catch at
- // least a couple of the issues.
- QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- for (int i = 0; i < paths.size(); ++i) {
- const QString &path = paths.at(i);
-
- QFileInfo fileInfo(path);
- if (!fileInfo.exists()) {
- failedToAdd.append(path);
- continue;
- }
-
- if (fileInfo.isDir()) {
- if (directories->contains(path)) {
- failedToAdd.append(path);
- continue;
- } else {
- directories->append(path);
- // Full file path for dirs.
- QCFString cfpath(createFSStreamPath(fileInfo.canonicalFilePath()));
- addPathToHash(dirPathInfoHash, cfpath, fileInfo, path);
- CFArrayAppendValue(tmpArray, cfpath);
- }
- } else {
- if (files->contains(path)) {
- failedToAdd.append(path);
- continue;
- } else {
- // Just the absolute path (minus it's filename) for files.
- QCFString cfpath(createFSStreamPath(fileInfo.canonicalPath()));
- files->append(path);
- addPathToHash(filePathInfoHash, cfpath, fileInfo, path);
- CFArrayAppendValue(tmpArray, cfpath);
- }
- }
- }
-
- if (!pathsToWatch && failedToAdd.size() == paths.size()) {
- return failedToAdd;
- }
-
- if (CFArrayGetCount(tmpArray) > 0) {
- if (pathsToWatch) {
- CFArrayAppendArray(tmpArray, pathsToWatch, CFRangeMake(0, CFArrayGetCount(pathsToWatch)));
- CFRelease(pathsToWatch);
- }
- pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray);
- }
-
- FSEventStreamContext context = { 0, this, 0, 0, 0 };
- fsStream = FSEventStreamCreate(kCFAllocatorDefault,
- QFSEventsFileSystemWatcherEngine::fseventsCallback,
- &context, pathsToWatch,
- idToCheck, Latency, QtFSEventFlags);
- warmUpFSEvents();
-
- return failedToAdd;
-#else
- Q_UNUSED(paths);
- Q_UNUSED(files);
- Q_UNUSED(directories);
- return QStringList();
-#endif
-}
-
-void QFSEventsFileSystemWatcherEngine::warmUpFSEvents()
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- // This function assumes that the mutex has already been grabbed before calling it.
- // It exits with the mutex still locked (Q_ASSERT(mutex.isLocked()) ;-).
- start();
- waitCondition.wait(&mutex);
-#endif
-}
-
-QStringList QFSEventsFileSystemWatcherEngine::removePaths(const QStringList &paths,
- QStringList *files,
- QStringList *directories)
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- stop();
- wait();
- QMutexLocker locker(&mutex);
- // short circuit for smarties that call remove before add and we have nothing.
- if (pathsToWatch == 0)
- return paths;
- QStringList failedToRemove;
- // if we have a running FSStreamEvent, we have to stop it, we'll re-add the stream soon.
- FSEventStreamEventId idToCheck;
- if (fsStream) {
- idToCheck = FSEventStreamGetLatestEventId(fsStream);
- cleanupFSStream(fsStream);
- fsStream = 0;
- } else {
- idToCheck = kFSEventStreamEventIdSinceNow;
- }
-
- CFIndex itemCount = CFArrayGetCount(pathsToWatch);
- QCFType<CFMutableArrayRef> tmpArray = CFArrayCreateMutableCopy(kCFAllocatorDefault, itemCount,
- pathsToWatch);
- CFRelease(pathsToWatch);
- pathsToWatch = 0;
- for (int i = 0; i < paths.size(); ++i) {
- // Get the itemCount at the beginning to avoid any overruns during the iteration.
- itemCount = CFArrayGetCount(tmpArray);
- const QString &path = paths.at(i);
- QFileInfo fi(path);
- QCFString cfpath(createFSStreamPath(fi.canonicalPath()));
-
- CFIndex index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfpath);
- if (index != -1) {
- CFArrayRemoveValueAtIndex(tmpArray, index);
- files->removeAll(path);
- removePathFromHash(filePathInfoHash, cfpath, path);
- } else {
- // Could be a directory we are watching instead.
- QCFString cfdirpath(createFSStreamPath(fi.canonicalFilePath()));
- index = CFArrayGetFirstIndexOfValue(tmpArray, CFRangeMake(0, itemCount), cfdirpath);
- if (index != -1) {
- CFArrayRemoveValueAtIndex(tmpArray, index);
- directories->removeAll(path);
- removePathFromHash(dirPathInfoHash, cfpath, path);
- } else {
- failedToRemove.append(path);
- }
- }
- }
- itemCount = CFArrayGetCount(tmpArray);
- if (itemCount != 0) {
- pathsToWatch = CFArrayCreateCopy(kCFAllocatorDefault, tmpArray);
-
- FSEventStreamContext context = { 0, this, 0, 0, 0 };
- fsStream = FSEventStreamCreate(kCFAllocatorDefault,
- QFSEventsFileSystemWatcherEngine::fseventsCallback,
- &context, pathsToWatch, idToCheck, Latency, QtFSEventFlags);
- warmUpFSEvents();
- }
- return failedToRemove;
-#else
- Q_UNUSED(paths);
- Q_UNUSED(files);
- Q_UNUSED(directories);
- return QStringList();
-#endif
-}
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-void QFSEventsFileSystemWatcherEngine::updateList(PathInfoList &list, bool directory, bool emitSignals)
-{
- PathInfoList::iterator End = list.end();
- PathInfoList::iterator it = list.begin();
- while (it != End) {
- struct ::stat newInfo;
- if (::stat(it->absolutePath, &newInfo) == 0) {
- if (emitSignals) {
- if (newInfo != it->savedInfo) {
- it->savedInfo = newInfo;
- if (directory)
- emit directoryChanged(it->originalPath, false);
- else
- emit fileChanged(it->originalPath, false);
- }
- } else {
- it->savedInfo = newInfo;
- }
- } else {
- if (errno == ENOENT) {
- if (emitSignals) {
- if (directory)
- emit directoryChanged(it->originalPath, true);
- else
- emit fileChanged(it->originalPath, true);
- }
- it = list.erase(it);
- continue;
- } else {
- qWarning("%s:%d:QFSEventsFileSystemWatcherEngine: stat error on %s:%s",
- __FILE__, __LINE__, qPrintable(it->originalPath), strerror(errno));
-
- }
- }
- ++it;
- }
-}
-
-void QFSEventsFileSystemWatcherEngine::updateHash(PathHash &pathHash)
-{
- PathHash::iterator HashEnd = pathHash.end();
- PathHash::iterator it = pathHash.begin();
- const bool IsDirectory = (&pathHash == &dirPathInfoHash);
- while (it != HashEnd) {
- updateList(it.value(), IsDirectory, false);
- if (it.value().isEmpty())
- it = pathHash.erase(it);
- else
- ++it;
- }
-}
-#endif
-
-void QFSEventsFileSystemWatcherEngine::fseventsCallback(ConstFSEventStreamRef ,
- void *clientCallBackInfo, size_t numEvents,
- void *eventPaths,
- const FSEventStreamEventFlags eventFlags[],
- const FSEventStreamEventId [])
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- QFSEventsFileSystemWatcherEngine *watcher = static_cast<QFSEventsFileSystemWatcherEngine *>(clientCallBackInfo);
- QMutexLocker locker(&watcher->mutex);
- CFArrayRef paths = static_cast<CFArrayRef>(eventPaths);
- for (size_t i = 0; i < numEvents; ++i) {
- const QString path = QCFString::toQString(
- static_cast<CFStringRef>(CFArrayGetValueAtIndex(paths, i)));
- const FSEventStreamEventFlags pathFlags = eventFlags[i];
- // There are several flags that may be passed, but we really don't care about them ATM.
- // Here they are and why we don't care.
- // kFSEventStreamEventFlagHistoryDone--(very unlikely to be gotten, but even then, not much changes).
- // kFSEventStreamEventFlagMustScanSubDirs--Likely means the data is very much out of date, we
- // aren't coalescing our directories, so again not so much of an issue
- // kFSEventStreamEventFlagRootChanged | kFSEventStreamEventFlagMount | kFSEventStreamEventFlagUnmount--
- // These three flags indicate something has changed, but the stat will likely show this, so
- // there's not really much to worry about.
- // (btw, FSEvents is not the correct way of checking for mounts/unmounts,
- // there are real CarbonCore events for that.)
- Q_UNUSED(pathFlags);
- if (watcher->filePathInfoHash.contains(path))
- watcher->updateList(watcher->filePathInfoHash[path], false, true);
-
- if (watcher->dirPathInfoHash.contains(path))
- watcher->updateList(watcher->dirPathInfoHash[path], true, true);
- }
-#else
- Q_UNUSED(clientCallBackInfo);
- Q_UNUSED(numEvents);
- Q_UNUSED(eventPaths);
- Q_UNUSED(eventFlags);
-#endif
-}
-
-void QFSEventsFileSystemWatcherEngine::stop()
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- QMutexLocker locker(&mutex);
- stopFSStream(fsStream);
- if (threadsRunLoop) {
- CFRunLoopStop(threadsRunLoop);
- waitForStop.wait(&mutex);
- }
-#endif
-}
-
-void QFSEventsFileSystemWatcherEngine::updateFiles()
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- QMutexLocker locker(&mutex);
- updateHash(filePathInfoHash);
- updateHash(dirPathInfoHash);
- if (filePathInfoHash.isEmpty() && dirPathInfoHash.isEmpty()) {
- // Everything disappeared before we got to start, don't bother.
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- // Code duplicated from stop(), with the exception that we
- // don't wait on waitForStop here. Doing this will lead to
- // a deadlock since this function is called from the worker
- // thread. (waitForStop.wakeAll() is only called from the
- // end of run()).
- stopFSStream(fsStream);
- if (threadsRunLoop)
- CFRunLoopStop(threadsRunLoop);
-#endif
- cleanupFSStream(fsStream);
- }
- waitCondition.wakeAll();
-#endif
-}
-
-void QFSEventsFileSystemWatcherEngine::run()
-{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- threadsRunLoop = CFRunLoopGetCurrent();
- FSEventStreamScheduleWithRunLoop(fsStream, threadsRunLoop, kCFRunLoopDefaultMode);
- bool startedOK = FSEventStreamStart(fsStream);
- // It's recommended by Apple that you only update the files after you've started
- // the stream, because otherwise you might miss an update in between starting it.
- updateFiles();
-#ifdef QT_NO_DEBUG
- Q_UNUSED(startedOK);
-#else
- Q_ASSERT(startedOK);
-#endif
- // If for some reason we called stop up above (and invalidated our stream), this call will return
- // immediately.
- CFRunLoopRun();
- threadsRunLoop = 0;
- QMutexLocker locker(&mutex);
- waitForStop.wakeAll();
-#endif
-}
-
-QT_END_NAMESPACE
-#endif //QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents_p.h b/src/corelib/io/qfilesystemwatcher_fsevents_p.h
deleted file mode 100644
index 3830002c0a..0000000000
--- a/src/corelib/io/qfilesystemwatcher_fsevents_p.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef FILEWATCHER_FSEVENTS_P_H
-#define FILEWATCHER_FSEVENTS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qfilesystemwatcher_p.h"
-
-#ifndef QT_NO_FILESYSTEMWATCHER
-
-#include <QtCore/qmutex.h>
-#include <QtCore/qwaitcondition.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qlinkedlist.h>
-#include <private/qcore_mac_p.h>
-#include <sys/stat.h>
-
-typedef struct __FSEventStream *FSEventStreamRef;
-typedef const struct __FSEventStream *ConstFSEventStreamRef;
-typedef const struct __CFArray *CFArrayRef;
-typedef UInt32 FSEventStreamEventFlags;
-typedef uint64_t FSEventStreamEventId;
-
-QT_BEGIN_NAMESPACE
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-// Yes, I use a stat element here. QFileInfo requires too much knowledge about implementation
-// details to be used as a long-standing record. Since I'm going to have to store this information, I can
-// do the stat myself too.
-struct PathInfo {
- PathInfo(const QString &path, const QByteArray &absPath)
- : originalPath(path), absolutePath(absPath) {}
- QString originalPath; // The path we need to emit
- QByteArray absolutePath; // The path we need to stat.
- struct ::stat savedInfo; // All the info for the path so we can compare it.
-};
-typedef QLinkedList<PathInfo> PathInfoList;
-typedef QHash<QString, PathInfoList> PathHash;
-#endif
-
-class QFSEventsFileSystemWatcherEngine : public QFileSystemWatcherEngine
-{
- Q_OBJECT
-public:
- ~QFSEventsFileSystemWatcherEngine();
-
- static QFSEventsFileSystemWatcherEngine *create();
-
- QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
- QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
-
- void stop();
-
-private:
- QFSEventsFileSystemWatcherEngine();
- void warmUpFSEvents();
- void updateFiles();
-
- static void fseventsCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents,
- void *eventPaths, const FSEventStreamEventFlags eventFlags[],
- const FSEventStreamEventId eventIds[]);
- void run();
- FSEventStreamRef fsStream;
- CFArrayRef pathsToWatch;
- CFRunLoopRef threadsRunLoop;
- QMutex mutex;
- QWaitCondition waitCondition;
- QWaitCondition waitForStop;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
- PathHash filePathInfoHash;
- PathHash dirPathInfoHash;
- void updateHash(PathHash &pathHash);
- void updateList(PathInfoList &list, bool directory, bool emitSignals);
-#endif
-};
-
-#endif //QT_NO_FILESYSTEMWATCHER
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index ef302243da..ff732bc70e 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -210,7 +210,7 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create()
+QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create(QObject *parent)
{
register int fd = -1;
#ifdef IN_CLOEXEC
@@ -220,40 +220,32 @@ QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create()
fd = inotify_init();
if (fd == -1)
return 0;
- ::fcntl(fd, F_SETFD, FD_CLOEXEC);
}
- return new QInotifyFileSystemWatcherEngine(fd);
+ return new QInotifyFileSystemWatcherEngine(fd, parent);
}
-QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd)
- : inotifyFd(fd)
+QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ inotifyFd(fd),
+ notifier(fd, QSocketNotifier::Read, this)
{
fcntl(inotifyFd, F_SETFD, FD_CLOEXEC);
-
- moveToThread(this);
+ connect(&notifier, SIGNAL(activated(int)), SLOT(readFromInotify()));
}
QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine()
{
+ notifier.setEnabled(false);
foreach (int id, pathToID)
inotify_rm_watch(inotifyFd, id < 0 ? -id : id);
::close(inotifyFd);
}
-void QInotifyFileSystemWatcherEngine::run()
-{
- QSocketNotifier sn(inotifyFd, QSocketNotifier::Read, this);
- connect(&sn, SIGNAL(activated(int)), SLOT(readFromInotify()));
- (void) exec();
-}
-
QStringList QInotifyFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList *files,
QStringList *directories)
{
- QMutexLocker locker(&mutex);
-
QStringList p = paths;
QMutableListIterator<QString> it(p);
while (it.hasNext()) {
@@ -303,8 +295,6 @@ QStringList QInotifyFileSystemWatcherEngine::addPaths(const QStringList &paths,
idToPath.insert(id, path);
}
- start();
-
return p;
}
@@ -312,8 +302,6 @@ QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &path
QStringList *files,
QStringList *directories)
{
- QMutexLocker locker(&mutex);
-
QStringList p = paths;
QMutableListIterator<QString> it(p);
while (it.hasNext()) {
@@ -338,15 +326,8 @@ QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &path
return p;
}
-void QInotifyFileSystemWatcherEngine::stop()
-{
- quit();
-}
-
void QInotifyFileSystemWatcherEngine::readFromInotify()
{
- QMutexLocker locker(&mutex);
-
// qDebug() << "QInotifyFileSystemWatcherEngine::readFromInotify";
int buffSize = 0;
diff --git a/src/corelib/io/qfilesystemwatcher_inotify_p.h b/src/corelib/io/qfilesystemwatcher_inotify_p.h
index 0abd205237..8b3ce62c46 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify_p.h
+++ b/src/corelib/io/qfilesystemwatcher_inotify_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -57,8 +57,9 @@
#ifndef QT_NO_FILESYSTEMWATCHER
-#include <qhash.h>
-#include <qmutex.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qsocketnotifier.h>
QT_BEGIN_NAMESPACE
@@ -69,24 +70,20 @@ class QInotifyFileSystemWatcherEngine : public QFileSystemWatcherEngine
public:
~QInotifyFileSystemWatcherEngine();
- static QInotifyFileSystemWatcherEngine *create();
-
- void run();
+ static QInotifyFileSystemWatcherEngine *create(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
- void stop();
-
private Q_SLOTS:
void readFromInotify();
private:
- QInotifyFileSystemWatcherEngine(int fd);
+ QInotifyFileSystemWatcherEngine(int fd, QObject *parent);
int inotifyFd;
- QMutex mutex;
QHash<QString, int> pathToID;
QHash<int, QString> idToPath;
+ QSocketNotifier notifier;
};
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
index 387a7f7c4b..fd7bfa2b27 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp
+++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -67,49 +67,28 @@ QT_BEGIN_NAMESPACE
# define DEBUG if(false)qDebug
#endif
-QKqueueFileSystemWatcherEngine *QKqueueFileSystemWatcherEngine::create()
+QKqueueFileSystemWatcherEngine *QKqueueFileSystemWatcherEngine::create(QObject *parent)
{
int kqfd = kqueue();
if (kqfd == -1)
return 0;
- return new QKqueueFileSystemWatcherEngine(kqfd);
+ return new QKqueueFileSystemWatcherEngine(kqfd, parent);
}
-QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd)
- : kqfd(kqfd)
+QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd, QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ kqfd(kqfd),
+ notifier(kqfd, QSocketNotifier::Read, this)
{
- fcntl(kqfd, F_SETFD, FD_CLOEXEC);
+ connect(&notifier, SIGNAL(activated(int)), SLOT(readFromKqueue()));
- if (pipe(kqpipe) == -1) {
- perror("QKqueueFileSystemWatcherEngine: cannot create pipe");
- kqpipe[0] = kqpipe[1] = -1;
- return;
- }
- fcntl(kqpipe[0], F_SETFD, FD_CLOEXEC);
- fcntl(kqpipe[1], F_SETFD, FD_CLOEXEC);
-
- struct kevent kev;
- EV_SET(&kev,
- kqpipe[0],
- EVFILT_READ,
- EV_ADD | EV_ENABLE,
- 0,
- 0,
- 0);
- if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) {
- perror("QKqueueFileSystemWatcherEngine: cannot watch pipe, kevent returned");
- return;
- }
+ fcntl(kqfd, F_SETFD, FD_CLOEXEC);
}
QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine()
{
- stop();
- wait();
-
+ notifier.setEnabled(false);
close(kqfd);
- close(kqpipe[0]);
- close(kqpipe[1]);
foreach (int id, pathToID)
::close(id < 0 ? -id : id);
@@ -120,82 +99,73 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList *directories)
{
QStringList p = paths;
- {
- QMutexLocker locker(&mutex);
-
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
- int fd;
+ QMutableListIterator<QString> it(p);
+ while (it.hasNext()) {
+ QString path = it.next();
+ int fd;
#if defined(O_EVTONLY)
- fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY);
+ fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY);
#else
- fd = qt_safe_open(QFile::encodeName(path), O_RDONLY);
+ fd = qt_safe_open(QFile::encodeName(path), O_RDONLY);
#endif
- if (fd == -1) {
- perror("QKqueueFileSystemWatcherEngine::addPaths: open");
- continue;
- }
- if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
- int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
- if (fddup != -1) {
- ::close(fd);
- fd = fddup;
- }
+ if (fd == -1) {
+ perror("QKqueueFileSystemWatcherEngine::addPaths: open");
+ continue;
+ }
+ if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
+ int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
+ if (fddup != -1) {
+ ::close(fd);
+ fd = fddup;
}
- fcntl(fd, F_SETFD, FD_CLOEXEC);
+ }
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
- QT_STATBUF st;
- if (QT_FSTAT(fd, &st) == -1) {
- perror("QKqueueFileSystemWatcherEngine::addPaths: fstat");
+ QT_STATBUF st;
+ if (QT_FSTAT(fd, &st) == -1) {
+ perror("QKqueueFileSystemWatcherEngine::addPaths: fstat");
+ ::close(fd);
+ continue;
+ }
+ int id = (S_ISDIR(st.st_mode)) ? -fd : fd;
+ if (id < 0) {
+ if (directories->contains(path)) {
::close(fd);
continue;
}
- int id = (S_ISDIR(st.st_mode)) ? -fd : fd;
- if (id < 0) {
- if (directories->contains(path)) {
- ::close(fd);
- continue;
- }
- } else {
- if (files->contains(path)) {
- ::close(fd);
- continue;
- }
- }
-
- struct kevent kev;
- EV_SET(&kev,
- fd,
- EVFILT_VNODE,
- EV_ADD | EV_ENABLE | EV_CLEAR,
- NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
- 0,
- 0);
- if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) {
- perror("QKqueueFileSystemWatcherEngine::addPaths: kevent");
+ } else {
+ if (files->contains(path)) {
::close(fd);
continue;
}
+ }
- it.remove();
- if (id < 0) {
- DEBUG() << "QKqueueFileSystemWatcherEngine: added directory path" << path;
- directories->append(path);
- } else {
- DEBUG() << "QKqueueFileSystemWatcherEngine: added file path" << path;
- files->append(path);
- }
+ struct kevent kev;
+ EV_SET(&kev,
+ fd,
+ EVFILT_VNODE,
+ EV_ADD | EV_ENABLE | EV_CLEAR,
+ NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE,
+ 0,
+ 0);
+ if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) {
+ perror("QKqueueFileSystemWatcherEngine::addPaths: kevent");
+ ::close(fd);
+ continue;
+ }
- pathToID.insert(path, id);
- idToPath.insert(id, path);
+ it.remove();
+ if (id < 0) {
+ DEBUG() << "QKqueueFileSystemWatcherEngine: added directory path" << path;
+ directories->append(path);
+ } else {
+ DEBUG() << "QKqueueFileSystemWatcherEngine: added file path" << path;
+ files->append(path);
}
- }
- if (!isRunning())
- start();
- else
- write(kqpipe[1], "@", 1);
+ pathToID.insert(path, id);
+ idToPath.insert(id, path);
+ }
return p;
}
@@ -206,126 +176,86 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths
{
bool isEmpty;
QStringList p = paths;
- {
- QMutexLocker locker(&mutex);
- if (pathToID.isEmpty())
- return p;
-
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
- int id = pathToID.take(path);
- QString x = idToPath.take(id);
- if (x.isEmpty() || x != path)
- continue;
+ if (pathToID.isEmpty())
+ return p;
- ::close(id < 0 ? -id : id);
+ QMutableListIterator<QString> it(p);
+ while (it.hasNext()) {
+ QString path = it.next();
+ int id = pathToID.take(path);
+ QString x = idToPath.take(id);
+ if (x.isEmpty() || x != path)
+ continue;
- it.remove();
- if (id < 0)
- directories->removeAll(path);
- else
- files->removeAll(path);
- }
- isEmpty = pathToID.isEmpty();
- }
+ ::close(id < 0 ? -id : id);
- if (isEmpty) {
- stop();
- wait();
- } else {
- write(kqpipe[1], "@", 1);
+ it.remove();
+ if (id < 0)
+ directories->removeAll(path);
+ else
+ files->removeAll(path);
}
+ isEmpty = pathToID.isEmpty();
return p;
}
-void QKqueueFileSystemWatcherEngine::stop()
-{
- write(kqpipe[1], "q", 1);
-}
-
-void QKqueueFileSystemWatcherEngine::run()
+void QKqueueFileSystemWatcherEngine::readFromKqueue()
{
forever {
+ DEBUG() << "QKqueueFileSystemWatcherEngine: polling for changes";
int r;
struct kevent kev;
- DEBUG() << "QKqueueFileSystemWatcherEngine: waiting for kevents...";
- EINTR_LOOP(r, kevent(kqfd, 0, 0, &kev, 1, 0));
+ struct timespec ts = { 0, 0 }; // 0 ts, because we want to poll
+ EINTR_LOOP(r, kevent(kqfd, 0, 0, &kev, 1, &ts));
if (r < 0) {
perror("QKqueueFileSystemWatcherEngine: error during kevent wait");
return;
+ } else if (r == 0) {
+ // polling returned no events, so stop
+ break;
} else {
int fd = kev.ident;
DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
- if (fd == kqpipe[0]) {
- // read all pending data from the pipe
- QByteArray ba;
- ba.resize(kev.data);
- if (read(kqpipe[0], ba.data(), ba.size()) != ba.size()) {
- perror("QKqueueFileSystemWatcherEngine: error reading from pipe");
- return;
- }
- // read the command from the buffer (but break and return on 'q')
- char cmd = 0;
- for (int i = 0; i < ba.size(); ++i) {
- cmd = ba.constData()[i];
- if (cmd == 'q')
- break;
- }
- // handle the command
- switch (cmd) {
- case 'q':
- DEBUG() << "QKqueueFileSystemWatcherEngine: thread received 'q', exiting...";
- return;
- case '@':
- DEBUG() << "QKqueueFileSystemWatcherEngine: thread received '@', continuing...";
- break;
- default:
- DEBUG() << "QKqueueFileSystemWatcherEngine: thread received unknow message" << cmd;
- break;
- }
- } else {
- QMutexLocker locker(&mutex);
- int id = fd;
- QString path = idToPath.value(id);
+ int id = fd;
+ QString path = idToPath.value(id);
+ if (path.isEmpty()) {
+ // perhaps a directory?
+ id = -id;
+ path = idToPath.value(id);
if (path.isEmpty()) {
- // perhaps a directory?
- id = -id;
- path = idToPath.value(id);
- if (path.isEmpty()) {
- DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent for a file we're not watching";
- continue;
- }
- }
- if (kev.filter != EVFILT_VNODE) {
- DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent with the wrong filter";
+ DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent for a file we're not watching";
continue;
}
+ }
+ if (kev.filter != EVFILT_VNODE) {
+ DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent with the wrong filter";
+ continue;
+ }
- if ((kev.fflags & (NOTE_DELETE | NOTE_REVOKE | NOTE_RENAME)) != 0) {
- DEBUG() << path << "removed, removing watch also";
+ if ((kev.fflags & (NOTE_DELETE | NOTE_REVOKE | NOTE_RENAME)) != 0) {
+ DEBUG() << path << "removed, removing watch also";
- pathToID.remove(path);
- idToPath.remove(id);
- ::close(fd);
+ pathToID.remove(path);
+ idToPath.remove(id);
+ ::close(fd);
- if (id < 0)
- emit directoryChanged(path, true);
- else
- emit fileChanged(path, true);
- } else {
- DEBUG() << path << "changed";
+ if (id < 0)
+ emit directoryChanged(path, true);
+ else
+ emit fileChanged(path, true);
+ } else {
+ DEBUG() << path << "changed";
- if (id < 0)
- emit directoryChanged(path, false);
- else
- emit fileChanged(path, false);
- }
+ if (id < 0)
+ emit directoryChanged(path, false);
+ else
+ emit fileChanged(path, false);
}
}
+
}
}
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue_p.h b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
index fd9d820e7d..9bd9378c0c 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue_p.h
+++ b/src/corelib/io/qfilesystemwatcher_kqueue_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -59,6 +59,7 @@
#include <QtCore/qmutex.h>
#include <QtCore/qthread.h>
#include <QtCore/qvector.h>
+#include <QtCore/qsocketnotifier.h>
#ifndef QT_NO_FILESYSTEMWATCHER
struct kevent;
@@ -71,24 +72,22 @@ class QKqueueFileSystemWatcherEngine : public QFileSystemWatcherEngine
public:
~QKqueueFileSystemWatcherEngine();
- static QKqueueFileSystemWatcherEngine *create();
+ static QKqueueFileSystemWatcherEngine *create(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
- void stop();
+private Q_SLOTS:
+ void readFromKqueue();
private:
- QKqueueFileSystemWatcherEngine(int kqfd);
-
- void run();
+ QKqueueFileSystemWatcherEngine(int kqfd, QObject *parent);
int kqfd;
- int kqpipe[2];
- QMutex mutex;
QHash<QString, int> pathToID;
QHash<int, QString> idToPath;
+ QSocketNotifier notifier;
};
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_p.h b/src/corelib/io/qfilesystemwatcher_p.h
index e136273b36..9f403b308f 100644
--- a/src/corelib/io/qfilesystemwatcher_p.h
+++ b/src/corelib/io/qfilesystemwatcher_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,19 +60,17 @@
#include <private/qobject_p.h>
#include <QtCore/qstringlist.h>
-#include <QtCore/qthread.h>
QT_BEGIN_NAMESPACE
-class QFileSystemWatcherEngine : public QThread
+class QFileSystemWatcherEngine : public QObject
{
Q_OBJECT
protected:
- inline QFileSystemWatcherEngine(bool move = true)
+ inline QFileSystemWatcherEngine(QObject *parent)
+ : QObject(parent)
{
- if (move)
- moveToThread(this);
}
public:
@@ -88,8 +86,6 @@ public:
QStringList *files,
QStringList *directories) = 0;
- virtual void stop() = 0;
-
Q_SIGNALS:
void fileChanged(const QString &path, bool removed);
void directoryChanged(const QString &path, bool removed);
@@ -99,15 +95,14 @@ class QFileSystemWatcherPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QFileSystemWatcher)
- static QFileSystemWatcherEngine *createNativeEngine();
+ static QFileSystemWatcherEngine *createNativeEngine(QObject *parent);
public:
QFileSystemWatcherPrivate();
void init();
void initPollerEngine();
- void initForcedEngine(const QString &);
- QFileSystemWatcherEngine *native, *poller, *forced;
+ QFileSystemWatcherEngine *native, *poller;
QStringList files, directories;
// private slots
diff --git a/src/corelib/io/qfilesystemwatcher_polling.cpp b/src/corelib/io/qfilesystemwatcher_polling.cpp
new file mode 100644
index 0000000000..23dca140d6
--- /dev/null
+++ b/src/corelib/io/qfilesystemwatcher_polling.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfilesystemwatcher_polling_p.h"
+#include <QtCore/qtimer.h>
+
+QT_BEGIN_NAMESPACE
+
+QPollingFileSystemWatcherEngine::QPollingFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent),
+ timer(this)
+{
+ connect(&timer, SIGNAL(timeout()), SLOT(timeout()));
+}
+
+QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,
+ QStringList *files,
+ QStringList *directories)
+{
+ QStringList p = paths;
+ QMutableListIterator<QString> it(p);
+ while (it.hasNext()) {
+ QString path = it.next();
+ QFileInfo fi(path);
+ if (!fi.exists())
+ continue;
+ if (fi.isDir()) {
+ if (!directories->contains(path))
+ directories->append(path);
+ if (!path.endsWith(QLatin1Char('/')))
+ fi = QFileInfo(path + QLatin1Char('/'));
+ this->directories.insert(path, fi);
+ } else {
+ if (!files->contains(path))
+ files->append(path);
+ this->files.insert(path, fi);
+ }
+ it.remove();
+ }
+
+ if ((!this->files.isEmpty() ||
+ !this->directories.isEmpty()) &&
+ !timer.isActive()) {
+ timer.start(PollingInterval);
+ }
+
+ return p;
+}
+
+QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &paths,
+ QStringList *files,
+ QStringList *directories)
+{
+ QStringList p = paths;
+ QMutableListIterator<QString> it(p);
+ while (it.hasNext()) {
+ QString path = it.next();
+ if (this->directories.remove(path)) {
+ directories->removeAll(path);
+ it.remove();
+ } else if (this->files.remove(path)) {
+ files->removeAll(path);
+ it.remove();
+ }
+ }
+
+ if (this->files.isEmpty() &&
+ this->directories.isEmpty()) {
+ timer.stop();
+ }
+
+ return p;
+}
+
+void QPollingFileSystemWatcherEngine::timeout()
+{
+ QMutableHashIterator<QString, FileInfo> fit(files);
+ while (fit.hasNext()) {
+ QHash<QString, FileInfo>::iterator x = fit.next();
+ QString path = x.key();
+ QFileInfo fi(path);
+ if (!fi.exists()) {
+ fit.remove();
+ emit fileChanged(path, true);
+ } else if (x.value() != fi) {
+ x.value() = fi;
+ emit fileChanged(path, false);
+ }
+ }
+ QMutableHashIterator<QString, FileInfo> dit(directories);
+ while (dit.hasNext()) {
+ QHash<QString, FileInfo>::iterator x = dit.next();
+ QString path = x.key();
+ QFileInfo fi(path);
+ if (!path.endsWith(QLatin1Char('/')))
+ fi = QFileInfo(path + QLatin1Char('/'));
+ if (!fi.exists()) {
+ dit.remove();
+ emit directoryChanged(path, true);
+ } else if (x.value() != fi) {
+ fi.refresh();
+ if (!fi.exists()) {
+ dit.remove();
+ emit directoryChanged(path, true);
+ } else {
+ x.value() = fi;
+ emit directoryChanged(path, false);
+ }
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_dnotify_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h
index f759e87d89..3b3272a890 100644
--- a/src/corelib/io/qfilesystemwatcher_dnotify_p.h
+++ b/src/corelib/io/qfilesystemwatcher_polling_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFILESYSTEMWATCHER_DNOTIFY_P_H
-#define QFILESYSTEMWATCHER_DNOTIFY_P_H
+#ifndef QFILESYSTEMWATCHER_POLLING_P_H
+#define QFILESYSTEMWATCHER_POLLING_P_H
//
// W A R N I N G
@@ -53,79 +53,74 @@
// We mean it.
//
-#include "qfilesystemwatcher_p.h"
-
-#ifndef QT_NO_FILESYSTEMWATCHER
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qtimer.h>
-#include <qmutex.h>
-#include <qhash.h>
-#include <qdatetime.h>
-#include <qfile.h>
+#include "qfilesystemwatcher_p.h"
QT_BEGIN_NAMESPACE
-class QDnotifyFileSystemWatcherEngine : public QFileSystemWatcherEngine
+enum { PollingInterval = 1000 };
+
+class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine
{
Q_OBJECT
-public:
- virtual ~QDnotifyFileSystemWatcherEngine();
+ class FileInfo
+ {
+ uint ownerId;
+ uint groupId;
+ QFile::Permissions permissions;
+ QDateTime lastModified;
+ QStringList entries;
+
+ public:
+ FileInfo(const QFileInfo &fileInfo)
+ : ownerId(fileInfo.ownerId()),
+ groupId(fileInfo.groupId()),
+ permissions(fileInfo.permissions()),
+ lastModified(fileInfo.lastModified())
+ {
+ if (fileInfo.isDir()) {
+ entries = fileInfo.absoluteDir().entryList(QDir::AllEntries);
+ }
+ }
+ FileInfo &operator=(const QFileInfo &fileInfo)
+ {
+ *this = FileInfo(fileInfo);
+ return *this;
+ }
+
+ bool operator!=(const QFileInfo &fileInfo) const
+ {
+ if (fileInfo.isDir() && entries != fileInfo.absoluteDir().entryList(QDir::AllEntries))
+ return true;
+ return (ownerId != fileInfo.ownerId()
+ || groupId != fileInfo.groupId()
+ || permissions != fileInfo.permissions()
+ || lastModified != fileInfo.lastModified());
+ }
+ };
- static QDnotifyFileSystemWatcherEngine *create();
+ QHash<QString, FileInfo> files, directories;
- void run();
+public:
+ QPollingFileSystemWatcherEngine(QObject *parent);
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
- void stop();
-
private Q_SLOTS:
- void refresh(int);
+ void timeout();
private:
- struct Directory {
- Directory() : fd(0), parentFd(0), isMonitored(false) {}
- Directory(const Directory &o) : path(o.path),
- fd(o.fd),
- parentFd(o.parentFd),
- isMonitored(o.isMonitored),
- files(o.files) {}
- QString path;
- int fd;
- int parentFd;
- bool isMonitored;
-
- struct File {
- File() : ownerId(0u), groupId(0u), permissions(0u) { }
- File(const File &o) : path(o.path),
- ownerId(o.ownerId),
- groupId(o.groupId),
- permissions(o.permissions),
- lastWrite(o.lastWrite) {}
- QString path;
-
- bool updateInfo();
-
- uint ownerId;
- uint groupId;
- QFile::Permissions permissions;
- QDateTime lastWrite;
- };
-
- QList<File> files;
- };
-
- QDnotifyFileSystemWatcherEngine();
-
- QMutex mutex;
- QHash<QString, int> pathToFD;
- QHash<int, Directory> fdToDirectory;
- QHash<int, int> parentToFD;
+ QTimer timer;
};
+QT_END_NAMESPACE
+#endif // QFILESYSTEMWATCHER_POLLING_P_H
-QT_END_NAMESPACE
-#endif // QT_NO_FILESYSTEMWATCHER
-#endif // QFILESYSTEMWATCHER_DNOTIFY_P_H
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
deleted file mode 100644
index 6e5e91114c..0000000000
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfilesystemwatcher.h"
-#include "qfilesystemwatcher_symbian_p.h"
-#include "qfileinfo.h"
-#include "qdebug.h"
-#include "private/qcore_symbian_p.h"
-#include <QDir>
-
-#ifndef QT_NO_FILESYSTEMWATCHER
-
-
-QT_BEGIN_NAMESPACE
-
-QNotifyChangeEvent::QNotifyChangeEvent(RFs &fs, const TDesC &file,
- QSymbianFileSystemWatcherEngine *e, bool aIsDir,
- TInt aPriority) :
- CActive(aPriority),
- isDir(aIsDir),
- fsSession(fs),
- watchedPath(file),
- engine(e),
- failureCount(0)
-{
- if (isDir) {
- fsSession.NotifyChange(ENotifyEntry, iStatus, file);
- } else {
- fsSession.NotifyChange(ENotifyAll, iStatus, file);
- }
- CActiveScheduler::Add(this);
- SetActive();
-}
-
-QNotifyChangeEvent::~QNotifyChangeEvent()
-{
- Cancel();
-}
-
-void QNotifyChangeEvent::RunL()
-{
- if(iStatus.Int() == KErrNone) {
- failureCount = 0;
- } else {
- qWarning("QNotifyChangeEvent::RunL() - Failed to order change notifications: %d", iStatus.Int());
- failureCount++;
- }
-
- // Re-request failed notification once, but if it won't start working,
- // we can't do much besides just not request any more notifications.
- if (failureCount < 2) {
- if (isDir) {
- fsSession.NotifyChange(ENotifyEntry, iStatus, watchedPath);
- } else {
- fsSession.NotifyChange(ENotifyAll, iStatus, watchedPath);
- }
- SetActive();
-
- if (!failureCount) {
- int err;
- QT_TRYCATCH_ERROR(err, engine->emitPathChanged(this));
- if (err != KErrNone)
- qWarning("QNotifyChangeEvent::RunL() - emitPathChanged threw exception (Converted error code: %d)", err);
- }
- }
-}
-
-void QNotifyChangeEvent::DoCancel()
-{
- fsSession.NotifyChangeCancel(iStatus);
-}
-
-QSymbianFileSystemWatcherEngine::QSymbianFileSystemWatcherEngine() :
- watcherStarted(false)
-{
- moveToThread(this);
-}
-
-QSymbianFileSystemWatcherEngine::~QSymbianFileSystemWatcherEngine()
-{
- stop();
-}
-
-QStringList QSymbianFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files,
- QStringList *directories)
-{
- QMutexLocker locker(&mutex);
- QStringList p = paths;
-
- startWatcher();
-
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
- QFileInfo fi(path);
- if (!fi.exists())
- continue;
-
- bool isDir = fi.isDir();
- if (isDir) {
- if (directories->contains(path))
- continue;
- } else {
- if (files->contains(path))
- continue;
- }
-
- // Use absolute filepath as relative paths seem to have some issues.
- QString filePath = fi.absoluteFilePath();
- if (isDir && filePath.at(filePath.size() - 1) != QChar(L'/')) {
- filePath += QChar(L'/');
- }
-
- currentAddEvent = NULL;
- QMetaObject::invokeMethod(this,
- "addNativeListener",
- Qt::QueuedConnection,
- Q_ARG(QString, filePath));
-
- syncCondition.wait(&mutex);
- if (currentAddEvent) {
- currentAddEvent->isDir = isDir;
-
- activeObjectToPath.insert(currentAddEvent, path);
- it.remove();
-
- if (isDir)
- directories->append(path);
- else
- files->append(path);
- }
- }
-
- return p;
-}
-
-QStringList QSymbianFileSystemWatcherEngine::removePaths(const QStringList &paths,
- QStringList *files,
- QStringList *directories)
-{
- QMutexLocker locker(&mutex);
-
- QStringList p = paths;
- QMutableListIterator<QString> it(p);
- while (it.hasNext()) {
- QString path = it.next();
-
- currentRemoveEvent = activeObjectToPath.key(path);
- if (!currentRemoveEvent)
- continue;
- activeObjectToPath.remove(currentRemoveEvent);
-
- QMetaObject::invokeMethod(this,
- "removeNativeListener",
- Qt::QueuedConnection);
-
- syncCondition.wait(&mutex);
-
- it.remove();
-
- files->removeAll(path);
- directories->removeAll(path);
- }
-
- return p;
-}
-
-void QSymbianFileSystemWatcherEngine::emitPathChanged(QNotifyChangeEvent *e)
-{
- QMutexLocker locker(&mutex);
-
- QString path = activeObjectToPath.value(e);
- QFileInfo fi(path);
-
- if (e->isDir)
- emit directoryChanged(path, !fi.exists());
- else
- emit fileChanged(path, !fi.exists());
-}
-
-void QSymbianFileSystemWatcherEngine::stop()
-{
- quit();
- wait();
-}
-
-// This method must be called inside mutex
-void QSymbianFileSystemWatcherEngine::startWatcher()
-{
- if (!watcherStarted) {
- setStackSize(0x5000);
- start();
- syncCondition.wait(&mutex);
- watcherStarted = true;
- }
-}
-
-
-void QSymbianFileSystemWatcherEngine::run()
-{
- mutex.lock();
- syncCondition.wakeOne();
- mutex.unlock();
-
- exec();
-
- foreach(QNotifyChangeEvent *e, activeObjectToPath.keys()) {
- e->Cancel();
- delete e;
- }
-
- activeObjectToPath.clear();
-}
-
-void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directoryPath)
-{
- QMutexLocker locker(&mutex);
- QString nativeDir(QDir::toNativeSeparators(directoryPath));
- TPtrC ptr(qt_QString2TPtrC(nativeDir));
- currentAddEvent = new QNotifyChangeEvent(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
- syncCondition.wakeOne();
-}
-
-void QSymbianFileSystemWatcherEngine::removeNativeListener()
-{
- QMutexLocker locker(&mutex);
- currentRemoveEvent->Cancel();
- delete currentRemoveEvent;
- currentRemoveEvent = NULL;
- syncCondition.wakeOne();
-}
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_FILESYSTEMWATCHER
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 4e94623844..e82a9a5b56 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -50,25 +50,12 @@
#include <qset.h>
#include <qdatetime.h>
#include <qdir.h>
+#include <qtextstream.h>
QT_BEGIN_NAMESPACE
-void QWindowsFileSystemWatcherEngine::stop()
-{
- foreach(QWindowsFileSystemWatcherEngineThread *thread, threads)
- thread->stop();
-}
-
-QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine()
- : QFileSystemWatcherEngine(false)
-{
-}
-
QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine()
{
- if (threads.isEmpty())
- return;
-
foreach(QWindowsFileSystemWatcherEngineThread *thread, threads) {
thread->stop();
thread->wait();
@@ -310,7 +297,6 @@ QWindowsFileSystemWatcherEngineThread::QWindowsFileSystemWatcherEngineThread()
handles.reserve(MAXIMUM_WAIT_OBJECTS);
handles.append(h);
}
- moveToThread(this);
}
@@ -326,6 +312,17 @@ QWindowsFileSystemWatcherEngineThread::~QWindowsFileSystemWatcherEngineThread()
}
}
+static inline QString msgFindNextFailed(const QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &pathInfos)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "QFileSystemWatcher: FindNextChangeNotification failed for";
+ foreach (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo, pathInfos)
+ str << " \"" << QDir::toNativeSeparators(pathInfo.absolutePath) << '"';
+ str << ' ';
+ return result;
+}
+
void QWindowsFileSystemWatcherEngineThread::run()
{
QMutexLocker locker(&mutex);
@@ -356,11 +353,11 @@ void QWindowsFileSystemWatcherEngineThread::run()
// for some reason, so we must check if the handle exist in the handles vector
if (handles.contains(handle)) {
// qDebug()<<"thread"<<this<<"Acknowledged handle:"<<at<<handle;
+ QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle];
if (!FindNextChangeNotification(handle)) {
- qErrnoWarning("QFileSystemWatcher: FindNextChangeNotification failed!!");
+ const DWORD error = GetLastError();
+ qErrnoWarning(error, "%s", qPrintable(msgFindNextFailed(h)));
}
-
- QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle];
QMutableHashIterator<QString, QWindowsFileSystemWatcherEngine::PathInfo> it(h);
while (it.hasNext()) {
QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo>::iterator x = it.next();
diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h
index 3e9938a490..8e6b779b93 100644
--- a/src/corelib/io/qfilesystemwatcher_win_p.h
+++ b/src/corelib/io/qfilesystemwatcher_win_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,6 +60,7 @@
#include <qt_windows.h>
#include <QtCore/qdatetime.h>
+#include <QtCore/qthread.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qhash.h>
@@ -78,15 +79,14 @@ class QWindowsFileSystemWatcherEngine : public QFileSystemWatcherEngine
{
Q_OBJECT
public:
- QWindowsFileSystemWatcherEngine();
+ inline QWindowsFileSystemWatcherEngine(QObject *parent)
+ : QFileSystemWatcherEngine(parent)
+ { }
~QWindowsFileSystemWatcherEngine();
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
- void stop();
-
-
class Handle
{
public:
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 0d23a27909..a49ea84603 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine.h b/src/corelib/io/qfsfileengine.h
index 2e0b1eb923..0ed883a4a7 100644
--- a/src/corelib/io/qfsfileengine.h
+++ b/src/corelib/io/qfsfileengine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine_iterator.cpp b/src/corelib/io/qfsfileengine_iterator.cpp
index 323ab58335..2d162f6a7d 100644
--- a/src/corelib/io/qfsfileengine_iterator.cpp
+++ b/src/corelib/io/qfsfileengine_iterator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine_iterator_p.h b/src/corelib/io/qfsfileengine_iterator_p.h
index deccb01bfb..782930a52c 100644
--- a/src/corelib/io/qfsfileengine_iterator_p.h
+++ b/src/corelib/io/qfsfileengine_iterator_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 89c08aeca7..158c6f3a23 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 681e55dff7..b09518865e 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index f2b3e5f534..5dc96ea8a2 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -550,7 +550,7 @@ QString QFSFileEngine::currentPath(const QString &fileName)
return ret;
#else
Q_UNUSED(fileName);
- return QFileSystemEngine::currentPath();
+ return QFileSystemEngine::currentPath().filePath();
#endif
}
@@ -661,6 +661,7 @@ bool QFSFileEngine::link(const QString &newName)
#endif // QT_NO_LIBRARY
#else
QString linkName = newName;
+ linkName.replace(QLatin1Char('/'), QLatin1Char('\\'));
if (!linkName.endsWith(QLatin1String(".lnk")))
linkName += QLatin1String(".lnk");
QString orgName = fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\'));
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 8e1b2d5d0c..ef530f379f 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index 7d4afca850..4b34ad4f69 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index 3ccad6254a..2515fe5705 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index 113ba4b4bb..ba711493c6 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h
index c7c94243b9..ded605681e 100644
--- a/src/corelib/io/qnoncontiguousbytedevice_p.h
+++ b/src/corelib/io/qnoncontiguousbytedevice_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index d2aee16c45..8f76e0e4b9 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -471,7 +471,7 @@ void QProcessPrivate::Channel::clear()
read the standard output by calling read(), readLine(), and
getChar(). Because it inherits QIODevice, QProcess can also be
used as an input source for QXmlReader, or for generating data to
- be uploaded using QFtp.
+ be uploaded using QNetworkAccessManager.
\note On Windows CE and Symbian, reading and writing to a process
is not supported.
@@ -617,6 +617,14 @@ void QProcessPrivate::Channel::clear()
writes to its standard output and standard error will be written
to the standard output and standard error of the main process.
+ \note Windows intentionally suppresses output from GUI-only
+ applications to inherited consoles.
+ This does \e not apply to output redirected to files or pipes.
+ To forward the output of GUI-only applications on the console
+ nonetheless, you must use SeparateChannels and do the forwarding
+ yourself by reading the output and writing it to the appropriate
+ output channels.
+
\sa setProcessChannelMode()
*/
@@ -2271,7 +2279,7 @@ QT_END_INCLUDE_NAMESPACE
However, note that repeated calls to this function will recreate the
list of environment variables, which is a non-trivial operation.
- \note For new code, it is recommended to use QProcessEvironment::systemEnvironment()
+ \note For new code, it is recommended to use QProcessEnvironment::systemEnvironment()
\sa QProcessEnvironment::systemEnvironment(), environment(), setEnvironment()
*/
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index b2a5a4cbff..96a1edefd8 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 5bebff089e..7e0fecc320 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
deleted file mode 100644
index 9fd0c3aa65..0000000000
--- a/src/corelib/io/qprocess_symbian.cpp
+++ /dev/null
@@ -1,1072 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//#define QPROCESS_DEBUG
-
-#ifdef QPROCESS_DEBUG
-#include "qdebug.h"
-#define QPROCESS_DEBUG_PRINT(args...) qDebug(args);
-#else
-#define QPROCESS_DEBUG_PRINT(args...)
-#endif
-
-#ifndef QT_NO_PROCESS
-
-#define QPROCESS_ASSERT(check, panicReason, args...) \
- if (!(check)) { \
- qWarning(args); \
- User::Panic(KQProcessPanic, panicReason); \
- }
-
-#include <exception>
-#include <e32base.h>
-#include <e32std.h>
-#include <stdio.h>
-#include "qplatformdefs.h"
-
-#include "qdir.h"
-#include "qstring.h"
-#include "qprocess.h"
-#include "qprocess_p.h"
-#include "private/qeventdispatcher_symbian_p.h"
-
-#include <private/qthread_p.h>
-#include <qmutex.h>
-#include <qmap.h>
-#include <qsocketnotifier.h>
-
-#include <errno.h>
-
-
-QT_BEGIN_NAMESPACE
-
-_LIT(KQProcessManagerThreadName, "QProcManThread");
-_LIT(KQProcessPanic, "QPROCESS");
-enum TQProcessPanic {
- EProcessManagerMediatorRunError = 1,
- EProcessManagerMediatorInactive = 2,
- EProcessManagerMediatorNotPending = 3,
- EProcessManagerMediatorInvalidCmd = 4,
- EProcessManagerMediatorCreationFailed = 5,
- EProcessManagerMediatorThreadOpenFailed = 6,
- EProcessManagerMediatorNullObserver = 7,
- EProcessActiveRunError = 10,
- EProcessActiveNullParameter = 11,
- EProcessManagerMutexCreationFail = 20,
- EProcessManagerThreadCreationFail = 21,
- EProcessManagerSchedulerCreationFail = 22,
- EProcessManagerNullParam = 23
-};
-
-// Forward declarations
-class QProcessManager;
-
-
-// Active object to listen for child process death
-class QProcessActive : public CActive
-{
-public:
- static QProcessActive *construct(QProcess *process,
- RProcess **proc,
- int serial,
- int deathPipe);
-
- virtual ~QProcessActive();
-
- void start();
- void stop();
-
- bool error();
-
-protected:
-
- // Inherited from CActive
- void RunL();
- TInt RunError(TInt aError);
- void DoCancel();
-
- QProcessActive();
-
-private:
-
- QProcess *process;
- RProcess **pproc;
- int serial;
- int deathPipe;
- bool errorValue;
-};
-
-// Active object to communicate synchronously with process manager thread
-class QProcessManagerMediator : public CActive
-{
-public:
- static QProcessManagerMediator *construct();
-
- virtual ~QProcessManagerMediator();
-
- bool add(QProcessActive *processObserver);
- void remove(QProcessActive *processObserver);
- void terminate();
-
-protected:
-
- enum Commands {
- ENoCommand,
- EAdd,
- ERemove,
- ETerminate
- };
-
- // Inherited from CActive
- void RunL();
- TInt RunError(TInt aError);
- void DoCancel();
-
- QProcessManagerMediator();
-
- bool notify(QProcessActive *processObserver, Commands command);
-
-private:
- QProcessActive *currentObserver;
- Commands currentCommand;
-
- RThread processManagerThread;
-};
-
-// Process manager manages child process death listeners.
-//
-// Note: Because QProcess can be used outside event loop, we cannot be guaranteed
-// an active scheduler exists for us to add our process death listener objects.
-// We can't just install active scheduler on the calling thread, as that would block it
-// if we want to actually use it, so a separate manager thread is required.
-class QProcessManager
-{
-public:
- QProcessManager();
- ~QProcessManager();
-
- void startThread();
-
- TInt run(void *param);
- bool add(QProcess *process);
- void remove(QProcess *process);
-
- inline void setMediator(QProcessManagerMediator *newMediator) {
- mediator = newMediator;
- };
-
-private:
- inline void lock() {
- managerMutex.Wait();
- };
- inline void unlock() {
- managerMutex.Signal();
- };
-
- QMap<int, QProcessActive *> children;
- QProcessManagerMediator *mediator;
- RMutex managerMutex;
- bool threadStarted;
- RThread managerThread;
-};
-
-static bool qt_rprocess_running(RProcess *proc)
-{
- if (proc && proc->Handle()) {
- TExitType et = proc->ExitType();
- if (et == EExitPending)
- return true;
- }
-
- return false;
-}
-
-static void qt_create_symbian_commandline(
- const QStringList &arguments, const QString &nativeArguments, QString &commandLine)
-{
- for (int i = 0; i < arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace(QLatin1String("\\\""), QLatin1String("\\\\\""));
- // escape a single " because the arguments will be parsed
- tmp.replace(QLatin1String("\""), QLatin1String("\\\""));
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- QString endQuote(QLatin1String("\""));
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) {
- --i;
- endQuote += QLatin1String("\\");
- }
- commandLine += QLatin1String("\"") + tmp.left(i) + endQuote + QLatin1Char(' ');
- } else {
- commandLine += tmp + QLatin1Char(' ');
- }
- }
-
- if (!nativeArguments.isEmpty())
- commandLine += nativeArguments;
- else if (!commandLine.isEmpty()) // Chop the extra trailing space if any arguments were appended
- commandLine.chop(1);
-}
-
-static TInt qt_create_symbian_process(RProcess **proc,
- const QString &programName, const QStringList &arguments, const QString &nativeArguments)
-{
- RProcess *newProc = NULL;
- newProc = new RProcess();
-
- if (!newProc)
- return KErrNoMemory;
-
- QString commandLine;
- qt_create_symbian_commandline(arguments, nativeArguments, commandLine);
-
- TPtrC program_ptr(reinterpret_cast<const TText*>(programName.constData()));
- TPtrC cmdline_ptr(reinterpret_cast<const TText*>(commandLine.constData()));
-
- TInt err = newProc->Create(program_ptr, cmdline_ptr);
-
- if (err == KErrNotFound) {
- // Strip path from program name and try again (i.e. try from default location "\sys\bin")
- int index = programName.lastIndexOf(QDir::separator());
- int index2 = programName.lastIndexOf(QChar(QLatin1Char('/')));
- index = qMax(index, index2);
-
- if (index != -1 && programName.length() >= index) {
- QString strippedName;
- strippedName = programName.mid(index + 1);
- QPROCESS_DEBUG_PRINT("qt_create_symbian_process() Executable '%s' not found, trying stripped version '%s'",
- qPrintable(programName), qPrintable(strippedName));
-
- TPtrC stripped_ptr(reinterpret_cast<const TText*>(strippedName.constData()));
- err = newProc->Create(stripped_ptr, cmdline_ptr);
-
- if (err != KErrNone) {
- QPROCESS_DEBUG_PRINT("qt_create_symbian_process() Unable to create process '%s': %d",
- qPrintable(strippedName), err);
- }
- }
- }
-
- if (err == KErrNone)
- *proc = newProc;
- else
- delete newProc;
-
- return err;
-}
-
-static qint64 qt_native_read(int fd, char *data, qint64 maxlen)
-{
- qint64 ret = 0;
- do {
- ret = ::read(fd, data, maxlen);
- } while (ret == -1 && errno == EINTR);
-
- QPROCESS_DEBUG_PRINT("qt_native_read(): fd: %d, result: %d, errno = %d", fd, (int)ret, errno);
-
- return ret;
-}
-
-static qint64 qt_native_write(int fd, const char *data, qint64 len)
-{
- qint64 ret = 0;
- do {
- ret = ::write(fd, data, len);
- } while (ret == -1 && errno == EINTR);
-
- QPROCESS_DEBUG_PRINT("qt_native_write(): fd: %d, result: %d, errno = %d", fd, (int)ret, errno);
-
- return ret;
-}
-
-static void qt_native_close(int fd)
-{
- int ret;
- do {
- ret = ::close(fd);
- } while (ret == -1 && errno == EINTR);
-}
-
-static void qt_create_pipe(int *pipe)
-{
- if (pipe[0] != -1)
- qt_native_close(pipe[0]);
- if (pipe[1] != -1)
- qt_native_close(pipe[1]);
- if (::pipe(pipe) != 0) {
- qWarning("QProcessPrivate::createPipe: Cannot create pipe %p: %s",
- pipe, qPrintable(qt_error_string(errno)));
- } else {
- QPROCESS_DEBUG_PRINT("qt_create_pipe(): Created pipe %d - %d", pipe[0], pipe[1]);
- }
-}
-
-// Called from ProcessManagerThread
-QProcessActive *QProcessActive::construct(QProcess *process,
- RProcess **proc,
- int serial,
- int deathPipe)
-{
- QPROCESS_ASSERT((process || proc || *proc),
- EProcessActiveNullParameter,
- "QProcessActive::construct(): process (0x%x), proc (0x%x) or *proc == NULL, not creating an instance", process, proc)
-
- QProcessActive *newInstance = new QProcessActive();
-
- if (!newInstance) {
- QPROCESS_DEBUG_PRINT("QProcessActive::construct(): Failed to create new instance");
- } else {
- newInstance->process = process;
- newInstance->pproc = proc;
- newInstance->serial = serial;
- newInstance->deathPipe = deathPipe;
- newInstance->errorValue = false;
- }
-
- return newInstance;
-}
-
-// Called from ProcessManagerThread
-QProcessActive::QProcessActive()
- : CActive(CActive::EPriorityStandard)
-{
- // Nothing to do
-}
-
-// Called from main thread
-QProcessActive::~QProcessActive()
-{
- process = NULL;
- pproc = NULL;
-}
-
-// Called from ProcessManagerThread
-void QProcessActive::start()
-{
- if (qt_rprocess_running(*pproc)) {
- CActiveScheduler::Add(this);
- (*pproc)->Logon(iStatus);
- SetActive();
- QPROCESS_DEBUG_PRINT("QProcessActive::start(): Started monitoring for process exit.");
- } else {
- QPROCESS_DEBUG_PRINT("QProcessActive::start(): Process doesn't exist or is already dead");
- // Assume process has already died
- qt_native_write(deathPipe, "", 1);
- errorValue = true;
- }
-}
-
-// Called from ProcessManagerThread
-void QProcessActive::stop()
-{
- QPROCESS_DEBUG_PRINT("QProcessActive::stop()");
-
- // Remove this from scheduler (also cancels the request)
- Deque();
-}
-
-bool QProcessActive::error()
-{
- return errorValue;
-}
-
-// Called from ProcessManagerThread
-void QProcessActive::RunL()
-{
- // If this method gets executed, the monitored process has died
-
- // Notify main thread
- qt_native_write(deathPipe, "", 1);
- QPROCESS_DEBUG_PRINT("QProcessActive::RunL() sending death notice to %d", deathPipe);
-}
-
-// Called from ProcessManagerThread
-TInt QProcessActive::RunError(TInt aError)
-{
- Q_UNUSED(aError);
- // Handle RunL leave (should never happen)
- QPROCESS_ASSERT(0, EProcessActiveRunError, "QProcessActive::RunError(): Should never get here!")
- return 0;
-}
-
-// Called from ProcessManagerThread
-void QProcessActive::DoCancel()
-{
- QPROCESS_DEBUG_PRINT("QProcessActive::DoCancel()");
-
- if (qt_rprocess_running(*pproc)) {
- (*pproc)->LogonCancel(iStatus);
- QPROCESS_DEBUG_PRINT("QProcessActive::DoCancel(): Stopped monitoring for process exit.");
- } else {
- QPROCESS_DEBUG_PRINT("QProcessActive::DoCancel(): Process doesn't exist");
- }
-}
-
-
-// Called from ProcessManagerThread
-QProcessManagerMediator *QProcessManagerMediator::construct()
-{
- QProcessManagerMediator *newInstance = new QProcessManagerMediator;
- TInt err(KErrNone);
-
- newInstance->currentCommand = ENoCommand;
- newInstance->currentObserver = NULL;
-
- if (newInstance) {
- err = newInstance->processManagerThread.Open(newInstance->processManagerThread.Id());
- QPROCESS_ASSERT((err == KErrNone),
- EProcessManagerMediatorThreadOpenFailed,
- "QProcessManagerMediator::construct(): Failed to open processManagerThread (err:%d)", err)
- } else {
- QPROCESS_ASSERT(0,
- EProcessManagerMediatorCreationFailed,
- "QProcessManagerMediator::construct(): Failed to open construct mediator")
- }
-
- // Activate mediator
- CActiveScheduler::Add(newInstance);
- newInstance->iStatus = KRequestPending;
- newInstance->SetActive();
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::construct(): new instance successfully created and activated");
-
- return newInstance;
-}
-
-// Called from ProcessManagerThread
-QProcessManagerMediator::QProcessManagerMediator()
- : CActive(CActive::EPriorityStandard)
-{
- // Nothing to do
-}
-
-// Called from main thread
-QProcessManagerMediator::~QProcessManagerMediator()
-{
- processManagerThread.Close();
- currentCommand = ENoCommand;
- currentObserver = NULL;
-}
-
-// Called from main thread
-bool QProcessManagerMediator::add(QProcessActive *processObserver)
-{
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::add()");
- return notify(processObserver, EAdd);
-}
-
-// Called from main thread
-void QProcessManagerMediator::remove(QProcessActive *processObserver)
-{
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::remove()");
- notify(processObserver, ERemove);
-}
-
-// Called from main thread
-void QProcessManagerMediator::terminate()
-{
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::terminate()");
- notify(NULL, ETerminate);
-}
-
-// Called from main thread
-bool QProcessManagerMediator::notify(QProcessActive *processObserver, Commands command)
-{
- bool success(true);
-
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::Notify(): Command: %d, processObserver: 0x%x", command, processObserver);
-
- QPROCESS_ASSERT((command == ETerminate || processObserver),
- EProcessManagerMediatorNullObserver,
- "QProcessManagerMediator::Notify(): NULL processObserver not allowed for command: %d", command)
-
- QPROCESS_ASSERT(IsActive(),
- EProcessManagerMediatorInactive,
- "QProcessManagerMediator::Notify(): Mediator is not active!")
-
- QPROCESS_ASSERT(iStatus == KRequestPending,
- EProcessManagerMediatorNotPending,
- "QProcessManagerMediator::Notify(): Mediator request not pending!")
-
- currentObserver = processObserver;
- currentCommand = command;
-
- // Sync with process manager thread
- TRequestStatus pmStatus;
- processManagerThread.Rendezvous(pmStatus);
-
- // Complete request -> RunL will run in the process manager thread
- TRequestStatus *status = &iStatus;
- processManagerThread.RequestComplete(status, command);
-
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::Notify(): Waiting process manager to complete...");
- User::WaitForRequest(pmStatus);
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::Notify(): Wait over");
-
- if (currentObserver) {
- success = !(currentObserver->error());
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::Notify(): success = %d", success);
- }
-
- currentObserver = NULL;
- currentCommand = ENoCommand;
-
- return success;
-}
-
-// Called from ProcessManagerThread
-void QProcessManagerMediator::RunL()
-{
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::RunL(): currentCommand: %d, iStatus: %d", currentCommand, iStatus.Int());
- switch (currentCommand) {
- case EAdd:
- currentObserver->start();
- break;
- case ERemove:
- currentObserver->stop();
- break;
- case ETerminate:
- Deque();
- CActiveScheduler::Stop();
- return;
- default:
- QPROCESS_ASSERT(0,
- EProcessManagerMediatorInvalidCmd,
- "QProcessManagerMediator::RunL(): Invalid command!")
- break;
- }
-
- iStatus = KRequestPending;
- SetActive();
-
- // Notify main thread that we are done
- RThread::Rendezvous(KErrNone);
-}
-
-// Called from ProcessManagerThread
-TInt QProcessManagerMediator::RunError(TInt aError)
-{
- Q_UNUSED(aError);
- // Handle RunL leave (should never happen)
- QPROCESS_ASSERT(0,
- EProcessManagerMediatorRunError,
- "QProcessManagerMediator::RunError(): Should never get here!")
- return 0;
-}
-
-// Called from ProcessManagerThread
-void QProcessManagerMediator::DoCancel()
-{
- QPROCESS_DEBUG_PRINT("QProcessManagerMediator::DoCancel()");
- TRequestStatus *status = &iStatus;
- processManagerThread.RequestComplete(status, KErrCancel);
-}
-
-Q_GLOBAL_STATIC(QProcessManager, processManager)
-
-TInt processManagerThreadFunction(TAny *param)
-{
- QPROCESS_ASSERT(param,
- EProcessManagerNullParam,
- "processManagerThreadFunction(): NULL param")
-
- QProcessManager *manager = reinterpret_cast<QProcessManager*>(param);
-
- CActiveScheduler *scheduler = new CQtActiveScheduler();
-
- QPROCESS_ASSERT(scheduler,
- EProcessManagerSchedulerCreationFail,
- "processManagerThreadFunction(): Scheduler creation failed")
-
- CActiveScheduler::Install(scheduler);
-
- //Creating mediator also adds it to scheduler and activates it. Failure will panic.
- manager->setMediator(QProcessManagerMediator::construct());
- RThread::Rendezvous(KErrNone);
-
- CActiveScheduler::Start();
-
- CActiveScheduler::Install(NULL);
- delete scheduler;
-
- return KErrNone;
-}
-
-QProcessManager::QProcessManager()
- : mediator(NULL), threadStarted(false)
-{
- TInt err = managerMutex.CreateLocal();
-
- QPROCESS_ASSERT(err == KErrNone,
- EProcessManagerMutexCreationFail,
- "QProcessManager::QProcessManager(): Failed to create new managerMutex (err: %d)", err)
-}
-
-QProcessManager::~QProcessManager()
-{
- QPROCESS_DEBUG_PRINT("QProcessManager::~QProcessManager()");
-
- // Check if manager thread is still alive. If this destructor is ran as part of global
- // static cleanup, manager thread will most likely be terminated by kernel at this point,
- // so trying to delete QProcessActives and QProcessMediators will panic as they
- // will still be active. They can also no longer be canceled as the thread is already gone.
- // In case manager thread has already died, we simply do nothing and let the deletion of
- // the main heap at process exit take care of stray objects.
-
- if (managerThread.Handle() && managerThread.ExitType() == EExitPending) {
- // Cancel death listening for all child processes
- if (mediator) {
- QMap<int, QProcessActive *>::Iterator it = children.begin();
- while (it != children.end()) {
- // Remove all monitors
- QProcessActive *active = it.value();
- mediator->remove(active);
-
- QPROCESS_DEBUG_PRINT("QProcessManager::~QProcessManager() removed listening for a process");
- ++it;
- }
-
- // Terminate process manager thread.
- mediator->terminate();
- delete mediator;
- }
-
- qDeleteAll(children.values());
- children.clear();
- }
-
- managerThread.Close();
- managerMutex.Close();
-}
-
-void QProcessManager::startThread()
-{
- lock();
-
- if (!threadStarted) {
- TInt err = managerThread.Create(KQProcessManagerThreadName,
- processManagerThreadFunction,
- 0x5000,
- (RAllocator*)NULL,
- (TAny*)this,
- EOwnerProcess);
-
- QPROCESS_ASSERT(err == KErrNone,
- EProcessManagerThreadCreationFail,
- "QProcessManager::startThread(): Failed to create new managerThread (err:%d)", err)
-
- threadStarted = true;
-
- // Manager thread must start running before we continue, so sync with rendezvous
- TRequestStatus status;
- managerThread.Rendezvous(status);
- managerThread.Resume();
- User::WaitForRequest(status);
- }
-
- unlock();
-}
-
-static QBasicAtomicInt idCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
-
-bool QProcessManager::add(QProcess *process)
-{
- QPROCESS_ASSERT(process,
- EProcessManagerNullParam,
- "QProcessManager::add(): Failed to add QProcessActive to ProcessManager - NULL process")
-
- lock();
-
- int serial = idCounter.fetchAndAddRelaxed(1);
- process->d_func()->serial = serial;
-
- QPROCESS_DEBUG_PRINT("QProcessManager::add(): serial: %d, deathPipe: %d - %d, symbianProcess: 0x%x", serial, process->d_func()->deathPipe[0], process->d_func()->deathPipe[1], process->d_func()->symbianProcess);
-
- QProcessActive *newActive =
- QProcessActive::construct(process,
- &(process->d_func()->symbianProcess),
- serial,
- process->d_func()->deathPipe[1]);
-
- if (newActive) {
- if (mediator->add(newActive)) {
- children.insert(serial, newActive);
- unlock();
- return true;
- } else {
- QPROCESS_DEBUG_PRINT("QProcessManager::add(): Failed to add QProcessActive to ProcessManager");
- delete newActive;
- }
- }
-
- unlock();
-
- return false;
-}
-
-void QProcessManager::remove(QProcess *process)
-{
- QPROCESS_ASSERT(process,
- EProcessManagerNullParam,
- "QProcessManager::remove(): Failed to remove QProcessActive from ProcessManager - NULL process")
-
- lock();
-
- int serial = process->d_func()->serial;
- QProcessActive *active = children.value(serial);
- if (!active) {
- unlock();
- return;
- }
-
- mediator->remove(active);
-
- children.remove(serial);
- delete active;
-
- unlock();
-}
-
-void QProcessPrivate::destroyPipe(int *pipe)
-{
- if (pipe[1] != -1) {
- qt_native_close(pipe[1]);
- pipe[1] = -1;
- }
- if (pipe[0] != -1) {
- qt_native_close(pipe[0]);
- pipe[0] = -1;
- }
-}
-
-bool QProcessPrivate::createChannel(Channel &channel)
-{
- Q_UNUSED(channel);
- // No channels used
- return false;
-}
-
-void QProcessPrivate::startProcess()
-{
- Q_Q(QProcess);
-
- QPROCESS_DEBUG_PRINT("QProcessPrivate::startProcess()");
-
- // Start the process (platform dependent)
- q->setProcessState(QProcess::Starting);
-
- processManager()->startThread();
-
- qt_create_pipe(deathPipe);
- if (threadData->eventDispatcher) {
- deathNotifier = new QSocketNotifier(deathPipe[0],
- QSocketNotifier::Read, q);
- QObject::connect(deathNotifier, SIGNAL(activated(int)),
- q, SLOT(_q_processDied()));
- }
-
- TInt err = qt_create_symbian_process(&symbianProcess, program, arguments, nativeArguments);
-
- if (err == KErrNone) {
- pid = symbianProcess->Id().Id();
-
- ::fcntl(deathPipe[0], F_SETFL, ::fcntl(deathPipe[0], F_GETFL) | O_NONBLOCK);
-
- if (!processManager()->add(q)) {
- qWarning("QProcessPrivate::startProcess(): Failed to start monitoring for process death.");
- err = KErrNoMemory;
- }
- }
-
- if (err != KErrNone) {
- // Cleanup, report error and return
- QPROCESS_DEBUG_PRINT("QProcessPrivate::startProcess() Process open failed, err: %d, '%s'", err, qPrintable(program));
- q->setProcessState(QProcess::NotRunning);
- processError = QProcess::FailedToStart;
- q->setErrorString(QLatin1String(QT_TRANSLATE_NOOP(QProcess, "Resource error (qt_create_symbian_process failure)")));
- emit q->error(processError);
- cleanup();
- return;
- }
-
- processLaunched = true;
-
- symbianProcess->Resume();
-
- QPROCESS_DEBUG_PRINT("QProcessPrivate::startProcess(): this: 0x%x, pid: %ld", this, pid);
-
- // Notify child start
- _q_startupNotification();
-
-}
-
-bool QProcessPrivate::processStarted()
-{
- QPROCESS_DEBUG_PRINT("QProcessPrivate::processStarted() == %s", processLaunched ? "true" : "false");
-
- // Since we cannot get information whether process has actually been launched
- // or not in Symbian, we need to fake it. Assume process is started if launch was
- // successful.
-
- return processLaunched;
-}
-
-qint64 QProcessPrivate::bytesAvailableFromStdout() const
-{
- // In Symbian, stdout is not supported
- return 0;
-}
-
-qint64 QProcessPrivate::bytesAvailableFromStderr() const
-{
- // In Symbian, stderr is not supported
- return 0;
-}
-
-qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
- // In Symbian, stdout is not supported
- return 0;
-}
-
-qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
- // In Symbian, stderr is not supported
- return 0;
-}
-
-qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
-{
- Q_UNUSED(data);
- Q_UNUSED(maxlen);
- // In Symbian, stdin is not supported
- return 0;
-}
-
-void QProcessPrivate::terminateProcess()
-{
- // Needs PowerMgmt capability if process has been started; will panic kern-exec 46 otherwise.
- // Always works if process is not yet started.
- if (qt_rprocess_running(symbianProcess)) {
- symbianProcess->Terminate(0);
- } else {
- QPROCESS_DEBUG_PRINT("QProcessPrivate::terminateProcess(), Process not running");
- }
-}
-
-void QProcessPrivate::killProcess()
-{
- // Needs PowerMgmt capability if process has been started; will panic kern-exec 46 otherwise.
- // Always works if process is not yet started.
- if (qt_rprocess_running(symbianProcess)) {
- symbianProcess->Kill(0);
- } else {
- QPROCESS_DEBUG_PRINT("QProcessPrivate::killProcess(), Process not running");
- }
-}
-
-bool QProcessPrivate::waitForStarted(int msecs)
-{
- Q_UNUSED(msecs);
- // Since we can get no actual feedback from process beyond its death,
- // assume that started has already been emitted if process has been launched
- return processLaunched;
-}
-
-bool QProcessPrivate::waitForReadyRead(int msecs)
-{
- // Functionality not supported in Symbian
- Q_UNUSED(msecs);
- return false;
-}
-
-bool QProcessPrivate::waitForBytesWritten(int msecs)
-{
- // Functionality not supported in Symbian
- Q_UNUSED(msecs);
- return false;
-}
-
-bool QProcessPrivate::waitForFinished(int msecs)
-{
- Q_Q(QProcess);
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished(%d)", msecs);
-
- TRequestStatus timerStatus = KErrNone;
- TRequestStatus logonStatus = KErrNone;
- bool timeoutOccurred = false;
-
- // Logon to process to observe its death
- if (qt_rprocess_running(symbianProcess)) {
- symbianProcess->Logon(logonStatus);
-
- if (msecs < 0) {
- // If timeout is negative, there is no timeout
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished() - Waiting (just logon)...");
- User::WaitForRequest(logonStatus);
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished() - Wait completed");
- } else {
- // Create timer
- RTimer timer;
- timer.CreateLocal();
- TTimeIntervalMicroSeconds32 interval(msecs*1000);
- timer.After(timerStatus, interval);
-
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished() - Waiting (logon + timer)...");
- User::WaitForRequest(logonStatus, timerStatus);
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished() - Wait completed");
-
- if (logonStatus != KRequestPending) {
- timer.Cancel();
- User::WaitForRequest(timerStatus);
- } else {
- timeoutOccurred = true;
- symbianProcess->LogonCancel(logonStatus);
- User::WaitForRequest(logonStatus);
- }
- timer.Close();
- }
- } else {
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForFinished(), qt_rprocess_running returned false");
- }
-
- if (timeoutOccurred) {
- processError = QProcess::Timedout;
- q->setErrorString(QLatin1String(QT_TRANSLATE_NOOP(QProcess, "Process operation timed out")));
- return false;
- }
-
- _q_processDied();
-
- return true;
-}
-
-bool QProcessPrivate::waitForWrite(int msecs)
-{
- // Functionality not supported in Symbian
- Q_UNUSED(msecs);
- return false;
-}
-
-// Deceptively named function. Exit code is actually got in waitForDeadChild().
-void QProcessPrivate::findExitCode()
-{
- Q_Q(QProcess);
- processManager()->remove(q);
-}
-
-bool QProcessPrivate::waitForDeadChild()
-{
- Q_Q(QProcess);
-
- // read a byte from the death pipe
- char c;
- qt_native_read(deathPipe[0], &c, 1);
-
- if (symbianProcess && symbianProcess->Handle()) {
- TExitType et = symbianProcess->ExitType();
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForDeadChild() symbianProcess->ExitType: %d", et);
- if (et != EExitPending) {
- processManager()->remove(q);
- exitCode = symbianProcess->ExitReason();
- crashed = (et == EExitPanic);
-#if defined QPROCESS_DEBUG
- TExitCategoryName catName = symbianProcess->ExitCategory();
- qDebug() << "QProcessPrivate::waitForDeadChild() dead with exitCode"
- << exitCode << ", crashed:" << crashed
- << ", category:" << QString((const QChar *)catName.Ptr());
-#endif
- } else {
- QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForDeadChild() not dead!");
- }
- }
-
- return true;
-}
-
-void QProcessPrivate::_q_notified()
-{
- // Nothing to do in Symbian
-}
-
-bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
-{
- QPROCESS_DEBUG_PRINT("QProcessPrivate::startDetached()");
- Q_UNUSED(workingDirectory);
-
- RProcess *newProc = NULL;
-
- TInt err = qt_create_symbian_process(&newProc, program, arguments, QString());
-
- if (err == KErrNone) {
- if (pid)
- *pid = newProc->Id().Id();
-
- newProc->Resume();
- newProc->Close();
- delete newProc;
- return true;
- }
-
- return false;
-}
-
-
-void QProcessPrivate::initializeProcessManager()
-{
- (void) processManager();
-}
-
-QProcessEnvironment QProcessEnvironment::systemEnvironment()
-{
- return QProcessEnvironment();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 5fc69ed2cd..f01df3c078 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index d47e55dee4..8c6444d173 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -72,7 +72,6 @@ static void qt_create_pipe(Q_PIPE *pipe, bool in)
// read handles to avoid non-closable handles (this is done by the
// DuplicateHandle() call).
-#if !defined(Q_OS_WINCE)
SECURITY_ATTRIBUTES secAtt = { sizeof( SECURITY_ATTRIBUTES ), NULL, TRUE };
HANDLE tmpHandle;
@@ -91,10 +90,15 @@ static void qt_create_pipe(Q_PIPE *pipe, bool in)
}
CloseHandle(tmpHandle);
-#else
- Q_UNUSED(pipe);
- Q_UNUSED(in);
-#endif
+}
+
+static void duplicateStdWriteChannel(Q_PIPE *pipe, DWORD nStdHandle)
+{
+ pipe[0] = INVALID_Q_PIPE;
+ HANDLE hStdWriteChannel = GetStdHandle(nStdHandle);
+ HANDLE hCurrentProcess = GetCurrentProcess();
+ DuplicateHandle(hCurrentProcess, hStdWriteChannel, hCurrentProcess,
+ &pipe[1], 0, TRUE, DUPLICATE_SAME_ACCESS);
}
/*
@@ -113,8 +117,11 @@ bool QProcessPrivate::createChannel(Channel &channel)
if (channel.type == Channel::Normal) {
// we're piping this channel to our own process
- qt_create_pipe(channel.pipe, &channel == &stdinChannel);
-
+ const bool isStdInChannel = (&channel == &stdinChannel);
+ if (isStdInChannel || processChannelMode != QProcess::ForwardedChannels)
+ qt_create_pipe(channel.pipe, isStdInChannel);
+ else
+ duplicateStdWriteChannel(channel.pipe, (&channel == &stdoutChannel) ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
return true;
} else if (channel.type == Channel::Redirect) {
// we're redirecting the channel to/from a file
@@ -277,7 +284,6 @@ static QString qt_create_commandline(const QString &program, const QStringList &
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(Q_OS_WINCE)
// Calls to setenv() affect the low-level environment as well.
// This is not the case the other way round.
if (wchar_t *envStrings = GetEnvironmentStringsW()) {
@@ -293,11 +299,9 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
}
FreeEnvironmentStringsW(envStrings);
}
-#endif
return env;
}
-#if !defined(Q_OS_WINCE)
static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &environment)
{
QByteArray envlist;
@@ -357,7 +361,6 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Hash &
}
return envlist;
}
-#endif
void QProcessPrivate::startProcess()
{
@@ -381,14 +384,10 @@ void QProcessPrivate::startProcess()
!createChannel(stderrChannel))
return;
-#if defined(Q_OS_WINCE)
- QString args = qt_create_commandline(QString(), arguments);
-#else
QString args = qt_create_commandline(program, arguments);
QByteArray envlist;
if (environment.d.constData())
envlist = qt_create_environment(environment.d.constData()->hash);
-#endif
if (!nativeArguments.isEmpty()) {
if (!args.isEmpty())
args += QLatin1Char(' ');
@@ -402,15 +401,6 @@ void QProcessPrivate::startProcess()
qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
#endif
-#if defined(Q_OS_WINCE)
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath();
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, 0, 0, 0, 0, pid);
-#else
DWORD dwCreationFlags = CREATE_NO_WINDOW;
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
@@ -443,7 +433,6 @@ void QProcessPrivate::startProcess()
CloseHandle(stderrChannel.pipe[1]);
stderrChannel.pipe[1] = INVALID_Q_PIPE;
}
-#endif // Q_OS_WINCE
if (!success) {
cleanup();
@@ -484,24 +473,10 @@ qint64 QProcessPrivate::bytesAvailableFromStdout() const
return 0;
DWORD bytesAvail = 0;
-#if !defined(Q_OS_WINCE)
PeekNamedPipe(stdoutChannel.pipe[0], 0, 0, 0, &bytesAvail, 0);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::bytesAvailableFromStdout() == %d", bytesAvail);
#endif
- if (processChannelMode == QProcess::ForwardedChannels && bytesAvail > 0) {
- QByteArray buf(bytesAvail, 0);
- DWORD bytesRead = 0;
- if (ReadFile(stdoutChannel.pipe[0], buf.data(), buf.size(), &bytesRead, 0) && bytesRead > 0) {
- HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- if (hStdout) {
- DWORD bytesWritten = 0;
- WriteFile(hStdout, buf.data(), bytesRead, &bytesWritten, 0);
- }
- }
- bytesAvail = 0;
- }
-#endif
return bytesAvail;
}
@@ -511,24 +486,10 @@ qint64 QProcessPrivate::bytesAvailableFromStderr() const
return 0;
DWORD bytesAvail = 0;
-#if !defined(Q_OS_WINCE)
PeekNamedPipe(stderrChannel.pipe[0], 0, 0, 0, &bytesAvail, 0);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::bytesAvailableFromStderr() == %d", bytesAvail);
#endif
- if (processChannelMode == QProcess::ForwardedChannels && bytesAvail > 0) {
- QByteArray buf(bytesAvail, 0);
- DWORD bytesRead = 0;
- if (ReadFile(stderrChannel.pipe[0], buf.data(), buf.size(), &bytesRead, 0) && bytesRead > 0) {
- HANDLE hStderr = GetStdHandle(STD_ERROR_HANDLE);
- if (hStderr) {
- DWORD bytesWritten = 0;
- WriteFile(hStderr, buf.data(), bytesRead, &bytesWritten, 0);
- }
- }
- bytesAvail = 0;
- }
-#endif
return bytesAvail;
}
@@ -596,13 +557,6 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
{
Q_Q(QProcess);
-#if defined(Q_OS_WINCE)
- processError = QProcess::ReadError;
- q->setErrorString(QProcess::tr("Error reading from process"));
- emit q->error(processError);
- return false;
-#endif
-
QIncrementalSleepTimer timer(msecs);
forever {
@@ -646,13 +600,6 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
{
Q_Q(QProcess);
-#if defined(Q_OS_WINCE)
- processError = QProcess::ReadError;
- q->setErrorString(QProcess::tr("Error reading from process"));
- emit q->error(processError);
- return false;
-#endif
-
QIncrementalSleepTimer timer(msecs);
forever {
@@ -786,13 +733,6 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
{
Q_Q(QProcess);
-#if defined(Q_OS_WINCE)
- processError = QProcess::WriteError;
- q->setErrorString(QProcess::tr("Error writing to process"));
- emit q->error(processError);
- return -1;
-#endif
-
if (!pipeWriter) {
pipeWriter = new QWindowsPipeWriter(stdinChannel.pipe[1], q);
pipeWriter->start();
@@ -832,36 +772,19 @@ void QProcessPrivate::_q_notified()
bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid)
{
-#if defined(Q_OS_WINCE)
- Q_UNUSED(workingDir);
- QString args = qt_create_commandline(QString(), arguments);
-#else
QString args = qt_create_commandline(program, arguments);
-#endif
-
bool success = false;
-
PROCESS_INFORMATION pinfo;
-#if defined(Q_OS_WINCE)
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/')));
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo);
-#else
- STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
- (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
- (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- success = CreateProcess(0, (wchar_t*)args.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
- workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(),
- &startupInfo, &pinfo);
-#endif // Q_OS_WINCE
+ STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
+ (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
+ (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ success = CreateProcess(0, (wchar_t*)args.utf16(),
+ 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(),
+ &startupInfo, &pinfo);
if (success) {
CloseHandle(pinfo.hThread);
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
new file mode 100644
index 0000000000..16a34469e7
--- /dev/null
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprocess.h"
+#include "qprocess_p.h"
+
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <qregexp.h>
+#include <qtimer.h>
+#include <qwineventnotifier.h>
+#include <qdebug.h>
+
+#ifndef QT_NO_PROCESS
+
+QT_BEGIN_NAMESPACE
+
+//#define QPROCESS_DEBUG
+
+void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
+{
+ Q_UNUSED(pipe);
+}
+
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString args;
+ if (!program.isEmpty()) {
+ QString programName = program;
+ if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
+ programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
+ programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+
+ // add the prgram as the first arg ... it works better
+ args = programName + QLatin1Char(' ');
+ }
+
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // Quotes are escaped and their preceding backslashes are doubled.
+ tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
+ if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ int i = tmp.length();
+ while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
+ --i;
+ tmp.insert(i, QLatin1Char('"'));
+ tmp.prepend(QLatin1Char('"'));
+ }
+ args += QLatin1Char(' ') + tmp;
+ }
+ return args;
+}
+
+QProcessEnvironment QProcessEnvironment::systemEnvironment()
+{
+ QProcessEnvironment env;
+ return env;
+}
+
+void QProcessPrivate::startProcess()
+{
+ Q_Q(QProcess);
+
+ bool success = false;
+
+ if (pid) {
+ CloseHandle(pid->hThread);
+ CloseHandle(pid->hProcess);
+ delete pid;
+ pid = 0;
+ }
+ pid = new PROCESS_INFORMATION;
+ memset(pid, 0, sizeof(PROCESS_INFORMATION));
+
+ q->setProcessState(QProcess::Starting);
+
+ QString args = qt_create_commandline(QString(), arguments);
+ if (!nativeArguments.isEmpty()) {
+ if (!args.isEmpty())
+ args += QLatin1Char(' ');
+ args += nativeArguments;
+ }
+
+#if defined QPROCESS_DEBUG
+ qDebug("Creating process");
+ qDebug(" program : [%s]", program.toLatin1().constData());
+ qDebug(" args : %s", args.toLatin1().constData());
+ qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
+#endif
+
+ QString fullPathProgram = program;
+ if (!QDir::isAbsolutePath(fullPathProgram))
+ fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath();
+ fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
+ (wchar_t*)args.utf16(),
+ 0, 0, false, 0, 0, 0, 0, pid);
+
+ if (!success) {
+ cleanup();
+ processError = QProcess::FailedToStart;
+ emit q->error(processError);
+ q->setProcessState(QProcess::NotRunning);
+ return;
+ }
+
+ q->setProcessState(QProcess::Running);
+ // User can call kill()/terminate() from the stateChanged() slot
+ // so check before proceeding
+ if (!pid)
+ return;
+
+ if (threadData->eventDispatcher) {
+ processFinishedNotifier = new QWinEventNotifier(pid->hProcess, q);
+ QObject::connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied()));
+ processFinishedNotifier->setEnabled(true);
+ }
+
+ // give the process a chance to start ...
+ Sleep(SLEEPMIN * 2);
+ _q_startupNotification();
+}
+
+bool QProcessPrivate::processStarted()
+{
+ return processState == QProcess::Running;
+}
+
+qint64 QProcessPrivate::bytesAvailableFromStdout() const
+{
+ return 0;
+}
+
+qint64 QProcessPrivate::bytesAvailableFromStderr() const
+{
+ return 0;
+}
+
+qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen)
+{
+ return -1;
+}
+
+qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen)
+{
+ return -1;
+}
+
+static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId)
+{
+ DWORD currentProcId = 0;
+ GetWindowThreadProcessId(hwnd, &currentProcId);
+ if (currentProcId == (DWORD)procId)
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+
+ return TRUE;
+}
+
+void QProcessPrivate::terminateProcess()
+{
+ if (pid) {
+ EnumWindows(qt_terminateApp, (LPARAM)pid->dwProcessId);
+ PostThreadMessage(pid->dwThreadId, WM_CLOSE, 0, 0);
+ }
+}
+
+void QProcessPrivate::killProcess()
+{
+ if (pid)
+ TerminateProcess(pid->hProcess, 0xf291);
+}
+
+bool QProcessPrivate::waitForStarted(int)
+{
+ Q_Q(QProcess);
+
+ if (processStarted())
+ return true;
+
+ if (processError == QProcess::FailedToStart)
+ return false;
+
+ processError = QProcess::Timedout;
+ q->setErrorString(QProcess::tr("Process operation timed out"));
+ return false;
+}
+
+bool QProcessPrivate::waitForReadyRead(int msecs)
+{
+ return false;
+}
+
+bool QProcessPrivate::waitForBytesWritten(int msecs)
+{
+ return false;
+}
+
+bool QProcessPrivate::waitForFinished(int msecs)
+{
+ Q_Q(QProcess);
+#if defined QPROCESS_DEBUG
+ qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
+#endif
+
+ QIncrementalSleepTimer timer(msecs);
+
+ forever {
+ if (!pid)
+ return true;
+
+ if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) {
+ _q_processDied();
+ return true;
+ }
+
+ if (timer.hasTimedOut())
+ break;
+ }
+ processError = QProcess::Timedout;
+ q->setErrorString(QProcess::tr("Process operation timed out"));
+ return false;
+}
+
+void QProcessPrivate::findExitCode()
+{
+ DWORD theExitCode;
+ if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
+ exitCode = theExitCode;
+ //### for now we assume a crash if exit code is less than -1 or the magic number
+ crashed = (exitCode == 0xf291 || (int)exitCode < 0);
+ }
+}
+
+void QProcessPrivate::flushPipeWriter()
+{
+}
+
+qint64 QProcessPrivate::pipeWriterBytesToWrite() const
+{
+ return 0;
+}
+
+qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(maxlen);
+ return -1;
+}
+
+bool QProcessPrivate::waitForWrite(int msecs)
+{
+ Q_UNUSED(msecs);
+ return false;
+}
+
+void QProcessPrivate::_q_notified()
+{
+}
+
+bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid)
+{
+ Q_UNUSED(workingDir);
+ QString args = qt_create_commandline(QString(), arguments);
+
+ bool success = false;
+
+ PROCESS_INFORMATION pinfo;
+
+ QString fullPathProgram = program;
+ if (!QDir::isAbsolutePath(fullPathProgram))
+ fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/')));
+ fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
+ (wchar_t*)args.utf16(),
+ 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo);
+
+ if (success) {
+ CloseHandle(pinfo.hThread);
+ CloseHandle(pinfo.hProcess);
+ if (pid)
+ *pid = pinfo.dwProcessId;
+ }
+
+ return success;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 6ad15788b0..0ae3f9e647 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -1491,6 +1491,4 @@ bool QResourceFileEnginePrivate::unmap(uchar *ptr)
return true;
}
-Q_CORE_EXPORT void qInitResourceIO() { } // ### Qt 5: remove
-
QT_END_NAMESPACE
diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h
index 1edc7a4f13..452e141e41 100644
--- a/src/corelib/io/qresource.h
+++ b/src/corelib/io/qresource.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qresource_iterator.cpp b/src/corelib/io/qresource_iterator.cpp
index e19bad1e03..3317ef5fff 100644
--- a/src/corelib/io/qresource_iterator.cpp
+++ b/src/corelib/io/qresource_iterator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qresource_iterator_p.h b/src/corelib/io/qresource_iterator_p.h
index 519f46199c..3603c64819 100644
--- a/src/corelib/io/qresource_iterator_p.h
+++ b/src/corelib/io/qresource_iterator_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qresource_p.h b/src/corelib/io/qresource_p.h
index 4beda142ed..f558319dc2 100644
--- a/src/corelib/io/qresource_p.h
+++ b/src/corelib/io/qresource_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 37bd8c460d..81dc5bb078 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h
index b144a9af4c..65aeb89523 100644
--- a/src/corelib/io/qsettings.h
+++ b/src/corelib/io/qsettings.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 11e0c3c103..6bb815c561 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index 5d62c839a6..cf348122dc 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index bbc7dd1677..2cac379ec6 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 43ae5c07ab..5accb61cc5 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -83,6 +83,8 @@ QT_BEGIN_NAMESPACE
returned for GenericDataLocation.
\value CacheLocation Returns a directory location where user-specific
non-essential (cached) data should be written.
+ \value GenericCacheLocation Returns a directory location where user-specific
+ non-essential (cached) data, shared across applications, should be written.
\value GenericDataLocation Returns a directory location where persistent
data shared across applications can be stored.
\value RuntimeLocation Returns a directory location where runtime communication
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index d91da9de2f..bae7b3f7b5 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -73,7 +73,8 @@ public:
GenericDataLocation,
RuntimeLocation,
ConfigLocation,
- DownloadLocation
+ DownloadLocation,
+ GenericCacheLocation
};
static QString writableLocation(StandardLocation type);
diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp
index 84fc81494c..f37c21ed39 100644
--- a/src/corelib/io/qstandardpaths_mac.cpp
+++ b/src/corelib/io/qstandardpaths_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -82,6 +82,7 @@ OSType translateLocation(QStandardPaths::StandardLocation type)
case QStandardPaths::RuntimeLocation:
case QStandardPaths::DataLocation:
return kApplicationSupportFolderType;
+ case QStandardPaths::GenericCacheLocation:
case QStandardPaths::CacheLocation:
return kCachedDataFolderType;
default:
@@ -128,6 +129,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return QDir::tempPath();
case GenericDataLocation:
case DataLocation:
+ case GenericCacheLocation:
case CacheLocation:
case RuntimeLocation:
return macLocation(type, kUserDomain);
@@ -140,7 +142,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
- if (type == GenericDataLocation || type == DataLocation || type == CacheLocation) {
+ if (type == GenericDataLocation || type == DataLocation || type == GenericCacheLocation || type == CacheLocation) {
const QString path = macLocation(type, kOnAppropriateDisk);
if (!path.isEmpty())
dirs.append(path);
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index b1c5869f71..5aef52eaba 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -62,15 +62,18 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case TempLocation:
return QDir::tempPath();
case CacheLocation:
+ case GenericCacheLocation:
{
// http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME"));
if (xdgCacheHome.isEmpty())
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
- if (!QCoreApplication::organizationName().isEmpty())
- xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName();
- if (!QCoreApplication::applicationName().isEmpty())
- xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
+ if (type == QStandardPaths::CacheLocation) {
+ if (!QCoreApplication::organizationName().isEmpty())
+ xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName();
+ if (!QCoreApplication::applicationName().isEmpty())
+ xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
+ }
return xdgCacheHome;
}
case DataLocation:
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index e9093649f3..e3f86b7134 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -160,6 +160,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// cache directory located in their AppData directory
return writableLocation(DataLocation) + QLatin1String("\\cache");
+ case GenericCacheLocation:
+ return writableLocation(GenericDataLocation) + QLatin1String("\\cache");
+
case RuntimeLocation:
case HomeLocation:
result = QDir::homePath();
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index 78ec1774eb..15d3258a9a 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtemporarydir.h b/src/corelib/io/qtemporarydir.h
index da0d1214c4..22c0a271e4 100644
--- a/src/corelib/io/qtemporarydir.h
+++ b/src/corelib/io/qtemporarydir.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 677be45f65..eb645fabe8 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtemporaryfile.h b/src/corelib/io/qtemporaryfile.h
index 282b897813..20956d2cf0 100644
--- a/src/corelib/io/qtemporaryfile.h
+++ b/src/corelib/io/qtemporaryfile.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 177f73def3..8c7f57fddf 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index db038855a8..0531d4017d 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index 7d06ca4b17..2c725f17fd 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h
index 77c0a15823..0a94f3015b 100644
--- a/src/corelib/io/qtldurl_p.h
+++ b/src/corelib/io/qtldurl_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index c921a89b30..53b4df4729 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index e62cd0a85b..75a88e8048 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
new file mode 100644
index 0000000000..8da786ebd9
--- /dev/null
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -0,0 +1,315 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowspipereader_p.h"
+#include <qdebug.h>
+#include <qelapsedtimer.h>
+#include <qeventloop.h>
+#include <qtimer.h>
+#include <qwineventnotifier.h>
+
+QT_BEGIN_NAMESPACE
+
+QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
+ : QObject(parent),
+ handle(INVALID_HANDLE_VALUE),
+ readBufferMaxSize(0),
+ actualReadBufferSize(0),
+ emitReadyReadTimer(new QTimer(this)),
+ pipeBroken(false)
+{
+ emitReadyReadTimer->setSingleShot(true);
+ connect(emitReadyReadTimer, SIGNAL(timeout()), SIGNAL(readyRead()));
+
+ ZeroMemory(&overlapped, sizeof(overlapped));
+ overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ dataReadNotifier = new QWinEventNotifier(overlapped.hEvent, this);
+ connect(dataReadNotifier, SIGNAL(activated(HANDLE)), SLOT(readEventSignalled()));
+}
+
+QWindowsPipeReader::~QWindowsPipeReader()
+{
+ CloseHandle(overlapped.hEvent);
+}
+
+/*!
+ Sets the handle to read from. The handle must be valid.
+ */
+void QWindowsPipeReader::setHandle(HANDLE hPipeReadEnd)
+{
+ readBuffer.clear();
+ actualReadBufferSize = 0;
+ handle = hPipeReadEnd;
+ pipeBroken = false;
+ dataReadNotifier->setEnabled(true);
+}
+
+/*!
+ Stops the asynchronous read sequence.
+ This function assumes that the file already has been closed.
+ It does not cancel any I/O operation.
+ */
+void QWindowsPipeReader::stop()
+{
+ dataReadNotifier->setEnabled(false);
+ readSequenceStarted = false;
+ handle = INVALID_HANDLE_VALUE;
+ ResetEvent(overlapped.hEvent);
+}
+
+/*!
+ Returns the number of bytes we've read so far.
+ */
+qint64 QWindowsPipeReader::bytesAvailable() const
+{
+ return actualReadBufferSize;
+}
+
+/*!
+ Stops the asynchronous read sequence.
+ */
+qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
+{
+ if (pipeBroken && actualReadBufferSize == 0)
+ return -1; // signal EOF
+
+ qint64 readSoFar;
+ // If startAsyncRead() has read data, copy it to its destination.
+ if (maxlen == 1 && actualReadBufferSize > 0) {
+ *data = readBuffer.getChar();
+ actualReadBufferSize--;
+ readSoFar = 1;
+ } else {
+ qint64 bytesToRead = qMin(qint64(actualReadBufferSize), maxlen);
+ readSoFar = 0;
+ while (readSoFar < bytesToRead) {
+ const char *ptr = readBuffer.readPointer();
+ int bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
+ qint64(readBuffer.nextDataBlockSize()));
+ memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
+ readSoFar += bytesToReadFromThisBlock;
+ readBuffer.free(bytesToReadFromThisBlock);
+ actualReadBufferSize -= bytesToReadFromThisBlock;
+ }
+ }
+
+ if (!pipeBroken) {
+ if (!actualReadBufferSize)
+ emitReadyReadTimer->stop();
+ if (!readSequenceStarted)
+ startAsyncRead();
+ }
+
+ return readSoFar;
+}
+
+bool QWindowsPipeReader::canReadLine() const
+{
+ return readBuffer.indexOf('\n', actualReadBufferSize) >= 0;
+}
+
+/*!
+ \internal
+ Will be called whenever the read operation completes.
+ Returns true, if readyRead() has been emitted.
+ */
+bool QWindowsPipeReader::readEventSignalled()
+{
+ if (!completeAsyncRead()) {
+ pipeBroken = true;
+ emit pipeClosed();
+ return false;
+ }
+ startAsyncRead();
+ emitReadyReadTimer->stop();
+ emit readyRead();
+ return true;
+}
+
+/*!
+ \internal
+ Reads data from the socket into the readbuffer
+ */
+void QWindowsPipeReader::startAsyncRead()
+{
+ do {
+ DWORD bytesToRead = checkPipeState();
+ if (pipeBroken)
+ return;
+
+ if (bytesToRead == 0) {
+ // There are no bytes in the pipe but we need to
+ // start the overlapped read with some buffer size.
+ bytesToRead = initialReadBufferSize;
+ }
+
+ if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) {
+ bytesToRead = readBufferMaxSize - readBuffer.size();
+ if (bytesToRead == 0) {
+ // Buffer is full. User must read data from the buffer
+ // before we can read more from the pipe.
+ return;
+ }
+ }
+
+ char *ptr = readBuffer.reserve(bytesToRead);
+
+ readSequenceStarted = true;
+ if (ReadFile(handle, ptr, bytesToRead, NULL, &overlapped)) {
+ completeAsyncRead();
+ } else {
+ switch (GetLastError()) {
+ case ERROR_IO_PENDING:
+ // This is not an error. We're getting notified, when data arrives.
+ return;
+ case ERROR_MORE_DATA:
+ // This is not an error. The synchronous read succeeded.
+ // We're connected to a message mode pipe and the message
+ // didn't fit into the pipe's system buffer.
+ completeAsyncRead();
+ break;
+ case ERROR_PIPE_NOT_CONNECTED:
+ {
+ // It may happen, that the other side closes the connection directly
+ // after writing data. Then we must set the appropriate socket state.
+ pipeBroken = true;
+ emit pipeClosed();
+ return;
+ }
+ default:
+ emit winError(GetLastError(), QLatin1String("QWindowsPipeReader::startAsyncRead"));
+ return;
+ }
+ }
+ } while (!readSequenceStarted);
+}
+
+/*!
+ \internal
+ Sets the correct size of the read buffer after a read operation.
+ Returns false, if an error occurred or the connection dropped.
+ */
+bool QWindowsPipeReader::completeAsyncRead()
+{
+ ResetEvent(overlapped.hEvent);
+ readSequenceStarted = false;
+
+ DWORD bytesRead;
+ if (!GetOverlappedResult(handle, &overlapped, &bytesRead, TRUE)) {
+ switch (GetLastError()) {
+ case ERROR_MORE_DATA:
+ // This is not an error. We're connected to a message mode
+ // pipe and the message didn't fit into the pipe's system
+ // buffer. We will read the remaining data in the next call.
+ break;
+ case ERROR_BROKEN_PIPE:
+ case ERROR_PIPE_NOT_CONNECTED:
+ return false;
+ default:
+ emit winError(GetLastError(), QLatin1String("QWindowsPipeReader::completeAsyncRead"));
+ return false;
+ }
+ }
+
+ actualReadBufferSize += bytesRead;
+ readBuffer.truncate(actualReadBufferSize);
+ if (!emitReadyReadTimer->isActive())
+ emitReadyReadTimer->start();
+ return true;
+}
+
+/*!
+ \internal
+ Returns the number of available bytes in the pipe.
+ Sets QWindowsPipeReader::pipeBroken to true if the connection is broken.
+ */
+DWORD QWindowsPipeReader::checkPipeState()
+{
+ DWORD bytes;
+ if (PeekNamedPipe(handle, NULL, 0, NULL, &bytes, NULL)) {
+ return bytes;
+ } else {
+ if (!pipeBroken) {
+ pipeBroken = true;
+ emit pipeClosed();
+ }
+ }
+ return 0;
+}
+
+/*!
+ Waits for the completion of the asynchronous read operation.
+ Returns true, if we've emitted the readyRead signal.
+ */
+bool QWindowsPipeReader::waitForReadyRead(int msecs)
+{
+ Q_ASSERT(readSequenceStarted);
+ DWORD result = WaitForSingleObject(overlapped.hEvent, msecs == -1 ? INFINITE : msecs);
+ switch (result) {
+ case WAIT_OBJECT_0:
+ return readEventSignalled();
+ case WAIT_TIMEOUT:
+ return false;
+ }
+
+ qWarning("QWindowsPipeReader::waitForReadyRead WaitForSingleObject failed with error code %d.", int(GetLastError()));
+ return false;
+}
+
+/*!
+ Waits until the pipe is closed.
+ */
+bool QWindowsPipeReader::waitForPipeClosed(int msecs)
+{
+ const int sleepTime = 10;
+ QElapsedTimer stopWatch;
+ stopWatch.start();
+ forever {
+ checkPipeState();
+ if (pipeBroken)
+ return true;
+ if (stopWatch.hasExpired(msecs - sleepTime))
+ return false;
+ Sleep(sleepTime);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qwindowspipereader_p.h
index 0b317a062f..e78d6b29ad 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian_p.h
+++ b/src/corelib/io/qwindowspipereader_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFILESYSTEMWATCHER_SYMBIAN_P_H
-#define QFILESYSTEMWATCHER_SYMBIAN_P_H
+#ifndef QWINDOWSPIPEREADER_P_H
+#define QWINDOWSPIPEREADER_P_H
//
// W A R N I N G
@@ -53,78 +53,70 @@
// We mean it.
//
-#include "qfilesystemwatcher_p.h"
+#include <qbytearray.h>
+#include <qobject.h>
+#include <qtimer.h>
+#include <qt_windows.h>
-#ifndef QT_NO_FILESYSTEMWATCHER
+#include <private/qringbuffer_p.h>
-#include "qhash.h"
-#include "qmutex.h"
-#include "qwaitcondition.h"
-
-#include <e32base.h>
-#include <f32file.h>
+QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QSymbianFileSystemWatcherEngine;
-
-class QNotifyChangeEvent : public CActive
-{
-public:
- QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherEngine *engine,
- bool aIsDir, TInt aPriority = EPriorityStandard);
- ~QNotifyChangeEvent();
-
- bool isDir;
+QT_MODULE(Core)
-private:
- void RunL();
- void DoCancel();
-
- RFs &fsSession;
- TPath watchedPath;
- QSymbianFileSystemWatcherEngine *engine;
-
- int failureCount;
-};
+class QWinEventNotifier;
-class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine
+class Q_CORE_EXPORT QWindowsPipeReader : public QObject
{
Q_OBJECT
-
public:
- QSymbianFileSystemWatcherEngine();
- ~QSymbianFileSystemWatcherEngine();
-
- QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
- QStringList removePaths(const QStringList &paths, QStringList *files,
- QStringList *directories);
+ explicit QWindowsPipeReader(QObject *parent = 0);
+ ~QWindowsPipeReader();
+ void setHandle(HANDLE hPipeReadEnd);
void stop();
-protected:
- void run();
+ void setMaxReadBufferSize(qint64 size) { readBufferMaxSize = size; }
+ qint64 maxReadBufferSize() const { return readBufferMaxSize; }
-public Q_SLOTS:
- void addNativeListener(const QString &directoryPath);
- void removeNativeListener();
+ bool isPipeClosed() const { return pipeBroken; }
+ qint64 bytesAvailable() const;
+ qint64 read(char *data, qint64 maxlen);
+ bool canReadLine() const;
+ bool waitForReadyRead(int msecs);
+ bool waitForPipeClosed(int msecs);
-private:
- friend class QNotifyChangeEvent;
- void emitPathChanged(QNotifyChangeEvent *e);
+ void startAsyncRead();
+ bool completeAsyncRead();
- void startWatcher();
+Q_SIGNALS:
+ void winError(ulong, const QString &);
+ void readyRead();
+ void pipeClosed();
- QHash<QNotifyChangeEvent*, QString> activeObjectToPath;
- QMutex mutex;
- QWaitCondition syncCondition;
- bool watcherStarted;
- QNotifyChangeEvent *currentAddEvent;
- QNotifyChangeEvent *currentRemoveEvent;
-};
+private Q_SLOTS:
+ bool readEventSignalled();
-#endif // QT_NO_FILESYSTEMWATCHER
+private:
+ DWORD checkPipeState();
+
+private:
+ HANDLE handle;
+ OVERLAPPED overlapped;
+ QWinEventNotifier *dataReadNotifier;
+ qint64 readBufferMaxSize;
+ QRingBuffer readBuffer;
+ int actualReadBufferSize;
+ bool readSequenceStarted;
+ QTimer *emitReadyReadTimer;
+ bool pipeBroken;
+ static const qint64 initialReadBufferSize = 4096;
+};
QT_END_NAMESPACE
-#endif // QFILESYSTEMWATCHER_WIN_P_H
+QT_END_HEADER
+
+#endif // QWINDOWSPIPEREADER_P_H
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index cb802f1d91..a1765b4178 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index dfcb77e17c..44a1d04b4e 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/itemmodels/itemmodels.pri b/src/corelib/itemmodels/itemmodels.pri
new file mode 100644
index 0000000000..83ec4c5dbf
--- /dev/null
+++ b/src/corelib/itemmodels/itemmodels.pri
@@ -0,0 +1,20 @@
+# Qt itemmodels core module
+
+HEADERS += \
+ itemmodels/qabstractitemmodel.h \
+ itemmodels/qabstractitemmodel_p.h \
+ itemmodels/qabstractproxymodel.h \
+ itemmodels/qabstractproxymodel_p.h \
+ itemmodels/qitemselectionmodel.h \
+ itemmodels/qitemselectionmodel_p.h \
+ itemmodels/qidentityproxymodel.h \
+ itemmodels/qsortfilterproxymodel.h \
+ itemmodels/qstringlistmodel.h
+
+SOURCES += \
+ itemmodels/qabstractitemmodel.cpp \
+ itemmodels/qabstractproxymodel.cpp \
+ itemmodels/qitemselectionmodel.cpp \
+ itemmodels/qidentityproxymodel.cpp \
+ itemmodels/qsortfilterproxymodel.cpp \
+ itemmodels/qstringlistmodel.cpp
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 99455371ae..dec1fe4cef 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -1759,18 +1759,19 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const
Returns true if the data and action can be handled by the model; otherwise
returns false.
- Although the specified \a row, \a column and \a parent indicate the
- location of an item in the model where the operation ended, it is the
- responsibility of the view to provide a suitable location for where the
- data should be inserted.
+ The specified \a row, \a column and \a parent indicate the location of an
+ item in the model where the operation ended. It is the responsibility of
+ the model to complete the action at the correct location.
For instance, a drop action on an item in a QTreeView can result in new
items either being inserted as children of the item specified by \a row,
\a column, and \a parent, or as siblings of the item.
- When row and column are -1 it means that it is up to the model to decide
- where to place the data. This can occur in a tree when data is dropped on
- a parent. Models will usually append the data to the parent in this case.
+ When \a row and \a column are -1 it means that the dropped data should be
+ considered as dropped directly on \a parent. Usually this will mean
+ appending the data as child items of \a parent. If \a row and column are
+ greater than or equal zero, it means that the drop occurred just before the
+ specified \a row and \a column in the specified \a parent.
\sa supportedDropActions(), {Using drag and drop with item views}
*/
@@ -1830,7 +1831,6 @@ Qt::DropActions QAbstractItemModel::supportedDropActions() const
*/
Qt::DropActions QAbstractItemModel::supportedDragActions() const
{
- // ### Qt 5: make this virtual or these properties
Q_D(const QAbstractItemModel);
if (d->supportedDragActions != -1)
return d->supportedDragActions;
@@ -1838,17 +1838,22 @@ Qt::DropActions QAbstractItemModel::supportedDragActions() const
}
/*!
+ \internal
+ */
+void QAbstractItemModel::doSetSupportedDragActions(Qt::DropActions actions)
+{
+ Q_D(QAbstractItemModel);
+ d->supportedDragActions = actions;
+}
+
+/*!
\since 4.2
+ \obsolete
Sets the supported drag \a actions for the items in the model.
\sa supportedDragActions(), {Using drag and drop with item views}
*/
-void QAbstractItemModel::setSupportedDragActions(Qt::DropActions actions)
-{
- Q_D(QAbstractItemModel);
- d->supportedDragActions = actions;
-}
/*!
\note The base class implementation of this function does nothing and
@@ -2131,6 +2136,7 @@ QSize QAbstractItemModel::span(const QModelIndex &) const
/*!
\since 4.6
+ \obsolete
Sets the model's role names to \a roleNames.
@@ -2141,7 +2147,11 @@ QSize QAbstractItemModel::span(const QModelIndex &) const
\sa roleNames()
*/
-void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
+
+/*!
+ \internal
+ */
+void QAbstractItemModel::doSetRoleNames(const QHash<int,QByteArray> &roleNames)
{
Q_D(QAbstractItemModel);
d->roleNames = roleNames;
@@ -2154,7 +2164,7 @@ void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
\sa setRoleNames()
*/
-const QHash<int,QByteArray> &QAbstractItemModel::roleNames() const
+QHash<int,QByteArray> QAbstractItemModel::roleNames() const
{
Q_D(const QAbstractItemModel);
return d->roleNames;
diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 0aa8144602..46dd7880ce 100644
--- a/src/corelib/kernel/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -198,8 +198,13 @@ public:
int row, int column, const QModelIndex &parent);
virtual Qt::DropActions supportedDropActions() const;
- Qt::DropActions supportedDragActions() const;
- void setSupportedDragActions(Qt::DropActions);
+ virtual Qt::DropActions supportedDragActions() const;
+#if QT_DEPRECATED_SINCE(5, 0)
+ void setSupportedDragActions(Qt::DropActions actions)
+ {
+ doSetSupportedDragActions(actions);
+ }
+#endif
virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
@@ -222,7 +227,7 @@ public:
Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
virtual QSize span(const QModelIndex &index) const;
- const QHash<int,QByteArray> &roleNames() const;
+ virtual QHash<int,QByteArray> roleNames() const;
#ifdef Q_NO_USING_KEYWORD
inline QObject *parent() const { return QObject::parent(); }
@@ -302,9 +307,17 @@ protected:
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
QModelIndexList persistentIndexList() const;
- void setRoleNames(const QHash<int,QByteArray> &roleNames);
+#if QT_DEPRECATED_SINCE(5,0)
+ QT_DEPRECATED void setRoleNames(const QHash<int,QByteArray> &theRoleNames)
+ {
+ doSetRoleNames(theRoleNames);
+ }
+#endif
private:
+ void doSetRoleNames(const QHash<int,QByteArray> &roleNames);
+ void doSetSupportedDragActions(Qt::DropActions actions);
+
Q_DECLARE_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
};
diff --git a/src/corelib/kernel/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h
index 86680dd0bc..3c5d8e5d20 100644
--- a/src/corelib/kernel/qabstractitemmodel_p.h
+++ b/src/corelib/itemmodels/qabstractitemmodel_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
new file mode 100644
index 0000000000..46678403db
--- /dev/null
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -0,0 +1,388 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractproxymodel.h"
+
+#ifndef QT_NO_PROXYMODEL
+
+#include "qitemselectionmodel.h"
+#include <private/qabstractproxymodel_p.h>
+#include <QtCore/QSize>
+#include <QtCore/QStringList>
+
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 4.1
+ \class QAbstractProxyModel
+ \brief The QAbstractProxyModel class provides a base class for proxy item
+ models that can do sorting, filtering or other data processing tasks.
+ \ingroup model-view
+ \inmodule QtCore
+
+ This class defines the standard interface that proxy models must use to be
+ able to interoperate correctly with other model/view components. It is not
+ supposed to be instantiated directly.
+
+ All standard proxy models are derived from the QAbstractProxyModel class.
+ If you need to create a new proxy model class, it is usually better to
+ subclass an existing class that provides the closest behavior to the one
+ you want to provide.
+
+ Proxy models that filter or sort items of data from a source model should
+ be created by using or subclassing QSortFilterProxyModel.
+
+ To subclass QAbstractProxyModel, you need to implement mapFromSource() and
+ mapToSource(). The mapSelectionFromSource() and mapSelectionToSource()
+ functions only need to be reimplemented if you need a behavior different
+ from the default behavior.
+
+ \note If the source model is deleted or no source model is specified, the
+ proxy model operates on a empty placeholder model.
+
+ \sa QSortFilterProxyModel, QAbstractItemModel, {Model/View Programming}
+*/
+
+//detects the deletion of the source model
+void QAbstractProxyModelPrivate::_q_sourceModelDestroyed()
+{
+ model = QAbstractItemModelPrivate::staticEmptyModel();
+}
+
+/*!
+ Constructs a proxy model with the given \a parent.
+*/
+
+QAbstractProxyModel::QAbstractProxyModel(QObject *parent)
+ :QAbstractItemModel(*new QAbstractProxyModelPrivate, parent)
+{
+ setSourceModel(QAbstractItemModelPrivate::staticEmptyModel());
+}
+
+/*!
+ \internal
+*/
+
+QAbstractProxyModel::QAbstractProxyModel(QAbstractProxyModelPrivate &dd, QObject *parent)
+ : QAbstractItemModel(dd, parent)
+{
+ setSourceModel(QAbstractItemModelPrivate::staticEmptyModel());
+}
+
+/*!
+ Destroys the proxy model.
+*/
+QAbstractProxyModel::~QAbstractProxyModel()
+{
+
+}
+
+/*!
+ Sets the given \a sourceModel to be processed by the proxy model.
+*/
+void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
+{
+ Q_D(QAbstractProxyModel);
+ if (d->model)
+ disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
+
+ if (sourceModel) {
+ d->model = sourceModel;
+ connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
+ } else {
+ d->model = QAbstractItemModelPrivate::staticEmptyModel();
+ }
+ d->roleNames = d->model->roleNames();
+}
+
+/*!
+ Returns the model that contains the data that is available through the proxy model.
+*/
+QAbstractItemModel *QAbstractProxyModel::sourceModel() const
+{
+ Q_D(const QAbstractProxyModel);
+ if (d->model == QAbstractItemModelPrivate::staticEmptyModel())
+ return 0;
+ return d->model;
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::submit()
+{
+ Q_D(QAbstractProxyModel);
+ return d->model->submit();
+}
+
+/*!
+ \reimp
+ */
+void QAbstractProxyModel::revert()
+{
+ Q_D(QAbstractProxyModel);
+ d->model->revert();
+}
+
+
+/*!
+ \fn QModelIndex QAbstractProxyModel::mapToSource(const QModelIndex &proxyIndex) const
+
+ Reimplement this function to return the model index in the source model that
+ corresponds to the \a proxyIndex in the proxy model.
+
+ \sa mapFromSource()
+*/
+
+/*!
+ \fn QModelIndex QAbstractProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
+
+ Reimplement this function to return the model index in the proxy model that
+ corresponds to the \a sourceIndex from the source model.
+
+ \sa mapToSource()
+*/
+
+/*!
+ Returns a source selection mapped from the specified \a proxySelection.
+
+ Reimplement this method to map proxy selections to source selections.
+ */
+QItemSelection QAbstractProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const
+{
+ QModelIndexList proxyIndexes = proxySelection.indexes();
+ QItemSelection sourceSelection;
+ for (int i = 0; i < proxyIndexes.size(); ++i) {
+ const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i));
+ if (!proxyIdx.isValid())
+ continue;
+ sourceSelection << QItemSelectionRange(proxyIdx);
+ }
+ return sourceSelection;
+}
+
+/*!
+ Returns a proxy selection mapped from the specified \a sourceSelection.
+
+ Reimplement this method to map source selections to proxy selections.
+*/
+QItemSelection QAbstractProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const
+{
+ QModelIndexList sourceIndexes = sourceSelection.indexes();
+ QItemSelection proxySelection;
+ for (int i = 0; i < sourceIndexes.size(); ++i) {
+ const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i));
+ if (!srcIdx.isValid())
+ continue;
+ proxySelection << QItemSelectionRange(srcIdx);
+ }
+ return proxySelection;
+}
+
+/*!
+ \reimp
+ */
+QVariant QAbstractProxyModel::data(const QModelIndex &proxyIndex, int role) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->data(mapToSource(proxyIndex), role);
+}
+
+/*!
+ \reimp
+ */
+QVariant QAbstractProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_D(const QAbstractProxyModel);
+ int sourceSection;
+ if (orientation == Qt::Horizontal) {
+ const QModelIndex proxyIndex = index(0, section);
+ sourceSection = mapToSource(proxyIndex).column();
+ } else {
+ const QModelIndex proxyIndex = index(section, 0);
+ sourceSection = mapToSource(proxyIndex).row();
+ }
+ return d->model->headerData(sourceSection, orientation, role);
+}
+
+/*!
+ \reimp
+ */
+QMap<int, QVariant> QAbstractProxyModel::itemData(const QModelIndex &proxyIndex) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->itemData(mapToSource(proxyIndex));
+}
+
+/*!
+ \reimp
+ */
+Qt::ItemFlags QAbstractProxyModel::flags(const QModelIndex &index) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->flags(mapToSource(index));
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_D(QAbstractProxyModel);
+ return d->model->setData(mapToSource(index), value, role);
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap< int, QVariant >& roles)
+{
+ Q_D(QAbstractProxyModel);
+ return d->model->setItemData(mapToSource(index), roles);
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
+{
+ Q_D(QAbstractProxyModel);
+ int sourceSection;
+ if (orientation == Qt::Horizontal) {
+ const QModelIndex proxyIndex = index(0, section);
+ sourceSection = mapToSource(proxyIndex).column();
+ } else {
+ const QModelIndex proxyIndex = index(section, 0);
+ sourceSection = mapToSource(proxyIndex).row();
+ }
+ return d->model->setHeaderData(sourceSection, orientation, value, role);
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const
+{
+ Q_D(const QAbstractProxyModel);
+ return mapFromSource(d->model->buddy(mapToSource(index)));
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->canFetchMore(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QAbstractProxyModel::fetchMore(const QModelIndex &parent)
+{
+ Q_D(QAbstractProxyModel);
+ d->model->fetchMore(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QAbstractProxyModel::sort(int column, Qt::SortOrder order)
+{
+ Q_D(QAbstractProxyModel);
+ d->model->sort(column, order);
+}
+
+/*!
+ \reimp
+ */
+QSize QAbstractProxyModel::span(const QModelIndex &index) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->span(mapToSource(index));
+}
+
+/*!
+ \reimp
+ */
+bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->hasChildren(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
+{
+ Q_D(const QAbstractProxyModel);
+ QModelIndexList list;
+ foreach(const QModelIndex &index, indexes)
+ list << mapToSource(index);
+ return d->model->mimeData(list);
+}
+
+/*!
+ \reimp
+ */
+QStringList QAbstractProxyModel::mimeTypes() const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->mimeTypes();
+}
+
+/*!
+ \reimp
+ */
+Qt::DropActions QAbstractProxyModel::supportedDropActions() const
+{
+ Q_D(const QAbstractProxyModel);
+ return d->model->supportedDropActions();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qabstractproxymodel.cpp"
+
+#endif // QT_NO_PROXYMODEL
diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h
new file mode 100644
index 0000000000..000fc8d0ce
--- /dev/null
+++ b/src/corelib/itemmodels/qabstractproxymodel.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTPROXYMODEL_H
+#define QABSTRACTPROXYMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+#ifndef QT_NO_PROXYMODEL
+
+class QAbstractProxyModelPrivate;
+class QItemSelection;
+
+class Q_CORE_EXPORT QAbstractProxyModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ QAbstractProxyModel(QObject *parent = 0);
+ ~QAbstractProxyModel();
+
+ virtual void setSourceModel(QAbstractItemModel *sourceModel);
+ QAbstractItemModel *sourceModel() const;
+
+ virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const = 0;
+ virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const = 0;
+
+ virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const;
+ virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const;
+
+ bool submit();
+ void revert();
+
+ QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ QMap<int, QVariant> itemData(const QModelIndex &index) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+ bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles);
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);
+
+ QModelIndex buddy(const QModelIndex &index) const;
+ bool canFetchMore(const QModelIndex &parent) const;
+ void fetchMore(const QModelIndex &parent);
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+ QSize span(const QModelIndex &index) const;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ QMimeData* mimeData(const QModelIndexList &indexes) const;
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+
+protected:
+ QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent);
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractProxyModel)
+ Q_DISABLE_COPY(QAbstractProxyModel)
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceModelDestroyed())
+};
+
+#endif // QT_NO_PROXYMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTPROXYMODEL_H
diff --git a/src/corelib/itemmodels/qabstractproxymodel_p.h b/src/corelib/itemmodels/qabstractproxymodel_p.h
new file mode 100644
index 0000000000..7d6e49a235
--- /dev/null
+++ b/src/corelib/itemmodels/qabstractproxymodel_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTPROXYMODEL_P_H
+#define QABSTRACTPROXYMODEL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of QAbstractItemModel*. This header file may change from version
+// to version without notice, or even be removed.
+//
+// We mean it.
+//
+//
+
+#include "private/qabstractitemmodel_p.h"
+
+#ifndef QT_NO_PROXYMODEL
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QAbstractProxyModelPrivate : public QAbstractItemModelPrivate
+{
+ Q_DECLARE_PUBLIC(QAbstractProxyModel)
+public:
+ QAbstractProxyModelPrivate() : QAbstractItemModelPrivate(), model(0) {}
+ QAbstractItemModel *model;
+ virtual void _q_sourceModelDestroyed();
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PROXYMODEL
+
+#endif // QABSTRACTPROXYMODEL_P_H
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp
new file mode 100644
index 0000000000..6edb5df0fb
--- /dev/null
+++ b/src/corelib/itemmodels/qidentityproxymodel.cpp
@@ -0,0 +1,578 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qidentityproxymodel.h"
+
+#ifndef QT_NO_IDENTITYPROXYMODEL
+
+#include "qitemselectionmodel.h"
+#include <private/qabstractproxymodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QIdentityProxyModelPrivate : public QAbstractProxyModelPrivate
+{
+ QIdentityProxyModelPrivate()
+ {
+
+ }
+
+ Q_DECLARE_PUBLIC(QIdentityProxyModel)
+
+ QList<QPersistentModelIndex> layoutChangePersistentIndexes;
+ QModelIndexList proxyIndexes;
+
+ void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+ void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+
+ void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsInserted(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end);
+ void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+ void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest);
+
+ void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last);
+
+ void _q_sourceLayoutAboutToBeChanged();
+ void _q_sourceLayoutChanged();
+ void _q_sourceModelAboutToBeReset();
+ void _q_sourceModelReset();
+
+};
+
+/*!
+ \since 4.8
+ \class QIdentityProxyModel
+ \brief The QIdentityProxyModel class proxies its source model unmodified
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation.
+ This is similar in concept to an identity matrix where A.I = A.
+
+ Because it does no sorting or filtering, this class is most suitable to proxy models which transform the data() of the source model.
+ For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the
+ need to implement all data handling in the same class that creates the structure of the model, and can also be used to create
+ re-usable components.
+
+ This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified.
+
+ \snippet doc/src/snippets/code/src_gui_itemviews_qidentityproxymodel.cpp 0
+
+ \sa QAbstractProxyModel, {Model/View Programming}, QAbstractItemModel
+
+*/
+
+/*!
+ Constructs an identity model with the given \a parent.
+*/
+QIdentityProxyModel::QIdentityProxyModel(QObject* parent)
+ : QAbstractProxyModel(*new QIdentityProxyModelPrivate, parent)
+{
+
+}
+
+/*! \internal
+ */
+QIdentityProxyModel::QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent)
+ : QAbstractProxyModel(dd, parent)
+{
+
+}
+
+/*!
+ Destroys this identity model.
+*/
+QIdentityProxyModel::~QIdentityProxyModel()
+{
+}
+
+/*!
+ \reimp
+ */
+int QIdentityProxyModel::columnCount(const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ return d->model->columnCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->dropMimeData(data, action, row, column, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+ const QModelIndex sourceParent = mapToSource(parent);
+ const QModelIndex sourceIndex = d->model->index(row, column, sourceParent);
+ Q_ASSERT(sourceIndex.isValid());
+ return mapFromSource(sourceIndex);
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->insertColumns(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->insertRows(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex& sourceIndex) const
+{
+ Q_D(const QIdentityProxyModel);
+ if (!d->model || !sourceIndex.isValid())
+ return QModelIndex();
+
+ Q_ASSERT(sourceIndex.model() == d->model);
+ return createIndex(sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
+}
+
+/*!
+ \reimp
+ */
+QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection& selection) const
+{
+ Q_D(const QIdentityProxyModel);
+ QItemSelection proxySelection;
+
+ if (!d->model)
+ return proxySelection;
+
+ QItemSelection::const_iterator it = selection.constBegin();
+ const QItemSelection::const_iterator end = selection.constEnd();
+ for ( ; it != end; ++it) {
+ Q_ASSERT(it->model() == d->model);
+ const QItemSelectionRange range(mapFromSource(it->topLeft()), mapFromSource(it->bottomRight()));
+ proxySelection.append(range);
+ }
+
+ return proxySelection;
+}
+
+/*!
+ \reimp
+ */
+QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection& selection) const
+{
+ Q_D(const QIdentityProxyModel);
+ QItemSelection sourceSelection;
+
+ if (!d->model)
+ return sourceSelection;
+
+ QItemSelection::const_iterator it = selection.constBegin();
+ const QItemSelection::const_iterator end = selection.constEnd();
+ for ( ; it != end; ++it) {
+ Q_ASSERT(it->model() == this);
+ const QItemSelectionRange range(mapToSource(it->topLeft()), mapToSource(it->bottomRight()));
+ sourceSelection.append(range);
+ }
+
+ return sourceSelection;
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex& proxyIndex) const
+{
+ Q_D(const QIdentityProxyModel);
+ if (!d->model || !proxyIndex.isValid())
+ return QModelIndex();
+ Q_ASSERT(proxyIndex.model() == this);
+ return d->model->createIndex(proxyIndex.row(), proxyIndex.column(), proxyIndex.internalPointer());
+}
+
+/*!
+ \reimp
+ */
+QModelIndexList QIdentityProxyModel::match(const QModelIndex& start, int role, const QVariant& value, int hits, Qt::MatchFlags flags) const
+{
+ Q_D(const QIdentityProxyModel);
+ Q_ASSERT(start.isValid() ? start.model() == this : true);
+ if (!d->model)
+ return QModelIndexList();
+
+ const QModelIndexList sourceList = d->model->match(mapToSource(start), role, value, hits, flags);
+ QModelIndexList::const_iterator it = sourceList.constBegin();
+ const QModelIndexList::const_iterator end = sourceList.constEnd();
+ QModelIndexList proxyList;
+ for ( ; it != end; ++it)
+ proxyList.append(mapFromSource(*it));
+ return proxyList;
+}
+
+/*!
+ \reimp
+ */
+QModelIndex QIdentityProxyModel::parent(const QModelIndex& child) const
+{
+ Q_ASSERT(child.isValid() ? child.model() == this : true);
+ const QModelIndex sourceIndex = mapToSource(child);
+ const QModelIndex sourceParent = sourceIndex.parent();
+ return mapFromSource(sourceParent);
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->removeColumns(column, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& parent)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(QIdentityProxyModel);
+ return d->model->removeRows(row, count, mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+int QIdentityProxyModel::rowCount(const QModelIndex& parent) const
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == this : true);
+ Q_D(const QIdentityProxyModel);
+ return d->model->rowCount(mapToSource(parent));
+}
+
+/*!
+ \reimp
+ */
+void QIdentityProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
+{
+ beginResetModel();
+
+ if (sourceModel) {
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
+ this, SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int)));
+ disconnect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ this, SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ disconnect(sourceModel, SIGNAL(modelAboutToBeReset()),
+ this, SLOT(_q_sourceModelAboutToBeReset()));
+ disconnect(sourceModel, SIGNAL(modelReset()),
+ this, SLOT(_q_sourceModelReset()));
+ disconnect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+ disconnect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+ disconnect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+ this, SLOT(_q_sourceLayoutAboutToBeChanged()));
+ disconnect(sourceModel, SIGNAL(layoutChanged()),
+ this, SLOT(_q_sourceLayoutChanged()));
+ }
+
+ QAbstractProxyModel::setSourceModel(sourceModel);
+
+ if (sourceModel) {
+ connect(sourceModel, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsAboutToBeInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceRowsRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsAboutToBeInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsInserted(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsAboutToBeRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
+ SLOT(_q_sourceColumnsRemoved(const QModelIndex &, int, int)));
+ connect(sourceModel, SIGNAL(columnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceColumnsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)),
+ SLOT(_q_sourceColumnsMoved(const QModelIndex &, int, int, const QModelIndex &, int)));
+ connect(sourceModel, SIGNAL(modelAboutToBeReset()),
+ SLOT(_q_sourceModelAboutToBeReset()));
+ connect(sourceModel, SIGNAL(modelReset()),
+ SLOT(_q_sourceModelReset()));
+ connect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
+ SLOT(_q_sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+ connect(sourceModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+ connect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+ SLOT(_q_sourceLayoutAboutToBeChanged()));
+ connect(sourceModel, SIGNAL(layoutChanged()),
+ SLOT(_q_sourceLayoutChanged()));
+ }
+
+ endResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginInsertColumns(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginRemoveColumns(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endInsertColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(sourceParent)
+ Q_UNUSED(sourceStart)
+ Q_UNUSED(sourceEnd)
+ Q_UNUSED(destParent)
+ Q_UNUSED(dest)
+ q->endMoveColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endRemoveColumns();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ Q_ASSERT(topLeft.isValid() ? topLeft.model() == model : true);
+ Q_ASSERT(bottomRight.isValid() ? bottomRight.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight));
+}
+
+void QIdentityProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last)
+{
+ Q_Q(QIdentityProxyModel);
+ q->headerDataChanged(orientation, first, last);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
+{
+ Q_Q(QIdentityProxyModel);
+
+ foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
+ proxyIndexes << proxyPersistentIndex;
+ Q_ASSERT(proxyPersistentIndex.isValid());
+ const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
+ Q_ASSERT(srcPersistentIndex.isValid());
+ layoutChangePersistentIndexes << srcPersistentIndex;
+ }
+
+ q->layoutAboutToBeChanged();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceLayoutChanged()
+{
+ Q_Q(QIdentityProxyModel);
+
+ for (int i = 0; i < proxyIndexes.size(); ++i) {
+ q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i)));
+ }
+
+ layoutChangePersistentIndexes.clear();
+ proxyIndexes.clear();
+
+ q->layoutChanged();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceModelAboutToBeReset()
+{
+ Q_Q(QIdentityProxyModel);
+ q->beginResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceModelReset()
+{
+ Q_Q(QIdentityProxyModel);
+ q->endResetModel();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginInsertRows(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ q->beginRemoveRows(q->mapFromSource(parent), start, end);
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endInsertRows();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
+{
+ Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == model : true);
+ Q_ASSERT(destParent.isValid() ? destParent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(sourceParent)
+ Q_UNUSED(sourceStart)
+ Q_UNUSED(sourceEnd)
+ Q_UNUSED(destParent)
+ Q_UNUSED(dest)
+ q->endMoveRows();
+}
+
+void QIdentityProxyModelPrivate::_q_sourceRowsRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_ASSERT(parent.isValid() ? parent.model() == model : true);
+ Q_Q(QIdentityProxyModel);
+ Q_UNUSED(parent)
+ Q_UNUSED(start)
+ Q_UNUSED(end)
+ q->endRemoveRows();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qidentityproxymodel.cpp"
+
+#endif // QT_NO_IDENTITYPROXYMODEL
diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h
new file mode 100644
index 0000000000..9d3c085829
--- /dev/null
+++ b/src/corelib/itemmodels/qidentityproxymodel.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QIDENTITYPROXYMODEL_H
+#define QIDENTITYPROXYMODEL_H
+
+#include <QtCore/qabstractproxymodel.h>
+
+#ifndef QT_NO_IDENTITYPROXYMODEL
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+class QIdentityProxyModelPrivate;
+
+class Q_CORE_EXPORT QIdentityProxyModel : public QAbstractProxyModel
+{
+ Q_OBJECT
+public:
+ explicit QIdentityProxyModel(QObject* parent = 0);
+ ~QIdentityProxyModel();
+
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
+ QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
+ QModelIndex parent(const QModelIndex& child) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
+
+ QItemSelection mapSelectionFromSource(const QItemSelection& selection) const;
+ QItemSelection mapSelectionToSource(const QItemSelection& selection) const;
+ QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+ void setSourceModel(QAbstractItemModel* sourceModel);
+
+ bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
+ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
+ bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
+
+protected:
+ QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent);
+
+private:
+ Q_DECLARE_PRIVATE(QIdentityProxyModel)
+ Q_DISABLE_COPY(QIdentityProxyModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex,QModelIndex))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_IDENTITYPROXYMODEL
+
+#endif // QIDENTITYPROXYMODEL_H
+
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
new file mode 100644
index 0000000000..3321735498
--- /dev/null
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -0,0 +1,1641 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qitemselectionmodel.h"
+#include <private/qitemselectionmodel_p.h>
+#include <qdebug.h>
+
+#ifndef QT_NO_ITEMVIEWS
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QItemSelectionRange
+
+ \brief The QItemSelectionRange class manages information about a
+ range of selected items in a model.
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ A QItemSelectionRange contains information about a range of
+ selected items in a model. A range of items is a contiguous array
+ of model items, extending to cover a number of adjacent rows and
+ columns with a common parent item; this can be visualized as a
+ two-dimensional block of cells in a table. A selection range has a
+ top(), left() a bottom(), right() and a parent().
+
+ The QItemSelectionRange class is one of the \l{Model/View Classes}
+ and is part of Qt's \l{Model/View Programming}{model/view framework}.
+
+ The model items contained in the selection range can be obtained
+ using the indexes() function. Use QItemSelectionModel::selectedIndexes()
+ to get a list of all selected items for a view.
+
+ You can determine whether a given model item lies within a
+ particular range by using the contains() function. Ranges can also
+ be compared using the overloaded operators for equality and
+ inequality, and the intersects() function allows you to determine
+ whether two ranges overlap.
+
+ \sa {Model/View Programming}, QAbstractItemModel, QItemSelection,
+ QItemSelectionModel
+*/
+
+/*!
+ \fn QItemSelectionRange::QItemSelectionRange()
+
+ Constructs an empty selection range.
+*/
+
+/*!
+ \fn QItemSelectionRange::QItemSelectionRange(const QItemSelectionRange &other)
+
+ Copy constructor. Constructs a new selection range with the same contents
+ as the \a other range given.
+
+*/
+
+/*!
+ \fn QItemSelectionRange::QItemSelectionRange(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+
+ Constructs a new selection range containing only the index specified
+ by the \a topLeft and the index \a bottomRight.
+
+*/
+
+/*!
+ \fn QItemSelectionRange::QItemSelectionRange(const QModelIndex &index)
+
+ Constructs a new selection range containing only the model item specified
+ by the model index \a index.
+*/
+
+/*!
+ \fn int QItemSelectionRange::top() const
+
+ Returns the row index corresponding to the uppermost selected row in the
+ selection range.
+
+*/
+
+/*!
+ \fn int QItemSelectionRange::left() const
+
+ Returns the column index corresponding to the leftmost selected column in the
+ selection range.
+*/
+
+/*!
+ \fn int QItemSelectionRange::bottom() const
+
+ Returns the row index corresponding to the lowermost selected row in the
+ selection range.
+
+*/
+
+/*!
+ \fn int QItemSelectionRange::right() const
+
+ Returns the column index corresponding to the rightmost selected column in
+ the selection range.
+
+*/
+
+/*!
+ \fn int QItemSelectionRange::width() const
+
+ Returns the number of selected columns in the selection range.
+
+*/
+
+/*!
+ \fn int QItemSelectionRange::height() const
+
+ Returns the number of selected rows in the selection range.
+
+*/
+
+/*!
+ \fn const QAbstractItemModel *QItemSelectionRange::model() const
+
+ Returns the model that the items in the selection range belong to.
+*/
+
+/*!
+ \fn QModelIndex QItemSelectionRange::topLeft() const
+
+ Returns the index for the item located at the top-left corner of
+ the selection range.
+
+ \sa top(), left(), bottomRight()
+*/
+
+/*!
+ \fn QModelIndex QItemSelectionRange::bottomRight() const
+
+ Returns the index for the item located at the bottom-right corner
+ of the selection range.
+
+ \sa bottom(), right(), topLeft()
+*/
+
+/*!
+ \fn QModelIndex QItemSelectionRange::parent() const
+
+ Returns the parent model item index of the items in the selection range.
+
+*/
+
+/*!
+ \fn bool QItemSelectionRange::contains(const QModelIndex &index) const
+
+ Returns true if the model item specified by the \a index lies within the
+ range of selected items; otherwise returns false.
+*/
+
+/*!
+ \fn bool QItemSelectionRange::contains(int row, int column,
+ const QModelIndex &parentIndex) const
+ \overload
+
+ Returns true if the model item specified by (\a row, \a column)
+ and with \a parentIndex as the parent item lies within the range
+ of selected items; otherwise returns false.
+*/
+
+/*!
+ \fn bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
+
+ Returns true if this selection range intersects (overlaps with) the \a other
+ range given; otherwise returns false.
+
+*/
+bool QItemSelectionRange::intersects(const QItemSelectionRange &other) const
+{
+ return (isValid() && other.isValid()
+ && parent() == other.parent()
+ && model() == other.model()
+ && ((top() <= other.top() && bottom() >= other.top())
+ || (top() >= other.top() && top() <= other.bottom()))
+ && ((left() <= other.left() && right() >= other.left())
+ || (left() >= other.left() && left() <= other.right())));
+}
+
+/*!
+ \fn QItemSelectionRange QItemSelectionRange::intersect(const QItemSelectionRange &other) const
+ \obsolete
+
+ Use intersected(\a other) instead.
+*/
+
+/*!
+ \fn QItemSelectionRange QItemSelectionRange::intersected(const QItemSelectionRange &other) const
+ \since 4.2
+
+ Returns a new selection range containing only the items that are found in
+ both the selection range and the \a other selection range.
+*/
+
+QItemSelectionRange QItemSelectionRange::intersect(const QItemSelectionRange &other) const
+{
+ if (model() == other.model() && parent() == other.parent()) {
+ QModelIndex topLeft = model()->index(qMax(top(), other.top()),
+ qMax(left(), other.left()),
+ other.parent());
+ QModelIndex bottomRight = model()->index(qMin(bottom(), other.bottom()),
+ qMin(right(), other.right()),
+ other.parent());
+ return QItemSelectionRange(topLeft, bottomRight);
+ }
+ return QItemSelectionRange();
+}
+
+/*!
+ \fn bool QItemSelectionRange::operator==(const QItemSelectionRange &other) const
+
+ Returns true if the selection range is exactly the same as the \a other
+ range given; otherwise returns false.
+
+*/
+
+/*!
+ \fn bool QItemSelectionRange::operator!=(const QItemSelectionRange &other) const
+
+ Returns true if the selection range differs from the \a other range given;
+ otherwise returns false.
+
+*/
+
+/*!
+ \fn bool QItemSelectionRange::isValid() const
+
+ Returns true if the selection range is valid; otherwise returns false.
+
+*/
+
+/*
+ \internal
+
+ utility function for getting the indexes from a range
+ it avoid concatenating list and works on one
+ */
+
+static void indexesFromRange(const QItemSelectionRange &range, QModelIndexList &result)
+{
+ if (range.isValid() && range.model()) {
+ for (int column = range.left(); column <= range.right(); ++column) {
+ for (int row = range.top(); row <= range.bottom(); ++row) {
+ QModelIndex index = range.model()->index(row, column, range.parent());
+ Qt::ItemFlags flags = range.model()->flags(index);
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
+ result.append(index);
+ }
+ }
+ }
+}
+
+/*!
+ Returns true if the selection range contains no selectable item
+ \since 4.7
+*/
+
+bool QItemSelectionRange::isEmpty() const
+{
+ if (!isValid() || !model())
+ return true;
+
+ for (int column = left(); column <= right(); ++column) {
+ for (int row = top(); row <= bottom(); ++row) {
+ QModelIndex index = model()->index(row, column, parent());
+ Qt::ItemFlags flags = model()->flags(index);
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
+ return false;
+ }
+ }
+ return true;
+}
+
+/*!
+ Returns the list of model index items stored in the selection.
+*/
+
+QModelIndexList QItemSelectionRange::indexes() const
+{
+ QModelIndexList result;
+ indexesFromRange(*this, result);
+ return result;
+}
+
+/*!
+ \class QItemSelection
+
+ \brief The QItemSelection class manages information about selected items in a model.
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ A QItemSelection describes the items in a model that have been
+ selected by the user. A QItemSelection is basically a list of
+ selection ranges, see QItemSelectionRange. It provides functions for
+ creating and manipulating selections, and selecting a range of items
+ from a model.
+
+ The QItemSelection class is one of the \l{Model/View Classes}
+ and is part of Qt's \l{Model/View Programming}{model/view framework}.
+
+ An item selection can be constructed and initialized to contain a
+ range of items from an existing model. The following example constructs
+ a selection that contains a range of items from the given \c model,
+ beginning at the \c topLeft, and ending at the \c bottomRight.
+
+ \snippet doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp 0
+
+ An empty item selection can be constructed, and later populated as
+ required. So, if the model is going to be unavailable when we construct
+ the item selection, we can rewrite the above code in the following way:
+
+ \snippet doc/src/snippets/code/src_gui_itemviews_qitemselectionmodel.cpp 1
+
+ QItemSelection saves memory, and avoids unnecessary work, by working with
+ selection ranges rather than recording the model item index for each
+ item in the selection. Generally, an instance of this class will contain
+ a list of non-overlapping selection ranges.
+
+ Use merge() to merge one item selection into another without making
+ overlapping ranges. Use split() to split one selection range into
+ smaller ranges based on a another selection range.
+
+ \sa {Model/View Programming}, QItemSelectionModel
+*/
+
+/*!
+ \fn QItemSelection::QItemSelection()
+
+ Constructs an empty selection.
+*/
+
+/*!
+ Constructs an item selection that extends from the top-left model item,
+ specified by the \a topLeft index, to the bottom-right item, specified
+ by \a bottomRight.
+*/
+QItemSelection::QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ select(topLeft, bottomRight);
+}
+
+/*!
+ Adds the items in the range that extends from the top-left model
+ item, specified by the \a topLeft index, to the bottom-right item,
+ specified by \a bottomRight to the list.
+
+ \note \a topLeft and \a bottomRight must have the same parent.
+*/
+void QItemSelection::select(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ if (!topLeft.isValid() || !bottomRight.isValid())
+ return;
+
+ if ((topLeft.model() != bottomRight.model())
+ || topLeft.parent() != bottomRight.parent()) {
+ qWarning("Can't select indexes from different model or with different parents");
+ return;
+ }
+ if (topLeft.row() > bottomRight.row() || topLeft.column() > bottomRight.column()) {
+ int top = qMin(topLeft.row(), bottomRight.row());
+ int bottom = qMax(topLeft.row(), bottomRight.row());
+ int left = qMin(topLeft.column(), bottomRight.column());
+ int right = qMax(topLeft.column(), bottomRight.column());
+ QModelIndex tl = topLeft.sibling(top, left);
+ QModelIndex br = bottomRight.sibling(bottom, right);
+ append(QItemSelectionRange(tl, br));
+ return;
+ }
+ append(QItemSelectionRange(topLeft, bottomRight));
+}
+
+/*!
+ Returns true if the selection contains the given \a index; otherwise
+ returns false.
+*/
+
+bool QItemSelection::contains(const QModelIndex &index) const
+{
+ if (index.flags() & Qt::ItemIsSelectable) {
+ QList<QItemSelectionRange>::const_iterator it = begin();
+ for (; it != end(); ++it)
+ if ((*it).contains(index))
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Returns a list of model indexes that correspond to the selected items.
+*/
+
+QModelIndexList QItemSelection::indexes() const
+{
+ QModelIndexList result;
+ QList<QItemSelectionRange>::const_iterator it = begin();
+ for (; it != end(); ++it)
+ indexesFromRange(*it, result);
+ return result;
+}
+
+/*!
+ Merges the \a other selection with this QItemSelection using the
+ \a command given. This method guarantees that no ranges are overlapping.
+
+ Note that only QItemSelectionModel::Select,
+ QItemSelectionModel::Deselect, and QItemSelectionModel::Toggle are
+ supported.
+
+ \sa split()
+*/
+void QItemSelection::merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command)
+{
+ if (other.isEmpty() ||
+ !(command & QItemSelectionModel::Select ||
+ command & QItemSelectionModel::Deselect ||
+ command & QItemSelectionModel::Toggle))
+ return;
+
+ QItemSelection newSelection = other;
+ // Collect intersections
+ QItemSelection intersections;
+ QItemSelection::iterator it = newSelection.begin();
+ while (it != newSelection.end()) {
+ if (!(*it).isValid()) {
+ it = newSelection.erase(it);
+ continue;
+ }
+ for (int t = 0; t < count(); ++t) {
+ if ((*it).intersects(at(t)))
+ intersections.append(at(t).intersected(*it));
+ }
+ ++it;
+ }
+
+ // Split the old (and new) ranges using the intersections
+ for (int i = 0; i < intersections.count(); ++i) { // for each intersection
+ for (int t = 0; t < count();) { // splitt each old range
+ if (at(t).intersects(intersections.at(i))) {
+ split(at(t), intersections.at(i), this);
+ removeAt(t);
+ } else {
+ ++t;
+ }
+ }
+ // only split newSelection if Toggle is specified
+ for (int n = 0; (command & QItemSelectionModel::Toggle) && n < newSelection.count();) {
+ if (newSelection.at(n).intersects(intersections.at(i))) {
+ split(newSelection.at(n), intersections.at(i), &newSelection);
+ newSelection.removeAt(n);
+ } else {
+ ++n;
+ }
+ }
+ }
+ // do not add newSelection for Deselect
+ if (!(command & QItemSelectionModel::Deselect))
+ operator+=(newSelection);
+}
+
+/*!
+ Splits the selection \a range using the selection \a other range.
+ Removes all items in \a other from \a range and puts the result in \a result.
+ This can be compared with the semantics of the \e subtract operation of a set.
+ \sa merge()
+*/
+
+void QItemSelection::split(const QItemSelectionRange &range,
+ const QItemSelectionRange &other, QItemSelection *result)
+{
+ if (range.parent() != other.parent() || range.model() != other.model())
+ return;
+
+ QModelIndex parent = other.parent();
+ int top = range.top();
+ int left = range.left();
+ int bottom = range.bottom();
+ int right = range.right();
+ int other_top = other.top();
+ int other_left = other.left();
+ int other_bottom = other.bottom();
+ int other_right = other.right();
+ const QAbstractItemModel *model = range.model();
+ Q_ASSERT(model);
+ if (other_top > top) {
+ QModelIndex tl = model->index(top, left, parent);
+ QModelIndex br = model->index(other_top - 1, right, parent);
+ result->append(QItemSelectionRange(tl, br));
+ top = other_top;
+ }
+ if (other_bottom < bottom) {
+ QModelIndex tl = model->index(other_bottom + 1, left, parent);
+ QModelIndex br = model->index(bottom, right, parent);
+ result->append(QItemSelectionRange(tl, br));
+ bottom = other_bottom;
+ }
+ if (other_left > left) {
+ QModelIndex tl = model->index(top, left, parent);
+ QModelIndex br = model->index(bottom, other_left - 1, parent);
+ result->append(QItemSelectionRange(tl, br));
+ left = other_left;
+ }
+ if (other_right < right) {
+ QModelIndex tl = model->index(top, other_right + 1, parent);
+ QModelIndex br = model->index(bottom, right, parent);
+ result->append(QItemSelectionRange(tl, br));
+ right = other_right;
+ }
+}
+
+
+void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model)
+{
+ this->model = model;
+ if (model) {
+ Q_Q(QItemSelectionModel);
+ QObject::connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+ q, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+ q, SLOT(_q_rowsAboutToBeInserted(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+ q, SLOT(_q_columnsAboutToBeInserted(QModelIndex,int,int)));
+ QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, SLOT(_q_layoutAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, SLOT(_q_layoutAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, SLOT(_q_layoutChanged()));
+ QObject::connect(model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
+ q, SLOT(_q_layoutChanged()));
+ QObject::connect(model, SIGNAL(layoutAboutToBeChanged()),
+ q, SLOT(_q_layoutAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(layoutChanged()),
+ q, SLOT(_q_layoutChanged()));
+ }
+}
+
+/*!
+ \internal
+
+ returns a QItemSelection where all ranges have been expanded to:
+ Rows: left: 0 and right: columnCount()-1
+ Columns: top: 0 and bottom: rowCount()-1
+*/
+
+QItemSelection QItemSelectionModelPrivate::expandSelection(const QItemSelection &selection,
+ QItemSelectionModel::SelectionFlags command) const
+{
+ if (selection.isEmpty() && !((command & QItemSelectionModel::Rows) ||
+ (command & QItemSelectionModel::Columns)))
+ return selection;
+
+ QItemSelection expanded;
+ if (command & QItemSelectionModel::Rows) {
+ for (int i = 0; i < selection.count(); ++i) {
+ QModelIndex parent = selection.at(i).parent();
+ int colCount = model->columnCount(parent);
+ QModelIndex tl = model->index(selection.at(i).top(), 0, parent);
+ QModelIndex br = model->index(selection.at(i).bottom(), colCount - 1, parent);
+ //we need to merge because the same row could have already been inserted
+ expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select);
+ }
+ }
+ if (command & QItemSelectionModel::Columns) {
+ for (int i = 0; i < selection.count(); ++i) {
+ QModelIndex parent = selection.at(i).parent();
+ int rowCount = model->rowCount(parent);
+ QModelIndex tl = model->index(0, selection.at(i).left(), parent);
+ QModelIndex br = model->index(rowCount - 1, selection.at(i).right(), parent);
+ //we need to merge because the same column could have already been inserted
+ expanded.merge(QItemSelection(tl, br), QItemSelectionModel::Select);
+ }
+ }
+ return expanded;
+}
+
+/*!
+ \internal
+*/
+void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &parent,
+ int start, int end)
+{
+ Q_Q(QItemSelectionModel);
+ finalize();
+
+ // update current index
+ if (currentIndex.isValid() && parent == currentIndex.parent()
+ && currentIndex.row() >= start && currentIndex.row() <= end) {
+ QModelIndex old = currentIndex;
+ if (start > 0) // there are rows left above the change
+ currentIndex = model->index(start - 1, old.column(), parent);
+ else if (model && end < model->rowCount(parent) - 1) // there are rows left below the change
+ currentIndex = model->index(end + 1, old.column(), parent);
+ else // there are no rows left in the table
+ currentIndex = QModelIndex();
+ emit q->currentChanged(currentIndex, old);
+ emit q->currentRowChanged(currentIndex, old);
+ if (currentIndex.column() != old.column())
+ emit q->currentColumnChanged(currentIndex, old);
+ }
+
+ QItemSelection deselected;
+ QItemSelection newParts;
+ QItemSelection::iterator it = ranges.begin();
+ while (it != ranges.end()) {
+ if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range
+ QModelIndex itParent = it->topLeft().parent();
+ while (itParent.isValid() && itParent.parent() != parent)
+ itParent = itParent.parent();
+
+ if (itParent.isValid() && start <= itParent.row() && itParent.row() <= end) {
+ deselected.append(*it);
+ it = ranges.erase(it);
+ } else {
+ ++it;
+ }
+ } else if (start <= it->bottom() && it->bottom() <= end // Full inclusion
+ && start <= it->top() && it->top() <= end) {
+ deselected.append(*it);
+ it = ranges.erase(it);
+ } else if (start <= it->top() && it->top() <= end) { // Top intersection
+ deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent())));
+ *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight());
+ ++it;
+ } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection
+ deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight()));
+ *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent()));
+ ++it;
+ } else if (it->top() < start && end < it->bottom()) { // Middle intersection
+ // If the parent contains (1, 2, 3, 4, 5, 6, 7, 8) and [3, 4, 5, 6] is selected,
+ // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6].
+ // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection
+ // in ranges.
+ const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()),
+ model->index(end, it->left(), it->parent()));
+ deselected.append(removedRange);
+ QItemSelection::split(*it, removedRange, &newParts);
+ it = ranges.erase(it);
+ } else
+ ++it;
+ }
+ ranges.append(newParts);
+
+ if (!deselected.isEmpty())
+ emit q->selectionChanged(QItemSelection(), deselected);
+}
+
+/*!
+ \internal
+*/
+void QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(const QModelIndex &parent,
+ int start, int end)
+{
+ Q_Q(QItemSelectionModel);
+
+ // update current index
+ if (currentIndex.isValid() && parent == currentIndex.parent()
+ && currentIndex.column() >= start && currentIndex.column() <= end) {
+ QModelIndex old = currentIndex;
+ if (start > 0) // there are columns to the left of the change
+ currentIndex = model->index(old.row(), start - 1, parent);
+ else if (model && end < model->columnCount() - 1) // there are columns to the right of the change
+ currentIndex = model->index(old.row(), end + 1, parent);
+ else // there are no columns left in the table
+ currentIndex = QModelIndex();
+ emit q->currentChanged(currentIndex, old);
+ if (currentIndex.row() != old.row())
+ emit q->currentRowChanged(currentIndex, old);
+ emit q->currentColumnChanged(currentIndex, old);
+ }
+
+ // update selections
+ QModelIndex tl = model->index(0, start, parent);
+ QModelIndex br = model->index(model->rowCount(parent) - 1, end, parent);
+ q->select(QItemSelection(tl, br), QItemSelectionModel::Deselect);
+ finalize();
+}
+
+/*!
+ \internal
+
+ Split selection ranges if columns are about to be inserted in the middle.
+*/
+void QItemSelectionModelPrivate::_q_columnsAboutToBeInserted(const QModelIndex &parent,
+ int start, int end)
+{
+ Q_UNUSED(end);
+ finalize();
+ QList<QItemSelectionRange> split;
+ QList<QItemSelectionRange>::iterator it = ranges.begin();
+ for (; it != ranges.end(); ) {
+ if ((*it).isValid() && (*it).parent() == parent
+ && (*it).left() < start && (*it).right() >= start) {
+ QModelIndex bottomMiddle = model->index((*it).bottom(), start - 1, (*it).parent());
+ QItemSelectionRange left((*it).topLeft(), bottomMiddle);
+ QModelIndex topMiddle = model->index((*it).top(), start, (*it).parent());
+ QItemSelectionRange right(topMiddle, (*it).bottomRight());
+ it = ranges.erase(it);
+ split.append(left);
+ split.append(right);
+ } else {
+ ++it;
+ }
+ }
+ ranges += split;
+}
+
+/*!
+ \internal
+
+ Split selection ranges if rows are about to be inserted in the middle.
+*/
+void QItemSelectionModelPrivate::_q_rowsAboutToBeInserted(const QModelIndex &parent,
+ int start, int end)
+{
+ Q_UNUSED(end);
+ finalize();
+ QList<QItemSelectionRange> split;
+ QList<QItemSelectionRange>::iterator it = ranges.begin();
+ for (; it != ranges.end(); ) {
+ if ((*it).isValid() && (*it).parent() == parent
+ && (*it).top() < start && (*it).bottom() >= start) {
+ QModelIndex middleRight = model->index(start - 1, (*it).right(), (*it).parent());
+ QItemSelectionRange top((*it).topLeft(), middleRight);
+ QModelIndex middleLeft = model->index(start, (*it).left(), (*it).parent());
+ QItemSelectionRange bottom(middleLeft, (*it).bottomRight());
+ it = ranges.erase(it);
+ split.append(top);
+ split.append(bottom);
+ } else {
+ ++it;
+ }
+ }
+ ranges += split;
+}
+
+/*!
+ \internal
+
+ Split selection into individual (persistent) indexes. This is done in
+ preparation for the layoutChanged() signal, where the indexes can be
+ merged again.
+*/
+void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged()
+{
+ savedPersistentIndexes.clear();
+ savedPersistentCurrentIndexes.clear();
+
+ // optimization for when all indexes are selected
+ // (only if there is lots of items (1000) because this is not entirely correct)
+ if (ranges.isEmpty() && currentSelection.count() == 1) {
+ QItemSelectionRange range = currentSelection.first();
+ QModelIndex parent = range.parent();
+ tableRowCount = model->rowCount(parent);
+ tableColCount = model->columnCount(parent);
+ if (tableRowCount * tableColCount > 1000
+ && range.top() == 0
+ && range.left() == 0
+ && range.bottom() == tableRowCount - 1
+ && range.right() == tableColCount - 1) {
+ tableSelected = true;
+ tableParent = parent;
+ return;
+ }
+ }
+ tableSelected = false;
+
+ QModelIndexList indexes = ranges.indexes();
+ QModelIndexList::const_iterator it;
+ for (it = indexes.constBegin(); it != indexes.constEnd(); ++it)
+ savedPersistentIndexes.append(QPersistentModelIndex(*it));
+ indexes = currentSelection.indexes();
+ for (it = indexes.constBegin(); it != indexes.constEnd(); ++it)
+ savedPersistentCurrentIndexes.append(QPersistentModelIndex(*it));
+}
+
+/*!
+ \internal
+
+ Merges \a indexes into an item selection made up of ranges.
+ Assumes that the indexes are sorted.
+*/
+static QItemSelection mergeIndexes(const QList<QPersistentModelIndex> &indexes)
+{
+ QItemSelection colSpans;
+ // merge columns
+ int i = 0;
+ while (i < indexes.count()) {
+ QModelIndex tl = indexes.at(i);
+ QModelIndex br = tl;
+ while (++i < indexes.count()) {
+ QModelIndex next = indexes.at(i);
+ if ((next.parent() == br.parent())
+ && (next.row() == br.row())
+ && (next.column() == br.column() + 1))
+ br = next;
+ else
+ break;
+ }
+ colSpans.append(QItemSelectionRange(tl, br));
+ }
+ // merge rows
+ QItemSelection rowSpans;
+ i = 0;
+ while (i < colSpans.count()) {
+ QModelIndex tl = colSpans.at(i).topLeft();
+ QModelIndex br = colSpans.at(i).bottomRight();
+ QModelIndex prevTl = tl;
+ while (++i < colSpans.count()) {
+ QModelIndex nextTl = colSpans.at(i).topLeft();
+ QModelIndex nextBr = colSpans.at(i).bottomRight();
+
+ if (nextTl.parent() != tl.parent())
+ break; // we can't merge selection ranges from different parents
+
+ if ((nextTl.column() == prevTl.column()) && (nextBr.column() == br.column())
+ && (nextTl.row() == prevTl.row() + 1) && (nextBr.row() == br.row() + 1)) {
+ br = nextBr;
+ prevTl = nextTl;
+ } else {
+ break;
+ }
+ }
+ rowSpans.append(QItemSelectionRange(tl, br));
+ }
+ return rowSpans;
+}
+
+/*!
+ \internal
+
+ Merge the selected indexes into selection ranges again.
+*/
+void QItemSelectionModelPrivate::_q_layoutChanged()
+{
+ // special case for when all indexes are selected
+ if (tableSelected && tableColCount == model->columnCount(tableParent)
+ && tableRowCount == model->rowCount(tableParent)) {
+ ranges.clear();
+ currentSelection.clear();
+ int bottom = tableRowCount - 1;
+ int right = tableColCount - 1;
+ QModelIndex tl = model->index(0, 0, tableParent);
+ QModelIndex br = model->index(bottom, right, tableParent);
+ currentSelection << QItemSelectionRange(tl, br);
+ tableParent = QModelIndex();
+ tableSelected = false;
+ return;
+ }
+
+ if (savedPersistentCurrentIndexes.isEmpty() && savedPersistentIndexes.isEmpty()) {
+ // either the selection was actually empty, or we
+ // didn't get the layoutAboutToBeChanged() signal
+ return;
+ }
+ // clear the "old" selection
+ ranges.clear();
+ currentSelection.clear();
+
+ // sort the "new" selection, as preparation for merging
+ qStableSort(savedPersistentIndexes.begin(), savedPersistentIndexes.end());
+ qStableSort(savedPersistentCurrentIndexes.begin(), savedPersistentCurrentIndexes.end());
+
+ // update the selection by merging the individual indexes
+ ranges = mergeIndexes(savedPersistentIndexes);
+ currentSelection = mergeIndexes(savedPersistentCurrentIndexes);
+
+ // release the persistent indexes
+ savedPersistentIndexes.clear();
+ savedPersistentCurrentIndexes.clear();
+}
+
+/*!
+ \class QItemSelectionModel
+
+ \brief The QItemSelectionModel class keeps track of a view's selected items.
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ A QItemSelectionModel keeps track of the selected items in a view, or
+ in several views onto the same model. It also keeps track of the
+ currently selected item in a view.
+
+ The QItemSelectionModel class is one of the \l{Model/View Classes}
+ and is part of Qt's \l{Model/View Programming}{model/view framework}.
+
+ The selected items are stored using ranges. Whenever you want to
+ modify the selected items use select() and provide either a
+ QItemSelection, or a QModelIndex and a QItemSelectionModel::SelectionFlag.
+
+ The QItemSelectionModel takes a two layer approach to selection
+ management, dealing with both selected items that have been committed
+ and items that are part of the current selection. The current
+ selected items are part of the current interactive selection (for
+ example with rubber-band selection or keyboard-shift selections).
+
+ To update the currently selected items, use the bitwise OR of
+ QItemSelectionModel::Current and any of the other SelectionFlags.
+ If you omit the QItemSelectionModel::Current command, a new current
+ selection will be created, and the previous one added to the whole
+ selection. All functions operate on both layers; for example,
+ selectedItems() will return items from both layers.
+
+ \sa {Model/View Programming}, QAbstractItemModel, {Chart Example}
+*/
+
+/*!
+ Constructs a selection model that operates on the specified item \a model.
+*/
+QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model)
+ : QObject(*new QItemSelectionModelPrivate, model)
+{
+ d_func()->initModel(model);
+}
+
+/*!
+ Constructs a selection model that operates on the specified item \a model with \a parent.
+*/
+QItemSelectionModel::QItemSelectionModel(QAbstractItemModel *model, QObject *parent)
+ : QObject(*new QItemSelectionModelPrivate, parent)
+{
+ d_func()->initModel(model);
+}
+
+/*!
+ \internal
+*/
+QItemSelectionModel::QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model)
+ : QObject(dd, model)
+{
+ dd.initModel(model);
+}
+
+/*!
+ Destroys the selection model.
+*/
+QItemSelectionModel::~QItemSelectionModel()
+{
+}
+
+/*!
+ Selects the model item \a index using the specified \a command, and emits
+ selectionChanged().
+
+ \sa QItemSelectionModel::SelectionFlags
+*/
+void QItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
+{
+ QItemSelection selection(index, index);
+ select(selection, command);
+}
+
+/*!
+ \fn void QItemSelectionModel::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+
+ This signal is emitted whenever the current item changes. The \a previous
+ model item index is replaced by the \a current index as the selection's
+ current item.
+
+ Note that this signal will not be emitted when the item model is reset.
+
+ \sa currentIndex() setCurrentIndex() selectionChanged()
+*/
+
+/*!
+ \fn void QItemSelectionModel::currentColumnChanged(const QModelIndex &current, const QModelIndex &previous)
+
+ This signal is emitted if the \a current item changes and its column is
+ different to the column of the \a previous current item.
+
+ Note that this signal will not be emitted when the item model is reset.
+
+ \sa currentChanged() currentRowChanged() currentIndex() setCurrentIndex()
+*/
+
+/*!
+ \fn void QItemSelectionModel::currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
+
+ This signal is emitted if the \a current item changes and its row is
+ different to the row of the \a previous current item.
+
+ Note that this signal will not be emitted when the item model is reset.
+
+ \sa currentChanged() currentColumnChanged() currentIndex() setCurrentIndex()
+*/
+
+/*!
+ \fn void QItemSelectionModel::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
+
+ This signal is emitted whenever the selection changes. The change in the
+ selection is represented as an item selection of \a deselected items and
+ an item selection of \a selected items.
+
+ Note the that the current index changes independently from the selection.
+ Also note that this signal will not be emitted when the item model is reset.
+
+ \sa select() currentChanged()
+*/
+
+/*!
+ \enum QItemSelectionModel::SelectionFlag
+
+ This enum describes the way the selection model will be updated.
+
+ \value NoUpdate No selection will be made.
+ \value Clear The complete selection will be cleared.
+ \value Select All specified indexes will be selected.
+ \value Deselect All specified indexes will be deselected.
+ \value Toggle All specified indexes will be selected or
+ deselected depending on their current state.
+ \value Current The current selection will be updated.
+ \value Rows All indexes will be expanded to span rows.
+ \value Columns All indexes will be expanded to span columns.
+ \value SelectCurrent A combination of Select and Current, provided for
+ convenience.
+ \value ToggleCurrent A combination of Toggle and Current, provided for
+ convenience.
+ \value ClearAndSelect A combination of Clear and Select, provided for
+ convenience.
+*/
+
+/*!
+ Selects the item \a selection using the specified \a command, and emits
+ selectionChanged().
+
+ \sa QItemSelectionModel::SelectionFlag
+*/
+void QItemSelectionModel::select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
+{
+ Q_D(QItemSelectionModel);
+ if (command == NoUpdate)
+ return;
+
+ // store old selection
+ QItemSelection sel = selection;
+ // If d->ranges is non-empty when the source model is reset the persistent indexes
+ // it contains will be invalid. We can't clear them in a modelReset slot because that might already
+ // be too late if another model observer is connected to the same modelReset slot and is invoked first
+ // it might call select() on this selection model before any such QItemSelectionModelPrivate::_q_modelReset() slot
+ // is invoked, so it would not be cleared yet. We clear it invalid ranges in it here.
+ QItemSelection::iterator it = d->ranges.begin();
+ while (it != d->ranges.end()) {
+ if (!it->isValid())
+ it = d->ranges.erase(it);
+ else
+ ++it;
+ }
+
+ QItemSelection old = d->ranges;
+ old.merge(d->currentSelection, d->currentCommand);
+
+ // expand selection according to SelectionBehavior
+ if (command & Rows || command & Columns)
+ sel = d->expandSelection(sel, command);
+
+ // clear ranges and currentSelection
+ if (command & Clear) {
+ d->ranges.clear();
+ d->currentSelection.clear();
+ }
+
+ // merge and clear currentSelection if Current was not set (ie. start new currentSelection)
+ if (!(command & Current))
+ d->finalize();
+
+ // update currentSelection
+ if (command & Toggle || command & Select || command & Deselect) {
+ d->currentCommand = command;
+ d->currentSelection = sel;
+ }
+
+ // generate new selection, compare with old and emit selectionChanged()
+ QItemSelection newSelection = d->ranges;
+ newSelection.merge(d->currentSelection, d->currentCommand);
+ emitSelectionChanged(newSelection, old);
+}
+
+/*!
+ Clears the selection model. Emits selectionChanged() and currentChanged().
+*/
+void QItemSelectionModel::clear()
+{
+ clearSelection();
+ clearCurrentIndex();
+}
+
+/*!
+ Clears the current index. Emits currentChanged().
+ */
+void QItemSelectionModel::clearCurrentIndex()
+{
+ Q_D(QItemSelectionModel);
+ QModelIndex previous = d->currentIndex;
+ d->currentIndex = QModelIndex();
+ if (previous.isValid()) {
+ emit currentChanged(d->currentIndex, previous);
+ emit currentRowChanged(d->currentIndex, previous);
+ emit currentColumnChanged(d->currentIndex, previous);
+ }
+}
+
+/*!
+ Clears the selection model. Does not emit any signals.
+*/
+void QItemSelectionModel::reset()
+{
+ bool block = blockSignals(true);
+ clear();
+ blockSignals(block);
+}
+
+/*!
+ \since 4.2
+ Clears the selection in the selection model. Emits selectionChanged().
+*/
+void QItemSelectionModel::clearSelection()
+{
+ Q_D(QItemSelectionModel);
+ if (d->ranges.count() == 0 && d->currentSelection.count() == 0)
+ return;
+
+ select(QItemSelection(), Clear);
+}
+
+
+/*!
+ Sets the model item \a index to be the current item, and emits
+ currentChanged(). The current item is used for keyboard navigation and
+ focus indication; it is independent of any selected items, although a
+ selected item can also be the current item.
+
+ Depending on the specified \a command, the \a index can also become part
+ of the current selection.
+ \sa select()
+*/
+void QItemSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
+{
+ Q_D(QItemSelectionModel);
+ if (index == d->currentIndex) {
+ if (command != NoUpdate)
+ select(index, command); // select item
+ return;
+ }
+ QPersistentModelIndex previous = d->currentIndex;
+ d->currentIndex = index; // set current before emitting selection changed below
+ if (command != NoUpdate)
+ select(d->currentIndex, command); // select item
+ emit currentChanged(d->currentIndex, previous);
+ if (d->currentIndex.row() != previous.row() ||
+ d->currentIndex.parent() != previous.parent())
+ emit currentRowChanged(d->currentIndex, previous);
+ if (d->currentIndex.column() != previous.column() ||
+ d->currentIndex.parent() != previous.parent())
+ emit currentColumnChanged(d->currentIndex, previous);
+}
+
+/*!
+ Returns the model item index for the current item, or an invalid index
+ if there is no current item.
+*/
+QModelIndex QItemSelectionModel::currentIndex() const
+{
+ return static_cast<QModelIndex>(d_func()->currentIndex);
+}
+
+/*!
+ Returns true if the given model item \a index is selected.
+*/
+bool QItemSelectionModel::isSelected(const QModelIndex &index) const
+{
+ Q_D(const QItemSelectionModel);
+ if (d->model != index.model() || !index.isValid())
+ return false;
+
+ bool selected = false;
+ // search model ranges
+ QList<QItemSelectionRange>::const_iterator it = d->ranges.begin();
+ for (; it != d->ranges.end(); ++it) {
+ if ((*it).isValid() && (*it).contains(index)) {
+ selected = true;
+ break;
+ }
+ }
+
+ // check currentSelection
+ if (d->currentSelection.count()) {
+ if ((d->currentCommand & Deselect) && selected)
+ selected = !d->currentSelection.contains(index);
+ else if (d->currentCommand & Toggle)
+ selected ^= d->currentSelection.contains(index);
+ else if ((d->currentCommand & Select) && !selected)
+ selected = d->currentSelection.contains(index);
+ }
+
+ if (selected) {
+ Qt::ItemFlags flags = d->model->flags(index);
+ return (flags & Qt::ItemIsSelectable);
+ }
+
+ return false;
+}
+
+/*!
+ Returns true if all items are selected in the \a row with the given
+ \a parent.
+
+ Note that this function is usually faster than calling isSelected()
+ on all items in the same row and that unselectable items are
+ ignored.
+*/
+bool QItemSelectionModel::isRowSelected(int row, const QModelIndex &parent) const
+{
+ Q_D(const QItemSelectionModel);
+ if (parent.isValid() && d->model != parent.model())
+ return false;
+
+ // return false if row exist in currentSelection (Deselect)
+ if (d->currentCommand & Deselect && d->currentSelection.count()) {
+ for (int i=0; i<d->currentSelection.count(); ++i) {
+ if (d->currentSelection.at(i).parent() == parent &&
+ row >= d->currentSelection.at(i).top() &&
+ row <= d->currentSelection.at(i).bottom())
+ return false;
+ }
+ }
+ // return false if ranges in both currentSelection and ranges
+ // intersect and have the same row contained
+ if (d->currentCommand & Toggle && d->currentSelection.count()) {
+ for (int i=0; i<d->currentSelection.count(); ++i)
+ if (d->currentSelection.at(i).top() <= row &&
+ d->currentSelection.at(i).bottom() >= row)
+ for (int j=0; j<d->ranges.count(); ++j)
+ if (d->ranges.at(j).top() <= row && d->ranges.at(j).bottom() >= row
+ && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid())
+ return false;
+ }
+ // add ranges and currentSelection and check through them all
+ QList<QItemSelectionRange>::const_iterator it;
+ QList<QItemSelectionRange> joined = d->ranges;
+ if (d->currentSelection.count())
+ joined += d->currentSelection;
+ int colCount = d->model->columnCount(parent);
+ for (int column = 0; column < colCount; ++column) {
+ for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
+ if ((*it).contains(row, column, parent)) {
+ bool selectable = false;
+ for (int i = column; !selectable && i <= (*it).right(); ++i) {
+ Qt::ItemFlags flags = d->model->index(row, i, parent).flags();
+ selectable = flags & Qt::ItemIsSelectable;
+ }
+ if (selectable){
+ column = qMax(column, (*it).right());
+ break;
+ }
+ }
+ }
+ if (it == joined.constEnd())
+ return false;
+ }
+ return colCount > 0; // no columns means no selected items
+}
+
+/*!
+ Returns true if all items are selected in the \a column with the given
+ \a parent.
+
+ Note that this function is usually faster than calling isSelected()
+ on all items in the same column and that unselectable items are
+ ignored.
+*/
+bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent) const
+{
+ Q_D(const QItemSelectionModel);
+ if (parent.isValid() && d->model != parent.model())
+ return false;
+
+ // return false if column exist in currentSelection (Deselect)
+ if (d->currentCommand & Deselect && d->currentSelection.count()) {
+ for (int i = 0; i < d->currentSelection.count(); ++i) {
+ if (d->currentSelection.at(i).parent() == parent &&
+ column >= d->currentSelection.at(i).left() &&
+ column <= d->currentSelection.at(i).right())
+ return false;
+ }
+ }
+ // return false if ranges in both currentSelection and the selection model
+ // intersect and have the same column contained
+ if (d->currentCommand & Toggle && d->currentSelection.count()) {
+ for (int i = 0; i < d->currentSelection.count(); ++i) {
+ if (d->currentSelection.at(i).left() <= column &&
+ d->currentSelection.at(i).right() >= column) {
+ for (int j = 0; j < d->ranges.count(); ++j) {
+ if (d->ranges.at(j).left() <= column && d->ranges.at(j).right() >= column
+ && d->currentSelection.at(i).intersected(d->ranges.at(j)).isValid()) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ // add ranges and currentSelection and check through them all
+ QList<QItemSelectionRange>::const_iterator it;
+ QList<QItemSelectionRange> joined = d->ranges;
+ if (d->currentSelection.count())
+ joined += d->currentSelection;
+ int rowCount = d->model->rowCount(parent);
+ for (int row = 0; row < rowCount; ++row) {
+ for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
+ if ((*it).contains(row, column, parent)) {
+ Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
+ row = qMax(row, (*it).bottom());
+ break;
+ }
+ }
+ }
+ if (it == joined.constEnd())
+ return false;
+ }
+ return rowCount > 0; // no rows means no selected items
+}
+
+/*!
+ Returns true if there are any items selected in the \a row with the given
+ \a parent.
+*/
+bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &parent) const
+{
+ Q_D(const QItemSelectionModel);
+ if (parent.isValid() && d->model != parent.model())
+ return false;
+
+ QItemSelection sel = d->ranges;
+ sel.merge(d->currentSelection, d->currentCommand);
+ for (int i = 0; i < sel.count(); ++i) {
+ int top = sel.at(i).top();
+ int bottom = sel.at(i).bottom();
+ int left = sel.at(i).left();
+ int right = sel.at(i).right();
+ if (top <= row && bottom >= row) {
+ for (int j = left; j <= right; j++) {
+ const Qt::ItemFlags flags = d->model->index(row, j, parent).flags();
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/*!
+ Returns true if there are any items selected in the \a column with the given
+ \a parent.
+*/
+bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelIndex &parent) const
+{
+ Q_D(const QItemSelectionModel);
+ if (parent.isValid() && d->model != parent.model())
+ return false;
+
+ QItemSelection sel = d->ranges;
+ sel.merge(d->currentSelection, d->currentCommand);
+ for (int i = 0; i < sel.count(); ++i) {
+ int left = sel.at(i).left();
+ int right = sel.at(i).right();
+ int top = sel.at(i).top();
+ int bottom = sel.at(i).bottom();
+ if (left <= column && right >= column) {
+ for (int j = top; j <= bottom; j++) {
+ const Qt::ItemFlags flags = d->model->index(j, column, parent).flags();
+ if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled))
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/*!
+ \since 4.2
+
+ Returns true if the selection model contains any selection ranges;
+ otherwise returns false.
+*/
+bool QItemSelectionModel::hasSelection() const
+{
+ Q_D(const QItemSelectionModel);
+ if (d->currentCommand & (Toggle | Deselect)) {
+ QItemSelection sel = d->ranges;
+ sel.merge(d->currentSelection, d->currentCommand);
+ return !sel.isEmpty();
+ } else {
+ return !(d->ranges.isEmpty() && d->currentSelection.isEmpty());
+ }
+}
+
+/*!
+ Returns a list of all selected model item indexes. The list contains no
+ duplicates, and is not sorted.
+*/
+QModelIndexList QItemSelectionModel::selectedIndexes() const
+{
+ Q_D(const QItemSelectionModel);
+ QItemSelection selected = d->ranges;
+ selected.merge(d->currentSelection, d->currentCommand);
+ return selected.indexes();
+}
+
+/*!
+ \since 4.2
+ Returns the indexes in the given \a column for the rows where all columns are selected.
+
+ \sa selectedIndexes(), selectedColumns()
+*/
+
+QModelIndexList QItemSelectionModel::selectedRows(int column) const
+{
+ QModelIndexList indexes;
+ //the QSet contains pairs of parent modelIndex
+ //and row number
+ QSet< QPair<QModelIndex, int> > rowsSeen;
+
+ const QItemSelection ranges = selection();
+ for (int i = 0; i < ranges.count(); ++i) {
+ const QItemSelectionRange &range = ranges.at(i);
+ QModelIndex parent = range.parent();
+ for (int row = range.top(); row <= range.bottom(); row++) {
+ QPair<QModelIndex, int> rowDef = qMakePair(parent, row);
+ if (!rowsSeen.contains(rowDef)) {
+ rowsSeen << rowDef;
+ if (isRowSelected(row, parent)) {
+ indexes.append(model()->index(row, column, parent));
+ }
+ }
+ }
+ }
+
+ return indexes;
+}
+
+/*!
+ \since 4.2
+ Returns the indexes in the given \a row for columns where all rows are selected.
+
+ \sa selectedIndexes(), selectedRows()
+*/
+
+QModelIndexList QItemSelectionModel::selectedColumns(int row) const
+{
+ QModelIndexList indexes;
+ //the QSet contains pairs of parent modelIndex
+ //and column number
+ QSet< QPair<QModelIndex, int> > columnsSeen;
+
+ const QItemSelection ranges = selection();
+ for (int i = 0; i < ranges.count(); ++i) {
+ const QItemSelectionRange &range = ranges.at(i);
+ QModelIndex parent = range.parent();
+ for (int column = range.left(); column <= range.right(); column++) {
+ QPair<QModelIndex, int> columnDef = qMakePair(parent, column);
+ if (!columnsSeen.contains(columnDef)) {
+ columnsSeen << columnDef;
+ if (isColumnSelected(column, parent)) {
+ indexes.append(model()->index(row, column, parent));
+ }
+ }
+ }
+ }
+
+ return indexes;
+}
+
+/*!
+ Returns the selection ranges stored in the selection model.
+*/
+const QItemSelection QItemSelectionModel::selection() const
+{
+ Q_D(const QItemSelectionModel);
+ QItemSelection selected = d->ranges;
+ selected.merge(d->currentSelection, d->currentCommand);
+ int i = 0;
+ // make sure we have no invalid ranges
+ // ### should probably be handled more generic somewhere else
+ while (i<selected.count()) {
+ if (selected.at(i).isValid())
+ ++i;
+ else
+ (selected.removeAt(i));
+ }
+ return selected;
+}
+
+/*!
+ Returns the item model operated on by the selection model.
+*/
+const QAbstractItemModel *QItemSelectionModel::model() const
+{
+ return d_func()->model;
+}
+
+/*!
+ Compares the two selections \a newSelection and \a oldSelection
+ and emits selectionChanged() with the deselected and selected items.
+*/
+void QItemSelectionModel::emitSelectionChanged(const QItemSelection &newSelection,
+ const QItemSelection &oldSelection)
+{
+ // if both selections are empty or equal we return
+ if ((oldSelection.isEmpty() && newSelection.isEmpty()) ||
+ oldSelection == newSelection)
+ return;
+
+ // if either selection is empty we do not need to compare
+ if (oldSelection.isEmpty() || newSelection.isEmpty()) {
+ emit selectionChanged(newSelection, oldSelection);
+ return;
+ }
+
+ QItemSelection deselected = oldSelection;
+ QItemSelection selected = newSelection;
+
+ // remove equal ranges
+ bool advance;
+ for (int o = 0; o < deselected.count(); ++o) {
+ advance = true;
+ for (int s = 0; s < selected.count() && o < deselected.count();) {
+ if (deselected.at(o) == selected.at(s)) {
+ deselected.removeAt(o);
+ selected.removeAt(s);
+ advance = false;
+ } else {
+ ++s;
+ }
+ }
+ if (advance)
+ ++o;
+ }
+
+ // find intersections
+ QItemSelection intersections;
+ for (int o = 0; o < deselected.count(); ++o) {
+ for (int s = 0; s < selected.count(); ++s) {
+ if (deselected.at(o).intersects(selected.at(s)))
+ intersections.append(deselected.at(o).intersected(selected.at(s)));
+ }
+ }
+
+ // compare remaining ranges with intersections and split them to find deselected and selected
+ for (int i = 0; i < intersections.count(); ++i) {
+ // split deselected
+ for (int o = 0; o < deselected.count();) {
+ if (deselected.at(o).intersects(intersections.at(i))) {
+ QItemSelection::split(deselected.at(o), intersections.at(i), &deselected);
+ deselected.removeAt(o);
+ } else {
+ ++o;
+ }
+ }
+ // split selected
+ for (int s = 0; s < selected.count();) {
+ if (selected.at(s).intersects(intersections.at(i))) {
+ QItemSelection::split(selected.at(s), intersections.at(i), &selected);
+ selected.removeAt(s);
+ } else {
+ ++s;
+ }
+ }
+ }
+
+ if (!selected.isEmpty() || !deselected.isEmpty())
+ emit selectionChanged(selected, deselected);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QItemSelectionRange &range)
+{
+#ifndef Q_BROKEN_DEBUG_STREAM
+ dbg.nospace() << "QItemSelectionRange(" << range.topLeft()
+ << ',' << range.bottomRight() << ')';
+ return dbg.space();
+#else
+ qWarning("This compiler doesn't support streaming QItemSelectionRange to QDebug");
+ return dbg;
+ Q_UNUSED(range);
+#endif
+}
+#endif
+
+QT_END_NAMESPACE
+
+#include "moc_qitemselectionmodel.cpp"
+
+#endif // QT_NO_ITEMVIEWS
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
new file mode 100644
index 0000000000..3b3fa8d1e8
--- /dev/null
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QITEMSELECTIONMODEL_H
+#define QITEMSELECTIONMODEL_H
+
+#include <QtCore/qset.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qabstractitemmodel.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class Q_CORE_EXPORT QItemSelectionRange
+{
+
+public:
+ inline QItemSelectionRange() {}
+ inline QItemSelectionRange(const QItemSelectionRange &other)
+ : tl(other.tl), br(other.br) {}
+ inline QItemSelectionRange(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ explicit inline QItemSelectionRange(const QModelIndex &index)
+ { tl = index; br = tl; }
+
+ inline int top() const { return tl.row(); }
+ inline int left() const { return tl.column(); }
+ inline int bottom() const { return br.row(); }
+ inline int right() const { return br.column(); }
+ inline int width() const { return br.column() - tl.column() + 1; }
+ inline int height() const { return br.row() - tl.row() + 1; }
+
+ inline QModelIndex topLeft() const { return QModelIndex(tl); }
+ inline QModelIndex bottomRight() const { return QModelIndex(br); }
+ inline QModelIndex parent() const { return tl.parent(); }
+ inline const QAbstractItemModel *model() const { return tl.model(); }
+
+ inline bool contains(const QModelIndex &index) const
+ {
+ return (parent() == index.parent()
+ && tl.row() <= index.row() && tl.column() <= index.column()
+ && br.row() >= index.row() && br.column() >= index.column());
+ }
+
+ inline bool contains(int row, int column, const QModelIndex &parentIndex) const
+ {
+ return (parent() == parentIndex
+ && tl.row() <= row && tl.column() <= column
+ && br.row() >= row && br.column() >= column);
+ }
+
+ bool intersects(const QItemSelectionRange &other) const;
+ QItemSelectionRange intersect(const QItemSelectionRange &other) const; // ### Qt 5: make QT4_SUPPORT
+ inline QItemSelectionRange intersected(const QItemSelectionRange &other) const
+ { return intersect(other); }
+
+ inline bool operator==(const QItemSelectionRange &other) const
+ { return (tl == other.tl && br == other.br); }
+ inline bool operator!=(const QItemSelectionRange &other) const
+ { return !operator==(other); }
+ inline bool operator<(const QItemSelectionRange &other) const
+ {
+ // Comparing parents will compare the models, but if two equivalent ranges
+ // in two different models have invalid parents, they would appear the same
+ if (other.tl.model() == tl.model()) {
+ // parent has to be calculated, so we only do so once.
+ const QModelIndex topLeftParent = tl.parent();
+ const QModelIndex otherTopLeftParent = other.tl.parent();
+ if (topLeftParent == otherTopLeftParent) {
+ if (other.tl.row() == tl.row()) {
+ if (other.tl.column() == tl.column()) {
+ if (other.br.row() == br.row()) {
+ return br.column() < other.br.column();
+ }
+ return br.row() < other.br.row();
+ }
+ return tl.column() < other.tl.column();
+ }
+ return tl.row() < other.tl.row();
+ }
+ return topLeftParent < otherTopLeftParent;
+ }
+ return tl.model() < other.tl.model();
+ }
+
+ inline bool isValid() const
+ {
+ return (tl.isValid() && br.isValid() && tl.parent() == br.parent()
+ && top() <= bottom() && left() <= right());
+ }
+
+ bool isEmpty() const;
+
+ QModelIndexList indexes() const;
+
+private:
+ QPersistentModelIndex tl, br;
+};
+Q_DECLARE_TYPEINFO(QItemSelectionRange, Q_MOVABLE_TYPE);
+
+inline QItemSelectionRange::QItemSelectionRange(const QModelIndex &atopLeft,
+ const QModelIndex &abottomRight)
+{ tl = atopLeft; br = abottomRight; }
+
+class QItemSelection;
+class QItemSelectionModelPrivate;
+
+class Q_CORE_EXPORT QItemSelectionModel : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QItemSelectionModel)
+ Q_FLAGS(SelectionFlags)
+
+public:
+
+ enum SelectionFlag {
+ NoUpdate = 0x0000,
+ Clear = 0x0001,
+ Select = 0x0002,
+ Deselect = 0x0004,
+ Toggle = 0x0008,
+ Current = 0x0010,
+ Rows = 0x0020,
+ Columns = 0x0040,
+ SelectCurrent = Select | Current,
+ ToggleCurrent = Toggle | Current,
+ ClearAndSelect = Clear | Select
+ };
+
+ Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)
+
+ explicit QItemSelectionModel(QAbstractItemModel *model);
+ explicit QItemSelectionModel(QAbstractItemModel *model, QObject *parent);
+ virtual ~QItemSelectionModel();
+
+ QModelIndex currentIndex() const;
+
+ bool isSelected(const QModelIndex &index) const;
+ bool isRowSelected(int row, const QModelIndex &parent) const;
+ bool isColumnSelected(int column, const QModelIndex &parent) const;
+
+ bool rowIntersectsSelection(int row, const QModelIndex &parent) const;
+ bool columnIntersectsSelection(int column, const QModelIndex &parent) const;
+
+ bool hasSelection() const;
+
+ QModelIndexList selectedIndexes() const;
+ QModelIndexList selectedRows(int column = 0) const;
+ QModelIndexList selectedColumns(int row = 0) const;
+ const QItemSelection selection() const;
+
+ const QAbstractItemModel *model() const;
+
+public Q_SLOTS:
+ virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
+ virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);
+ virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command);
+ virtual void clear();
+ virtual void reset();
+
+ void clearSelection();
+ virtual void clearCurrentIndex();
+
+Q_SIGNALS:
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+ void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
+ void currentColumnChanged(const QModelIndex &current, const QModelIndex &previous);
+
+protected:
+ QItemSelectionModel(QItemSelectionModelPrivate &dd, QAbstractItemModel *model);
+ void emitSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection);
+
+private:
+ Q_DISABLE_COPY(QItemSelectionModel)
+ Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeRemoved(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeInserted(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
+
+// dummy implentation of qHash() necessary for instantiating QList<QItemSelectionRange>::toSet() with MSVC
+inline uint qHash(const QItemSelectionRange &) { return 0; }
+
+class Q_CORE_EXPORT QItemSelection : public QList<QItemSelectionRange>
+{
+public:
+ QItemSelection() {}
+ QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void select(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ bool contains(const QModelIndex &index) const;
+ QModelIndexList indexes() const;
+ void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command);
+ static void split(const QItemSelectionRange &range,
+ const QItemSelectionRange &other,
+ QItemSelection *result);
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QItemSelectionRange &);
+#endif
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QITEMSELECTIONMODEL_H
diff --git a/src/corelib/itemmodels/qitemselectionmodel_p.h b/src/corelib/itemmodels/qitemselectionmodel_p.h
new file mode 100644
index 0000000000..919c4fab05
--- /dev/null
+++ b/src/corelib/itemmodels/qitemselectionmodel_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QITEMSELECTIONMODEL_P_H
+#define QITEMSELECTIONMODEL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ITEMVIEWS
+class QItemSelectionModelPrivate: public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QItemSelectionModel)
+public:
+ QItemSelectionModelPrivate()
+ : model(0),
+ currentCommand(QItemSelectionModel::NoUpdate),
+ tableSelected(false), tableColCount(0), tableRowCount(0) {}
+
+ QItemSelection expandSelection(const QItemSelection &selection,
+ QItemSelectionModel::SelectionFlags command) const;
+
+ void initModel(QAbstractItemModel *model);
+
+ void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ void _q_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
+ void _q_layoutAboutToBeChanged();
+ void _q_layoutChanged();
+
+ inline void remove(QList<QItemSelectionRange> &r)
+ {
+ QList<QItemSelectionRange>::const_iterator it = r.constBegin();
+ for (; it != r.constEnd(); ++it)
+ ranges.removeAll(*it);
+ }
+
+ inline void finalize()
+ {
+ ranges.merge(currentSelection, currentCommand);
+ if (!currentSelection.isEmpty()) // ### perhaps this should be in QList
+ currentSelection.clear();
+ }
+
+ QPointer<QAbstractItemModel> model;
+ QItemSelection ranges;
+ QItemSelection currentSelection;
+ QPersistentModelIndex currentIndex;
+ QItemSelectionModel::SelectionFlags currentCommand;
+ QList<QPersistentModelIndex> savedPersistentIndexes;
+ QList<QPersistentModelIndex> savedPersistentCurrentIndexes;
+ // optimization when all indexes are selected
+ bool tableSelected;
+ QPersistentModelIndex tableParent;
+ int tableColCount, tableRowCount;
+};
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+#endif // QITEMSELECTIONMODEL_P_H
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
new file mode 100644
index 0000000000..3a63c923d3
--- /dev/null
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -0,0 +1,2703 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsortfilterproxymodel.h"
+
+#ifndef QT_NO_SORTFILTERPROXYMODEL
+
+#include "qitemselectionmodel.h"
+#include <qsize.h>
+#include <qdebug.h>
+#include <qdatetime.h>
+#include <qpair.h>
+#include <qstringlist.h>
+#include <private/qabstractitemmodel_p.h>
+#include <private/qabstractproxymodel_p.h>
+
+QT_BEGIN_NAMESPACE
+
+typedef QList<QPair<QModelIndex, QPersistentModelIndex> > QModelIndexPairList;
+
+static inline QSet<int> qVectorToSet(const QVector<int> &vector)
+{
+ QSet<int> set;
+ set.reserve(vector.size());
+ for(int i=0; i < vector.size(); ++i)
+ set << vector.at(i);
+ return set;
+}
+
+class QSortFilterProxyModelLessThan
+{
+public:
+ inline QSortFilterProxyModelLessThan(int column, const QModelIndex &parent,
+ const QAbstractItemModel *source,
+ const QSortFilterProxyModel *proxy)
+ : sort_column(column), source_parent(parent), source_model(source), proxy_model(proxy) {}
+
+ inline bool operator()(int r1, int r2) const
+ {
+ QModelIndex i1 = source_model->index(r1, sort_column, source_parent);
+ QModelIndex i2 = source_model->index(r2, sort_column, source_parent);
+ return proxy_model->lessThan(i1, i2);
+ }
+
+private:
+ int sort_column;
+ QModelIndex source_parent;
+ const QAbstractItemModel *source_model;
+ const QSortFilterProxyModel *proxy_model;
+};
+
+class QSortFilterProxyModelGreaterThan
+{
+public:
+ inline QSortFilterProxyModelGreaterThan(int column, const QModelIndex &parent,
+ const QAbstractItemModel *source,
+ const QSortFilterProxyModel *proxy)
+ : sort_column(column), source_parent(parent),
+ source_model(source), proxy_model(proxy) {}
+
+ inline bool operator()(int r1, int r2) const
+ {
+ QModelIndex i1 = source_model->index(r1, sort_column, source_parent);
+ QModelIndex i2 = source_model->index(r2, sort_column, source_parent);
+ return proxy_model->lessThan(i2, i1);
+ }
+
+private:
+ int sort_column;
+ QModelIndex source_parent;
+ const QAbstractItemModel *source_model;
+ const QSortFilterProxyModel *proxy_model;
+};
+
+
+//this struct is used to store what are the rows that are removed
+//between a call to rowsAboutToBeRemoved and rowsRemoved
+//it avoids readding rows to the mapping that are currently being removed
+struct QRowsRemoval
+{
+ QRowsRemoval(const QModelIndex &parent_source, int start, int end) : parent_source(parent_source), start(start), end(end)
+ {
+ }
+
+ QRowsRemoval() : start(-1), end(-1)
+ {
+ }
+
+ bool contains(QModelIndex parent, int row)
+ {
+ do {
+ if (parent == parent_source)
+ return row >= start && row <= end;
+ row = parent.row();
+ parent = parent.parent();
+ } while (row >= 0);
+ return false;
+ }
+private:
+ QModelIndex parent_source;
+ int start;
+ int end;
+};
+
+class QSortFilterProxyModelPrivate : public QAbstractProxyModelPrivate
+{
+ Q_DECLARE_PUBLIC(QSortFilterProxyModel)
+
+public:
+ struct Mapping {
+ QVector<int> source_rows;
+ QVector<int> source_columns;
+ QVector<int> proxy_rows;
+ QVector<int> proxy_columns;
+ QVector<QModelIndex> mapped_children;
+ QHash<QModelIndex, Mapping *>::const_iterator map_iter;
+ };
+
+ mutable QHash<QModelIndex, Mapping*> source_index_mapping;
+
+ int source_sort_column;
+ int proxy_sort_column;
+ Qt::SortOrder sort_order;
+ Qt::CaseSensitivity sort_casesensitivity;
+ int sort_role;
+ bool sort_localeaware;
+
+ int filter_column;
+ QRegExp filter_regexp;
+ int filter_role;
+
+ bool dynamic_sortfilter;
+ QRowsRemoval itemsBeingRemoved;
+
+ QModelIndexPairList saved_persistent_indexes;
+
+ QHash<QModelIndex, Mapping *>::const_iterator create_mapping(
+ const QModelIndex &source_parent) const;
+ QModelIndex proxy_to_source(const QModelIndex &proxyIndex) const;
+ QModelIndex source_to_proxy(const QModelIndex &sourceIndex) const;
+ bool can_create_mapping(const QModelIndex &source_parent) const;
+
+ void remove_from_mapping(const QModelIndex &source_parent);
+
+ inline QHash<QModelIndex, Mapping *>::const_iterator index_to_iterator(
+ const QModelIndex &proxy_index) const
+ {
+ Q_ASSERT(proxy_index.isValid());
+ Q_ASSERT(proxy_index.model() == q_func());
+ const void *p = proxy_index.internalPointer();
+ Q_ASSERT(p);
+ QHash<QModelIndex, Mapping *>::const_iterator it =
+ static_cast<const Mapping*>(p)->map_iter;
+ Q_ASSERT(it != source_index_mapping.constEnd());
+ Q_ASSERT(it.value());
+ return it;
+ }
+
+ inline QModelIndex create_index(int row, int column,
+ QHash<QModelIndex, Mapping*>::const_iterator it) const
+ {
+ return q_func()->createIndex(row, column, *it);
+ }
+
+ void _q_sourceDataChanged(const QModelIndex &source_top_left,
+ const QModelIndex &source_bottom_right);
+ void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end);
+
+ void _q_sourceAboutToBeReset();
+ void _q_sourceReset();
+
+ void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents);
+ void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents);
+
+ void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceRowsInserted(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceRowsRemoved(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent,
+ int sourceStart, int sourceEnd,
+ const QModelIndex &destParent, int dest);
+ void _q_sourceRowsMoved(const QModelIndex &sourceParent,
+ int sourceStart, int sourceEnd,
+ const QModelIndex &destParent, int dest);
+ void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceColumnsInserted(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceColumnsRemoved(const QModelIndex &source_parent,
+ int start, int end);
+ void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent,
+ int sourceStart, int sourceEnd,
+ const QModelIndex &destParent, int dest);
+ void _q_sourceColumnsMoved(const QModelIndex &sourceParent,
+ int sourceStart, int sourceEnd,
+ const QModelIndex &destParent, int dest);
+
+ void _q_clearMapping();
+
+ void sort();
+ bool update_source_sort_column();
+ void sort_source_rows(QVector<int> &source_rows,
+ const QModelIndex &source_parent) const;
+ QVector<QPair<int, QVector<int > > > proxy_intervals_for_source_items_to_add(
+ const QVector<int> &proxy_to_source, const QVector<int> &source_items,
+ const QModelIndex &source_parent, Qt::Orientation orient) const;
+ QVector<QPair<int, int > > proxy_intervals_for_source_items(
+ const QVector<int> &source_to_proxy, const QVector<int> &source_items) const;
+ void insert_source_items(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QVector<int> &source_items, const QModelIndex &source_parent,
+ Qt::Orientation orient, bool emit_signal = true);
+ void remove_source_items(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QVector<int> &source_items, const QModelIndex &source_parent,
+ Qt::Orientation orient, bool emit_signal = true);
+ void remove_proxy_interval(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ int proxy_start, int proxy_end, const QModelIndex &proxy_parent,
+ Qt::Orientation orient, bool emit_signal = true);
+ void build_source_to_proxy_mapping(
+ const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const;
+ void source_items_inserted(const QModelIndex &source_parent,
+ int start, int end, Qt::Orientation orient);
+ void source_items_about_to_be_removed(const QModelIndex &source_parent,
+ int start, int end, Qt::Orientation orient);
+ void source_items_removed(const QModelIndex &source_parent,
+ int start, int end, Qt::Orientation orient);
+ void proxy_item_range(
+ const QVector<int> &source_to_proxy, const QVector<int> &source_items,
+ int &proxy_low, int &proxy_high) const;
+
+ QModelIndexPairList store_persistent_indexes();
+ void update_persistent_indexes(const QModelIndexPairList &source_indexes);
+
+ void filter_changed(const QModelIndex &source_parent = QModelIndex());
+ QSet<int> handle_filter_changed(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QModelIndex &source_parent, Qt::Orientation orient);
+
+ void updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping,
+ Qt::Orientation orient, int start, int end, int delta_item_count, bool remove);
+
+ virtual void _q_sourceModelDestroyed();
+};
+
+typedef QHash<QModelIndex, QSortFilterProxyModelPrivate::Mapping *> IndexMap;
+
+void QSortFilterProxyModelPrivate::_q_sourceModelDestroyed()
+{
+ QAbstractProxyModelPrivate::_q_sourceModelDestroyed();
+ _q_clearMapping();
+}
+
+void QSortFilterProxyModelPrivate::remove_from_mapping(const QModelIndex &source_parent)
+{
+ if (Mapping *m = source_index_mapping.take(source_parent)) {
+ for (int i = 0; i < m->mapped_children.size(); ++i)
+ remove_from_mapping(m->mapped_children.at(i));
+ delete m;
+ }
+}
+
+void QSortFilterProxyModelPrivate::_q_clearMapping()
+{
+ // store the persistent indexes
+ QModelIndexPairList source_indexes = store_persistent_indexes();
+
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+ if (dynamic_sortfilter && update_source_sort_column()) {
+ //update_source_sort_column might have created wrong mapping so we have to clear it again
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+ }
+
+ // update the persistent indexes
+ update_persistent_indexes(source_indexes);
+}
+
+IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping(
+ const QModelIndex &source_parent) const
+{
+ Q_Q(const QSortFilterProxyModel);
+
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_parent);
+ if (it != source_index_mapping.constEnd()) // was mapped already
+ return it;
+
+ Mapping *m = new Mapping;
+
+ int source_rows = model->rowCount(source_parent);
+ m->source_rows.reserve(source_rows);
+ for (int i = 0; i < source_rows; ++i) {
+ if (q->filterAcceptsRow(i, source_parent))
+ m->source_rows.append(i);
+ }
+ int source_cols = model->columnCount(source_parent);
+ m->source_columns.reserve(source_cols);
+ for (int i = 0; i < source_cols; ++i) {
+ if (q->filterAcceptsColumn(i, source_parent))
+ m->source_columns.append(i);
+ }
+
+ sort_source_rows(m->source_rows, source_parent);
+ m->proxy_rows.resize(source_rows);
+ build_source_to_proxy_mapping(m->source_rows, m->proxy_rows);
+ m->proxy_columns.resize(source_cols);
+ build_source_to_proxy_mapping(m->source_columns, m->proxy_columns);
+
+ it = IndexMap::const_iterator(source_index_mapping.insert(source_parent, m));
+ m->map_iter = it;
+
+ if (source_parent.isValid()) {
+ QModelIndex source_grand_parent = source_parent.parent();
+ IndexMap::const_iterator it2 = create_mapping(source_grand_parent);
+ Q_ASSERT(it2 != source_index_mapping.constEnd());
+ it2.value()->mapped_children.append(source_parent);
+ }
+
+ Q_ASSERT(it != source_index_mapping.constEnd());
+ Q_ASSERT(it.value());
+
+ return it;
+}
+
+QModelIndex QSortFilterProxyModelPrivate::proxy_to_source(const QModelIndex &proxy_index) const
+{
+ if (!proxy_index.isValid())
+ return QModelIndex(); // for now; we may want to be able to set a root index later
+ if (proxy_index.model() != q_func()) {
+ qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapToSource";
+ Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapToSource");
+ return QModelIndex();
+ }
+ IndexMap::const_iterator it = index_to_iterator(proxy_index);
+ Mapping *m = it.value();
+ if ((proxy_index.row() >= m->source_rows.size()) || (proxy_index.column() >= m->source_columns.size()))
+ return QModelIndex();
+ int source_row = m->source_rows.at(proxy_index.row());
+ int source_col = m->source_columns.at(proxy_index.column());
+ return model->index(source_row, source_col, it.key());
+}
+
+QModelIndex QSortFilterProxyModelPrivate::source_to_proxy(const QModelIndex &source_index) const
+{
+ if (!source_index.isValid())
+ return QModelIndex(); // for now; we may want to be able to set a root index later
+ if (source_index.model() != model) {
+ qWarning() << "QSortFilterProxyModel: index from wrong model passed to mapFromSource";
+ Q_ASSERT(!"QSortFilterProxyModel: index from wrong model passed to mapFromSource");
+ return QModelIndex();
+ }
+ QModelIndex source_parent = source_index.parent();
+ IndexMap::const_iterator it = create_mapping(source_parent);
+ Mapping *m = it.value();
+ if ((source_index.row() >= m->proxy_rows.size()) || (source_index.column() >= m->proxy_columns.size()))
+ return QModelIndex();
+ int proxy_row = m->proxy_rows.at(source_index.row());
+ int proxy_column = m->proxy_columns.at(source_index.column());
+ if (proxy_row == -1 || proxy_column == -1)
+ return QModelIndex();
+ return create_index(proxy_row, proxy_column, it);
+}
+
+bool QSortFilterProxyModelPrivate::can_create_mapping(const QModelIndex &source_parent) const
+{
+ if (source_parent.isValid()) {
+ QModelIndex source_grand_parent = source_parent.parent();
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_grand_parent);
+ if (it == source_index_mapping.constEnd()) {
+ // Don't care, since we don't have mapping for the grand parent
+ return false;
+ }
+ Mapping *gm = it.value();
+ if (gm->proxy_rows.at(source_parent.row()) == -1 ||
+ gm->proxy_columns.at(source_parent.column()) == -1) {
+ // Don't care, since parent is filtered
+ return false;
+ }
+ }
+ return true;
+}
+
+/*!
+ \internal
+
+ Sorts the existing mappings.
+*/
+void QSortFilterProxyModelPrivate::sort()
+{
+ Q_Q(QSortFilterProxyModel);
+ emit q->layoutAboutToBeChanged();
+ QModelIndexPairList source_indexes = store_persistent_indexes();
+ IndexMap::const_iterator it = source_index_mapping.constBegin();
+ for (; it != source_index_mapping.constEnd(); ++it) {
+ QModelIndex source_parent = it.key();
+ Mapping *m = it.value();
+ sort_source_rows(m->source_rows, source_parent);
+ build_source_to_proxy_mapping(m->source_rows, m->proxy_rows);
+ }
+ update_persistent_indexes(source_indexes);
+ emit q->layoutChanged();
+}
+
+/*!
+ \internal
+
+ update the source_sort_column according to the proxy_sort_column
+ return true if the column was changed
+*/
+bool QSortFilterProxyModelPrivate::update_source_sort_column()
+{
+ Q_Q(QSortFilterProxyModel);
+ QModelIndex proxy_index = q->index(0, proxy_sort_column, QModelIndex());
+ int old_source_sort_colum = source_sort_column;
+ source_sort_column = q->mapToSource(proxy_index).column();
+ return old_source_sort_colum != source_sort_column;
+}
+
+
+/*!
+ \internal
+
+ Sorts the given \a source_rows according to current sort column and order.
+*/
+void QSortFilterProxyModelPrivate::sort_source_rows(
+ QVector<int> &source_rows, const QModelIndex &source_parent) const
+{
+ Q_Q(const QSortFilterProxyModel);
+ if (source_sort_column >= 0) {
+ if (sort_order == Qt::AscendingOrder) {
+ QSortFilterProxyModelLessThan lt(source_sort_column, source_parent, model, q);
+ qStableSort(source_rows.begin(), source_rows.end(), lt);
+ } else {
+ QSortFilterProxyModelGreaterThan gt(source_sort_column, source_parent, model, q);
+ qStableSort(source_rows.begin(), source_rows.end(), gt);
+ }
+ } else { // restore the source model order
+ qStableSort(source_rows.begin(), source_rows.end());
+ }
+}
+
+/*!
+ \internal
+
+ Given source-to-proxy mapping \a source_to_proxy and the set of
+ source items \a source_items (which are part of that mapping),
+ determines the corresponding proxy item intervals that should
+ be removed from the proxy model.
+
+ The result is a vector of pairs, where each pair represents a
+ (start, end) tuple, sorted in ascending order.
+*/
+QVector<QPair<int, int > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items(
+ const QVector<int> &source_to_proxy, const QVector<int> &source_items) const
+{
+ QVector<QPair<int, int> > proxy_intervals;
+ if (source_items.isEmpty())
+ return proxy_intervals;
+
+ int source_items_index = 0;
+ while (source_items_index < source_items.size()) {
+ int first_proxy_item = source_to_proxy.at(source_items.at(source_items_index));
+ Q_ASSERT(first_proxy_item != -1);
+ int last_proxy_item = first_proxy_item;
+ ++source_items_index;
+ // Find end of interval
+ while ((source_items_index < source_items.size())
+ && (source_to_proxy.at(source_items.at(source_items_index)) == last_proxy_item + 1)) {
+ ++last_proxy_item;
+ ++source_items_index;
+ }
+ // Add interval to result
+ proxy_intervals.append(QPair<int, int>(first_proxy_item, last_proxy_item));
+ }
+ qStableSort(proxy_intervals.begin(), proxy_intervals.end());
+ return proxy_intervals;
+}
+
+/*!
+ \internal
+
+ Given source-to-proxy mapping \a src_to_proxy and proxy-to-source mapping
+ \a proxy_to_source, removes \a source_items from this proxy model.
+ The corresponding proxy items are removed in intervals, so that the proper
+ rows/columnsRemoved(start, end) signals will be generated.
+*/
+void QSortFilterProxyModelPrivate::remove_source_items(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QVector<int> &source_items, const QModelIndex &source_parent,
+ Qt::Orientation orient, bool emit_signal)
+{
+ Q_Q(QSortFilterProxyModel);
+ QModelIndex proxy_parent = q->mapFromSource(source_parent);
+ if (!proxy_parent.isValid() && source_parent.isValid())
+ return; // nothing to do (already removed)
+
+ QVector<QPair<int, int> > proxy_intervals;
+ proxy_intervals = proxy_intervals_for_source_items(source_to_proxy, source_items);
+
+ for (int i = proxy_intervals.size()-1; i >= 0; --i) {
+ QPair<int, int> interval = proxy_intervals.at(i);
+ int proxy_start = interval.first;
+ int proxy_end = interval.second;
+ remove_proxy_interval(source_to_proxy, proxy_to_source, proxy_start, proxy_end,
+ proxy_parent, orient, emit_signal);
+ }
+}
+
+/*!
+ \internal
+
+ Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping
+ \a proxy_to_source, removes items from \a proxy_start to \a proxy_end
+ (inclusive) from this proxy model.
+*/
+void QSortFilterProxyModelPrivate::remove_proxy_interval(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source, int proxy_start, int proxy_end,
+ const QModelIndex &proxy_parent, Qt::Orientation orient, bool emit_signal)
+{
+ Q_Q(QSortFilterProxyModel);
+ if (emit_signal) {
+ if (orient == Qt::Vertical)
+ q->beginRemoveRows(proxy_parent, proxy_start, proxy_end);
+ else
+ q->beginRemoveColumns(proxy_parent, proxy_start, proxy_end);
+ }
+
+ // Remove items from proxy-to-source mapping
+ proxy_to_source.remove(proxy_start, proxy_end - proxy_start + 1);
+
+ build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+
+ if (emit_signal) {
+ if (orient == Qt::Vertical)
+ q->endRemoveRows();
+ else
+ q->endRemoveColumns();
+ }
+}
+
+/*!
+ \internal
+
+ Given proxy-to-source mapping \a proxy_to_source and a set of
+ unmapped source items \a source_items, determines the proxy item
+ intervals at which the subsets of source items should be inserted
+ (but does not actually add them to the mapping).
+
+ The result is a vector of pairs, each pair representing a tuple (start,
+ items), where items is a vector containing the (sorted) source items that
+ should be inserted at that proxy model location.
+*/
+QVector<QPair<int, QVector<int > > > QSortFilterProxyModelPrivate::proxy_intervals_for_source_items_to_add(
+ const QVector<int> &proxy_to_source, const QVector<int> &source_items,
+ const QModelIndex &source_parent, Qt::Orientation orient) const
+{
+ Q_Q(const QSortFilterProxyModel);
+ QVector<QPair<int, QVector<int> > > proxy_intervals;
+ if (source_items.isEmpty())
+ return proxy_intervals;
+
+ int proxy_low = 0;
+ int proxy_item = 0;
+ int source_items_index = 0;
+ QVector<int> source_items_in_interval;
+ bool compare = (orient == Qt::Vertical && source_sort_column >= 0 && dynamic_sortfilter);
+ while (source_items_index < source_items.size()) {
+ source_items_in_interval.clear();
+ int first_new_source_item = source_items.at(source_items_index);
+ source_items_in_interval.append(first_new_source_item);
+ ++source_items_index;
+
+ // Find proxy item at which insertion should be started
+ int proxy_high = proxy_to_source.size() - 1;
+ QModelIndex i1 = compare ? model->index(first_new_source_item, source_sort_column, source_parent) : QModelIndex();
+ while (proxy_low <= proxy_high) {
+ proxy_item = (proxy_low + proxy_high) / 2;
+ if (compare) {
+ QModelIndex i2 = model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent);
+ if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1))
+ proxy_high = proxy_item - 1;
+ else
+ proxy_low = proxy_item + 1;
+ } else {
+ if (first_new_source_item < proxy_to_source.at(proxy_item))
+ proxy_high = proxy_item - 1;
+ else
+ proxy_low = proxy_item + 1;
+ }
+ }
+ proxy_item = proxy_low;
+
+ // Find the sequence of new source items that should be inserted here
+ if (proxy_item >= proxy_to_source.size()) {
+ for ( ; source_items_index < source_items.size(); ++source_items_index)
+ source_items_in_interval.append(source_items.at(source_items_index));
+ } else {
+ i1 = compare ? model->index(proxy_to_source.at(proxy_item), source_sort_column, source_parent) : QModelIndex();
+ for ( ; source_items_index < source_items.size(); ++source_items_index) {
+ int new_source_item = source_items.at(source_items_index);
+ if (compare) {
+ QModelIndex i2 = model->index(new_source_item, source_sort_column, source_parent);
+ if ((sort_order == Qt::AscendingOrder) ? q->lessThan(i1, i2) : q->lessThan(i2, i1))
+ break;
+ } else {
+ if (proxy_to_source.at(proxy_item) < new_source_item)
+ break;
+ }
+ source_items_in_interval.append(new_source_item);
+ }
+ }
+
+ // Add interval to result
+ proxy_intervals.append(QPair<int, QVector<int> >(proxy_item, source_items_in_interval));
+ }
+ return proxy_intervals;
+}
+
+/*!
+ \internal
+
+ Given source-to-proxy mapping \a source_to_proxy and proxy-to-source mapping
+ \a proxy_to_source, inserts the given \a source_items into this proxy model.
+ The source items are inserted in intervals (based on some sorted order), so
+ that the proper rows/columnsInserted(start, end) signals will be generated.
+*/
+void QSortFilterProxyModelPrivate::insert_source_items(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QVector<int> &source_items, const QModelIndex &source_parent,
+ Qt::Orientation orient, bool emit_signal)
+{
+ Q_Q(QSortFilterProxyModel);
+ QModelIndex proxy_parent = q->mapFromSource(source_parent);
+ if (!proxy_parent.isValid() && source_parent.isValid())
+ return; // nothing to do (source_parent is not mapped)
+
+ QVector<QPair<int, QVector<int> > > proxy_intervals;
+ proxy_intervals = proxy_intervals_for_source_items_to_add(
+ proxy_to_source, source_items, source_parent, orient);
+
+ for (int i = proxy_intervals.size()-1; i >= 0; --i) {
+ QPair<int, QVector<int> > interval = proxy_intervals.at(i);
+ int proxy_start = interval.first;
+ QVector<int> source_items = interval.second;
+ int proxy_end = proxy_start + source_items.size() - 1;
+
+ if (emit_signal) {
+ if (orient == Qt::Vertical)
+ q->beginInsertRows(proxy_parent, proxy_start, proxy_end);
+ else
+ q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+ }
+
+ for (int i = 0; i < source_items.size(); ++i)
+ proxy_to_source.insert(proxy_start + i, source_items.at(i));
+
+ build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+
+ if (emit_signal) {
+ if (orient == Qt::Vertical)
+ q->endInsertRows();
+ else
+ q->endInsertColumns();
+ }
+ }
+}
+
+/*!
+ \internal
+
+ Handles source model items insertion (columnsInserted(), rowsInserted()).
+ Determines
+ 1) which of the inserted items to also insert into proxy model (filtering),
+ 2) where to insert the items into the proxy model (sorting),
+ then inserts those items.
+ The items are inserted into the proxy model in intervals (based on
+ sorted order), so that the proper rows/columnsInserted(start, end)
+ signals will be generated.
+*/
+void QSortFilterProxyModelPrivate::source_items_inserted(
+ const QModelIndex &source_parent, int start, int end, Qt::Orientation orient)
+{
+ Q_Q(QSortFilterProxyModel);
+ if ((start < 0) || (end < 0))
+ return;
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_parent);
+ if (it == source_index_mapping.constEnd()) {
+ if (!can_create_mapping(source_parent))
+ return;
+ it = create_mapping(source_parent);
+ Mapping *m = it.value();
+ QModelIndex proxy_parent = q->mapFromSource(source_parent);
+ if (m->source_rows.count() > 0) {
+ q->beginInsertRows(proxy_parent, 0, m->source_rows.count() - 1);
+ q->endInsertRows();
+ }
+ if (m->source_columns.count() > 0) {
+ q->beginInsertColumns(proxy_parent, 0, m->source_columns.count() - 1);
+ q->endInsertColumns();
+ }
+ return;
+ }
+
+ Mapping *m = it.value();
+ QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns;
+ QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns;
+
+ int delta_item_count = end - start + 1;
+ int old_item_count = source_to_proxy.size();
+
+ updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, false);
+
+ // Expand source-to-proxy mapping to account for new items
+ if (start < 0 || start > source_to_proxy.size()) {
+ qWarning("QSortFilterProxyModel: invalid inserted rows reported by source model");
+ remove_from_mapping(source_parent);
+ return;
+ }
+ source_to_proxy.insert(start, delta_item_count, -1);
+
+ if (start < old_item_count) {
+ // Adjust existing "stale" indexes in proxy-to-source mapping
+ int proxy_count = proxy_to_source.size();
+ for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) {
+ int source_item = proxy_to_source.at(proxy_item);
+ if (source_item >= start)
+ proxy_to_source.replace(proxy_item, source_item + delta_item_count);
+ }
+ build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ }
+
+ // Figure out which items to add to mapping based on filter
+ QVector<int> source_items;
+ for (int i = start; i <= end; ++i) {
+ if ((orient == Qt::Vertical)
+ ? q->filterAcceptsRow(i, source_parent)
+ : q->filterAcceptsColumn(i, source_parent)) {
+ source_items.append(i);
+ }
+ }
+
+ if (model->rowCount(source_parent) == delta_item_count) {
+ // Items were inserted where there were none before.
+ // If it was new rows make sure to create mappings for columns so that a
+ // valid mapping can be retrieved later and vice-versa.
+
+ QVector<int> &orthogonal_proxy_to_source = (orient == Qt::Horizontal) ? m->source_rows : m->source_columns;
+ QVector<int> &orthogonal_source_to_proxy = (orient == Qt::Horizontal) ? m->proxy_rows : m->proxy_columns;
+
+ if (orthogonal_source_to_proxy.isEmpty()) {
+ const int ortho_end = (orient == Qt::Horizontal) ? model->rowCount(source_parent) : model->columnCount(source_parent);
+
+ orthogonal_source_to_proxy.resize(ortho_end);
+
+ for (int ortho_item = 0; ortho_item < ortho_end; ++ortho_item) {
+ if ((orient == Qt::Horizontal) ? q->filterAcceptsRow(ortho_item, source_parent)
+ : q->filterAcceptsColumn(ortho_item, source_parent)) {
+ orthogonal_proxy_to_source.append(ortho_item);
+ }
+ }
+ if (orient == Qt::Horizontal) {
+ // We're reacting to columnsInserted, but we've just inserted new rows. Sort them.
+ sort_source_rows(orthogonal_proxy_to_source, source_parent);
+ }
+ build_source_to_proxy_mapping(orthogonal_proxy_to_source, orthogonal_source_to_proxy);
+ }
+ }
+
+ // Sort and insert the items
+ if (orient == Qt::Vertical) // Only sort rows
+ sort_source_rows(source_items, source_parent);
+ insert_source_items(source_to_proxy, proxy_to_source, source_items, source_parent, orient);
+}
+
+/*!
+ \internal
+
+ Handles source model items removal
+ (columnsAboutToBeRemoved(), rowsAboutToBeRemoved()).
+*/
+void QSortFilterProxyModelPrivate::source_items_about_to_be_removed(
+ const QModelIndex &source_parent, int start, int end, Qt::Orientation orient)
+{
+ if ((start < 0) || (end < 0))
+ return;
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_parent);
+ if (it == source_index_mapping.constEnd()) {
+ // Don't care, since we don't have mapping for this index
+ return;
+ }
+
+ Mapping *m = it.value();
+ QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns;
+ QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns;
+
+ // figure out which items to remove
+ QVector<int> source_items_to_remove;
+ int proxy_count = proxy_to_source.size();
+ for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) {
+ int source_item = proxy_to_source.at(proxy_item);
+ if ((source_item >= start) && (source_item <= end))
+ source_items_to_remove.append(source_item);
+ }
+
+ remove_source_items(source_to_proxy, proxy_to_source, source_items_to_remove,
+ source_parent, orient);
+}
+
+/*!
+ \internal
+
+ Handles source model items removal (columnsRemoved(), rowsRemoved()).
+*/
+void QSortFilterProxyModelPrivate::source_items_removed(
+ const QModelIndex &source_parent, int start, int end, Qt::Orientation orient)
+{
+ if ((start < 0) || (end < 0))
+ return;
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_parent);
+ if (it == source_index_mapping.constEnd()) {
+ // Don't care, since we don't have mapping for this index
+ return;
+ }
+
+ Mapping *m = it.value();
+ QVector<int> &source_to_proxy = (orient == Qt::Vertical) ? m->proxy_rows : m->proxy_columns;
+ QVector<int> &proxy_to_source = (orient == Qt::Vertical) ? m->source_rows : m->source_columns;
+
+ if (end >= source_to_proxy.size())
+ end = source_to_proxy.size() - 1;
+
+ // Shrink the source-to-proxy mapping to reflect the new item count
+ int delta_item_count = end - start + 1;
+ source_to_proxy.remove(start, delta_item_count);
+
+ int proxy_count = proxy_to_source.size();
+ if (proxy_count > source_to_proxy.size()) {
+ // mapping is in an inconsistent state -- redo the whole mapping
+ qWarning("QSortFilterProxyModel: inconsistent changes reported by source model");
+ remove_from_mapping(source_parent);
+ Q_Q(QSortFilterProxyModel);
+ q->reset();
+ return;
+ }
+
+ // Adjust "stale" indexes in proxy-to-source mapping
+ for (int proxy_item = 0; proxy_item < proxy_count; ++proxy_item) {
+ int source_item = proxy_to_source.at(proxy_item);
+ if (source_item >= start) {
+ Q_ASSERT(source_item - delta_item_count >= 0);
+ proxy_to_source.replace(proxy_item, source_item - delta_item_count);
+ }
+ }
+ build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+
+ updateChildrenMapping(source_parent, m, orient, start, end, delta_item_count, true);
+
+}
+
+
+/*!
+ \internal
+ updates the mapping of the children when inserting or removing items
+*/
+void QSortFilterProxyModelPrivate::updateChildrenMapping(const QModelIndex &source_parent, Mapping *parent_mapping,
+ Qt::Orientation orient, int start, int end, int delta_item_count, bool remove)
+{
+ // see if any mapped children should be (re)moved
+ QVector<QPair<QModelIndex, Mapping*> > moved_source_index_mappings;
+ QVector<QModelIndex>::iterator it2 = parent_mapping->mapped_children.begin();
+ for ( ; it2 != parent_mapping->mapped_children.end();) {
+ const QModelIndex source_child_index = *it2;
+ const int pos = (orient == Qt::Vertical)
+ ? source_child_index.row()
+ : source_child_index.column();
+ if (pos < start) {
+ // not affected
+ ++it2;
+ } else if (remove && pos <= end) {
+ // in the removed interval
+ it2 = parent_mapping->mapped_children.erase(it2);
+ remove_from_mapping(source_child_index);
+ } else {
+ // below the removed items -- recompute the index
+ QModelIndex new_index;
+ const int newpos = remove ? pos - delta_item_count : pos + delta_item_count;
+ if (orient == Qt::Vertical) {
+ new_index = model->index(newpos,
+ source_child_index.column(),
+ source_parent);
+ } else {
+ new_index = model->index(source_child_index.row(),
+ newpos,
+ source_parent);
+ }
+ *it2 = new_index;
+ ++it2;
+
+ // update mapping
+ Mapping *cm = source_index_mapping.take(source_child_index);
+ Q_ASSERT(cm);
+ // we do not reinsert right away, because the new index might be identical with another, old index
+ moved_source_index_mappings.append(QPair<QModelIndex, Mapping*>(new_index, cm));
+ }
+ }
+
+ // reinsert moved, mapped indexes
+ QVector<QPair<QModelIndex, Mapping*> >::iterator it = moved_source_index_mappings.begin();
+ for (; it != moved_source_index_mappings.end(); ++it) {
+#ifdef QT_STRICT_ITERATORS
+ source_index_mapping.insert((*it).first, (*it).second);
+ (*it).second->map_iter = source_index_mapping.constFind((*it).first);
+#else
+ (*it).second->map_iter = source_index_mapping.insert((*it).first, (*it).second);
+#endif
+ }
+}
+
+/*!
+ \internal
+*/
+void QSortFilterProxyModelPrivate::proxy_item_range(
+ const QVector<int> &source_to_proxy, const QVector<int> &source_items,
+ int &proxy_low, int &proxy_high) const
+{
+ proxy_low = INT_MAX;
+ proxy_high = INT_MIN;
+ for (int i = 0; i < source_items.count(); ++i) {
+ int proxy_item = source_to_proxy.at(source_items.at(i));
+ Q_ASSERT(proxy_item != -1);
+ if (proxy_item < proxy_low)
+ proxy_low = proxy_item;
+ if (proxy_item > proxy_high)
+ proxy_high = proxy_item;
+ }
+}
+
+/*!
+ \internal
+*/
+void QSortFilterProxyModelPrivate::build_source_to_proxy_mapping(
+ const QVector<int> &proxy_to_source, QVector<int> &source_to_proxy) const
+{
+ source_to_proxy.fill(-1);
+ int proxy_count = proxy_to_source.size();
+ for (int i = 0; i < proxy_count; ++i)
+ source_to_proxy[proxy_to_source.at(i)] = i;
+}
+
+/*!
+ \internal
+
+ Maps the persistent proxy indexes to source indexes and
+ returns the list of source indexes.
+*/
+QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes()
+{
+ Q_Q(QSortFilterProxyModel);
+ QModelIndexPairList source_indexes;
+ foreach (QPersistentModelIndexData *data, persistent.indexes) {
+ QModelIndex proxy_index = data->index;
+ QModelIndex source_index = q->mapToSource(proxy_index);
+ source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index)));
+ }
+ return source_indexes;
+}
+
+/*!
+ \internal
+
+ Maps \a source_indexes to proxy indexes and stores those
+ as persistent indexes.
+*/
+void QSortFilterProxyModelPrivate::update_persistent_indexes(
+ const QModelIndexPairList &source_indexes)
+{
+ Q_Q(QSortFilterProxyModel);
+ QModelIndexList from, to;
+ for (int i = 0; i < source_indexes.count(); ++i) {
+ QModelIndex source_index = source_indexes.at(i).second;
+ QModelIndex old_proxy_index = source_indexes.at(i).first;
+ create_mapping(source_index.parent());
+ QModelIndex proxy_index = q->mapFromSource(source_index);
+ from << old_proxy_index;
+ to << proxy_index;
+ }
+ q->changePersistentIndexList(from, to);
+}
+
+
+/*!
+ \internal
+
+ Updates the proxy model (adds/removes rows) based on the
+ new filter.
+*/
+void QSortFilterProxyModelPrivate::filter_changed(const QModelIndex &source_parent)
+{
+ IndexMap::const_iterator it = source_index_mapping.constFind(source_parent);
+ if (it == source_index_mapping.constEnd())
+ return;
+ Mapping *m = it.value();
+ QSet<int> rows_removed = handle_filter_changed(m->proxy_rows, m->source_rows, source_parent, Qt::Vertical);
+ QSet<int> columns_removed = handle_filter_changed(m->proxy_columns, m->source_columns, source_parent, Qt::Horizontal);
+ QVector<QModelIndex>::iterator it2 = m->mapped_children.end();
+ while (it2 != m->mapped_children.begin()) {
+ --it2;
+ const QModelIndex source_child_index = *it2;
+ if (rows_removed.contains(source_child_index.row()) || columns_removed.contains(source_child_index.column())) {
+ it2 = m->mapped_children.erase(it2);
+ remove_from_mapping(source_child_index);
+ } else {
+ filter_changed(source_child_index);
+ }
+ }
+}
+
+/*!
+ \internal
+ returns the removed items indexes
+*/
+QSet<int> QSortFilterProxyModelPrivate::handle_filter_changed(
+ QVector<int> &source_to_proxy, QVector<int> &proxy_to_source,
+ const QModelIndex &source_parent, Qt::Orientation orient)
+{
+ Q_Q(QSortFilterProxyModel);
+ // Figure out which mapped items to remove
+ QVector<int> source_items_remove;
+ for (int i = 0; i < proxy_to_source.count(); ++i) {
+ const int source_item = proxy_to_source.at(i);
+ if ((orient == Qt::Vertical)
+ ? !q->filterAcceptsRow(source_item, source_parent)
+ : !q->filterAcceptsColumn(source_item, source_parent)) {
+ // This source item does not satisfy the filter, so it must be removed
+ source_items_remove.append(source_item);
+ }
+ }
+ // Figure out which non-mapped items to insert
+ QVector<int> source_items_insert;
+ int source_count = source_to_proxy.size();
+ for (int source_item = 0; source_item < source_count; ++source_item) {
+ if (source_to_proxy.at(source_item) == -1) {
+ if ((orient == Qt::Vertical)
+ ? q->filterAcceptsRow(source_item, source_parent)
+ : q->filterAcceptsColumn(source_item, source_parent)) {
+ // This source item satisfies the filter, so it must be added
+ source_items_insert.append(source_item);
+ }
+ }
+ }
+ if (!source_items_remove.isEmpty() || !source_items_insert.isEmpty()) {
+ // Do item removal and insertion
+ remove_source_items(source_to_proxy, proxy_to_source,
+ source_items_remove, source_parent, orient);
+ if (orient == Qt::Vertical)
+ sort_source_rows(source_items_insert, source_parent);
+ insert_source_items(source_to_proxy, proxy_to_source,
+ source_items_insert, source_parent, orient);
+ }
+ return qVectorToSet(source_items_remove);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &source_top_left,
+ const QModelIndex &source_bottom_right)
+{
+ Q_Q(QSortFilterProxyModel);
+ if (!source_top_left.isValid() || !source_bottom_right.isValid())
+ return;
+ QModelIndex source_parent = source_top_left.parent();
+ IndexMap::const_iterator it = source_index_mapping.find(source_parent);
+ if (it == source_index_mapping.constEnd()) {
+ // Don't care, since we don't have mapping for this index
+ return;
+ }
+ Mapping *m = it.value();
+
+ // Figure out how the source changes affect us
+ QVector<int> source_rows_remove;
+ QVector<int> source_rows_insert;
+ QVector<int> source_rows_change;
+ QVector<int> source_rows_resort;
+ int end = qMin(source_bottom_right.row(), m->proxy_rows.count() - 1);
+ for (int source_row = source_top_left.row(); source_row <= end; ++source_row) {
+ if (dynamic_sortfilter) {
+ if (m->proxy_rows.at(source_row) != -1) {
+ if (!q->filterAcceptsRow(source_row, source_parent)) {
+ // This source row no longer satisfies the filter, so it must be removed
+ source_rows_remove.append(source_row);
+ } else if (source_sort_column >= source_top_left.column() && source_sort_column <= source_bottom_right.column()) {
+ // This source row has changed in a way that may affect sorted order
+ source_rows_resort.append(source_row);
+ } else {
+ // This row has simply changed, without affecting filtering nor sorting
+ source_rows_change.append(source_row);
+ }
+ } else {
+ if (!itemsBeingRemoved.contains(source_parent, source_row) && q->filterAcceptsRow(source_row, source_parent)) {
+ // This source row now satisfies the filter, so it must be added
+ source_rows_insert.append(source_row);
+ }
+ }
+ } else {
+ if (m->proxy_rows.at(source_row) != -1)
+ source_rows_change.append(source_row);
+ }
+ }
+
+ if (!source_rows_remove.isEmpty()) {
+ remove_source_items(m->proxy_rows, m->source_rows,
+ source_rows_remove, source_parent, Qt::Vertical);
+ QSet<int> source_rows_remove_set = qVectorToSet(source_rows_remove);
+ QVector<QModelIndex>::iterator it = m->mapped_children.end();
+ while (it != m->mapped_children.begin()) {
+ --it;
+ const QModelIndex source_child_index = *it;
+ if (source_rows_remove_set.contains(source_child_index.row())) {
+ it = m->mapped_children.erase(it);
+ remove_from_mapping(source_child_index);
+ }
+ }
+ }
+
+ if (!source_rows_resort.isEmpty()) {
+ // Re-sort the rows of this level
+ QList<QPersistentModelIndex> parents;
+ parents << q->mapFromSource(source_parent);
+ emit q->layoutAboutToBeChanged(parents);
+ QModelIndexPairList source_indexes = store_persistent_indexes();
+ remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort,
+ source_parent, Qt::Vertical, false);
+ sort_source_rows(source_rows_resort, source_parent);
+ insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort,
+ source_parent, Qt::Vertical, false);
+ update_persistent_indexes(source_indexes);
+ emit q->layoutChanged(parents);
+ // Make sure we also emit dataChanged for the rows
+ source_rows_change += source_rows_resort;
+ }
+
+ if (!source_rows_change.isEmpty()) {
+ // Find the proxy row range
+ int proxy_start_row;
+ int proxy_end_row;
+ proxy_item_range(m->proxy_rows, source_rows_change,
+ proxy_start_row, proxy_end_row);
+ // ### Find the proxy column range also
+ if (proxy_end_row >= 0) {
+ // the row was accepted, but some columns might still be filtered out
+ int source_left_column = source_top_left.column();
+ while (source_left_column < source_bottom_right.column()
+ && m->proxy_columns.at(source_left_column) == -1)
+ ++source_left_column;
+ const QModelIndex proxy_top_left = create_index(
+ proxy_start_row, m->proxy_columns.at(source_left_column), it);
+ int source_right_column = source_bottom_right.column();
+ while (source_right_column > source_top_left.column()
+ && m->proxy_columns.at(source_right_column) == -1)
+ --source_right_column;
+ const QModelIndex proxy_bottom_right = create_index(
+ proxy_end_row, m->proxy_columns.at(source_right_column), it);
+ emit q->dataChanged(proxy_top_left, proxy_bottom_right);
+ }
+ }
+
+ if (!source_rows_insert.isEmpty()) {
+ sort_source_rows(source_rows_insert, source_parent);
+ insert_source_items(m->proxy_rows, m->source_rows,
+ source_rows_insert, source_parent, Qt::Vertical);
+ }
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation orientation,
+ int start, int end)
+{
+ Q_Q(QSortFilterProxyModel);
+ Mapping *m = create_mapping(QModelIndex()).value();
+ int proxy_start = (orientation == Qt::Vertical
+ ? m->proxy_rows.at(start)
+ : m->proxy_columns.at(start));
+ int proxy_end = (orientation == Qt::Vertical
+ ? m->proxy_rows.at(end)
+ : m->proxy_columns.at(end));
+ emit q->headerDataChanged(orientation, proxy_start, proxy_end);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset()
+{
+ Q_Q(QSortFilterProxyModel);
+ q->beginResetModel();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceReset()
+{
+ Q_Q(QSortFilterProxyModel);
+ invalidatePersistentIndexes();
+ _q_clearMapping();
+ // All internal structures are deleted in clear()
+ q->endResetModel();
+ update_source_sort_column();
+ if (dynamic_sortfilter)
+ sort();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents)
+{
+ Q_Q(QSortFilterProxyModel);
+ saved_persistent_indexes.clear();
+
+ QList<QPersistentModelIndex> parents;
+ foreach (const QPersistentModelIndex &parent, sourceParents) {
+ if (!parent.isValid()) {
+ parents << QModelIndex();
+ continue;
+ }
+ const QModelIndex mappedParent = q->mapFromSource(parent);
+ // Might be filtered out.
+ if (mappedParent.isValid())
+ parents << mappedParent;
+ }
+
+ // All parents filtered out.
+ if (!sourceParents.isEmpty() && parents.isEmpty())
+ return;
+
+ emit q->layoutAboutToBeChanged(parents);
+ if (persistent.indexes.isEmpty())
+ return;
+
+ saved_persistent_indexes = store_persistent_indexes();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents)
+{
+ Q_Q(QSortFilterProxyModel);
+
+ // Optimize: We only actually have to clear the mapping related to the contents of
+ // sourceParents, not everything.
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+
+ update_persistent_indexes(saved_persistent_indexes);
+ saved_persistent_indexes.clear();
+
+ if (dynamic_sortfilter && update_source_sort_column()) {
+ //update_source_sort_column might have created wrong mapping so we have to clear it again
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+ }
+
+ QList<QPersistentModelIndex> parents;
+ foreach (const QPersistentModelIndex &parent, sourceParents) {
+ if (!parent.isValid()) {
+ parents << QModelIndex();
+ continue;
+ }
+ const QModelIndex mappedParent = q->mapFromSource(parent);
+ if (mappedParent.isValid())
+ parents << mappedParent;
+ }
+
+ if (!sourceParents.isEmpty() && parents.isEmpty())
+ return;
+
+ emit q->layoutChanged(parents);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted(
+ const QModelIndex &source_parent, int start, int end)
+{
+ Q_UNUSED(start);
+ Q_UNUSED(end);
+ //Force the creation of a mapping now, even if its empty.
+ //We need it because the proxy can be acessed at the moment it emits rowsAboutToBeInserted in insert_source_items
+ if (can_create_mapping(source_parent))
+ create_mapping(source_parent);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsInserted(
+ const QModelIndex &source_parent, int start, int end)
+{
+ source_items_inserted(source_parent, start, end, Qt::Vertical);
+ if (update_source_sort_column() && dynamic_sortfilter) //previous call to update_source_sort_column may fail if the model has no column.
+ sort(); // now it should succeed so we need to make sure to sort again
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeRemoved(
+ const QModelIndex &source_parent, int start, int end)
+{
+ itemsBeingRemoved = QRowsRemoval(source_parent, start, end);
+ source_items_about_to_be_removed(source_parent, start, end,
+ Qt::Vertical);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsRemoved(
+ const QModelIndex &source_parent, int start, int end)
+{
+ itemsBeingRemoved = QRowsRemoval();
+ source_items_removed(source_parent, start, end, Qt::Vertical);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeMoved(
+ const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */)
+{
+ Q_Q(QSortFilterProxyModel);
+ // Because rows which are contiguous in the source model might not be contiguous
+ // in the proxy due to sorting, the best thing we can do here is be specific about what
+ // parents are having their children changed.
+ // Optimize: Emit move signals if the proxy is not sorted. Will need to account for rows
+ // being filtered out though.
+
+ saved_persistent_indexes.clear();
+
+ QList<QPersistentModelIndex> parents;
+ parents << q->mapFromSource(sourceParent);
+ if (sourceParent != destParent)
+ parents << q->mapFromSource(destParent);
+ emit q->layoutAboutToBeChanged(parents);
+ if (persistent.indexes.isEmpty())
+ return;
+ saved_persistent_indexes = store_persistent_indexes();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceRowsMoved(
+ const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */)
+{
+ Q_Q(QSortFilterProxyModel);
+
+ // Optimize: We only need to clear and update the persistent indexes which are children of
+ // sourceParent or destParent
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+
+ update_persistent_indexes(saved_persistent_indexes);
+ saved_persistent_indexes.clear();
+
+ if (dynamic_sortfilter && update_source_sort_column()) {
+ //update_source_sort_column might have created wrong mapping so we have to clear it again
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+ }
+
+ QList<QPersistentModelIndex> parents;
+ parents << q->mapFromSource(sourceParent);
+ if (sourceParent != destParent)
+ parents << q->mapFromSource(destParent);
+ emit q->layoutChanged(parents);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeInserted(
+ const QModelIndex &source_parent, int start, int end)
+{
+ Q_UNUSED(start);
+ Q_UNUSED(end);
+ //Force the creation of a mapping now, even if its empty.
+ //We need it because the proxy can be acessed at the moment it emits columnsAboutToBeInserted in insert_source_items
+ if (can_create_mapping(source_parent))
+ create_mapping(source_parent);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsInserted(
+ const QModelIndex &source_parent, int start, int end)
+{
+ Q_Q(const QSortFilterProxyModel);
+ source_items_inserted(source_parent, start, end, Qt::Horizontal);
+
+ if (source_parent.isValid())
+ return; //we sort according to the root column only
+ if (source_sort_column == -1) {
+ //we update the source_sort_column depending on the proxy_sort_column
+ if (update_source_sort_column() && dynamic_sortfilter)
+ sort();
+ } else {
+ if (start <= source_sort_column)
+ source_sort_column += end - start + 1;
+
+ proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column();
+ }
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeRemoved(
+ const QModelIndex &source_parent, int start, int end)
+{
+ source_items_about_to_be_removed(source_parent, start, end,
+ Qt::Horizontal);
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsRemoved(
+ const QModelIndex &source_parent, int start, int end)
+{
+ Q_Q(const QSortFilterProxyModel);
+ source_items_removed(source_parent, start, end, Qt::Horizontal);
+
+ if (source_parent.isValid())
+ return; //we sort according to the root column only
+ if (start <= source_sort_column) {
+ if (end < source_sort_column)
+ source_sort_column -= end - start + 1;
+ else
+ source_sort_column = -1;
+ }
+
+ proxy_sort_column = q->mapFromSource(model->index(0,source_sort_column, source_parent)).column();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsAboutToBeMoved(
+ const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */)
+{
+ Q_Q(QSortFilterProxyModel);
+
+ saved_persistent_indexes.clear();
+
+ QList<QPersistentModelIndex> parents;
+ parents << q->mapFromSource(sourceParent);
+ if (sourceParent != destParent)
+ parents << q->mapFromSource(destParent);
+ emit q->layoutAboutToBeChanged(parents);
+
+ if (persistent.indexes.isEmpty())
+ return;
+ saved_persistent_indexes = store_persistent_indexes();
+}
+
+void QSortFilterProxyModelPrivate::_q_sourceColumnsMoved(
+ const QModelIndex &sourceParent, int /* sourceStart */, int /* sourceEnd */, const QModelIndex &destParent, int /* dest */)
+{
+ Q_Q(QSortFilterProxyModel);
+
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+
+ update_persistent_indexes(saved_persistent_indexes);
+ saved_persistent_indexes.clear();
+
+ if (dynamic_sortfilter && update_source_sort_column()) {
+ qDeleteAll(source_index_mapping);
+ source_index_mapping.clear();
+ }
+
+ QList<QPersistentModelIndex> parents;
+ parents << q->mapFromSource(sourceParent);
+ if (sourceParent != destParent)
+ parents << q->mapFromSource(destParent);
+ emit q->layoutChanged(parents);
+}
+
+/*!
+ \since 4.1
+ \class QSortFilterProxyModel
+ \brief The QSortFilterProxyModel class provides support for sorting and
+ filtering data passed between another model and a view.
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ QSortFilterProxyModel can be used for sorting items, filtering out items,
+ or both. The model transforms the structure of a source model by mapping
+ the model indexes it supplies to new indexes, corresponding to different
+ locations, for views to use. This approach allows a given source model to
+ be restructured as far as views are concerned without requiring any
+ transformations on the underlying data, and without duplicating the data in
+ memory.
+
+ Let's assume that we want to sort and filter the items provided by a custom
+ model. The code to set up the model and the view, \e without sorting and
+ filtering, would look like this:
+
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 1
+
+ To add sorting and filtering support to \c MyItemModel, we need to create
+ a QSortFilterProxyModel, call setSourceModel() with the \c MyItemModel as
+ argument, and install the QSortFilterProxyModel on the view:
+
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 0
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 2
+
+ At this point, neither sorting nor filtering is enabled; the original data
+ is displayed in the view. Any changes made through the
+ QSortFilterProxyModel are applied to the original model.
+
+ The QSortFilterProxyModel acts as a wrapper for the original model. If you
+ need to convert source \l{QModelIndex}es to sorted/filtered model indexes
+ or vice versa, use mapToSource(), mapFromSource(), mapSelectionToSource(),
+ and mapSelectionFromSource().
+
+ \note By default, the model dynamically re-sorts and re-filters data
+ whenever the original model changes. This behavior can be changed by
+ setting the \l{QSortFilterProxyModel::dynamicSortFilter}{dynamicSortFilter}
+ property.
+
+ The \l{itemviews/basicsortfiltermodel}{Basic Sort/Filter Model} and
+ \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model} examples
+ illustrate how to use QSortFilterProxyModel to perform basic sorting and
+ filtering and how to subclass it to implement custom behavior.
+
+ \section1 Sorting
+
+ QTableView and QTreeView have a
+ \l{QTreeView::sortingEnabled}{sortingEnabled} property that controls
+ whether the user can sort the view by clicking the view's horizontal
+ header. For example:
+
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 3
+
+ When this feature is on (the default is off), clicking on a header section
+ sorts the items according to that column. By clicking repeatedly, the user
+ can alternate between ascending and descending order.
+
+ \image qsortfilterproxymodel-sorting.png A sorted QTreeView
+
+ Behind the scene, the view calls the sort() virtual function on the model
+ to reorder the data in the model. To make your data sortable, you can
+ either implement sort() in your model, or use a QSortFilterProxyModel to
+ wrap your model -- QSortFilterProxyModel provides a generic sort()
+ reimplementation that operates on the sortRole() (Qt::DisplayRole by
+ default) of the items and that understands several data types, including
+ \c int, QString, and QDateTime. For hierarchical models, sorting is applied
+ recursively to all child items. String comparisons are case sensitive by
+ default; this can be changed by setting the \l{QSortFilterProxyModel::}
+ {sortCaseSensitivity} property.
+
+ Custom sorting behavior is achieved by subclassing
+ QSortFilterProxyModel and reimplementing lessThan(), which is
+ used to compare items. For example:
+
+ \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 5
+
+ (This code snippet comes from the
+ \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model}
+ example.)
+
+ An alternative approach to sorting is to disable sorting on the view and to
+ impose a certain order to the user. This is done by explicitly calling
+ sort() with the desired column and order as arguments on the
+ QSortFilterProxyModel (or on the original model if it implements sort()).
+ For example:
+
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 4
+
+ QSortFilterProxyModel can be sorted by column -1, in which case it returns
+ to the sort order of the underlying source model.
+
+ \section1 Filtering
+
+ In addition to sorting, QSortFilterProxyModel can be used to hide items
+ that do not match a certain filter. The filter is specified using a QRegExp
+ object and is applied to the filterRole() (Qt::DisplayRole by default) of
+ each item, for a given column. The QRegExp object can be used to match a
+ regular expression, a wildcard pattern, or a fixed string. For example:
+
+ \snippet doc/src/snippets/qsortfilterproxymodel-details/main.cpp 5
+
+ For hierarchical models, the filter is applied recursively to all children.
+ If a parent item doesn't match the filter, none of its children will be
+ shown.
+
+ A common use case is to let the user specify the filter regexp, wildcard
+ pattern, or fixed string in a QLineEdit and to connect the
+ \l{QLineEdit::textChanged()}{textChanged()} signal to setFilterRegExp(),
+ setFilterWildcard(), or setFilterFixedString() to reapply the filter.
+
+ Custom filtering behavior can be achieved by reimplementing the
+ filterAcceptsRow() and filterAcceptsColumn() functions. For
+ example (from the \l{itemviews/customsortfiltermodel}
+ {Custom Sort/Filter Model} example), the following implementation ignores
+ the \l{QSortFilterProxyModel::filterKeyColumn}{filterKeyColumn} property
+ and performs filtering on columns 0, 1, and 2:
+
+ \snippet examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp 3
+
+ (This code snippet comes from the
+ \l{itemviews/customsortfiltermodel}{Custom Sort/Filter Model}
+ example.)
+
+ If you are working with large amounts of filtering and have to invoke
+ invalidateFilter() repeatedly, using reset() may be more efficient,
+ depending on the implementation of your model. However, reset() returns the
+ proxy model to its original state, losing selection information, and will
+ cause the proxy model to be repopulated.
+
+ \section1 Subclassing
+
+ Since QAbstractProxyModel and its subclasses are derived from
+ QAbstractItemModel, much of the same advice about subclassing normal models
+ also applies to proxy models. In addition, it is worth noting that many of
+ the default implementations of functions in this class are written so that
+ they call the equivalent functions in the relevant source model. This
+ simple proxying mechanism may need to be overridden for source models with
+ more complex behavior; for example, if the source model provides a custom
+ hasChildren() implementation, you should also provide one in the proxy
+ model.
+
+ \note Some general guidelines for subclassing models are available in the
+ \l{Model Subclassing Reference}.
+
+ \sa QAbstractProxyModel, QAbstractItemModel, {Model/View Programming},
+ {Basic Sort/Filter Model Example}, {Custom Sort/Filter Model Example}, QIdentityProxyModel
+*/
+
+/*!
+ Constructs a sorting filter model with the given \a parent.
+*/
+
+QSortFilterProxyModel::QSortFilterProxyModel(QObject *parent)
+ : QAbstractProxyModel(*new QSortFilterProxyModelPrivate, parent)
+{
+ Q_D(QSortFilterProxyModel);
+ d->proxy_sort_column = d->source_sort_column = -1;
+ d->sort_order = Qt::AscendingOrder;
+ d->sort_casesensitivity = Qt::CaseSensitive;
+ d->sort_role = Qt::DisplayRole;
+ d->sort_localeaware = false;
+ d->filter_column = 0;
+ d->filter_role = Qt::DisplayRole;
+ d->dynamic_sortfilter = true;
+ connect(this, SIGNAL(modelReset()), this, SLOT(_q_clearMapping()));
+}
+
+/*!
+ Destroys this sorting filter model.
+*/
+QSortFilterProxyModel::~QSortFilterProxyModel()
+{
+ Q_D(QSortFilterProxyModel);
+ qDeleteAll(d->source_index_mapping);
+ d->source_index_mapping.clear();
+}
+
+/*!
+ \reimp
+*/
+void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
+{
+ Q_D(QSortFilterProxyModel);
+
+ beginResetModel();
+
+ disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
+
+ disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+
+ disconnect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
+
+ disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ disconnect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)),
+ this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>)));
+
+ disconnect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)),
+ this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>)));
+
+ disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
+ disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
+
+ QAbstractProxyModel::setSourceModel(sourceModel);
+
+ connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
+
+ connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
+ this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
+
+ connect(d->model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
+ this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
+
+ connect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ connect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ connect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ connect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
+
+ connect(d->model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>)),
+ this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>)));
+
+ connect(d->model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>)),
+ this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>)));
+
+ connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
+ connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
+
+ d->_q_clearMapping();
+ endResetModel();
+ if (d->update_source_sort_column() && d->dynamic_sortfilter)
+ d->sort();
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QSortFilterProxyModel::index(int row, int column, const QModelIndex &parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ if (row < 0 || column < 0)
+ return QModelIndex();
+
+ QModelIndex source_parent = mapToSource(parent); // parent is already mapped at this point
+ IndexMap::const_iterator it = d->create_mapping(source_parent); // but make sure that the children are mapped
+ if (it.value()->source_rows.count() <= row || it.value()->source_columns.count() <= column)
+ return QModelIndex();
+
+ return d->create_index(row, column, it);
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QSortFilterProxyModel::parent(const QModelIndex &child) const
+{
+ Q_D(const QSortFilterProxyModel);
+ if (!d->indexValid(child))
+ return QModelIndex();
+ IndexMap::const_iterator it = d->index_to_iterator(child);
+ Q_ASSERT(it != d->source_index_mapping.constEnd());
+ QModelIndex source_parent = it.key();
+ QModelIndex proxy_parent = mapFromSource(source_parent);
+ return proxy_parent;
+}
+
+/*!
+ \reimp
+*/
+int QSortFilterProxyModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return 0;
+ IndexMap::const_iterator it = d->create_mapping(source_parent);
+ return it.value()->source_rows.count();
+}
+
+/*!
+ \reimp
+*/
+int QSortFilterProxyModel::columnCount(const QModelIndex &parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return 0;
+ IndexMap::const_iterator it = d->create_mapping(source_parent);
+ return it.value()->source_columns.count();
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return false;
+ if (!d->model->hasChildren(source_parent))
+ return false;
+
+ if (d->model->canFetchMore(source_parent))
+ return true; //we assume we might have children that can be fetched
+
+ QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
+ return m->source_rows.count() != 0 && m->source_columns.count() != 0;
+}
+
+/*!
+ \reimp
+*/
+QVariant QSortFilterProxyModel::data(const QModelIndex &index, int role) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_index = mapToSource(index);
+ if (index.isValid() && !source_index.isValid())
+ return QVariant();
+ return d->model->data(source_index, role);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ Q_D(QSortFilterProxyModel);
+ QModelIndex source_index = mapToSource(index);
+ if (index.isValid() && !source_index.isValid())
+ return false;
+ return d->model->setData(source_index, value, role);
+}
+
+/*!
+ \reimp
+*/
+QVariant QSortFilterProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_D(const QSortFilterProxyModel);
+ IndexMap::const_iterator it = d->create_mapping(QModelIndex());
+ if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0)
+ return QAbstractProxyModel::headerData(section, orientation, role);
+ int source_section;
+ if (orientation == Qt::Vertical) {
+ if (section < 0 || section >= it.value()->source_rows.count())
+ return QVariant();
+ source_section = it.value()->source_rows.at(section);
+ } else {
+ if (section < 0 || section >= it.value()->source_columns.count())
+ return QVariant();
+ source_section = it.value()->source_columns.at(section);
+ }
+ return d->model->headerData(source_section, orientation, role);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role)
+{
+ Q_D(QSortFilterProxyModel);
+ IndexMap::const_iterator it = d->create_mapping(QModelIndex());
+ if (it.value()->source_rows.count() * it.value()->source_columns.count() > 0)
+ return QAbstractProxyModel::setHeaderData(section, orientation, value, role);
+ int source_section;
+ if (orientation == Qt::Vertical) {
+ if (section < 0 || section >= it.value()->source_rows.count())
+ return false;
+ source_section = it.value()->source_rows.at(section);
+ } else {
+ if (section < 0 || section >= it.value()->source_columns.count())
+ return false;
+ source_section = it.value()->source_columns.at(section);
+ }
+ return d->model->setHeaderData(source_section, orientation, value, role);
+}
+
+/*!
+ \reimp
+*/
+QMimeData *QSortFilterProxyModel::mimeData(const QModelIndexList &indexes) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndexList source_indexes;
+ for (int i = 0; i < indexes.count(); ++i)
+ source_indexes << mapToSource(indexes.at(i));
+ return d->model->mimeData(source_indexes);
+}
+
+/*!
+ \reimp
+*/
+QStringList QSortFilterProxyModel::mimeTypes() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->model->mimeTypes();
+}
+
+/*!
+ \reimp
+*/
+Qt::DropActions QSortFilterProxyModel::supportedDropActions() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->model->supportedDropActions();
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ if ((row == -1) && (column == -1))
+ return d->model->dropMimeData(data, action, -1, -1, mapToSource(parent));
+ int source_destination_row = -1;
+ int source_destination_column = -1;
+ QModelIndex source_parent;
+ if (row == rowCount(parent)) {
+ source_parent = mapToSource(parent);
+ source_destination_row = d->model->rowCount(source_parent);
+ } else {
+ QModelIndex proxy_index = index(row, column, parent);
+ QModelIndex source_index = mapToSource(proxy_index);
+ source_destination_row = source_index.row();
+ source_destination_column = source_index.column();
+ source_parent = source_index.parent();
+ }
+ return d->model->dropMimeData(data, action, source_destination_row,
+ source_destination_column, source_parent);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ if (row < 0 || count <= 0)
+ return false;
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return false;
+ QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
+ if (row > m->source_rows.count())
+ return false;
+ int source_row = (row >= m->source_rows.count()
+ ? m->source_rows.count()
+ : m->source_rows.at(row));
+ return d->model->insertRows(source_row, count, source_parent);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::insertColumns(int column, int count, const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ if (column < 0|| count <= 0)
+ return false;
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return false;
+ QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
+ if (column > m->source_columns.count())
+ return false;
+ int source_column = (column >= m->source_columns.count()
+ ? m->source_columns.count()
+ : m->source_columns.at(column));
+ return d->model->insertColumns(source_column, count, source_parent);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ if (row < 0 || count <= 0)
+ return false;
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return false;
+ QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
+ if (row + count > m->source_rows.count())
+ return false;
+ if ((count == 1)
+ || ((d->source_sort_column < 0) && (m->proxy_rows.count() == m->source_rows.count()))) {
+ int source_row = m->source_rows.at(row);
+ return d->model->removeRows(source_row, count, source_parent);
+ }
+ // remove corresponding source intervals
+ // ### if this proves to be slow, we can switch to single-row removal
+ QVector<int> rows;
+ for (int i = row; i < row + count; ++i)
+ rows.append(m->source_rows.at(i));
+ qSort(rows.begin(), rows.end());
+
+ int pos = rows.count() - 1;
+ bool ok = true;
+ while (pos >= 0) {
+ const int source_end = rows.at(pos--);
+ int source_start = source_end;
+ while ((pos >= 0) && (rows.at(pos) == (source_start - 1))) {
+ --source_start;
+ --pos;
+ }
+ ok = ok && d->model->removeRows(source_start, source_end - source_start + 1,
+ source_parent);
+ }
+ return ok;
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::removeColumns(int column, int count, const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ if (column < 0 || count <= 0)
+ return false;
+ QModelIndex source_parent = mapToSource(parent);
+ if (parent.isValid() && !source_parent.isValid())
+ return false;
+ QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
+ if (column + count > m->source_columns.count())
+ return false;
+ if ((count == 1) || (m->proxy_columns.count() == m->source_columns.count())) {
+ int source_column = m->source_columns.at(column);
+ return d->model->removeColumns(source_column, count, source_parent);
+ }
+ // remove corresponding source intervals
+ QVector<int> columns;
+ for (int i = column; i < column + count; ++i)
+ columns.append(m->source_columns.at(i));
+
+ int pos = columns.count() - 1;
+ bool ok = true;
+ while (pos >= 0) {
+ const int source_end = columns.at(pos--);
+ int source_start = source_end;
+ while ((pos >= 0) && (columns.at(pos) == (source_start - 1))) {
+ --source_start;
+ --pos;
+ }
+ ok = ok && d->model->removeColumns(source_start, source_end - source_start + 1,
+ source_parent);
+ }
+ return ok;
+}
+
+/*!
+ \reimp
+*/
+void QSortFilterProxyModel::fetchMore(const QModelIndex &parent)
+{
+ Q_D(QSortFilterProxyModel);
+ QModelIndex source_parent;
+ if (d->indexValid(parent))
+ source_parent = mapToSource(parent);
+ d->model->fetchMore(source_parent);
+}
+
+/*!
+ \reimp
+*/
+bool QSortFilterProxyModel::canFetchMore(const QModelIndex &parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_parent;
+ if (d->indexValid(parent))
+ source_parent = mapToSource(parent);
+ return d->model->canFetchMore(source_parent);
+}
+
+/*!
+ \reimp
+*/
+Qt::ItemFlags QSortFilterProxyModel::flags(const QModelIndex &index) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_index;
+ if (d->indexValid(index))
+ source_index = mapToSource(index);
+ return d->model->flags(source_index);
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QSortFilterProxyModel::buddy(const QModelIndex &index) const
+{
+ Q_D(const QSortFilterProxyModel);
+ if (!d->indexValid(index))
+ return QModelIndex();
+ QModelIndex source_index = mapToSource(index);
+ QModelIndex source_buddy = d->model->buddy(source_index);
+ if (source_index == source_buddy)
+ return index;
+ return mapFromSource(source_buddy);
+}
+
+/*!
+ \reimp
+*/
+QModelIndexList QSortFilterProxyModel::match(const QModelIndex &start, int role,
+ const QVariant &value, int hits,
+ Qt::MatchFlags flags) const
+{
+ return QAbstractProxyModel::match(start, role, value, hits, flags);
+}
+
+/*!
+ \reimp
+*/
+QSize QSortFilterProxyModel::span(const QModelIndex &index) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QModelIndex source_index = mapToSource(index);
+ if (index.isValid() && !source_index.isValid())
+ return QSize();
+ return d->model->span(source_index);
+}
+
+/*!
+ \reimp
+*/
+void QSortFilterProxyModel::sort(int column, Qt::SortOrder order)
+{
+ Q_D(QSortFilterProxyModel);
+ if (d->dynamic_sortfilter && d->proxy_sort_column == column && d->sort_order == order)
+ return;
+ d->sort_order = order;
+ d->proxy_sort_column = column;
+ d->update_source_sort_column();
+ d->sort();
+}
+
+/*!
+ \since 4.5
+ \brief the column currently used for sorting
+
+ This returns the most recently used sort column.
+*/
+int QSortFilterProxyModel::sortColumn() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->proxy_sort_column;
+}
+
+/*!
+ \since 4.5
+ \brief the order currently used for sorting
+
+ This returns the most recently used sort order.
+*/
+Qt::SortOrder QSortFilterProxyModel::sortOrder() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->sort_order;
+}
+
+/*!
+ \property QSortFilterProxyModel::filterRegExp
+ \brief the QRegExp used to filter the contents of the source model
+
+ Setting this property overwrites the current
+ \l{QSortFilterProxyModel::filterCaseSensitivity}{filterCaseSensitivity}.
+ By default, the QRegExp is an empty string matching all contents.
+
+ If no QRegExp or an empty string is set, everything in the source model
+ will be accepted.
+
+ \sa filterCaseSensitivity, setFilterWildcard(), setFilterFixedString()
+*/
+QRegExp QSortFilterProxyModel::filterRegExp() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->filter_regexp;
+}
+
+void QSortFilterProxyModel::setFilterRegExp(const QRegExp &regExp)
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_regexp = regExp;
+ d->filter_changed();
+}
+
+/*!
+ \property QSortFilterProxyModel::filterKeyColumn
+ \brief the column where the key used to filter the contents of the
+ source model is read from.
+
+ The default value is 0. If the value is -1, the keys will be read
+ from all columns.
+*/
+int QSortFilterProxyModel::filterKeyColumn() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->filter_column;
+}
+
+void QSortFilterProxyModel::setFilterKeyColumn(int column)
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_column = column;
+ d->filter_changed();
+}
+
+/*!
+ \property QSortFilterProxyModel::filterCaseSensitivity
+
+ \brief the case sensitivity of the QRegExp pattern used to filter the
+ contents of the source model
+
+ By default, the filter is case sensitive.
+
+ \sa filterRegExp, sortCaseSensitivity
+*/
+Qt::CaseSensitivity QSortFilterProxyModel::filterCaseSensitivity() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->filter_regexp.caseSensitivity();
+}
+
+void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
+{
+ Q_D(QSortFilterProxyModel);
+ if (cs == d->filter_regexp.caseSensitivity())
+ return;
+ d->filter_regexp.setCaseSensitivity(cs);
+ d->filter_changed();
+}
+
+/*!
+ \since 4.2
+ \property QSortFilterProxyModel::sortCaseSensitivity
+ \brief the case sensitivity setting used for comparing strings when sorting
+
+ By default, sorting is case sensitive.
+
+ \sa filterCaseSensitivity, lessThan()
+*/
+Qt::CaseSensitivity QSortFilterProxyModel::sortCaseSensitivity() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->sort_casesensitivity;
+}
+
+void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs)
+{
+ Q_D(QSortFilterProxyModel);
+ if (d->sort_casesensitivity == cs)
+ return;
+
+ d->sort_casesensitivity = cs;
+ d->sort();
+}
+
+/*!
+ \since 4.3
+ \property QSortFilterProxyModel::isSortLocaleAware
+ \brief the local aware setting used for comparing strings when sorting
+
+ By default, sorting is not local aware.
+
+ \sa sortCaseSensitivity, lessThan()
+*/
+bool QSortFilterProxyModel::isSortLocaleAware() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->sort_localeaware;
+}
+
+void QSortFilterProxyModel::setSortLocaleAware(bool on)
+{
+ Q_D(QSortFilterProxyModel);
+ if (d->sort_localeaware == on)
+ return;
+
+ d->sort_localeaware = on;
+ d->sort();
+}
+
+/*!
+ \overload
+
+ Sets the regular expression used to filter the contents
+ of the source model to \a pattern.
+
+ \sa setFilterCaseSensitivity(), setFilterWildcard(), setFilterFixedString(), filterRegExp()
+*/
+void QSortFilterProxyModel::setFilterRegExp(const QString &pattern)
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_regexp.setPatternSyntax(QRegExp::RegExp);
+ d->filter_regexp.setPattern(pattern);
+ d->filter_changed();
+}
+
+/*!
+ Sets the wildcard expression used to filter the contents
+ of the source model to the given \a pattern.
+
+ \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterFixedString(), filterRegExp()
+*/
+void QSortFilterProxyModel::setFilterWildcard(const QString &pattern)
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_regexp.setPatternSyntax(QRegExp::Wildcard);
+ d->filter_regexp.setPattern(pattern);
+ d->filter_changed();
+}
+
+/*!
+ Sets the fixed string used to filter the contents
+ of the source model to the given \a pattern.
+
+ \sa setFilterCaseSensitivity(), setFilterRegExp(), setFilterWildcard(), filterRegExp()
+*/
+void QSortFilterProxyModel::setFilterFixedString(const QString &pattern)
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_regexp.setPatternSyntax(QRegExp::FixedString);
+ d->filter_regexp.setPattern(pattern);
+ d->filter_changed();
+}
+
+/*!
+ \since 4.2
+ \property QSortFilterProxyModel::dynamicSortFilter
+ \brief whether the proxy model is dynamically sorted and filtered
+ whenever the contents of the source model change
+
+ Note that you should not update the source model through the proxy
+ model when dynamicSortFilter is true. For instance, if you set the
+ proxy model on a QComboBox, then using functions that update the
+ model, e.g., \l{QComboBox::}{addItem()}, will not work as
+ expected. An alternative is to set dynamicSortFilter to false and
+ call \l{QSortFilterProxyModel::}{sort()} after adding items to the
+ QComboBox.
+
+ The default value is true.
+*/
+bool QSortFilterProxyModel::dynamicSortFilter() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->dynamic_sortfilter;
+}
+
+void QSortFilterProxyModel::setDynamicSortFilter(bool enable)
+{
+ Q_D(QSortFilterProxyModel);
+ d->dynamic_sortfilter = enable;
+ if (enable)
+ d->sort();
+}
+
+/*!
+ \since 4.2
+ \property QSortFilterProxyModel::sortRole
+ \brief the item role that is used to query the source model's data when sorting items
+
+ The default value is Qt::DisplayRole.
+
+ \sa lessThan()
+*/
+int QSortFilterProxyModel::sortRole() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->sort_role;
+}
+
+void QSortFilterProxyModel::setSortRole(int role)
+{
+ Q_D(QSortFilterProxyModel);
+ if (d->sort_role == role)
+ return;
+ d->sort_role = role;
+ d->sort();
+}
+
+/*!
+ \since 4.2
+ \property QSortFilterProxyModel::filterRole
+ \brief the item role that is used to query the source model's data when filtering items
+
+ The default value is Qt::DisplayRole.
+
+ \sa filterAcceptsRow()
+*/
+int QSortFilterProxyModel::filterRole() const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->filter_role;
+}
+
+void QSortFilterProxyModel::setFilterRole(int role)
+{
+ Q_D(QSortFilterProxyModel);
+ if (d->filter_role == role)
+ return;
+ d->filter_role = role;
+ d->filter_changed();
+}
+
+/*!
+ \obsolete
+
+ This function is obsolete. Use invalidate() instead.
+*/
+void QSortFilterProxyModel::clear()
+{
+ Q_D(QSortFilterProxyModel);
+ emit layoutAboutToBeChanged();
+ d->_q_clearMapping();
+ emit layoutChanged();
+}
+
+/*!
+ \since 4.3
+
+ Invalidates the current sorting and filtering.
+
+ \sa invalidateFilter()
+*/
+void QSortFilterProxyModel::invalidate()
+{
+ Q_D(QSortFilterProxyModel);
+ emit layoutAboutToBeChanged();
+ d->_q_clearMapping();
+ emit layoutChanged();
+}
+
+/*!
+ \obsolete
+
+ This function is obsolete. Use invalidateFilter() instead.
+*/
+void QSortFilterProxyModel::filterChanged()
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_changed();
+}
+
+/*!
+ \since 4.3
+
+ Invalidates the current filtering.
+
+ This function should be called if you are implementing custom filtering
+ (e.g. filterAcceptsRow()), and your filter parameters have changed.
+
+ \sa invalidate()
+*/
+void QSortFilterProxyModel::invalidateFilter()
+{
+ Q_D(QSortFilterProxyModel);
+ d->filter_changed();
+}
+
+/*!
+ Returns true if the value of the item referred to by the given
+ index \a left is less than the value of the item referred to by
+ the given index \a right, otherwise returns false.
+
+ This function is used as the < operator when sorting, and handles
+ the following QVariant types:
+
+ \list
+ \o QVariant::Int
+ \o QVariant::UInt
+ \o QVariant::LongLong
+ \o QVariant::ULongLong
+ \o QVariant::Double
+ \o QVariant::Char
+ \o QVariant::Date
+ \o QVariant::Time
+ \o QVariant::DateTime
+ \o QVariant::String
+ \endlist
+
+ Any other type will be converted to a QString using
+ QVariant::toString().
+
+ Comparison of \l{QString}s is case sensitive by default; this can
+ be changed using the \l {QSortFilterProxyModel::sortCaseSensitivity}
+ {sortCaseSensitivity} property.
+
+ By default, the Qt::DisplayRole associated with the
+ \l{QModelIndex}es is used for comparisons. This can be changed by
+ setting the \l {QSortFilterProxyModel::sortRole} {sortRole} property.
+
+ \note The indices passed in correspond to the source model.
+
+ \sa sortRole, sortCaseSensitivity, dynamicSortFilter
+*/
+bool QSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+{
+ Q_D(const QSortFilterProxyModel);
+ QVariant l = (left.model() ? left.model()->data(left, d->sort_role) : QVariant());
+ QVariant r = (right.model() ? right.model()->data(right, d->sort_role) : QVariant());
+ switch (l.userType()) {
+ case QVariant::Invalid:
+ return (r.type() != QVariant::Invalid);
+ case QVariant::Int:
+ return l.toInt() < r.toInt();
+ case QVariant::UInt:
+ return l.toUInt() < r.toUInt();
+ case QVariant::LongLong:
+ return l.toLongLong() < r.toLongLong();
+ case QVariant::ULongLong:
+ return l.toULongLong() < r.toULongLong();
+ case QMetaType::Float:
+ return l.toFloat() < r.toFloat();
+ case QVariant::Double:
+ return l.toDouble() < r.toDouble();
+ case QVariant::Char:
+ return l.toChar() < r.toChar();
+ case QVariant::Date:
+ return l.toDate() < r.toDate();
+ case QVariant::Time:
+ return l.toTime() < r.toTime();
+ case QVariant::DateTime:
+ return l.toDateTime() < r.toDateTime();
+ case QVariant::String:
+ default:
+ if (d->sort_localeaware)
+ return l.toString().localeAwareCompare(r.toString()) < 0;
+ else
+ return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0;
+ }
+ return false;
+}
+
+/*!
+ Returns true if the item in the row indicated by the given \a source_row
+ and \a source_parent should be included in the model; otherwise returns
+ false.
+
+ The default implementation returns true if the value held by the relevant item
+ matches the filter string, wildcard string or regular expression.
+
+ \note By default, the Qt::DisplayRole is used to determine if the row
+ should be accepted or not. This can be changed by setting the
+ \l{QSortFilterProxyModel::filterRole}{filterRole} property.
+
+ \sa filterAcceptsColumn(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard()
+*/
+bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+{
+ Q_D(const QSortFilterProxyModel);
+ if (d->filter_regexp.isEmpty())
+ return true;
+ if (d->filter_column == -1) {
+ int column_count = d->model->columnCount(source_parent);
+ for (int column = 0; column < column_count; ++column) {
+ QModelIndex source_index = d->model->index(source_row, column, source_parent);
+ QString key = d->model->data(source_index, d->filter_role).toString();
+ if (key.contains(d->filter_regexp))
+ return true;
+ }
+ return false;
+ }
+ QModelIndex source_index = d->model->index(source_row, d->filter_column, source_parent);
+ if (!source_index.isValid()) // the column may not exist
+ return true;
+ QString key = d->model->data(source_index, d->filter_role).toString();
+ return key.contains(d->filter_regexp);
+}
+
+/*!
+ Returns true if the item in the column indicated by the given \a source_column
+ and \a source_parent should be included in the model; otherwise returns false.
+
+ The default implementation returns true if the value held by the relevant item
+ matches the filter string, wildcard string or regular expression.
+
+ \note By default, the Qt::DisplayRole is used to determine if the row
+ should be accepted or not. This can be changed by setting the \l
+ filterRole property.
+
+ \sa filterAcceptsRow(), setFilterFixedString(), setFilterRegExp(), setFilterWildcard()
+*/
+bool QSortFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const
+{
+ Q_UNUSED(source_column);
+ Q_UNUSED(source_parent);
+ return true;
+}
+
+/*!
+ Returns the source model index corresponding to the given \a
+ proxyIndex from the sorting filter model.
+
+ \sa mapFromSource()
+*/
+QModelIndex QSortFilterProxyModel::mapToSource(const QModelIndex &proxyIndex) const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->proxy_to_source(proxyIndex);
+}
+
+/*!
+ Returns the model index in the QSortFilterProxyModel given the \a
+ sourceIndex from the source model.
+
+ \sa mapToSource()
+*/
+QModelIndex QSortFilterProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
+{
+ Q_D(const QSortFilterProxyModel);
+ return d->source_to_proxy(sourceIndex);
+}
+
+/*!
+ \reimp
+*/
+QItemSelection QSortFilterProxyModel::mapSelectionToSource(const QItemSelection &proxySelection) const
+{
+ return QAbstractProxyModel::mapSelectionToSource(proxySelection);
+}
+
+/*!
+ \reimp
+*/
+QItemSelection QSortFilterProxyModel::mapSelectionFromSource(const QItemSelection &sourceSelection) const
+{
+ return QAbstractProxyModel::mapSelectionFromSource(sourceSelection);
+}
+
+/*!
+ \fn QObject *QSortFilterProxyModel::parent() const
+ \internal
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qsortfilterproxymodel.cpp"
+
+#endif // QT_NO_SORTFILTERPROXYMODEL
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h
new file mode 100644
index 0000000000..c8cd581420
--- /dev/null
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.h
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSORTFILTERPROXYMODEL_H
+#define QSORTFILTERPROXYMODEL_H
+
+#include <QtCore/qabstractproxymodel.h>
+
+#ifndef QT_NO_SORTFILTERPROXYMODEL
+
+#include <QtCore/qregexp.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+class QSortFilterProxyModelPrivate;
+class QSortFilterProxyModelLessThan;
+class QSortFilterProxyModelGreaterThan;
+
+class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
+{
+ friend class QSortFilterProxyModelLessThan;
+ friend class QSortFilterProxyModelGreaterThan;
+
+ Q_OBJECT
+ Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
+ Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
+ Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
+ Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
+ Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
+ Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
+ Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
+ Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
+
+public:
+ QSortFilterProxyModel(QObject *parent = 0);
+ ~QSortFilterProxyModel();
+
+ void setSourceModel(QAbstractItemModel *sourceModel);
+
+ QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
+ QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
+
+ QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const;
+ QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const;
+
+ QRegExp filterRegExp() const;
+ void setFilterRegExp(const QRegExp &regExp);
+
+ int filterKeyColumn() const;
+ void setFilterKeyColumn(int column);
+
+ Qt::CaseSensitivity filterCaseSensitivity() const;
+ void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
+
+ Qt::CaseSensitivity sortCaseSensitivity() const;
+ void setSortCaseSensitivity(Qt::CaseSensitivity cs);
+
+ bool isSortLocaleAware() const;
+ void setSortLocaleAware(bool on);
+
+ int sortColumn() const;
+ Qt::SortOrder sortOrder() const;
+
+ bool dynamicSortFilter() const;
+ void setDynamicSortFilter(bool enable);
+
+ int sortRole() const;
+ void setSortRole(int role);
+
+ int filterRole() const;
+ void setFilterRole(int role);
+
+public Q_SLOTS:
+ void setFilterRegExp(const QString &pattern);
+ void setFilterWildcard(const QString &pattern);
+ void setFilterFixedString(const QString &pattern);
+ void clear();
+ void invalidate();
+
+protected:
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+ virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+
+ void filterChanged();
+ void invalidateFilter();
+
+public:
+#ifdef Q_NO_USING_KEYWORD
+ inline QObject *parent() const { return QObject::parent(); }
+#else
+ using QObject::parent;
+#endif
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &child) const;
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ bool setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role = Qt::EditRole);
+
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+
+ void fetchMore(const QModelIndex &parent);
+ bool canFetchMore(const QModelIndex &parent) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ QModelIndex buddy(const QModelIndex &index) const;
+ QModelIndexList match(const QModelIndex &start, int role,
+ const QVariant &value, int hits = 1,
+ Qt::MatchFlags flags =
+ Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+ QSize span(const QModelIndex &index) const;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+private:
+ Q_DECLARE_PRIVATE(QSortFilterProxyModel)
+ Q_DISABLE_COPY(QSortFilterProxyModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_clearMapping())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_SORTFILTERPROXYMODEL
+
+#endif // QSORTFILTERPROXYMODEL_H
diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp
new file mode 100644
index 0000000000..5e72977d20
--- /dev/null
+++ b/src/corelib/itemmodels/qstringlistmodel.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include "qstringlistmodel.h"
+
+#include <QtCore/qvector.h>
+
+#ifndef QT_NO_STRINGLISTMODEL
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QStringListModel
+ \brief The QStringListModel class provides a model that supplies strings to views.
+
+ \ingroup model-view
+ \inmodule QtCore
+
+ QStringListModel is an editable model that can be used for simple
+ cases where you need to display a number of strings in a view
+ widget, such as a QListView or a QComboBox.
+
+ The model provides all the standard functions of an editable
+ model, representing the data in the string list as a model with
+ one column and a number of rows equal to the number of items in
+ the list.
+
+ Model indexes corresponding to items are obtained with the
+ \l{QAbstractListModel::index()}{index()} function, and item flags
+ are obtained with flags(). Item data is read with the data()
+ function and written with setData(). The number of rows (and
+ number of items in the string list) can be found with the
+ rowCount() function.
+
+ The model can be constructed with an existing string list, or
+ strings can be set later with the setStringList() convenience
+ function. Strings can also be inserted in the usual way with the
+ insertRows() function, and removed with removeRows(). The contents
+ of the string list can be retrieved with the stringList()
+ convenience function.
+
+ An example usage of QStringListModel:
+
+ \snippet doc/src/snippets/qstringlistmodel/main.cpp 0
+
+ \sa QAbstractListModel, QAbstractItemModel, {Model Classes}
+*/
+
+/*!
+ Constructs a string list model with the given \a parent.
+*/
+
+QStringListModel::QStringListModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+}
+
+/*!
+ Constructs a string list model containing the specified \a strings
+ with the given \a parent.
+*/
+
+QStringListModel::QStringListModel(const QStringList &strings, QObject *parent)
+ : QAbstractListModel(parent), lst(strings)
+{
+}
+
+/*!
+ Returns the number of rows in the model. This value corresponds to the
+ number of items in the model's internal string list.
+
+ The optional \a parent argument is in most models used to specify
+ the parent of the rows to be counted. Because this is a list if a
+ valid parent is specified, the result will always be 0.
+
+ \sa insertRows(), removeRows(), QAbstractItemModel::rowCount()
+*/
+
+int QStringListModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ return lst.count();
+}
+
+/*!
+ Returns data for the specified \a role, from the item with the
+ given \a index.
+
+ If the view requests an invalid index, an invalid variant is returned.
+
+ \sa setData()
+*/
+
+QVariant QStringListModel::data(const QModelIndex &index, int role) const
+{
+ if (index.row() < 0 || index.row() >= lst.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return lst.at(index.row());
+
+ return QVariant();
+}
+
+/*!
+ Returns the flags for the item with the given \a index.
+
+ Valid items are enabled, selectable, editable, drag enabled and drop enabled.
+
+ \sa QAbstractItemModel::flags()
+*/
+
+Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QAbstractItemModel::flags(index) | Qt::ItemIsDropEnabled;
+
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
+}
+
+/*!
+ Sets the data for the specified \a role in the item with the given
+ \a index in the model, to the provided \a value.
+
+ The dataChanged() signal is emitted if the item is changed.
+
+ \sa Qt::ItemDataRole, data()
+*/
+
+bool QStringListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.row() >= 0 && index.row() < lst.size()
+ && (role == Qt::EditRole || role == Qt::DisplayRole)) {
+ lst.replace(index.row(), value.toString());
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Inserts \a count rows into the model, beginning at the given \a row.
+
+ The \a parent index of the rows is optional and is only used for
+ consistency with QAbstractItemModel. By default, a null index is
+ specified, indicating that the rows are inserted in the top level of
+ the model.
+
+ \sa QAbstractItemModel::insertRows()
+*/
+
+bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ if (count < 1 || row < 0 || row > rowCount(parent))
+ return false;
+
+ beginInsertRows(QModelIndex(), row, row + count - 1);
+
+ for (int r = 0; r < count; ++r)
+ lst.insert(row, QString());
+
+ endInsertRows();
+
+ return true;
+}
+
+/*!
+ Removes \a count rows from the model, beginning at the given \a row.
+
+ The \a parent index of the rows is optional and is only used for
+ consistency with QAbstractItemModel. By default, a null index is
+ specified, indicating that the rows are removed in the top level of
+ the model.
+
+ \sa QAbstractItemModel::removeRows()
+*/
+
+bool QStringListModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ if (count <= 0 || row < 0 || (row + count) > rowCount(parent))
+ return false;
+
+ beginRemoveRows(QModelIndex(), row, row + count - 1);
+
+ for (int r = 0; r < count; ++r)
+ lst.removeAt(row);
+
+ endRemoveRows();
+
+ return true;
+}
+
+static bool ascendingLessThan(const QPair<QString, int> &s1, const QPair<QString, int> &s2)
+{
+ return s1.first < s2.first;
+}
+
+static bool decendingLessThan(const QPair<QString, int> &s1, const QPair<QString, int> &s2)
+{
+ return s1.first > s2.first;
+}
+
+/*!
+ \reimp
+*/
+void QStringListModel::sort(int, Qt::SortOrder order)
+{
+ emit layoutAboutToBeChanged();
+
+ QList<QPair<QString, int> > list;
+ for (int i = 0; i < lst.count(); ++i)
+ list.append(QPair<QString, int>(lst.at(i), i));
+
+ if (order == Qt::AscendingOrder)
+ qSort(list.begin(), list.end(), ascendingLessThan);
+ else
+ qSort(list.begin(), list.end(), decendingLessThan);
+
+ lst.clear();
+ QVector<int> forwarding(list.count());
+ for (int i = 0; i < list.count(); ++i) {
+ lst.append(list.at(i).first);
+ forwarding[list.at(i).second] = i;
+ }
+
+ QModelIndexList oldList = persistentIndexList();
+ QModelIndexList newList;
+ for (int i = 0; i < oldList.count(); ++i)
+ newList.append(index(forwarding.at(oldList.at(i).row()), 0));
+ changePersistentIndexList(oldList, newList);
+
+ emit layoutChanged();
+}
+
+/*!
+ Returns the string list used by the model to store data.
+*/
+QStringList QStringListModel::stringList() const
+{
+ return lst;
+}
+
+/*!
+ Sets the model's internal string list to \a strings. The model will
+ notify any attached views that its underlying data has changed.
+
+ \sa dataChanged()
+*/
+void QStringListModel::setStringList(const QStringList &strings)
+{
+ emit beginResetModel();
+ lst = strings;
+ emit endResetModel();
+}
+
+/*!
+ \reimp
+*/
+Qt::DropActions QStringListModel::supportedDropActions() const
+{
+ return QAbstractItemModel::supportedDropActions() | Qt::MoveAction;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STRINGLISTMODEL
diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h
new file mode 100644
index 0000000000..c70072de9e
--- /dev/null
+++ b/src/corelib/itemmodels/qstringlistmodel.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTRINGLISTMODEL_H
+#define QSTRINGLISTMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+#ifndef QT_NO_STRINGLISTMODEL
+
+class Q_CORE_EXPORT QStringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit QStringListModel(QObject *parent = 0);
+ QStringListModel(const QStringList &strings, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList stringList() const;
+ void setStringList(const QStringList &strings);
+
+ Qt::DropActions supportedDropActions() const;
+
+private:
+ Q_DISABLE_COPY(QStringListModel)
+ QStringList lst;
+};
+
+#endif // QT_NO_STRINGLISTMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTRINGLISTMODEL_H
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 8b69d771b7..1139e3074a 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -2,8 +2,6 @@
HEADERS += \
kernel/qabstracteventdispatcher.h \
- kernel/qabstractitemmodel.h \
- kernel/qabstractitemmodel_p.h \
kernel/qbasictimer.h \
kernel/qeventloop.h\
kernel/qpointer.h \
@@ -42,7 +40,6 @@ HEADERS += \
SOURCES += \
kernel/qabstracteventdispatcher.cpp \
- kernel/qabstractitemmodel.cpp \
kernel/qbasictimer.cpp \
kernel/qeventloop.cpp \
kernel/qcoreapplication.cpp \
@@ -102,46 +99,31 @@ nacl {
kernel/qfunctions_nacl.h
}
-unix:!symbian {
- SOURCES += \
- kernel/qcore_unix.cpp \
- kernel/qcrashhandler.cpp \
- kernel/qsharedmemory_unix.cpp \
- kernel/qsystemsemaphore_unix.cpp
- HEADERS += \
- kernel/qcore_unix_p.h \
- kernel/qcrashhandler_p.h
-
- contains(QT_CONFIG, glib) {
- SOURCES += \
- kernel/qeventdispatcher_glib.cpp
- HEADERS += \
- kernel/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
- }
- SOURCES += \
- kernel/qeventdispatcher_unix.cpp
- HEADERS += \
- kernel/qeventdispatcher_unix_p.h
+unix|integrity {
+ SOURCES += \
+ kernel/qcore_unix.cpp \
+ kernel/qcrashhandler.cpp \
+ kernel/qsharedmemory_unix.cpp \
+ kernel/qsystemsemaphore_unix.cpp \
+ kernel/qeventdispatcher_unix.cpp \
+ kernel/qtimerinfo_unix.cpp
- contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
-}
+ HEADERS += \
+ kernel/qcore_unix_p.h \
+ kernel/qcrashhandler_p.h \
+ kernel/qeventdispatcher_unix_p.h \
+ kernel/qtimerinfo_unix_p.h
-symbian {
+ contains(QT_CONFIG, glib) {
SOURCES += \
- kernel/qcore_unix.cpp \
- kernel/qcrashhandler.cpp \
- kernel/qeventdispatcher_symbian.cpp \
- kernel/qcore_symbian_p.cpp \
- kernel/qsharedmemory_symbian.cpp \
- kernel/qsystemsemaphore_symbian.cpp
-
+ kernel/qeventdispatcher_glib.cpp
HEADERS += \
- kernel/qcore_unix_p.h \
- kernel/qcrashhandler_p.h \
- kernel/qeventdispatcher_symbian_p.h \
- kernel/qcore_symbian_p.h
+ kernel/qeventdispatcher_glib_p.h
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ }
+
+ contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
}
vxworks {
@@ -151,19 +133,3 @@ vxworks {
kernel/qfunctions_vxworks.h
}
-
-integrity {
- SOURCES += \
- kernel/qcore_unix.cpp \
- kernel/qcrashhandler.cpp \
- kernel/qsharedmemory_unix.cpp \
- kernel/qsystemsemaphore_unix.cpp \
- kernel/qeventdispatcher_unix.cpp
- HEADERS += \
- kernel/qcore_unix_p.h \
- kernel/qcrashhandler_p.h \
- kernel/qeventdispatcher_unix_p.h
-
- contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
-}
-
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index b936ac4ed2..1d4bf3cf1f 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -96,7 +96,10 @@ int QAbstractEventDispatcherPrivate::allocateTimerId()
void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId)
{
- timerIdFreeList()->release(timerId);
+ // this function may be called by a global destructor after
+ // timerIdFreeList() has been destructed
+ if (QtTimerIdFreeList *fl = timerIdFreeList())
+ fl->release(timerId);
}
/*!
@@ -230,22 +233,39 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread)
*/
/*!
+ \obsolete
+
\fn int QAbstractEventDispatcher::registerTimer(int interval, QObject *object)
- Registers a timer with the specified \a interval for the given \a object.
+ Registers a timer with the specified \a interval for the given \a object
+ and returns the timer id.
+*/
+
+/*!
+ \obsolete
+
+ \fn void QAbstractEventDispatcher::registerTimer(int timerId, int interval, QObject *object)
+
+ Register a timer with the specified \a timerId and \a interval for the
+ given \a object.
+*/
+
+/*!
+ Registers a timer with the specified \a interval and \a timerType for the
+ given \a object and returns the timer id.
*/
-int QAbstractEventDispatcher::registerTimer(int interval, QObject *object)
+int QAbstractEventDispatcher::registerTimer(int interval, Qt::TimerType timerType, QObject *object)
{
int id = QAbstractEventDispatcherPrivate::allocateTimerId();
- registerTimer(id, interval, object);
+ registerTimer(id, interval, timerType, object);
return id;
}
/*!
- \fn void QAbstractEventDispatcher::registerTimer(int timerId, int interval, QObject *object)
+ \fn void QAbstractEventDispatcher::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
- Register a timer with the specified \a timerId and \a interval for
- the given \a object.
+ Register a timer with the specified \a timerId, \a interval, and \a
+ timerType for the given \a object.
*/
/*!
@@ -269,8 +289,10 @@ int QAbstractEventDispatcher::registerTimer(int interval, QObject *object)
/*!
\fn QList<TimerInfo> QAbstractEventDispatcher::registeredTimers(QObject *object) const
- Returns a list of registered timers for \a object. The timer ID
- is the first member in each pair; the interval is the second.
+ Returns a list of registered timers for \a object. The TimerInfo struct has
+ \c timerId, \c interval, and \c timerType members.
+
+ \sa Qt::TimerType
*/
/*! \fn void QAbstractEventDispatcher::wakeUp()
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index 36bd1be368..80e77c02af 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -53,7 +53,6 @@ QT_MODULE(Core)
class QAbstractEventDispatcherPrivate;
class QSocketNotifier;
-template <typename T1, typename T2> struct QPair;
class Q_CORE_EXPORT QAbstractEventDispatcher : public QObject
{
@@ -61,7 +60,16 @@ class Q_CORE_EXPORT QAbstractEventDispatcher : public QObject
Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
public:
- typedef QPair<int, int> TimerInfo;
+ struct TimerInfo
+ {
+ int timerId;
+ int interval;
+ Qt::TimerType timerType;
+
+ inline TimerInfo(int id, int i, Qt::TimerType t)
+ : timerId(id), interval(i), timerType(t)
+ { }
+ };
explicit QAbstractEventDispatcher(QObject *parent = 0);
~QAbstractEventDispatcher();
@@ -74,8 +82,14 @@ public:
virtual void registerSocketNotifier(QSocketNotifier *notifier) = 0;
virtual void unregisterSocketNotifier(QSocketNotifier *notifier) = 0;
- int registerTimer(int interval, QObject *object);
- virtual void registerTimer(int timerId, int interval, QObject *object) = 0;
+#if QT_DEPRECATED_SINCE(5,0)
+ QT_DEPRECATED inline int registerTimer(int interval, QObject *object)
+ { return registerTimer(interval, Qt::CoarseTimer, object); }
+ QT_DEPRECATED inline void registerTimer(int timerId, int interval, QObject *object)
+ { registerTimer(timerId, interval, Qt::CoarseTimer, object); }
+#endif
+ int registerTimer(int interval, Qt::TimerType timerType, QObject *object);
+ virtual void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) = 0;
virtual bool unregisterTimer(int timerId) = 0;
virtual bool unregisterTimers(QObject *object) = 0;
virtual QList<TimerInfo> registeredTimers(QObject *object) const = 0;
diff --git a/src/corelib/kernel/qabstracteventdispatcher_p.h b/src/corelib/kernel/qabstracteventdispatcher_p.h
index 31c579d865..6e1c81ae33 100644
--- a/src/corelib/kernel/qabstracteventdispatcher_p.h
+++ b/src/corelib/kernel/qabstracteventdispatcher_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp
index 8efeea6fae..a52152875f 100644
--- a/src/corelib/kernel/qbasictimer.cpp
+++ b/src/corelib/kernel/qbasictimer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qbasictimer.h"
-#include "qcoreapplication.h"
#include "qabstracteventdispatcher.h"
+#include "qabstracteventdispatcher_p.h"
QT_BEGIN_NAMESPACE
@@ -106,18 +106,55 @@ QT_BEGIN_NAMESPACE
/*!
\fn void QBasicTimer::start(int msec, QObject *object)
- Starts (or restarts) the timer with a \a msec milliseconds
- timeout.
+ Starts (or restarts) the timer with a \a msec milliseconds timeout. The
+ timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the
+ different timer types.
The given \a object will receive timer events.
- \sa stop() isActive() QObject::timerEvent()
+ \sa stop() isActive() QObject::timerEvent() Qt::CoarseTimer
*/
void QBasicTimer::start(int msec, QObject *obj)
{
- stop();
- if (obj)
- id = obj->startTimer(msec);
+ QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
+ if (!eventDispatcher) {
+ qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
+ return;
+ }
+ if (id) {
+ eventDispatcher->unregisterTimer(id);
+ QAbstractEventDispatcherPrivate::releaseTimerId(id);
+ }
+ id = 0;
+ if (obj)
+ id = eventDispatcher->registerTimer(msec, Qt::CoarseTimer, obj);
+}
+
+/*!
+ \overload
+
+ Starts (or restarts) the timer with a \a msec milliseconds timeout and the
+ given \a timerType. See Qt::TimerType for information on the different
+ timer types.
+
+ The given \a object will receive timer events.
+
+ \sa stop() isActive() QObject::timerEvent() Qt::TimerType
+ */
+void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
+{
+ QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
+ if (!eventDispatcher) {
+ qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
+ return;
+ }
+ if (id) {
+ eventDispatcher->unregisterTimer(id);
+ QAbstractEventDispatcherPrivate::releaseTimerId(id);
+ }
+ id = 0;
+ if (obj)
+ id = eventDispatcher->registerTimer(msec, timerType, obj);
}
/*!
@@ -131,6 +168,7 @@ void QBasicTimer::stop()
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
if (eventDispatcher)
eventDispatcher->unregisterTimer(id);
+ QAbstractEventDispatcherPrivate::releaseTimerId(id);
}
id = 0;
}
diff --git a/src/corelib/kernel/qbasictimer.h b/src/corelib/kernel/qbasictimer.h
index f13848cb85..84b232e766 100644
--- a/src/corelib/kernel/qbasictimer.h
+++ b/src/corelib/kernel/qbasictimer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,6 +43,7 @@
#define QBASICTIMER_H
#include <QtCore/qglobal.h>
+#include <QtCore/qnamespace.h>
QT_BEGIN_HEADER
@@ -63,6 +64,7 @@ public:
inline int timerId() const { return id; }
void start(int msec, QObject *obj);
+ void start(int msec, Qt::TimerType timerType, QObject *obj);
void stop();
};
Q_DECLARE_TYPEINFO(QBasicTimer, Q_MOVABLE_TYPE);
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index 0814c1aec7..88cc83ce48 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index adbad83cad..4efd6bf653 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp
deleted file mode 100644
index 5b52ec22a1..0000000000
--- a/src/corelib/kernel/qcore_symbian_p.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <exception>
-#include <e32base.h>
-#include <e32uid.h>
-#include "qcore_symbian_p.h"
-#include <string>
-#include <in_sock.h>
-
-QT_BEGIN_NAMESPACE
-
-/*
- Helper function for calling into Symbian classes that expect a TDes&.
- This function converts a QString to a TDes by allocating memory that
- must be deleted by the caller.
-*/
-
-Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString)
-{
- HBufC *buffer;
-#ifdef QT_NO_UNICODE
- TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData()));
-#else
- TPtrC16 ptr(qt_QString2TPtrC(aString));
-#endif
- buffer = HBufC::New(ptr.Length());
- Q_CHECK_PTR(buffer);
- buffer->Des().Copy(ptr);
- return buffer;
-}
-
-Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor)
-{
-#ifdef QT_NO_UNICODE
- return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length());
-#else
- return QString(reinterpret_cast<const QChar *>(aDescriptor.Ptr()), aDescriptor.Length());
-#endif
-}
-
-QHBufC::QHBufC()
- : m_hBufC(0)
-{
-}
-
-QHBufC::QHBufC(const QHBufC &src)
- : m_hBufC(src.m_hBufC->Alloc())
-{
- Q_CHECK_PTR(m_hBufC);
-}
-
-/*!
- \internal
- Constructs a QHBufC from an HBufC. Note that the QHBufC instance takes
- ownership of the HBufC.
-*/
-QHBufC::QHBufC(HBufC *src)
- : m_hBufC(src)
-{
-}
-
-QHBufC::QHBufC(const QString &src)
-{
- m_hBufC = qt_QString2HBufC(src);
-}
-
-QHBufC::~QHBufC()
-{
- if (m_hBufC)
- delete m_hBufC;
-}
-
-class QS60PluginResolver
-{
-public:
- QS60PluginResolver()
- : initTried(false) {}
-
- ~QS60PluginResolver() {
- lib.Close();
- }
-
- TLibraryFunction resolve(int ordinal) {
- if (!initTried) {
- init();
- initTried = true;
- }
-
- if (lib.Handle())
- return lib.Lookup(ordinal);
- else
- return reinterpret_cast<TLibraryFunction>(NULL);
- }
-
-private:
- void init()
- {
- _LIT(KLibName_3_1, "qts60plugin_3_1" QT_LIBINFIX_UNICODE L".dll");
- _LIT(KLibName_3_2, "qts60plugin_3_2" QT_LIBINFIX_UNICODE L".dll");
- _LIT(KLibName_5_0, "qts60plugin_5_0" QT_LIBINFIX_UNICODE L".dll");
-
- TPtrC libName;
- TInt uidValue;
- switch (QSysInfo::s60Version()) {
- case QSysInfo::SV_S60_3_1:
- libName.Set(KLibName_3_1);
- uidValue = 0x2001E620;
- break;
- case QSysInfo::SV_S60_3_2:
- libName.Set(KLibName_3_2);
- uidValue = 0x2001E621;
- break;
- case QSysInfo::SV_S60_5_0: // Fall through to default
- default:
- // Default to 5.0 version, as any unknown platform is likely to be newer than that
- libName.Set(KLibName_5_0);
- uidValue = 0x2001E622;
- break;
- }
-
- TUidType libUid(KDynamicLibraryUid, KSharedLibraryUid, TUid::Uid(uidValue));
- lib.Load(libName, libUid);
-
- // Duplicate lib handle to enable process wide access to it. Since Duplicate overwrites
- // existing handle without closing it, store original for subsequent closing.
- RLibrary origHandleCloser = lib;
- lib.Duplicate(RThread(), EOwnerProcess);
- origHandleCloser.Close();
- }
-
- RLibrary lib;
- bool initTried;
-};
-
-Q_GLOBAL_STATIC(QS60PluginResolver, qt_s60_plugin_resolver);
-
-/*!
- \internal
- Resolves a platform version specific function from S60 plugin.
- If plugin is missing or resolving fails for another reason, NULL is returned.
-*/
-Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal)
-{
- return qt_s60_plugin_resolver()->resolve(ordinal);
-}
-
-class QS60RFsSession
-{
-public:
- QS60RFsSession() {
- qt_symbian_throwIfError(iFs.Connect());
- qt_symbian_throwIfError(iFs.ShareProtected());
- }
-
- ~QS60RFsSession() {
- iFs.Close();
- }
-
- RFs& GetRFs() {
- return iFs;
- }
-
-private:
-
- RFs iFs;
-};
-
-uint qHash(const RSubSessionBase& key)
-{
- return qHash(key.SubSessionHandle());
-}
-
-Q_GLOBAL_STATIC(QS60RFsSession, qt_s60_RFsSession);
-
-Q_CORE_EXPORT RFs& qt_s60GetRFs()
-{
- return qt_s60_RFsSession()->GetRFs();
-}
-
-QSymbianSocketManager::QSymbianSocketManager() :
- iNextSocket(0), iDefaultConnection(0)
-{
- TSessionPref preferences;
- // ### In future this could be changed to KAfInet6 when that is more common than IPv4
- preferences.iAddrFamily = KAfInet;
- preferences.iProtocol = KProtocolInetIp;
- //use global message pool, as we do not know how many sockets app will use
- //TODO: is this the right choice?
- qt_symbian_throwIfError(iSocketServ.Connect(preferences, -1));
- qt_symbian_throwIfError(iSocketServ.ShareAuto());
-}
-
-QSymbianSocketManager::~QSymbianSocketManager()
-{
- iSocketServ.Close();
- if(!socketMap.isEmpty()) {
- qWarning("leaked %d sockets on exit", socketMap.count());
- }
-}
-
-RSocketServ& QSymbianSocketManager::getSocketServer() {
- return iSocketServ;
-}
-
-int QSymbianSocketManager::addSocket(const RSocket& socket) {
- QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
- QMutexLocker l(&iMutex);
- Q_ASSERT(!socketMap.contains(sock));
- if(socketMap.contains(sock))
- return socketMap.value(sock);
- // allocate socket number
- int guard = 0;
- while(reverseSocketMap.contains(iNextSocket)) {
- iNextSocket++;
- iNextSocket %= max_sockets;
- guard++;
- if(guard > max_sockets)
- return -1;
- }
- int id = iNextSocket;
-
- socketMap[sock] = id;
- reverseSocketMap[id] = sock;
- return id + socket_offset;
-}
-
-bool QSymbianSocketManager::removeSocket(const RSocket &socket) {
- QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
- QMutexLocker l(&iMutex);
- if(!socketMap.contains(sock))
- return false;
- int id = socketMap.value(sock);
- socketMap.remove(sock);
- reverseSocketMap.remove(id);
- return true;
-}
-
-int QSymbianSocketManager::lookupSocket(const RSocket& socket) const {
- QHashableSocket sock(static_cast<const QHashableSocket &>(socket));
- QMutexLocker l(&iMutex);
- if(!socketMap.contains(sock))
- return -1;
- int id = socketMap.value(sock);
- return id + socket_offset;
-}
-
-bool QSymbianSocketManager::lookupSocket(int fd, RSocket& socket) const {
- QMutexLocker l(&iMutex);
- int id = fd - socket_offset;
- if(!reverseSocketMap.contains(id))
- return false;
- socket = reverseSocketMap.value(id);
- return true;
-}
-
-void QSymbianSocketManager::setDefaultConnection(RConnection* con)
-{
- iDefaultConnection = con;
-}
-
-RConnection* QSymbianSocketManager::defaultConnection() const
-{
- return iDefaultConnection;
-}
-
-Q_GLOBAL_STATIC(QSymbianSocketManager, qt_symbianSocketManager);
-
-QSymbianSocketManager& QSymbianSocketManager::instance()
-{
- return *(qt_symbianSocketManager());
-}
-
-Q_CORE_EXPORT RSocketServ& qt_symbianGetSocketServer()
-{
- return QSymbianSocketManager::instance().getSocketServer();
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h
deleted file mode 100644
index 84c6fed4db..0000000000
--- a/src/corelib/kernel/qcore_symbian_p.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCORE_SYMBIAN_P_H
-#define QCORE_SYMBIAN_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <e32std.h>
-#include <QtCore/qglobal.h>
-#include <QtCore/qmutex.h>
-#include <qstring.h>
-#include <qrect.h>
-#include <qhash.h>
-#include <f32file.h>
-#include <es_sock.h>
-
-#define QT_LSTRING2(x) L##x
-#define QT_LSTRING(x) QT_LSTRING2(x)
-
-#if defined(QT_LIBINFIX)
-# define QT_LIBINFIX_UNICODE QT_LSTRING(QT_LIBINFIX)
-#else
-# define QT_LIBINFIX_UNICODE L""
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-Q_CORE_EXPORT HBufC* qt_QString2HBufC(const QString& aString);
-
-Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor);
-inline QString qt_TDes2QString(const TDes& aDescriptor) { return qt_TDesC2QString(aDescriptor); }
-
-static inline QSize qt_TSize2QSize(const TSize& ts)
-{
- return QSize(ts.iWidth, ts.iHeight);
-}
-
-static inline TSize qt_QSize2TSize(const QSize& qs)
-{
- return TSize(qs.width(), qs.height());
-}
-
-static inline QRect qt_TRect2QRect(const TRect& tr)
-{
- return QRect(tr.iTl.iX, tr.iTl.iY, tr.Width(), tr.Height());
-}
-
-static inline TRect qt_QRect2TRect(const QRect& qr)
-{
- return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height()));
-}
-
-// Returned TPtrC is valid as long as the given parameter is valid and unmodified
-static inline TPtrC qt_QString2TPtrC( const QString& string )
-{
- return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length());
-}
-
-/*!
- \internal
- This class is a wrapper around the Symbian HBufC descriptor class.
- It makes sure that the heap allocated HBufC class is freed when it is
- destroyed.
-*/
-class Q_CORE_EXPORT QHBufC
-{
-public:
- QHBufC();
- QHBufC(const QHBufC &src);
- QHBufC(HBufC *src);
- QHBufC(const QString &src);
- ~QHBufC();
-
- inline operator HBufC *() { return m_hBufC; }
- inline operator const HBufC *() const { return m_hBufC; }
- inline HBufC *data() { return m_hBufC; }
- inline const HBufC *data() const { return m_hBufC; }
- inline HBufC & operator*() { return *m_hBufC; }
- inline const HBufC & operator*() const { return *m_hBufC; }
- inline HBufC * operator->() { return m_hBufC; }
- inline const HBufC * operator->() const { return m_hBufC; }
-
- inline bool operator==(const QHBufC &param) const { return data() == param.data(); }
- inline bool operator!=(const QHBufC &param) const { return data() != param.data(); }
-
-private:
- HBufC *m_hBufC;
-};
-
-inline uint qHash(TUid uid)
-{
- return qHash(uid.iUid);
-}
-
-// S60 version specific function ordinals that can be resolved
-enum S60PluginFuncOrdinals
-{
- S60Plugin_TimeFormatL = 1,
- S60Plugin_GetTimeFormatSpec = 2,
- S60Plugin_GetLongDateFormatSpec = 3,
- S60Plugin_GetShortDateFormatSpec = 4,
- S60Plugin_LocalizedDirectoryName = 5,
- S60Plugin_GetSystemDrive = 6
-};
-
-Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal);
-
-Q_CORE_EXPORT RFs& qt_s60GetRFs();
-Q_CORE_EXPORT RSocketServ& qt_symbianGetSocketServer();
-
-// Defined in qlocale_symbian.cpp.
-Q_CORE_EXPORT QByteArray qt_symbianLocaleName(int code);
-
-template <typename R>
-struct QScopedPointerRCloser
-{
- static inline void cleanup(R *rPointer)
- {
- // Enforce a complete type.
- // If you get a compile error here, read the section on forward declared
- // classes in the QScopedPointer documentation.
- typedef char IsIncompleteType[ sizeof(R) ? 1 : -1 ];
- (void) sizeof(IsIncompleteType);
-
- if (rPointer)
- rPointer->Close();
- }
-};
-
-//Wrapper for RSocket so it can be used as a key in QHash or QMap
-class QHashableSocket : public RSocket
-{
-public:
- bool operator==(const QHashableSocket &other) const
- {
- return SubSessionHandle() == other.SubSessionHandle()
- && Session().Handle() == other.Session().Handle();
- }
- bool operator<(const QHashableSocket &other) const
- {
- if (Session().Handle() == other.Session().Handle())
- return SubSessionHandle() < other.SubSessionHandle();
- return Session().Handle() < other.Session().Handle();
- }
-};
-
-uint qHash(const RSubSessionBase& key);
-
-/*!
- \internal
- This class exists in QtCore for the benefit of QSocketNotifier, which uses integer
- file descriptors in its public API.
- So we need a way to map between int and RSocket.
- Additionally, it is used to host the global RSocketServ session
-*/
-class Q_CORE_EXPORT QSymbianSocketManager
-{
-public:
- QSymbianSocketManager();
- ~QSymbianSocketManager();
-
- /*!
- \internal
- \return handle to the socket server
- */
- RSocketServ& getSocketServer();
- /*!
- \internal
- Adds a symbian socket to the global map
- \param an open socket
- \return pseudo file descriptor, -1 if out of resources
- */
- int addSocket(const RSocket &sock);
- /*!
- \internal
- Removes a symbian socket from the global map
- \param an open socket
- \return true if the socket was in the map
- */
- bool removeSocket(const RSocket &sock);
- /*!
- \internal
- Get pseudo file descriptor for a socket
- \param an open socket
- \return integer handle, or -1 if not in map
- */
- int lookupSocket(const RSocket &sock) const;
- /*!
- \internal
- Get socket for a pseudo file descriptor
- \param an open socket fd
- \param sock (out) socket handle
- \return true on success or false if not in map
- */
- bool lookupSocket(int fd, RSocket& sock) const;
-
- /*!
- \internal
- Set the default connection to use for new sockets
- \param an open connection
- */
- void setDefaultConnection(RConnection* con);
- /*!
- \internal
- Get the default connection to use for new sockets
- \return the connection, or null pointer if there is none set
- */
- RConnection *defaultConnection() const;
-
- /*!
- \internal
- Gets a reference to the singleton socket manager
- */
- static QSymbianSocketManager& instance();
-private:
- int allocateSocket();
-
- const static int max_sockets = 0x20000; //covers all TCP and UDP ports, probably run out of memory first
- const static int socket_offset = 0x40000000; //hacky way of separating sockets from file descriptors
- int iNextSocket;
- QHash<QHashableSocket, int> socketMap;
- QHash<int, RSocket> reverseSocketMap;
- mutable QMutex iMutex;
- RSocketServ iSocketServ;
- RConnection *iDefaultConnection;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QCORE_SYMBIAN_P_H
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index f30fceeb68..08a2f69bf3 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index e7259d29c9..9ac4f5c480 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 7ff82b1bca..05f26cc87f 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -143,7 +143,7 @@ static inline void qt_init_symbian_apa_arguments(int &argc, char **&argv)
TPtrC8 apaCmdLine = commandLine->TailEnd();
int tailLen = apaCmdLine.Length();
if (tailLen) {
- apaTail = reinterpret_cast<char *>(qMalloc(tailLen + 1));
+ apaTail = reinterpret_cast<char *>(malloc(tailLen + 1));
qMemCopy(apaTail, reinterpret_cast<const char *>(apaCmdLine.Ptr()), tailLen);
apaTail[tailLen] = '\0';
apaArgv = new QVector<char *>(8);
@@ -300,7 +300,7 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount()
QCoreApplication *QCoreApplication::self = 0;
QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0;
-uint QCoreApplicationPrivate::attribs;
+uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents);
#ifdef Q_OS_UNIX
Qt::HANDLE qt_application_thread_id = 0;
@@ -802,26 +802,7 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event)
QObjectPrivate *d = receiver->d_func();
QThreadData *threadData = d->threadData;
QScopedLoopLevelCounter loopLevelCounter(threadData);
-
-#ifdef QT_JAMBI_BUILD
- int deleteWatch = 0;
- int *oldDeleteWatch = QObjectPrivate::setDeleteWatch(d, &deleteWatch);
-
- bool inEvent = d->inEventHandler;
- d->inEventHandler = true;
-#endif
-
- bool returnValue;
- returnValue = notify(receiver, event);
-
-#ifdef QT_JAMBI_BUILD
- // Restore the previous state if the object was not deleted..
- if (!deleteWatch) {
- d->inEventHandler = inEvent;
- }
- QObjectPrivate::resetDeleteWatch(d, oldDeleteWatch, deleteWatch);
-#endif
- return returnValue;
+ return notify(receiver, event);
}
@@ -1424,9 +1405,18 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
if (!allowDeferredDelete) {
// cannot send deferred delete
if (!event_type && !receiver) {
- // don't lose the event
- data->postEventList.addEvent(pe);
+ // we must copy it first; we want to re-post the event
+ // with the event pointer intact, but we can't delay
+ // nulling the event ptr until after re-posting, as
+ // addEvent may invalidate pe.
+ QPostEvent pe_copy = pe;
+
+ // null out the event so if sendPostedEvents recurses, it
+ // will ignore this one, as it's been re-posted.
const_cast<QPostEvent &>(pe).event = 0;
+
+ // re-post the copied event so it isn't lost
+ data->postEventList.addEvent(pe_copy);
}
continue;
}
@@ -1528,7 +1518,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
const_cast<QPostEvent &>(pe).event = 0;
} else if (!data->postEventList.recursion) {
if (i != j)
- data->postEventList.swap(i, j);
+ qSwap(data->postEventList[i], data->postEventList[j]);
++j;
}
}
@@ -1842,9 +1832,9 @@ bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator)
/*!
Returns the directory that contains the application executable.
- For example, if you have installed Qt in the \c{C:\Trolltech\Qt}
+ For example, if you have installed Qt in the \c{C:\Qt}
directory, and you run the \c{regexp} example, this function will
- return "C:/Trolltech/Qt/examples/tools/regexp".
+ return "C:/Qt/examples/tools/regexp".
On Mac OS X this will point to the directory actually containing the
executable, which may be inside of an application bundle (if the
@@ -2587,6 +2577,14 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
\sa Q_OBJECT, QObject::tr(), QObject::trUtf8()
*/
+/*!
+ \enum QCoreApplication::Type
+
+ \value Tty a console application
+ \value GuiClient a GUI application
+ \value GuiServer \e{Deprecated.} this value is only left for compatibility.
+*/
+
QT_END_NAMESPACE
#include "moc_qcoreapplication.cpp"
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 3d6aa170fd..abbc6e5821 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -78,6 +78,12 @@ public:
enum { ApplicationFlags = QT_VERSION
};
+ enum Type {
+ Tty,
+ GuiClient,
+ GuiServer // # deprecated
+ };
+
QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
~QCoreApplication();
diff --git a/src/corelib/kernel/qcoreapplication_mac.cpp b/src/corelib/kernel/qcoreapplication_mac.cpp
index 8fec4bfcb2..289c2f4bdb 100644
--- a/src/corelib/kernel/qcoreapplication_mac.cpp
+++ b/src/corelib/kernel/qcoreapplication_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index d61a5a1bf5..692e460114 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 1b51e6f568..3cba628a41 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 2081d5cc17..937c9898cd 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 213f0e4a58..bf8207283b 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -108,7 +108,6 @@ QT_BEGIN_NAMESPACE
\value ApplicationPaletteChange The default application palette has changed.
\value ApplicationWindowIconChange The application's icon has changed.
\value ChildAdded An object gets a child (QChildEvent).
- \value ChildInserted An object gets a child (QChildEvent). Qt3Support only, use ChildAdded instead.
\value ChildPolished A widget child gets polished (QChildEvent).
\value ChildRemoved An object loses a child (QChildEvent).
\value Clipboard The clipboard contents have changed (QClipboardEvent).
@@ -252,8 +251,6 @@ QT_BEGIN_NAMESPACE
\omitvalue AcceptDropsChange
\omitvalue ActivateControl
\omitvalue CaptionChange
- \omitvalue ChildInsertedRequest
- \omitvalue ChildInserted
\omitvalue Create
\omitvalue DeactivateControl
\omitvalue Destroy
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index ba1106276a..cbdf13c992 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -185,9 +185,6 @@ public:
HoverLeave = 128, // mouse cursor leaves a hover widget
HoverMove = 129, // mouse cursor move inside a hover widget
- AccessibilityHelp = 119, // accessibility help text request
- AccessibilityDescription = 130, // accessibility description text request
-
// last event id used = 132
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp
index bac95251fd..3854f7d53a 100644
--- a/src/corelib/kernel/qcoreglobaldata.cpp
+++ b/src/corelib/kernel/qcoreglobaldata.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h
index f12d42842b..7b5120a0dc 100644
--- a/src/corelib/kernel/qcoreglobaldata_p.h
+++ b/src/corelib/kernel/qcoreglobaldata_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcrashhandler.cpp b/src/corelib/kernel/qcrashhandler.cpp
index 979e215997..8f4577be24 100644
--- a/src/corelib/kernel/qcrashhandler.cpp
+++ b/src/corelib/kernel/qcrashhandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qcrashhandler_p.h b/src/corelib/kernel/qcrashhandler_p.h
index 2383bb9dcc..a23dc98967 100644
--- a/src/corelib/kernel/qcrashhandler_p.h
+++ b/src/corelib/kernel/qcrashhandler_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 0773915391..f34570007b 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -509,7 +509,7 @@ void QEventDispatcherGlib::unregisterSocketNotifier(QSocketNotifier *notifier)
}
}
-void QEventDispatcherGlib::registerTimer(int timerId, int interval, QObject *object)
+void QEventDispatcherGlib::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
{
#ifndef QT_NO_DEBUG
if (timerId < 1 || interval < 0 || !object) {
@@ -522,7 +522,7 @@ void QEventDispatcherGlib::registerTimer(int timerId, int interval, QObject *obj
#endif
Q_D(QEventDispatcherGlib);
- d->timerSource->timerList.registerTimer(timerId, interval, object);
+ d->timerSource->timerList.registerTimer(timerId, interval, timerType, object);
}
bool QEventDispatcherGlib::unregisterTimer(int timerId)
diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h
index 419f2f3dc0..facacb07a8 100644
--- a/src/corelib/kernel/qeventdispatcher_glib_p.h
+++ b/src/corelib/kernel/qeventdispatcher_glib_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -80,7 +80,7 @@ public:
void registerSocketNotifier(QSocketNotifier *socketNotifier);
void unregisterSocketNotifier(QSocketNotifier *socketNotifier);
- void registerTimer(int timerId, int interval, QObject *object);
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
bool unregisterTimer(int timerId);
bool unregisterTimers(QObject *object);
QList<TimerInfo> registeredTimers(QObject *object) const;
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
deleted file mode 100644
index 1d7ecce9ae..0000000000
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ /dev/null
@@ -1,1316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeventdispatcher_symbian_p.h"
-#include <private/qthread_p.h>
-#include <qcoreapplication.h>
-#include <private/qcoreapplication_p.h>
-#include <qsemaphore.h>
-
-#include <unistd.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
-// when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed.
-#undef QT_SYMBIAN_PRIORITY_DROP
-#else
-#define QT_SYMBIAN_PRIORITY_DROP
-#endif
-
-#define WAKE_UP_PRIORITY CActive::EPriorityStandard
-#define TIMER_PRIORITY CActive::EPriorityHigh
-#define NULLTIMER_PRIORITY CActive::EPriorityLow
-#define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle
-
-static inline int qt_pipe_write(int socket, const char *data, qint64 len)
-{
- return ::write(socket, data, len);
-}
-#if defined(write)
-# undef write
-#endif
-
-static inline int qt_pipe_close(int socket)
-{
- return ::close(socket);
-}
-#if defined(close)
-# undef close
-#endif
-
-static inline int qt_pipe_fcntl(int socket, int command)
-{
- return ::fcntl(socket, command);
-}
-static inline int qt_pipe2_fcntl(int socket, int command, int option)
-{
- return ::fcntl(socket, command, option);
-}
-#if defined(fcntl)
-# undef fcntl
-#endif
-
-static inline int qt_socket_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
-{
- return ::select(nfds, readfds, writefds, exceptfds, timeout);
-}
-
-// This simply interrupts the select and locks the mutex until destroyed.
-class QSelectMutexGrabber
-{
-public:
- QSelectMutexGrabber(int writeFd, int readFd, QMutex *mutex)
- : m_mutex(mutex)
- {
- if (m_mutex->tryLock())
- return;
-
- char dummy = 0;
- qt_pipe_write(writeFd, &dummy, 1);
-
- m_mutex->lock();
-
- char buffer;
- while (::read(readFd, &buffer, 1) > 0) {}
- }
-
- ~QSelectMutexGrabber()
- {
- m_mutex->unlock();
- }
-
-private:
- QMutex *m_mutex;
-};
-
-/*
- * This class is designed to aid in implementing event handling in a more round robin fashion. We
- * cannot change active objects that we do not own, but the active objects that Qt owns will use
- * this as a base class with convenience functions.
- *
- * Here is how it works: On every RunL, the deriving class should call maybeQueueForLater().
- * This will return whether the active object has been queued, or whether it should run immediately.
- * Queued objects will run again after other events have been processed.
- *
- * The QCompleteDeferredAOs class is a special object that runs after all others, which will
- * reactivate the objects that were previously not run.
- */
-QActiveObject::QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher)
- : CActive(priority),
- m_dispatcher(dispatcher),
- m_hasAlreadyRun(false),
- m_hasRunAgain(false),
- m_iterationCount(1)
-{
-}
-
-QActiveObject::~QActiveObject()
-{
- if (m_hasRunAgain)
- m_dispatcher->removeDeferredActiveObject(this);
-}
-
-bool QActiveObject::maybeQueueForLater()
-{
- Q_ASSERT(!m_hasRunAgain);
-
- if (!m_hasAlreadyRun || m_dispatcher->iterationCount() != m_iterationCount) {
- // First occurrence of this event in this iteration.
- m_hasAlreadyRun = true;
- m_iterationCount = m_dispatcher->iterationCount();
- return false;
- } else {
- // The event has already occurred.
- m_dispatcher->addDeferredActiveObject(this);
- m_hasRunAgain = true;
- return true;
- }
-}
-
-bool QActiveObject::maybeDeferSocketEvent()
-{
- Q_ASSERT(!m_hasRunAgain);
- Q_ASSERT(m_dispatcher);
- if (!m_dispatcher->areSocketEventsBlocked()) {
- return false;
- }
- m_hasRunAgain = true;
- m_dispatcher->addDeferredSocketActiveObject(this);
- return true;
-}
-
-void QActiveObject::reactivateAndComplete()
-{
- TInt error = iStatus.Int();
- iStatus = KRequestPending;
- SetActive();
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, error);
-
- m_hasRunAgain = false;
- m_hasAlreadyRun = false;
-}
-
-QWakeUpActiveObject::QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher)
- : QActiveObject(WAKE_UP_PRIORITY, dispatcher)
-{
- m_hostThreadId = RThread().Id();
- CActiveScheduler::Add(this);
- iStatus = KRequestPending;
- SetActive();
-}
-
-QWakeUpActiveObject::~QWakeUpActiveObject()
-{
- Cancel();
-}
-
-void QWakeUpActiveObject::DoCancel()
-{
- if (iStatus.Int() == KRequestPending) {
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- } else if (IsActive() && m_hostThreadId != RThread().Id()) {
- // This is being cancelled in the adopted monitor thread, which can happen if an adopted thread with
- // an event loop has exited. The event loop creates an event dispatcher with this active object, which may be complete but not run on exit.
- // We force a cancellation in this thread, because a) the object cannot be deleted while active and b) without a cancellation
- // the thread semaphore will be one count down.
- // It is possible for this problem to affect other active objects. They symptom would be that finished signals
- // from adopted threads are not sent, or they arrive much later than they should.
- TRequestStatus *status = &iStatus;
- User::RequestComplete(status, KErrNone);
- }
-}
-
-void QWakeUpActiveObject::RunL()
-{
- if (maybeQueueForLater())
- return;
-
- iStatus = KRequestPending;
- SetActive();
- QT_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled());
-}
-
-QTimerActiveObject::QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo)
- : QActiveObject((timerInfo->interval) ? TIMER_PRIORITY : NULLTIMER_PRIORITY , dispatcher),
- m_timerInfo(timerInfo), m_expectedTimeSinceLastEvent(0)
-{
- // start the timeout timer to ensure initialisation
- m_timeoutTimer.start();
-}
-
-QTimerActiveObject::~QTimerActiveObject()
-{
- Cancel();
- m_rTimer.Close(); //close of null handle is safe
-}
-
-void QTimerActiveObject::DoCancel()
-{
- if (m_timerInfo->interval > 0) {
- m_rTimer.Cancel();
- } else {
- if (iStatus.Int() == KRequestPending) {
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
- }
-}
-
-void QTimerActiveObject::RunL()
-{
- int error = KErrNone;
- if (iStatus == KErrNone) {
- QT_TRYCATCH_ERROR(error, Run());
- } else {
- error = iStatus.Int();
- }
- // All Symbian error codes are negative.
- if (error < 0) {
- CActiveScheduler::Current()->Error(error); // stop and report here, as this timer will be deleted on scope exit
- }
-}
-
-#define MAX_SYMBIAN_TIMEOUT_MS 2000000
-void QTimerActiveObject::StartTimer()
-{
- if (m_timerInfo->msLeft > MAX_SYMBIAN_TIMEOUT_MS) {
- //There is loss of accuracy anyway due to needing to restart the timer every 33 minutes,
- //so the 1/64s res of After() is acceptable for these very long timers.
- m_rTimer.After(iStatus, MAX_SYMBIAN_TIMEOUT_MS * 1000);
- m_timerInfo->msLeft -= MAX_SYMBIAN_TIMEOUT_MS;
- } else {
- // this algorithm implements drift correction for repeating timers
- // calculate how late we are for this event
- int timeSinceLastEvent = m_timeoutTimer.restart();
- int overshoot = timeSinceLastEvent - m_expectedTimeSinceLastEvent;
- if (overshoot > m_timerInfo->msLeft) {
- // we skipped a whole timeout, restart from here
- overshoot = 0;
- }
- // calculate when the next event should happen
- int waitTime = m_timerInfo->msLeft - overshoot;
- m_expectedTimeSinceLastEvent = waitTime;
- // limit the actual ms wait time to avoid wild corrections
- // this will cause the real event time to slowly drift back to the expected event time
- // measurements show that Symbian timers always fire 1 or 2 ms late
- const int limit = 4;
- waitTime = qMax(m_timerInfo->msLeft - limit, waitTime);
- m_rTimer.HighRes(iStatus, waitTime * 1000);
- m_timerInfo->msLeft = 0;
- }
- SetActive();
-}
-
-void QTimerActiveObject::Run()
-{
- //restart timer immediately, if the timeout has been split because it overflows max for platform.
- if (m_timerInfo->msLeft > 0) {
- StartTimer();
- return;
- }
-
- if (maybeQueueForLater())
- return;
-
- if (m_timerInfo->interval > 0) {
- // Start a new timer immediately so that we don't lose time.
- m_timerInfo->msLeft = m_timerInfo->interval;
- StartTimer();
-
- m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId);
- } else {
- // However, we only complete zero timers after the event has finished,
- // in order to prevent busy looping when doing nested loops.
-
- // Keep the refpointer around in order to avoid deletion until the end of this function.
- SymbianTimerInfoPtr timerInfoPtr(m_timerInfo);
-
- m_timerInfo->dispatcher->timerFired(m_timerInfo->timerId);
-
- iStatus = KRequestPending;
- SetActive();
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
-}
-
-void QTimerActiveObject::Start()
-{
- CActiveScheduler::Add(this);
- m_timerInfo->msLeft = m_timerInfo->interval;
- if (m_timerInfo->interval > 0) {
- if (!m_rTimer.Handle()) {
- qt_symbian_throwIfError(m_rTimer.CreateLocal());
- }
- m_timeoutTimer.start();
- m_expectedTimeSinceLastEvent = 0;
- StartTimer();
- } else {
- iStatus = KRequestPending;
- SetActive();
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
-}
-
-SymbianTimerInfo::SymbianTimerInfo()
- : timerAO(0)
-{
-}
-
-SymbianTimerInfo::~SymbianTimerInfo()
-{
- delete timerAO;
-}
-
-QCompleteDeferredAOs::QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher)
- : CActive(COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY),
- m_dispatcher(dispatcher)
-{
- CActiveScheduler::Add(this);
- iStatus = KRequestPending;
- SetActive();
-}
-
-QCompleteDeferredAOs::~QCompleteDeferredAOs()
-{
- Cancel();
-}
-
-void QCompleteDeferredAOs::complete()
-{
- if (iStatus.Int() == KRequestPending) {
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
-}
-
-void QCompleteDeferredAOs::DoCancel()
-{
- if (iStatus.Int() == KRequestPending) {
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
-}
-
-void QCompleteDeferredAOs::RunL()
-{
- iStatus = KRequestPending;
- SetActive();
-
- QT_TRYCATCH_LEAVING(m_dispatcher->reactivateDeferredActiveObjects());
-}
-
-QSelectThread::QSelectThread()
- : m_quit(false)
-{
- if (::pipe(m_pipeEnds) != 0) {
- qWarning("Select thread was unable to open a pipe, errno: %i", errno);
- } else {
- int flags0 = qt_pipe_fcntl(m_pipeEnds[0], F_GETFL);
- int flags1 = qt_pipe_fcntl(m_pipeEnds[1], F_GETFL);
- // We should check the error code here, but Open C has a bug that returns
- // failure even though the operation was successful.
- qt_pipe2_fcntl(m_pipeEnds[0], F_SETFL, flags0 | O_NONBLOCK);
- qt_pipe2_fcntl(m_pipeEnds[1], F_SETFL, flags1 | O_NONBLOCK);
- }
-}
-
-QSelectThread::~QSelectThread()
-{
- qt_pipe_close(m_pipeEnds[1]);
- qt_pipe_close(m_pipeEnds[0]);
-}
-
-void QSelectThread::run()
-{
- Q_D(QThread);
-
- m_mutex.lock();
-
- while (!m_quit) {
- fd_set readfds;
- fd_set writefds;
- fd_set exceptionfds;
-
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- FD_ZERO(&exceptionfds);
-
- int maxfd = 0;
- maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Read, &readfds));
- maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Write, &writefds));
- maxfd = qMax(maxfd, updateSocketSet(QSocketNotifier::Exception, &exceptionfds));
- maxfd = qMax(maxfd, m_pipeEnds[0]);
- maxfd++;
-
- FD_SET(m_pipeEnds[0], &readfds);
-
- int ret;
- int savedSelectErrno;
- ret = qt_socket_select(maxfd, &readfds, &writefds, &exceptionfds, 0);
- savedSelectErrno = errno;
-
- if(ret == 0) {
- // do nothing
- } else if (ret < 0) {
- switch (savedSelectErrno) {
- case EBADF:
- case EINVAL:
- case ENOMEM:
- case EFAULT:
- qWarning("::select() returned an error: %i", savedSelectErrno);
- break;
- case ECONNREFUSED:
- case EPIPE:
- qWarning("::select() returned an error: %i (go through sockets)", savedSelectErrno);
- // prepare to go through all sockets
- // mark in fd sets both:
- // good ones
- // ones that return -1 in select
- // after loop update notifiers for all of them
-
- // as we don't have "exception" notifier type
- // we should force monitoring fd_set of this
- // type as well
-
- // clean @ start
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- FD_ZERO(&exceptionfds);
- for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin();
- i != m_AOStatuses.end(); ++i) {
-
- fd_set onefds;
- FD_ZERO(&onefds);
- FD_SET(i.key()->socket(), &onefds);
-
- fd_set excfds;
- FD_ZERO(&excfds);
- FD_SET(i.key()->socket(), &excfds);
-
- maxfd = i.key()->socket() + 1;
-
- struct timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
-
- ret = 0;
-
- if(i.key()->type() == QSocketNotifier::Read) {
- ret = ::select(maxfd, &onefds, 0, &excfds, &timeout);
- if(ret != 0) FD_SET(i.key()->socket(), &readfds);
- } else if(i.key()->type() == QSocketNotifier::Write) {
- ret = ::select(maxfd, 0, &onefds, &excfds, &timeout);
- if(ret != 0) FD_SET(i.key()->socket(), &writefds);
- }
-
- } // end for
-
- // traversed all, so update
- updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds);
- updateActivatedNotifiers(QSocketNotifier::Read, &readfds);
- updateActivatedNotifiers(QSocketNotifier::Write, &writefds);
-
- break;
- case EINTR: // Should never occur on Symbian, but this is future proof!
- default:
- qWarning("::select() returned an unknown error: %i", savedSelectErrno);
-
- break;
- }
- } else {
- updateActivatedNotifiers(QSocketNotifier::Exception, &exceptionfds);
- updateActivatedNotifiers(QSocketNotifier::Read, &readfds);
- updateActivatedNotifiers(QSocketNotifier::Write, &writefds);
- }
-
- if (FD_ISSET(m_pipeEnds[0], &readfds))
- m_waitCond.wait(&m_mutex);
- }
-
- m_mutex.unlock();
-}
-
-void QSelectThread::requestSocketEvents ( QSocketNotifier *notifier, TRequestStatus *status )
-{
- Q_D(QThread);
-
- if (!isRunning()) {
- start();
- }
-
- Q_ASSERT(QThread::currentThread() == this->thread());
-
- QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex);
-
- Q_ASSERT(!m_AOStatuses.contains(notifier));
-
- m_AOStatuses.insert(notifier, status);
-
- m_waitCond.wakeAll();
-}
-
-void QSelectThread::cancelSocketEvents ( QSocketNotifier *notifier )
-{
- Q_ASSERT(QThread::currentThread() == this->thread());
-
- QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex);
-
- m_AOStatuses.remove(notifier);
-
- m_waitCond.wakeAll();
-}
-
-void QSelectThread::restart()
-{
- Q_ASSERT(QThread::currentThread() == this->thread());
-
- QSelectMutexGrabber lock(m_pipeEnds[1], m_pipeEnds[0], &m_mutex);
-
- m_waitCond.wakeAll();
-}
-
-int QSelectThread::updateSocketSet(QSocketNotifier::Type type, fd_set *fds)
-{
- int maxfd = 0;
- if(m_AOStatuses.isEmpty()) {
- /*
- * Wonder if should return -1
- * to signal that no descriptors
- * added to fds
- */
- return maxfd;
- }
- for ( QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin();
- i != m_AOStatuses.end(); ++i) {
- if (i.key()->type() == type) {
- FD_SET(i.key()->socket(), fds);
- maxfd = qMax(maxfd, i.key()->socket());
- } else if(type == QSocketNotifier::Exception) {
- /*
- * We are registering existing sockets
- * always to exception set
- *
- * Doing double FD_SET shouldn't
- * matter
- */
- FD_SET(i.key()->socket(), fds);
- maxfd = qMax(maxfd, i.key()->socket());
- }
- }
-
- return maxfd;
-}
-
-void QSelectThread::updateActivatedNotifiers(QSocketNotifier::Type type, fd_set *fds)
-{
- Q_D(QThread);
- if(m_AOStatuses.isEmpty()) {
- return;
- }
- QList<QSocketNotifier *> toRemove;
- for (QHash<QSocketNotifier *, TRequestStatus *>::const_iterator i = m_AOStatuses.begin();
- i != m_AOStatuses.end(); ++i) {
- if (i.key()->type() == type && FD_ISSET(i.key()->socket(), fds)) {
- toRemove.append(i.key());
- TRequestStatus *status = i.value();
- // Thread data is still owned by the main thread.
- QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone);
- } else if(type == QSocketNotifier::Exception && FD_ISSET(i.key()->socket(), fds)) {
- /*
- * check if socket is in exception set
- * then signal RequestComplete for it
- */
- qWarning("exception on %d [will close the socket handle - hack]", i.key()->socket());
- // quick fix; there is a bug
- // when doing read on socket
- // errors not preoperly mapped
- // after offline-ing the device
- // on some devices we do get exception
- ::close(i.key()->socket());
- toRemove.append(i.key());
- TRequestStatus *status = i.value();
- QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone);
- }
- }
-
- for (int c = 0; c < toRemove.size(); ++c) {
- m_AOStatuses.remove(toRemove[c]);
- }
-}
-
-void QSelectThread::stop()
-{
- m_quit = true;
- restart();
- wait();
-}
-
-QSocketActiveObject::QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier)
- : QActiveObject(CActive::EPriorityStandard, dispatcher),
- m_notifier(notifier),
- m_inSocketEvent(false),
- m_deleteLater(false)
-{
- CActiveScheduler::Add(this);
- iStatus = KRequestPending;
- SetActive();
-}
-
-QSocketActiveObject::~QSocketActiveObject()
-{
- Cancel();
-}
-
-void QSocketActiveObject::DoCancel()
-{
- if (iStatus.Int() == KRequestPending) {
- TRequestStatus *status = &iStatus;
- QEventDispatcherSymbian::RequestComplete(status, KErrNone);
- }
-}
-
-void QSocketActiveObject::RunL()
-{
- if (maybeDeferSocketEvent())
- return;
- if (maybeQueueForLater())
- return;
-
- QT_TRYCATCH_LEAVING(run());
-}
-
-void QSocketActiveObject::run()
-{
- QEvent e(QEvent::SockAct);
- m_inSocketEvent = true;
- QCoreApplication::sendEvent(m_notifier, &e);
- m_inSocketEvent = false;
-
- if (m_deleteLater) {
- delete this;
- } else {
- iStatus = KRequestPending;
- SetActive();
- m_dispatcher->reactivateSocketNotifier(m_notifier);
- }
-}
-
-void QSocketActiveObject::deleteLater()
-{
- if (m_inSocketEvent) {
- m_deleteLater = true;
- } else {
- delete this;
- }
-}
-
-#ifdef QT_SYMBIAN_PRIORITY_DROP
-class QIdleDetectorThread
-{
-public:
- QIdleDetectorThread()
- : m_state(STATE_RUN), m_stop(false), m_running(false)
- {
- start();
- }
-
- ~QIdleDetectorThread()
- {
- stop();
- }
-
- void start()
- {
- QMutexLocker lock(&m_mutex);
- if (m_running)
- return;
- m_stop = false;
- m_state = STATE_RUN;
- TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this);
- if (err != KErrNone)
- return; // Fail silently on error. Next kick will try again. Exception might stop the event being processed
- m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal);
- m_idleDetectorThread.Resume();
- m_running = true;
- // get a callback from QCoreApplication destruction to stop this thread
- qAddPostRoutine(StopIdleDetectorThread);
- }
-
- void stop()
- {
- QMutexLocker lock(&m_mutex);
- if (!m_running)
- return;
- // close down the idle thread because if corelib is loaded temporarily, this would leak threads into the host process
- m_stop = true;
- m_kick.release();
- m_idleDetectorThread.SetPriority(EPriorityNormal);
- TRequestStatus s;
- m_idleDetectorThread.Logon(s);
- User::WaitForRequest(s);
- m_idleDetectorThread.Close();
- m_running = false;
- }
-
- void kick()
- {
- start();
- m_state = STATE_KICKED;
- m_kick.release();
- }
-
- bool hasRun()
- {
- return m_state == STATE_RUN;
- }
-
-private:
- static TInt idleDetectorThreadFunc(TAny* self)
- {
- User::RenameThread(_L("IdleDetectorThread"));
- static_cast<QIdleDetectorThread*>(self)->IdleLoop();
- return KErrNone;
- }
-
- void IdleLoop()
- {
- while (!m_stop) {
- m_kick.acquire();
- m_state = STATE_RUN;
- }
- }
-
- static void StopIdleDetectorThread();
-
-private:
- enum IdleStates {STATE_KICKED, STATE_RUN} m_state;
- bool m_stop;
- bool m_running;
- RThread m_idleDetectorThread;
- QSemaphore m_kick;
- QMutex m_mutex;
-};
-
-Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread);
-
-void QIdleDetectorThread::StopIdleDetectorThread()
-{
- idleDetectorThread()->stop();
-}
-
-const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds
-const int baseDelay = 1000; // minimum delay time used when backing off to allow idling, in microseconds
-#endif
-
-QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent)
- : QAbstractEventDispatcher(parent),
- m_selectThread(0),
- m_activeScheduler(0),
- m_wakeUpAO(0),
- m_completeDeferredAOs(0),
- m_interrupt(false),
- m_wakeUpDone(0),
- m_iterationCount(0),
- m_insideTimerEvent(false),
- m_noSocketEvents(false)
-{
-#ifdef QT_SYMBIAN_PRIORITY_DROP
- m_delay = baseDelay;
- m_avgEventTime = 0;
- idleDetectorThread();
-#endif
-}
-
-QEventDispatcherSymbian::~QEventDispatcherSymbian()
-{
-}
-
-void QEventDispatcherSymbian::startingUp()
-{
- if( !CActiveScheduler::Current() ) {
- m_activeScheduler = q_check_ptr(new CQtActiveScheduler()); // CBase derived class needs to be checked on new
- CActiveScheduler::Install(m_activeScheduler);
- }
- m_wakeUpAO = q_check_ptr(new QWakeUpActiveObject(this));
- m_completeDeferredAOs = q_check_ptr(new QCompleteDeferredAOs(this));
- // We already might have posted events, wakeup once to process them
- wakeUp();
-}
-
-QSelectThread& QEventDispatcherSymbian::selectThread() {
- if (!m_selectThread)
- m_selectThread = new QSelectThread;
- return *m_selectThread;
-}
-
-void QEventDispatcherSymbian::closingDown()
-{
- if (m_selectThread && m_selectThread->isRunning()) {
- m_selectThread->stop();
- }
- delete m_selectThread;
- m_selectThread = 0;
-
- delete m_completeDeferredAOs;
- delete m_wakeUpAO;
- if (m_activeScheduler) {
- delete m_activeScheduler;
- }
-}
-
-bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags flags )
-{
- bool handledAnyEvent = false;
- bool oldNoSocketEventsValue = m_noSocketEvents;
- bool oldInsideTimerEventValue = m_insideTimerEvent;
-
- m_insideTimerEvent = 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;
- }
-
- if (flags & QEventLoop::ExcludeSocketNotifiers) {
- m_noSocketEvents = true;
- } else {
- m_noSocketEvents = false;
- handledAnyEvent = sendDeferredSocketEvents();
- }
-
- bool handledSymbianEvent = false;
- m_interrupt = false;
-
-#ifdef QT_SYMBIAN_PRIORITY_DROP
- QElapsedTimer eventTimer;
-#endif
-
- while (1) {
- if (block) {
- // This is where Qt will spend most of its time.
- CActiveScheduler::Current()->WaitForAnyRequest();
- } else {
- if (thread.RequestCount() == 0) {
-#ifdef QT_SYMBIAN_PRIORITY_DROP
- if (idleDetectorThread()->hasRun()) {
- m_lastIdleRequestTimer.start();
- idleDetectorThread()->kick();
- } else if (m_lastIdleRequestTimer.elapsed() > maxBusyTime) {
- User::AfterHighRes(m_delay);
- }
-#endif
- break;
- }
- // This one should return without delay.
- CActiveScheduler::Current()->WaitForAnyRequest();
- }
-
-#ifdef QT_SYMBIAN_PRIORITY_DROP
- if (idleDetectorThread()->hasRun()) {
- if (m_delay > baseDelay)
- m_delay -= baseDelay;
- m_lastIdleRequestTimer.start();
- idleDetectorThread()->kick();
- } else if (m_lastIdleRequestTimer.elapsed() > maxBusyTime) {
- User::AfterHighRes(m_delay);
- // allow delay to be up to 1/4 of execution time
- if (!idleDetectorThread()->hasRun() && m_delay*3 < m_avgEventTime)
- m_delay += baseDelay;
- }
- eventTimer.start();
-#endif
-
- TInt error;
- handledSymbianEvent = CActiveScheduler::RunIfReady(error, KMinTInt);
- if (error) {
- qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error);
- CActiveScheduler::Current()->Error(error);
- }
-
-#ifdef QT_SYMBIAN_PRIORITY_DROP
- int eventDur = eventTimer.elapsed()*1000;
- // average is calcualted as a 5% decaying exponential average
- m_avgEventTime = (m_avgEventTime * 95 + eventDur * 5) / 100;
-#endif
-
- if (!handledSymbianEvent) {
- qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal");
- }
- handledAnyEvent = true;
- if (m_interrupt) {
- break;
- }
- block = false;
- };
-
- emit awake();
- } QT_CATCH (const std::exception& ex) {
-#ifndef QT_NO_EXCEPTIONS
- CActiveScheduler::Current()->Error(qt_symbian_exception2Error(ex));
-#endif
- }
-
- m_noSocketEvents = oldNoSocketEventsValue;
- m_insideTimerEvent = oldInsideTimerEventValue;
-
- return handledAnyEvent;
-}
-
-void QEventDispatcherSymbian::timerFired(int timerId)
-{
- QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.find(timerId);
- if (i == m_timerList.end()) {
- // The timer has been deleted. Ignore this event.
- return;
- }
-
- SymbianTimerInfoPtr timerInfo = *i;
-
- // Prevent infinite timer recursion.
- if (timerInfo->inTimerEvent) {
- return;
- }
-
- timerInfo->inTimerEvent = true;
- bool oldInsideTimerEventValue = m_insideTimerEvent;
- m_insideTimerEvent = true;
-
- QTimerEvent event(timerInfo->timerId);
- QCoreApplication::sendEvent(timerInfo->receiver, &event);
-
- m_insideTimerEvent = oldInsideTimerEventValue;
- timerInfo->inTimerEvent = false;
-
- return;
-}
-
-void QEventDispatcherSymbian::wakeUpWasCalled()
-{
- // The reactivation should happen in RunL, right before the call to this function.
- // This is because m_wakeUpDone is the "signal" that the object can be completed
- // once more.
- // Also, by dispatching the posted events after resetting m_wakeUpDone, we guarantee
- // that no posted event notification will be lost. If we did it the other way
- // around, it would be possible for another thread to post an event right after
- // the sendPostedEvents was done, but before the object was ready to be completed
- // again. This could deadlock the application if there are no other posted events.
- m_wakeUpDone.fetchAndStoreOrdered(0);
- sendPostedEvents();
-}
-
-void QEventDispatcherSymbian::interrupt()
-{
- m_interrupt = true;
- wakeUp();
-}
-
-void QEventDispatcherSymbian::wakeUp()
-{
- Q_D(QAbstractEventDispatcher);
-
- if (m_wakeUpAO && m_wakeUpDone.testAndSetAcquire(0, 1)) {
- TRequestStatus *status = &m_wakeUpAO->iStatus;
- QEventDispatcherSymbian::RequestComplete(d->threadData->symbian_thread_handle, status, KErrNone);
- }
-}
-
-bool QEventDispatcherSymbian::sendPostedEvents()
-{
- Q_D(QAbstractEventDispatcher);
-
- // moveToThread calls this and canWait == true -> Events will never get processed
- // if we check for d->threadData->canWait
- //
- // QCoreApplication::postEvent sets canWait = false, but after the object and events
- // are moved to a new thread, the canWait in new thread is true i.e. not changed to reflect
- // the flag on old thread. That's why events in a new thread will not get processed.
- // This migth be actually bug in moveToThread functionality, but because other platforms
- // do not check canWait in wakeUp (where we essentially are now) - decided to remove it from
- // here as well.
-
- //if (!d->threadData->canWait) {
- QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
- return true;
- //}
- //return false;
-}
-
-inline void QEventDispatcherSymbian::addDeferredActiveObject(QActiveObject *object)
-{
- queueDeferredActiveObjectsCompletion();
- m_deferredActiveObjects.append(object);
-}
-
-inline void QEventDispatcherSymbian::removeDeferredActiveObject(QActiveObject *object)
-{
- m_deferredActiveObjects.removeAll(object);
- m_deferredSocketEvents.removeAll(object);
-}
-
-inline void QEventDispatcherSymbian::addDeferredSocketActiveObject(QActiveObject *object)
-{
- m_deferredSocketEvents.append(object);
-}
-
-void QEventDispatcherSymbian::queueDeferredActiveObjectsCompletion()
-{
- m_completeDeferredAOs->complete();
-}
-
-void QEventDispatcherSymbian::reactivateDeferredActiveObjects()
-{
- while (!m_deferredActiveObjects.isEmpty()) {
- QActiveObject *object = m_deferredActiveObjects.takeFirst();
- object->reactivateAndComplete();
- }
-
- // We do this because we want to return from processEvents. This is because
- // each invocation of processEvents should only run each active object once.
- // The active scheduler should run them continously, however.
- m_interrupt = true;
-}
-
-bool QEventDispatcherSymbian::sendDeferredSocketEvents()
-{
- bool sentAnyEvents = false;
- while (!m_deferredSocketEvents.isEmpty()) {
- sentAnyEvents = true;
- QActiveObject *object = m_deferredSocketEvents.takeFirst();
- object->reactivateAndComplete();
- }
-
- return sentAnyEvents;
-}
-
-void QEventDispatcherSymbian::flush()
-{
-}
-
-bool QEventDispatcherSymbian::hasPendingEvents()
-{
- Q_D(QAbstractEventDispatcher);
- return (d->threadData->symbian_thread_handle.RequestCount() != 0
- || !d->threadData->canWait || !m_deferredSocketEvents.isEmpty());
-}
-
-void QEventDispatcherSymbian::registerSocketNotifier ( QSocketNotifier * notifier )
-{
- //check socket descriptor is usable
- if (notifier->socket() >= FD_SETSIZE || notifier->socket() < 0) {
- //same warning message as the unix event dispatcher for easy testing
- qWarning("QSocketNotifier: Internal error");
- return;
- }
- //note - this is only for "open C" file descriptors
- //for native sockets, an active object in the symbian socket engine handles this
- QSocketActiveObject *socketAO = new QSocketActiveObject(this, notifier);
- Q_CHECK_PTR(socketAO);
- m_notifiers.insert(notifier, socketAO);
- selectThread().requestSocketEvents(notifier, &socketAO->iStatus);
-}
-
-void QEventDispatcherSymbian::unregisterSocketNotifier ( QSocketNotifier * notifier )
-{
- //note - this is only for "open C" file descriptors
- //for native sockets, an active object in the symbian socket engine handles this
- if (m_selectThread)
- m_selectThread->cancelSocketEvents(notifier);
- if (m_notifiers.contains(notifier)) {
- QSocketActiveObject *sockObj = *m_notifiers.find(notifier);
- m_deferredSocketEvents.removeAll(sockObj);
- sockObj->deleteLater();
- m_notifiers.remove(notifier);
- }
-}
-
-void QEventDispatcherSymbian::reactivateSocketNotifier(QSocketNotifier *notifier)
-{
- selectThread().requestSocketEvents(notifier, &m_notifiers[notifier]->iStatus);
-}
-
-void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject * object )
-{
- if (interval < 0) {
- qWarning("Timer interval < 0");
- interval = 0;
- }
-
- SymbianTimerInfoPtr timer(new SymbianTimerInfo);
- timer->timerId = timerId;
- timer->interval = interval;
- timer->inTimerEvent = false;
- timer->receiver = object;
- timer->dispatcher = this;
- timer->timerAO = q_check_ptr(new QTimerActiveObject(this, timer.data()));
- m_timerList.insert(timerId, timer);
-
- timer->timerAO->Start();
-
- if (m_insideTimerEvent)
- // If we are inside a timer event, we need to prevent event starvation
- // by preventing newly created timers from running in the same event processing
- // iteration. Do this by calling the maybeQueueForLater() function to "fake" that we have
- // already run once. This will cause the next run to be added to the deferred
- // queue instead.
- timer->timerAO->maybeQueueForLater();
-}
-
-bool QEventDispatcherSymbian::unregisterTimer ( int timerId )
-{
- if (!m_timerList.contains(timerId)) {
- return false;
- }
-
- SymbianTimerInfoPtr timerInfo = m_timerList.take(timerId);
-
- if (!QObjectPrivate::get(timerInfo->receiver)->inThreadChangeEvent)
- QAbstractEventDispatcherPrivate::releaseTimerId(timerId);
-
- return true;
-}
-
-bool QEventDispatcherSymbian::unregisterTimers ( QObject * object )
-{
- if (m_timerList.isEmpty())
- return false;
-
- bool unregistered = false;
- for (QHash<int, SymbianTimerInfoPtr>::iterator i = m_timerList.begin(); i != m_timerList.end(); ) {
- if ((*i)->receiver == object) {
- i = m_timerList.erase(i);
- unregistered = true;
- } else {
- ++i;
- }
- }
-
- return unregistered;
-}
-
-QList<QEventDispatcherSymbian::TimerInfo> QEventDispatcherSymbian::registeredTimers ( QObject * object ) const
-{
- QList<TimerInfo> list;
- for (QHash<int, SymbianTimerInfoPtr>::const_iterator i = m_timerList.begin(); i != m_timerList.end(); ++i) {
- if ((*i)->receiver == object) {
- list.push_back(TimerInfo((*i)->timerId, (*i)->interval));
- }
- }
-
- return list;
-}
-
-/*
- * This active scheduler class implements a simple report and continue policy, for Symbian OS leaves
- * or exceptions from Qt that fall back to the scheduler.
- * It will be used in cases where there is no existing active scheduler installed.
- * Apps which link to qts60main.lib will have the UI active scheduler installed in the main thread
- * instead of this one. But this would be used in other threads in the UI.
- * An app could replace this behaviour by installing an alternative active scheduler.
- */
-void CQtActiveScheduler::Error(TInt aError) const
-{
- QT_TRY {
- qWarning("Error from active scheduler %d", aError);
- }
- QT_CATCH (const std::bad_alloc&) {} // ignore alloc fails, nothing more can be done
-}
-
-bool QActiveObject::wait(CActive* ao, int ms)
-{
- if (!ao->IsActive())
- return true; //request already complete
- bool timedout = false;
- if (ms > 0) {
- TRequestStatus tstat;
- RTimer t;
- if (KErrNone != t.CreateLocal())
- return false;
- t.HighRes(tstat, ms*1000);
- User::WaitForRequest(tstat, ao->iStatus);
- if (tstat != KRequestPending) {
- timedout = true;
- } else {
- t.Cancel();
- //balance thread semaphore
- User::WaitForRequest(tstat);
- }
- t.Close();
- } else {
- User::WaitForRequest(ao->iStatus);
- }
- if (timedout)
- return false;
-
- //evil cast to allow calling of protected virtual
- ((QActiveObject*)ao)->RunL();
-
- //clear active & pending flags
- ao->iStatus = TRequestStatus();
-
- return true;
-}
-
-bool QActiveObject::wait(QList<CActive*> aos, int ms)
-{
- QVector<TRequestStatus*> stati;
- stati.reserve(aos.count() + 1);
- foreach (CActive* ao, aos) {
- if (!ao->IsActive())
- return true; //request already complete
- stati.append(&(ao->iStatus));
- }
- bool timedout = false;
- TRequestStatus tstat;
- RTimer t;
- if (ms > 0) {
- if (KErrNone != t.CreateLocal())
- return false;
- t.HighRes(tstat, ms*1000);
- stati.append(&tstat);
- }
- User::WaitForNRequest(stati.data(), stati.count());
- if (ms > 0) {
- if (tstat != KRequestPending) {
- timedout = true;
- } else {
- t.Cancel();
- //balance thread semaphore
- User::WaitForRequest(tstat);
- }
- t.Close();
- }
- if (timedout)
- return false;
-
- foreach (CActive* ao, aos) {
- if (ao->iStatus != KRequestPending) {
- //evil cast to allow calling of protected virtual
- ((QActiveObject*)ao)->RunL();
-
- //clear active & pending flags
- ao->iStatus = TRequestStatus();
- break; //only call one
- }
- }
- return true;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qeventdispatcher_symbian_p.cpp"
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
deleted file mode 100644
index e327a9cdc5..0000000000
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEVENTDISPATCHER_SYMBIAN_P_H
-#define QEVENTDISPATCHER_SYMBIAN_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 <qhash.h>
-#include <qset.h>
-#include <qshareddata.h>
-#include <qabstracteventdispatcher.h>
-#include <private/qabstracteventdispatcher_p.h>
-#include <qthread.h>
-#include <qmutex.h>
-#include <qwaitcondition.h>
-#include <qsocketnotifier.h>
-#include <qdatetime.h>
-#include <qelapsedtimer.h>
-
-#include <e32base.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QEventDispatcherSymbian;
-class QTimerActiveObject;
-
-class Q_CORE_EXPORT QActiveObject : public CActive
-{
-public:
- QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher);
- ~QActiveObject();
-
- bool maybeQueueForLater();
- bool maybeDeferSocketEvent();
-
- void reactivateAndComplete();
-
- static bool wait(CActive* ao, int ms);
- static bool wait(QList<CActive*> aos, int ms);
-protected:
- QEventDispatcherSymbian *m_dispatcher;
-
-private:
- bool m_hasAlreadyRun : 1;
- bool m_hasRunAgain : 1;
- int m_iterationCount;
-};
-
-class QWakeUpActiveObject : public QActiveObject
-{
-public:
- QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher);
- ~QWakeUpActiveObject();
-
- void Complete();
-
-protected:
- void DoCancel();
- void RunL();
-
-private:
- TThreadId m_hostThreadId;
-};
-
-struct SymbianTimerInfo : public QSharedData
-{
- SymbianTimerInfo();
- ~SymbianTimerInfo();
-
- int timerId;
- int interval;
- int msLeft;
- bool inTimerEvent;
- QObject *receiver;
- QTimerActiveObject *timerAO;
- QEventDispatcherSymbian *dispatcher;
-};
-
-typedef QExplicitlySharedDataPointer<SymbianTimerInfo> SymbianTimerInfoPtr;
-
-// This is a bit of a proxy class. See comments in SetActive and Start for details.
-class QTimerActiveObject : public QActiveObject
-{
-public:
- QTimerActiveObject(QEventDispatcherSymbian *dispatcher, SymbianTimerInfo *timerInfo);
- ~QTimerActiveObject();
-
- void Start();
-
-protected:
- void DoCancel();
- void RunL();
-
-private:
- void Run();
- void StartTimer();
-
-private:
- SymbianTimerInfo *m_timerInfo;
- QElapsedTimer m_timeoutTimer;
- int m_expectedTimeSinceLastEvent;
- RTimer m_rTimer;
-};
-
-class QCompleteDeferredAOs : public CActive
-{
-public:
- QCompleteDeferredAOs(QEventDispatcherSymbian *dispatcher);
- ~QCompleteDeferredAOs();
-
- void complete();
-
-protected:
- void DoCancel();
- void RunL();
-
-private:
- QEventDispatcherSymbian *m_dispatcher;
-};
-
-class QSocketActiveObject : public QActiveObject
-{
-public:
- QSocketActiveObject(QEventDispatcherSymbian *dispatcher, QSocketNotifier *notifier);
- ~QSocketActiveObject();
-
- void deleteLater();
-
-protected:
- void DoCancel();
- void RunL();
- void run();
-
-private:
- QSocketNotifier *m_notifier;
- bool m_inSocketEvent;
- bool m_deleteLater;
-
- friend class QEventDispatcherSymbian;
-};
-
-class QSelectThread : public QThread
-{
- Q_DECLARE_PRIVATE(QThread)
-
-public:
- QSelectThread();
- ~QSelectThread();
-
- void requestSocketEvents ( QSocketNotifier *notifier, TRequestStatus *status );
- void cancelSocketEvents ( QSocketNotifier *notifier );
- void restart();
- void stop();
-
-protected:
- void run();
-
-private:
- int updateSocketSet(QSocketNotifier::Type type, fd_set *fds);
- void updateActivatedNotifiers(QSocketNotifier::Type type, fd_set *fds);
-
-private:
- int m_pipeEnds[2];
- QHash<QSocketNotifier *, TRequestStatus *> m_AOStatuses;
- QMutex m_mutex;
- QWaitCondition m_waitCond;
- bool m_quit;
-};
-
-class Q_CORE_EXPORT CQtActiveScheduler : public CActiveScheduler
-{
-public: // from CActiveScheduler
- virtual void Error(TInt aError) const;
-};
-
-class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
-
-public:
- QEventDispatcherSymbian(QObject *parent = 0);
- ~QEventDispatcherSymbian();
-
- void flush();
- bool hasPendingEvents();
- void interrupt();
- bool processEvents ( QEventLoop::ProcessEventsFlags flags );
- void registerSocketNotifier ( QSocketNotifier * notifier );
- void registerTimer ( int timerId, int interval, QObject * object );
- QList<TimerInfo> registeredTimers ( QObject * object ) const;
- void unregisterSocketNotifier ( QSocketNotifier * notifier );
- bool unregisterTimer ( int timerId );
- bool unregisterTimers ( QObject * object );
- void wakeUp();
-
- void startingUp();
- void closingDown();
-
- void timerFired(int timerId);
- void wakeUpWasCalled();
- void reactivateSocketNotifier(QSocketNotifier *notifier);
-
- void addDeferredActiveObject(QActiveObject *object);
- void removeDeferredActiveObject(QActiveObject *object);
- void queueDeferredActiveObjectsCompletion();
- // Can be overridden to activate local active objects too, but do call baseclass!
- virtual void reactivateDeferredActiveObjects();
-
- inline int iterationCount() const { return m_iterationCount; }
-
- void addDeferredSocketActiveObject(QActiveObject *object);
- inline bool areSocketEventsBlocked() const { return m_noSocketEvents; }
-
- static void RequestComplete(TRequestStatus *&status, TInt reason);
- static void RequestComplete(RThread &threadHandle, TRequestStatus *&status, TInt reason);
-
-private:
- bool sendPostedEvents();
- bool sendDeferredSocketEvents();
-
- QSelectThread& selectThread();
-private:
- QSelectThread *m_selectThread;
-
- CQtActiveScheduler *m_activeScheduler;
-
- QHash<int, SymbianTimerInfoPtr> m_timerList;
- QHash<QSocketNotifier *, QSocketActiveObject *> m_notifiers;
-
- QWakeUpActiveObject *m_wakeUpAO;
- QCompleteDeferredAOs *m_completeDeferredAOs;
-
- volatile bool m_interrupt;
- QAtomicInt m_wakeUpDone;
-
- unsigned char m_iterationCount;
- bool m_insideTimerEvent;
- bool m_noSocketEvents;
- //deferred until socket events are enabled
- QList<QActiveObject *> m_deferredSocketEvents;
- //deferred until idle
- QList<QActiveObject *> m_deferredActiveObjects;
-
- int m_delay;
- int m_avgEventTime;
- QElapsedTimer m_lastIdleRequestTimer;
-};
-
-#ifdef QT_DEBUG
-# define VERIFY_PENDING_REQUEST_STATUS \
- Q_ASSERT(status->Int() == KRequestPending);
-#else
-# define VERIFY_PENDING_REQUEST_STATUS
-#endif
-
-// Convenience functions for doing some sanity checking on our own complete code.
-// Unless QT_DEBUG is defined, it is exactly equivalent to the Symbian version.
-inline void QEventDispatcherSymbian::RequestComplete(TRequestStatus *&status, TInt reason)
-{
- VERIFY_PENDING_REQUEST_STATUS
- User::RequestComplete(status, reason);
-}
-inline void QEventDispatcherSymbian::RequestComplete(RThread &threadHandle, TRequestStatus *&status, TInt reason)
-{
- VERIFY_PENDING_REQUEST_STATUS
- threadHandle.RequestComplete(status, reason);
-}
-
-#undef VERIFY_PENDING_REQUEST_STATUS
-
-QT_END_NAMESPACE
-
-#endif // QEVENTDISPATCHER_SYMBIAN_P_H
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 27efac6985..26a9e9f0ca 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -72,8 +72,6 @@
QT_BEGIN_NAMESPACE
-Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false;
-
/*****************************************************************************
UNIX signal handling
*****************************************************************************/
@@ -309,326 +307,6 @@ int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags,
return (nevents + q->activateSocketNotifiers());
}
-/*
- * Internal functions for manipulating timer data structures. The
- * timerBitVec array is used for keeping track of timer identifiers.
- */
-
-QTimerInfoList::QTimerInfoList()
-{
-#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_NACL)
- if (!QElapsedTimer::isMonotonic()) {
- // not using monotonic timers, initialize the timeChanged() machinery
- previousTime = qt_gettime();
-
- tms unused;
- previousTicks = times(&unused);
-
- ticksPerSecond = sysconf(_SC_CLK_TCK);
- msPerTick = 1000/ticksPerSecond;
- } else {
- // detected monotonic timers
- previousTime.tv_sec = previousTime.tv_usec = 0;
- previousTicks = 0;
- ticksPerSecond = 0;
- msPerTick = 0;
- }
-#endif
-
- firstTimerInfo = 0;
-}
-
-timeval QTimerInfoList::updateCurrentTime()
-{
- return (currentTime = qt_gettime());
-}
-
-#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED)
-
-template <>
-timeval qAbs(const timeval &t)
-{
- timeval tmp = t;
- if (tmp.tv_sec < 0) {
- tmp.tv_sec = -tmp.tv_sec - 1;
- tmp.tv_usec -= 1000000;
- }
- if (tmp.tv_sec == 0 && tmp.tv_usec < 0) {
- tmp.tv_usec = -tmp.tv_usec;
- }
- return normalizedTimeval(tmp);
-}
-
-/*
- Returns true if the real time clock has changed by more than 10%
- relative to the processor time since the last time this function was
- called. This presumably means that the system time has been changed.
-
- If /a delta is nonzero, delta is set to our best guess at how much the system clock was changed.
-*/
-bool QTimerInfoList::timeChanged(timeval *delta)
-{
-#ifdef Q_OS_NACL
- Q_UNUSED(delta)
- return false; // Calling "times" crashes.
-#endif
- struct tms unused;
- clock_t currentTicks = times(&unused);
-
- clock_t elapsedTicks = currentTicks - previousTicks;
- timeval elapsedTime = currentTime - previousTime;
-
- timeval elapsedTimeTicks;
- elapsedTimeTicks.tv_sec = elapsedTicks / ticksPerSecond;
- elapsedTimeTicks.tv_usec = (((elapsedTicks * 1000) / ticksPerSecond) % 1000) * 1000;
-
- timeval dummy;
- if (!delta)
- delta = &dummy;
- *delta = elapsedTime - elapsedTimeTicks;
-
- previousTicks = currentTicks;
- previousTime = currentTime;
-
- // If tick drift is more than 10% off compared to realtime, we assume that the clock has
- // been set. Of course, we have to allow for the tick granularity as well.
- timeval tickGranularity;
- tickGranularity.tv_sec = 0;
- tickGranularity.tv_usec = msPerTick * 1000;
- return elapsedTimeTicks < ((qAbs(*delta) - tickGranularity) * 10);
-}
-
-void QTimerInfoList::repairTimersIfNeeded()
-{
- if (QElapsedTimer::isMonotonic())
- return;
- timeval delta;
- if (timeChanged(&delta))
- timerRepair(delta);
-}
-
-#else // !(_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(QT_BOOTSTRAPPED)
-
-void QTimerInfoList::repairTimersIfNeeded()
-{
-}
-
-#endif
-
-/*
- insert timer info into list
-*/
-void QTimerInfoList::timerInsert(QTimerInfo *ti)
-{
- int index = size();
- while (index--) {
- register const QTimerInfo * const t = at(index);
- if (!(ti->timeout < t->timeout))
- break;
- }
- insert(index+1, ti);
-}
-
-/*
- repair broken timer
-*/
-void QTimerInfoList::timerRepair(const timeval &diff)
-{
- // repair all timers
- for (int i = 0; i < size(); ++i) {
- register QTimerInfo *t = at(i);
- t->timeout = t->timeout + diff;
- }
-}
-
-static timeval roundToMillisecond(timeval val)
-{
- // always round up
- // worst case scenario is that the first trigger of a 1-ms timer is 0.999 ms late
-
- int us = val.tv_usec % 1000;
- val.tv_usec += 1000 - us;
- return normalizedTimeval(val);
-}
-
-/*
- Returns the time to wait for the next timer, or null if no timers
- are waiting.
-*/
-bool QTimerInfoList::timerWait(timeval &tm)
-{
- timeval currentTime = updateCurrentTime();
- repairTimersIfNeeded();
-
- // Find first waiting timer not already active
- QTimerInfo *t = 0;
- for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
- if (!(*it)->activateRef) {
- t = *it;
- break;
- }
- }
-
- if (!t)
- return false;
-
- if (currentTime < t->timeout) {
- // time to wait
- tm = roundToMillisecond(t->timeout - currentTime);
- } else {
- // no time to wait
- tm.tv_sec = 0;
- tm.tv_usec = 0;
- }
-
- return true;
-}
-
-void QTimerInfoList::registerTimer(int timerId, int interval, QObject *object)
-{
- QTimerInfo *t = new QTimerInfo;
- t->id = timerId;
- t->interval.tv_sec = interval / 1000;
- t->interval.tv_usec = (interval % 1000) * 1000;
- t->timeout = updateCurrentTime() + t->interval;
- t->obj = object;
- t->activateRef = 0;
-
- timerInsert(t);
-}
-
-bool QTimerInfoList::unregisterTimer(int timerId)
-{
- // set timer inactive
- for (int i = 0; i < count(); ++i) {
- register QTimerInfo *t = at(i);
- if (t->id == timerId) {
- // found it
- removeAt(i);
- if (t == firstTimerInfo)
- firstTimerInfo = 0;
- if (t->activateRef)
- *(t->activateRef) = 0;
-
- // release the timer id
- if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent)
- QAbstractEventDispatcherPrivate::releaseTimerId(timerId);
-
- delete t;
- return true;
- }
- }
- // id not found
- return false;
-}
-
-bool QTimerInfoList::unregisterTimers(QObject *object)
-{
- if (isEmpty())
- return false;
- for (int i = 0; i < count(); ++i) {
- register QTimerInfo *t = at(i);
- if (t->obj == object) {
- // object found
- removeAt(i);
- if (t == firstTimerInfo)
- firstTimerInfo = 0;
- if (t->activateRef)
- *(t->activateRef) = 0;
-
- // release the timer id
- if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent)
- QAbstractEventDispatcherPrivate::releaseTimerId(t->id);
-
- delete t;
- // move back one so that we don't skip the new current item
- --i;
- }
- }
- return true;
-}
-
-QList<QPair<int, int> > QTimerInfoList::registeredTimers(QObject *object) const
-{
- QList<QPair<int, int> > list;
- for (int i = 0; i < count(); ++i) {
- register const QTimerInfo * const t = at(i);
- if (t->obj == object)
- list << QPair<int, int>(t->id, t->interval.tv_sec * 1000 + t->interval.tv_usec / 1000);
- }
- return list;
-}
-
-/*
- Activate pending timers, returning how many where activated.
-*/
-int QTimerInfoList::activateTimers()
-{
- if (qt_disable_lowpriority_timers || isEmpty())
- return 0; // nothing to do
-
- int n_act = 0, maxCount = 0;
- firstTimerInfo = 0;
-
- timeval currentTime = updateCurrentTime();
- repairTimersIfNeeded();
-
-
- // Find out how many timer have expired
- for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
- if (currentTime < (*it)->timeout)
- break;
- maxCount++;
- }
-
- //fire the timers.
- while (maxCount--) {
- if (isEmpty())
- break;
-
- QTimerInfo *currentTimerInfo = first();
- if (currentTime < currentTimerInfo->timeout)
- break; // no timer has expired
-
- if (!firstTimerInfo) {
- firstTimerInfo = currentTimerInfo;
- } else if (firstTimerInfo == currentTimerInfo) {
- // avoid sending the same timer multiple times
- break;
- } else if (currentTimerInfo->interval < firstTimerInfo->interval
- || currentTimerInfo->interval == firstTimerInfo->interval) {
- firstTimerInfo = currentTimerInfo;
- }
-
- // remove from list
- removeFirst();
-
- // determine next timeout time
- currentTimerInfo->timeout += currentTimerInfo->interval;
- if (currentTimerInfo->timeout < currentTime)
- currentTimerInfo->timeout = currentTime + currentTimerInfo->interval;
-
- // reinsert timer
- timerInsert(currentTimerInfo);
- if (currentTimerInfo->interval.tv_usec > 0 || currentTimerInfo->interval.tv_sec > 0)
- n_act++;
-
- if (!currentTimerInfo->activateRef) {
- // send event, but don't allow it to recurse
- currentTimerInfo->activateRef = &currentTimerInfo;
-
- QTimerEvent e(currentTimerInfo->id);
- QCoreApplication::sendEvent(currentTimerInfo->obj, &e);
-
- if (currentTimerInfo)
- currentTimerInfo->activateRef = 0;
- }
- }
-
- firstTimerInfo = 0;
- return n_act;
-}
-
QEventDispatcherUNIX::QEventDispatcherUNIX(QObject *parent)
: QAbstractEventDispatcher(*new QEventDispatcherUNIXPrivate, parent)
{ }
@@ -652,7 +330,7 @@ int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd
/*!
\internal
*/
-void QEventDispatcherUNIX::registerTimer(int timerId, int interval, QObject *obj)
+void QEventDispatcherUNIX::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *obj)
{
#ifndef QT_NO_DEBUG
if (timerId < 1 || interval < 0 || !obj) {
@@ -665,7 +343,7 @@ void QEventDispatcherUNIX::registerTimer(int timerId, int interval, QObject *obj
#endif
Q_D(QEventDispatcherUNIX);
- d->timerList.registerTimer(timerId, interval, obj);
+ d->timerList.registerTimer(timerId, interval, timerType, obj);
}
/*!
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index 122f17f9e9..f4862bd9c3 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -59,6 +59,7 @@
#include "private/qcore_unix_p.h"
#include "private/qpodlist_p.h"
#include "QtCore/qvarlengtharray.h"
+#include "private/qtimerinfo_unix_p.h"
#if defined(Q_OS_VXWORKS)
# include <sys/times.h>
@@ -71,50 +72,6 @@
QT_BEGIN_NAMESPACE
-// internal timer info
-struct QTimerInfo {
- int id; // - timer identifier
- timeval interval; // - timer interval
- timeval timeout; // - when to sent event
- QObject *obj; // - object to receive event
- QTimerInfo **activateRef; // - ref from activateTimers
-};
-
-class QTimerInfoList : public QList<QTimerInfo*>
-{
-#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
- timeval previousTime;
- clock_t previousTicks;
- int ticksPerSecond;
- int msPerTick;
-
- bool timeChanged(timeval *delta);
-#endif
-
- // state variables used by activateTimers()
- QTimerInfo *firstTimerInfo;
-
-public:
- QTimerInfoList();
-
- timeval currentTime;
- timeval updateCurrentTime();
-
- // must call updateCurrentTime() first!
- void repairTimersIfNeeded();
-
- bool timerWait(timeval &);
- void timerInsert(QTimerInfo *);
- void timerRepair(const timeval &);
-
- void registerTimer(int timerId, int interval, QObject *object);
- bool unregisterTimer(int timerId);
- bool unregisterTimers(QObject *object);
- QList<QPair<int, int> > registeredTimers(QObject *object) const;
-
- int activateTimers();
-};
-
struct QSockNot
{
QSocketNotifier *obj;
@@ -154,7 +111,7 @@ public:
void registerSocketNotifier(QSocketNotifier *notifier);
void unregisterSocketNotifier(QSocketNotifier *notifier);
- void registerTimer(int timerId, int interval, QObject *object);
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
bool unregisterTimer(int timerId);
bool unregisterTimers(QObject *object);
QList<TimerInfo> registeredTimers(QObject *object) const;
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index afee536d02..3ade11ca60 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -332,26 +332,6 @@ void QEventDispatcherWin32Private::activateEventNotifier(QWinEventNotifier * wen
QCoreApplication::sendEvent(wen, &event);
}
-// ### Qt 5: remove
-Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
- UINT wMsgFilterMax, UINT wRemoveMsg)
-{
- return PeekMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg);
-}
-
-// ### Qt 5: remove
-Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- return PostMessage(hWnd, msg, wParam, lParam);
-}
-
-// ### Qt 5: remove
-Q_CORE_EXPORT bool winGetMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
- UINT wMsgFilterMax)
-{
- return GetMessage(msg, hWnd, wMsgFilterMin, wMsgFilterMax);
-}
-
// This function is called by a workerthread
void WINAPI QT_WIN_CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_PTR user, DWORD_PTR /*reserved*/, DWORD_PTR /*reserved*/)
{
@@ -501,11 +481,16 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
wc.lpszClassName = reinterpret_cast<const wchar_t *> (className.utf16());
RegisterClass(&wc);
+#ifdef Q_OS_WINCE
+ HWND parent = 0;
+#else
+ HWND parent = HWND_MESSAGE;
+#endif
HWND wnd = CreateWindow(wc.lpszClassName, // classname
wc.lpszClassName, // window name
0, // style
0, 0, 0, 0, // geometry
- 0, // parent
+ parent, // parent
0, // menu handle
qWinAppInst(), // application
0); // windows creation data.
@@ -530,30 +515,29 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
Q_Q(QEventDispatcherWin32);
int ok = 0;
- if (t->interval > 20 || !t->interval || !qtimeSetEvent) {
+ uint interval = t->interval;
+ if (interval == 0u) {
+ // optimization for single-shot-zero-timer
+ QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
ok = 1;
- if (!t->interval) // optimization for single-shot-zero-timer
- QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
- else
- ok = SetTimer(internalHwnd, t->timerId, (uint) t->interval, 0);
- } else {
- ok = t->fastTimerId = qtimeSetEvent(t->interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
+ } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
+ ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
- if (ok == 0) { // fall back to normal timer if no more multimedia timers available
- ok = SetTimer(internalHwnd, t->timerId, (uint) t->interval, 0);
- }
+ } else if (interval >= 20000u || t->timerType == Qt::VeryCoarseTimer) {
+ // round the interval, VeryCoarseTimers only have full second accuracy
+ interval = ((interval + 500)) / 1000 * 1000;
+ }
+ if (ok == 0) {
+ // user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
+ ok = SetTimer(internalHwnd, t->timerId, interval, 0);
}
if (ok == 0)
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
}
-void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t, bool closingDown)
+void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
{
- // mark timer as unused
- if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent && !closingDown)
- QAbstractEventDispatcherPrivate::releaseTimerId(t->timerId);
-
if (t->interval == 0) {
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (t->fastTimerId != 0) {
@@ -859,7 +843,7 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
d->doWsaAsyncSelect(sockfd);
}
-void QEventDispatcherWin32::registerTimer(int timerId, int interval, QObject *object)
+void QEventDispatcherWin32::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
{
if (timerId < 1 || interval < 0 || !object) {
qWarning("QEventDispatcherWin32::registerTimer: invalid arguments");
@@ -875,6 +859,7 @@ void QEventDispatcherWin32::registerTimer(int timerId, int interval, QObject *ob
t->dispatcher = this;
t->timerId = timerId;
t->interval = interval;
+ t->timerType = timerType;
t->obj = object;
t->inTimerEvent = false;
t->fastTimerId = 0;
@@ -953,7 +938,7 @@ QEventDispatcherWin32::registeredTimers(QObject *object) const
for (int i = 0; i < d->timerVec.size(); ++i) {
const WinTimerInfo *t = d->timerVec.at(i);
if (t && t->obj == object)
- list << TimerInfo(t->timerId, t->interval);
+ list << TimerInfo(t->timerId, t->interval, t->timerType);
}
return list;
}
@@ -1050,7 +1035,7 @@ void QEventDispatcherWin32::closingDown()
// clean up any timers
for (int i = 0; i < d->timerVec.count(); ++i)
- d->unregisterTimer(d->timerVec.at(i), true);
+ d->unregisterTimer(d->timerVec.at(i));
d->timerVec.clear();
d->timerDict.clear();
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 4a7aac0c04..833fcf13ac 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -84,7 +84,7 @@ public:
void registerSocketNotifier(QSocketNotifier *notifier);
void unregisterSocketNotifier(QSocketNotifier *notifier);
- void registerTimer(int timerId, int interval, QObject *object);
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
bool unregisterTimer(int timerId);
bool unregisterTimers(QObject *object);
QList<TimerInfo> registeredTimers(QObject *object) const;
@@ -120,6 +120,7 @@ struct WinTimerInfo { // internal timer info
QObject *dispatcher;
int timerId;
int interval;
+ Qt::TimerType timerType;
QObject *obj; // - object to receive events
bool inTimerEvent;
int fastTimerId;
@@ -160,7 +161,7 @@ public:
WinTimerVec timerVec;
WinTimerDict timerDict;
void registerTimer(WinTimerInfo *t);
- void unregisterTimer(WinTimerInfo *t, bool closingDown = false);
+ void unregisterTimer(WinTimerInfo *t);
void sendTimerEvent(int timerId);
// socket notifiers
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 37c06a2093..05e284ba34 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index 5bd4146352..a76ba0ad93 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_nacl.cpp b/src/corelib/kernel/qfunctions_nacl.cpp
index 410df0f1e8..76272154b3 100644
--- a/src/corelib/kernel/qfunctions_nacl.cpp
+++ b/src/corelib/kernel/qfunctions_nacl.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_nacl.h b/src/corelib/kernel/qfunctions_nacl.h
index c4c1fd0e2e..a2f5d928f0 100644
--- a/src/corelib/kernel/qfunctions_nacl.h
+++ b/src/corelib/kernel/qfunctions_nacl.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 1e75fec25d..88686e976a 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_vxworks.cpp b/src/corelib/kernel/qfunctions_vxworks.cpp
index 845825740e..c39e6ad458 100644
--- a/src/corelib/kernel/qfunctions_vxworks.cpp
+++ b/src/corelib/kernel/qfunctions_vxworks.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h
index d7d4ebe382..22dc7bcc06 100644
--- a/src/corelib/kernel/qfunctions_vxworks.h
+++ b/src/corelib/kernel/qfunctions_vxworks.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp
index f0f1a071b9..8fd09679ce 100644
--- a/src/corelib/kernel/qfunctions_wince.cpp
+++ b/src/corelib/kernel/qfunctions_wince.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index 5569b7c777..d634cba67e 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmath.cpp b/src/corelib/kernel/qmath.cpp
index 376a707d66..fb5087092c 100644
--- a/src/corelib/kernel/qmath.cpp
+++ b/src/corelib/kernel/qmath.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index cc20f96166..793138a5e0 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc
index 5b21740d3a..b2de54ee32 100644
--- a/src/corelib/kernel/qmath.qdoc
+++ b/src/corelib/kernel/qmath.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 3178ee1b26..d7cbab8e3a 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -657,26 +657,17 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
if (strcmp(self->d.stringdata, name) == 0)
return self;
if (self->d.extradata) {
-#ifdef Q_NO_DATA_RELOCATION
- const QMetaObjectAccessor *e;
- Q_ASSERT(priv(self->d.data)->revision >= 2);
-#else
const QMetaObject **e;
if (priv(self->d.data)->revision < 2) {
e = (const QMetaObject**)(self->d.extradata);
} else
-#endif
{
const QMetaObjectExtraData *extra = (const QMetaObjectExtraData*)(self->d.extradata);
e = extra->objects;
}
if (e) {
while (*e) {
-#ifdef Q_NO_DATA_RELOCATION
- if (const QMetaObject *m =QMetaObject_findMetaObject(&((*e)()), name))
-#else
if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
-#endif
return m;
++e;
}
@@ -855,7 +846,7 @@ QMetaProperty QMetaObject::property(int index) const
Q_ASSERT(colon <= enum_name || *(colon-1) == ':');
if (colon > enum_name) {
int len = colon-enum_name-1;
- scope_buffer = (char *)qMalloc(len+1);
+ scope_buffer = (char *)malloc(len+1);
qMemCopy(scope_buffer, enum_name, len);
scope_buffer[len] = '\0';
scope_name = scope_buffer;
@@ -870,7 +861,7 @@ QMetaProperty QMetaObject::property(int index) const
if (scope)
result.menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
if (scope_buffer)
- qFree(scope_buffer);
+ free(scope_buffer);
}
}
}
@@ -1644,9 +1635,9 @@ bool QMetaMethod::invoke(QObject *object,
}
int nargs = 1; // include return type
- void **args = (void **) qMalloc(paramCount * sizeof(void *));
+ void **args = (void **) malloc(paramCount * sizeof(void *));
Q_CHECK_PTR(args);
- int *types = (int *) qMalloc(paramCount * sizeof(int));
+ int *types = (int *) malloc(paramCount * sizeof(int));
Q_CHECK_PTR(types);
types[0] = 0; // return type
args[0] = 0;
@@ -1663,8 +1654,8 @@ bool QMetaMethod::invoke(QObject *object,
if (types[x] && args[x])
QMetaType::destroy(types[x], args[x]);
}
- qFree(types);
- qFree(args);
+ free(types);
+ free(args);
return false;
}
}
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 47ccc9e2b7..61ca373745 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h
index fd4e5d25c8..abfdc442c0 100644
--- a/src/corelib/kernel/qmetaobject_moc_p.h
+++ b/src/corelib/kernel/qmetaobject_moc_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index b99907e822..45fb95495c 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index dd098e8a64..601d52529f 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -265,11 +265,7 @@ public:
QList<QByteArray> classInfoNames;
QList<QByteArray> classInfoValues;
QList<QMetaEnumBuilderPrivate> enumerators;
-#ifdef Q_NO_DATA_RELOCATION
- QList<QMetaObjectAccessor> relatedMetaObjects;
-#else
QList<const QMetaObject *> relatedMetaObjects;
-#endif
int flags;
};
@@ -695,11 +691,7 @@ int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& v
\sa relatedMetaObjectCount(), relatedMetaObject()
\sa removeRelatedMetaObject()
*/
-#ifdef Q_NO_DATA_RELOCATION
-int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObjectAccessor &meta)
-#else
int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
-#endif
{
Q_ASSERT(meta);
int index = d->relatedMetaObjects.size();
@@ -772,14 +764,10 @@ void QMetaObjectBuilder::addMetaObject
}
if ((members & RelatedMetaObjects) != 0) {
-#ifdef Q_NO_DATA_RELOCATION
- const QMetaObjectAccessor *objects = 0;
-#else
const QMetaObject **objects;
if (priv(prototype->d.data)->revision < 2) {
objects = (const QMetaObject **)(prototype->d.extradata);
} else
-#endif
{
const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
if (extra)
@@ -871,11 +859,7 @@ QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const
{
if (index >= 0 && index < d->relatedMetaObjects.size())
-#ifdef Q_NO_DATA_RELOCATION
- return &((*(d->relatedMetaObjects[index]))());
-#else
return d->relatedMetaObjects[index];
-#endif
else
return 0;
}
@@ -1414,13 +1398,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
reinterpret_cast<QMetaObjectExtraData *>(buf + size);
size += sizeof(QMetaObjectExtraData);
ALIGN(size, QMetaObject *);
-#ifdef Q_NO_DATA_RELOCATION
- QMetaObjectAccessor *objects =
- reinterpret_cast<QMetaObjectAccessor *>(buf + size);
-#else
const QMetaObject **objects =
reinterpret_cast<const QMetaObject **>(buf + size);
-#endif
if (buf) {
if (d->relatedMetaObjects.size() > 0) {
extra->objects = objects;
@@ -1444,7 +1423,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
/*!
Converts this meta object builder into a concrete QMetaObject.
- The return value should be deallocated using qFree() once it
+ The return value should be deallocated using free() once it
is no longer needed.
The returned meta object is a snapshot of the state of the
@@ -1455,7 +1434,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
QMetaObject *QMetaObjectBuilder::toMetaObject() const
{
int size = buildMetaObject(d, 0, false);
- char *buf = reinterpret_cast<char *>(qMalloc(size));
+ char *buf = reinterpret_cast<char *>(malloc(size));
memset(buf, 0, size);
buildMetaObject(d, buf, false);
return reinterpret_cast<QMetaObject *>(buf);
@@ -1619,14 +1598,10 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Write the related meta objects.
-#ifdef Q_NO_DATA_RELOCATION
- //### What do we do here?
-#else
for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
const QMetaObject *meta = d->relatedMetaObjects[index];
stream << QByteArray(meta->className());
}
-#endif
// Add an extra empty QByteArray for additional data in future versions.
// This should help maintain backwards compatibility, allowing older
@@ -1799,9 +1774,6 @@ void QMetaObjectBuilder::deserialize
}
// Read the related meta objects.
-#ifdef Q_NO_DATA_RELOCATION
- //### What do we do here
-#else
for (index = 0; index < relatedMetaObjectCount; ++index) {
if (stream.status() != QDataStream::Ok)
return;
@@ -1813,7 +1785,6 @@ void QMetaObjectBuilder::deserialize
}
addRelatedMetaObject(cl);
}
-#endif
// Read the extra data block, which is reserved for future use.
stream >> name;
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index a563d6a5cd..bf3fd2499c 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -136,11 +136,7 @@ public:
int addClassInfo(const QByteArray& name, const QByteArray& value);
-#ifdef Q_NO_DATA_RELOCATION
- int addRelatedMetaObject(const QMetaObjectAccessor &meta);
-#else
int addRelatedMetaObject(const QMetaObject *meta);
-#endif
void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 76537c79cb..375c7b75bb 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -50,6 +50,7 @@
#include "qvector.h"
#include "qlocale.h"
#include "qeasingcurve.h"
+#include "quuid.h"
#include "qvariant.h"
#include "qmetatypeswitcher_p.h"
@@ -61,6 +62,7 @@
# include "qbitarray.h"
# include "qurl.h"
# include "qvariant.h"
+# include "qabstractitemmodel.h"
#endif
#ifndef QT_NO_GEOM_VARIANT
@@ -107,6 +109,7 @@ template<> struct TypeDefiniton<QVariant> { static const bool IsAvailable = fals
template<> struct TypeDefiniton<QBitArray> { static const bool IsAvailable = false; };
template<> struct TypeDefiniton<QUrl> { static const bool IsAvailable = false; };
template<> struct TypeDefiniton<QEasingCurve> { static const bool IsAvailable = false; };
+template<> struct TypeDefiniton<QModelIndex> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_REGEXP
template<> struct TypeDefiniton<QRegExp> { static const bool IsAvailable = false; };
@@ -240,6 +243,16 @@ template<> struct TypeDefiniton<QRegExp> { static const bool IsAvailable = false
*/
/*!
+ \enum QMetaType::TypeFlags
+
+ The enum describes attributes of a type supported by QMetaType.
+
+ \value NeedsConstruction This type has non-trivial constructors. If the flag is not set instances can be safely initialized with memset to 0.
+ \value NeedsDestruction This type has a non-trivial destructor. If the flag is not set calls to the destructor are not necessary before discarding objects.
+ \value MovableType An instance of a type having this attribute can be safely moved by memcpy.
+*/
+
+/*!
\class QMetaType
\brief The QMetaType class manages named types in the meta-object system.
@@ -297,6 +310,14 @@ public:
int alias;
};
+namespace
+{
+union CheckThatItIsPod
+{ // This should break if QMetaTypeInterface is not a POD type
+ QMetaTypeInterface iface;
+};
+}
+
Q_DECLARE_TYPEINFO(QCustomTypeInfo, Q_MOVABLE_TYPE);
Q_GLOBAL_STATIC(QVector<QCustomTypeInfo>, customTypes)
Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock)
@@ -415,7 +436,7 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
int QMetaType::registerType(const char *typeName, Deleter deleter,
Creator creator)
{
- return registerType(typeName, deleter, creator, 0, 0, 0);
+ return registerType(typeName, deleter, creator, 0, 0, 0, TypeFlags());
}
/*! \internal
@@ -430,7 +451,7 @@ int QMetaType::registerType(const char *typeName, Deleter deleter,
Creator creator,
Destructor destructor,
Constructor constructor,
- int size)
+ int size, TypeFlags flags)
{
QVector<QCustomTypeInfo> *ct = customTypes();
if (!ct || !typeName || !deleter || !creator)
@@ -454,10 +475,15 @@ int QMetaType::registerType(const char *typeName, Deleter deleter,
inf.typeName = normalizedTypeName;
inf.creator = creator;
inf.deleter = deleter;
+#ifndef QT_NO_DATASTREAM
+ inf.loadOp = 0;
+ inf.saveOp = 0;
+#endif
inf.alias = -1;
inf.constructor = constructor;
inf.destructor = destructor;
inf.size = size;
+ inf.flags = flags;
idx = ct->size() + User;
ct->append(inf);
}
@@ -765,6 +791,9 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
return false;
qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data);
break;
+ case QMetaType::QUuid:
+ stream << *static_cast<const NS(QUuid)*>(data);
+ break;
default: {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
@@ -972,6 +1001,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
return false;
qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data);
break;
+ case QMetaType::QUuid:
+ stream >> *static_cast< NS(QUuid)*>(data);
+ break;
default: {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
@@ -1092,6 +1124,12 @@ void *QMetaType::create(int type, const void *copy)
case QMetaType::QEasingCurve:
return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy));
#endif
+ case QMetaType::QUuid:
+ return new NS(QUuid)(*static_cast<const NS(QUuid)*>(copy));
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QModelIndex:
+ return new NS(QModelIndex)(*static_cast<const NS(QModelIndex)*>(copy));
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1189,6 +1227,12 @@ void *QMetaType::create(int type, const void *copy)
case QMetaType::QEasingCurve:
return new NS(QEasingCurve);
#endif
+ case QMetaType::QUuid:
+ return new NS(QUuid);
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QModelIndex:
+ return new NS(QModelIndex);
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1356,6 +1400,14 @@ void QMetaType::destroy(int type, void *data)
delete static_cast< NS(QEasingCurve)* >(data);
break;
#endif
+ case QMetaType::QUuid:
+ delete static_cast< NS(QUuid)* >(data);
+ break;
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QModelIndex:
+ delete static_cast< NS(QModelIndex)* >(data);
+ break;
+#endif
case QMetaType::Void:
break;
default: {
@@ -1387,9 +1439,8 @@ void QMetaType::destroy(int type, void *data)
}
namespace {
-template<class Filter>
class TypeConstructor {
- template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted>
+ template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct ConstructorImpl {
static void *Construct(const int /*type*/, void *where, const T *copy) { return qMetaTypeConstructHelper(where, copy); }
};
@@ -1398,13 +1449,11 @@ class TypeConstructor {
static void *Construct(const int type, void *where, const T *copy)
{
QMetaType::Constructor ctor = 0;
- if (type >= QMetaType::FirstGuiType && type <= QMetaType::LastGuiType) {
- Q_ASSERT(qMetaTypeGuiHelper);
+ if (QTypeModuleInfo<T>::IsGui) {
if (!qMetaTypeGuiHelper)
return 0;
ctor = qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].constructor;
- } else if (type >= QMetaType::FirstWidgetsType && type <= QMetaType::LastWidgetsType) {
- Q_ASSERT(qMetaTypeWidgetsHelper);
+ } else if (QTypeModuleInfo<T>::IsWidget) {
if (!qMetaTypeWidgetsHelper)
return 0;
ctor = qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].constructor;
@@ -1474,15 +1523,14 @@ void *QMetaType::construct(int type, void *where, const void *copy)
{
if (!where)
return 0;
- TypeConstructor<DefinedTypesFilter> constructor(type, where);
+ TypeConstructor constructor(type, where);
return QMetaTypeSwitcher::switcher<void*>(constructor, type, copy);
}
namespace {
-template<class Filter>
class TypeDestructor {
- template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted>
+ template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct DestructorImpl {
static void Destruct(const int /* type */, T *where) { qMetaTypeDestructHelper(where); }
};
@@ -1491,13 +1539,11 @@ class TypeDestructor {
static void Destruct(const int type, void *where)
{
QMetaType::Destructor dtor = 0;
- if (type >= QMetaType::FirstGuiType && type <= QMetaType::LastGuiType) {
- Q_ASSERT(qMetaTypeGuiHelper);
+ if (QTypeModuleInfo<T>::IsGui) {
if (!qMetaTypeGuiHelper)
return;
dtor = qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].destructor;
- } else if (type >= QMetaType::FirstWidgetsType && type <= QMetaType::LastWidgetsType) {
- Q_ASSERT(qMetaTypeWidgetsHelper);
+ } else if (QTypeModuleInfo<T>::IsWidget) {
if (!qMetaTypeWidgetsHelper)
return;
dtor = qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].destructor;
@@ -1550,15 +1596,14 @@ void QMetaType::destruct(int type, void *where)
{
if (!where)
return;
- TypeDestructor<DefinedTypesFilter> destructor(type);
+ TypeDestructor destructor(type);
QMetaTypeSwitcher::switcher<void>(destructor, type, where);
}
namespace {
-template<class Filter>
class SizeOf {
- template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted>
+ template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
struct SizeOfImpl {
static int Size(const int) { return sizeof(T); }
};
@@ -1566,13 +1611,11 @@ class SizeOf {
struct SizeOfImpl<T, /* IsAcceptedType = */ false> {
static int Size(const int type)
{
- if (type >= QMetaType::FirstGuiType && type <= QMetaType::LastGuiType) {
- Q_ASSERT(qMetaTypeGuiHelper);
+ if (QTypeModuleInfo<T>::IsGui) {
if (!qMetaTypeGuiHelper)
return 0;
return qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].size;
- } else if (type >= QMetaType::FirstWidgetsType && type <= QMetaType::LastWidgetsType) {
- Q_ASSERT(qMetaTypeWidgetsHelper);
+ } else if (QTypeModuleInfo<T>::IsWidget) {
if (!qMetaTypeWidgetsHelper)
return 0;
return qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].size;
@@ -1617,10 +1660,77 @@ private:
*/
int QMetaType::sizeOf(int type)
{
- SizeOf<DefinedTypesFilter> sizeOf(type);
+ SizeOf sizeOf(type);
return QMetaTypeSwitcher::switcher<int>(sizeOf, type, 0);
}
+namespace {
+class Flags
+{
+ template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted>
+ struct FlagsImpl
+ {
+ static quint32 Flags(const int)
+ {
+ return (!QTypeInfo<T>::isStatic * QMetaType::MovableType)
+ | (QTypeInfo<T>::isComplex * QMetaType::NeedsConstruction)
+ | (QTypeInfo<T>::isComplex * QMetaType::NeedsDestruction);
+ }
+ };
+ template<typename T>
+ struct FlagsImpl<T, /* IsAcceptedType = */ false>
+ {
+ static quint32 Flags(const int type)
+ {
+ return Flags::undefinedTypeFlags(type);
+ }
+ };
+public:
+ Flags(const int type)
+ : m_type(type)
+ {}
+ template<typename T>
+ quint32 delegate(const T*) { return FlagsImpl<T>::Flags(m_type); }
+ quint32 delegate(const QMetaTypeSwitcher::UnknownType*) { return customTypeFlags(m_type); }
+private:
+ const int m_type;
+ static quint32 customTypeFlags(const int type)
+ {
+ const QVector<QCustomTypeInfo> * const ct = customTypes();
+ if (!ct)
+ return 0;
+ QReadLocker locker(customTypesLock());
+ if (ct->count() <= type - QMetaType::User)
+ return 0;
+ return ct->at(type - QMetaType::User).flags;
+ }
+ static quint32 undefinedTypeFlags(const int type);
+};
+
+quint32 Flags::undefinedTypeFlags(const int type)
+{
+ if (type >= QMetaType::FirstGuiType && type <= QMetaType::LastGuiType)
+ return qMetaTypeGuiHelper ? qMetaTypeGuiHelper[type - QMetaType::FirstGuiType].flags : 0;
+ else if (type >= QMetaType::FirstWidgetsType && type <= QMetaType::LastWidgetsType)
+ return qMetaTypeWidgetsHelper ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].flags : 0;
+ return customTypeFlags(type);
+}
+
+} // namespace
+
+/*!
+ \since 5.0
+
+ Returns flags of the given \a type.
+
+ \sa TypeFlags()
+*/
+QMetaType::TypeFlags QMetaType::typeFlags(int type)
+{
+ Flags flags(type);
+ return static_cast<QMetaType::TypeFlags>(QMetaTypeSwitcher::switcher<quint32>(flags, type, 0));
+}
+
/*!
\fn int qRegisterMetaType(const char *typeName)
\relates QMetaType
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 717e72c810..843044eee6 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -98,6 +98,8 @@ QT_MODULE(Core)
F(QPointF, 26, QPointF) \
F(QRegExp, 27, QRegExp) \
F(QEasingCurve, 29, QEasingCurve) \
+ F(QUuid, 30, QUuid) \
+ F(QModelIndex, 31, QModelIndex) \
F(QVariant, 138, QVariant) \
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
@@ -182,7 +184,7 @@ public:
// these are merged with QVariant
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
- LastCoreType = QEasingCurve,
+ LastCoreType = QModelIndex,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QIcon,
@@ -202,6 +204,13 @@ public:
User = 256
};
+ enum TypeFlag {
+ NeedsConstruction = 0x1,
+ NeedsDestruction = 0x2,
+ MovableType = 0x4
+ };
+ Q_DECLARE_FLAGS(TypeFlags, TypeFlag)
+
typedef void (*Deleter)(void *);
typedef void *(*Creator)(const void *);
@@ -222,11 +231,13 @@ public:
Creator creator,
Destructor destructor,
Constructor constructor,
- int size);
+ int size,
+ QMetaType::TypeFlags flags);
static int registerTypedef(const char *typeName, int aliasId);
static int type(const char *typeName);
static const char *typeName(int type);
static int sizeOf(int type);
+ static TypeFlags typeFlags(int type);
static bool isRegistered(int type);
static void *create(int type, const void *copy = 0);
#if QT_DEPRECATED_SINCE(5, 0)
@@ -246,6 +257,8 @@ public:
#undef QT_DEFINE_METATYPE_ID
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
+
template <typename T>
void qMetaTypeDeleteHelper(T *t)
{
@@ -334,11 +347,20 @@ int qRegisterMetaType(const char *typeName
typedef void(*DestructPtr)(T*);
DestructPtr ipdptr = qMetaTypeDestructHelper<T>;
+ QMetaType::TypeFlags flags;
+ if (!QTypeInfo<T>::isStatic)
+ flags |= QMetaType::MovableType;
+ if (QTypeInfo<T>::isComplex) {
+ flags |= QMetaType::NeedsConstruction;
+ flags |= QMetaType::NeedsDestruction;
+ }
+
return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Deleter>(dptr),
reinterpret_cast<QMetaType::Creator>(cptr),
reinterpret_cast<QMetaType::Destructor>(ipdptr),
reinterpret_cast<QMetaType::Constructor>(ipcptr),
- sizeof(T));
+ sizeof(T),
+ flags);
}
#ifndef QT_NO_DATASTREAM
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 92311afc8e..11139288d1 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -57,11 +57,22 @@
QT_BEGIN_NAMESPACE
-enum { /* TYPEMODULEINFO flags */
- Q_CORE_TYPE = 1,
- Q_GUI_TYPE = 2,
- Q_WIDGET_TYPE = 3
-};
+namespace QModulesPrivate {
+enum Names { Core, Gui, Widgets, Unknown, ModulesCount /* ModulesCount has to be at the end */ };
+
+static inline int moduleForType(const int typeId)
+{
+ if (typeId <= QMetaType::LastCoreType)
+ return Core;
+ if (typeId <= QMetaType::LastGuiType)
+ return Gui;
+ if (typeId <= QMetaType::LastWidgetsType)
+ return Widgets;
+ if (typeId <= QMetaType::LastCoreExtType)
+ return Core;
+ return Unknown;
+}
+}
template <typename T>
class QTypeModuleInfo
@@ -73,7 +84,6 @@ public:
IsGui = false,
IsUnknown = !IsCore
};
- static inline int module() { return IsCore ? Q_CORE_TYPE : 0; }
};
#define QT_ASSIGN_TYPE_TO_MODULE(TYPE, MODULE) \
@@ -82,9 +92,9 @@ class QTypeModuleInfo<TYPE > \
{ \
public: \
enum Module { \
- IsCore = (((MODULE) == (Q_CORE_TYPE))), \
- IsWidget = (((MODULE) == (Q_WIDGET_TYPE))), \
- IsGui = (((MODULE) == (Q_GUI_TYPE))), \
+ IsCore = (((MODULE) == (QModulesPrivate::Core))), \
+ IsWidget = (((MODULE) == (QModulesPrivate::Widgets))), \
+ IsGui = (((MODULE) == (QModulesPrivate::Gui))), \
IsUnknown = !(IsCore || IsWidget || IsGui) \
}; \
static inline int module() { return MODULE; } \
@@ -96,11 +106,11 @@ public: \
#define QT_DECLARE_CORE_MODULE_TYPES_ITER(TypeName, TypeId, Name) \
- QT_ASSIGN_TYPE_TO_MODULE(Name, Q_CORE_TYPE);
+ QT_ASSIGN_TYPE_TO_MODULE(Name, QModulesPrivate::Core);
#define QT_DECLARE_GUI_MODULE_TYPES_ITER(TypeName, TypeId, Name) \
- QT_ASSIGN_TYPE_TO_MODULE(Name, Q_GUI_TYPE);
+ QT_ASSIGN_TYPE_TO_MODULE(Name, QModulesPrivate::Gui);
#define QT_DECLARE_WIDGETS_MODULE_TYPES_ITER(TypeName, TypeId, Name) \
- QT_ASSIGN_TYPE_TO_MODULE(Name, Q_WIDGET_TYPE);
+ QT_ASSIGN_TYPE_TO_MODULE(Name, QModulesPrivate::Widgets);
QT_FOR_EACH_STATIC_CORE_CLASS(QT_DECLARE_CORE_MODULE_TYPES_ITER)
QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_DECLARE_CORE_MODULE_TYPES_ITER)
@@ -113,7 +123,7 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_DECLARE_WIDGETS_MODULE_TYPES_ITER)
class QMetaTypeInterface
{
-private:
+public:
template<typename T>
struct Impl {
static void *creator(const T *t)
@@ -140,31 +150,6 @@ private:
return new (where) T;
}
};
-public:
- template<typename T>
- explicit QMetaTypeInterface(T *)
- : creator(reinterpret_cast<QMetaType::Creator>(Impl<T>::creator))
- , deleter(reinterpret_cast<QMetaType::Deleter>(Impl<T>::deleter))
- #ifndef QT_NO_DATASTREAM
- , saveOp(reinterpret_cast<QMetaType::SaveOperator>(Impl<T>::saver))
- , loadOp(reinterpret_cast<QMetaType::LoadOperator>(Impl<T>::loader))
- #endif
- , constructor(reinterpret_cast<QMetaType::Constructor>(Impl<T>::constructor))
- , destructor(reinterpret_cast<QMetaType::Destructor>(Impl<T>::destructor))
- , size(sizeof(T))
- {}
-
- QMetaTypeInterface()
- : creator(0)
- , deleter(0)
- #ifndef QT_NO_DATASTREAM
- , saveOp(0)
- , loadOp(0)
- #endif
- , constructor(0)
- , destructor(0)
- , size(0)
- {}
QMetaType::Creator creator;
QMetaType::Deleter deleter;
@@ -175,8 +160,30 @@ public:
QMetaType::Constructor constructor;
QMetaType::Destructor destructor;
int size;
+ quint32 flags; // same as QMetaType::TypeFlags
};
+#ifndef QT_NO_DATASTREAM
+# define QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type) \
+ /*saveOp*/(reinterpret_cast<QMetaType::SaveOperator>(QMetaTypeInterface::Impl<Type>::saver)), \
+ /*loadOp*/(reinterpret_cast<QMetaType::LoadOperator>(QMetaTypeInterface::Impl<Type>::loader)),
+#else
+# define QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type)
+#endif
+
+#define QT_METATYPE_INTERFACE_INIT(Type) \
+{ \
+ /*creator*/(reinterpret_cast<QMetaType::Creator>(QMetaTypeInterface::Impl<Type>::creator)), \
+ /*deleter*/(reinterpret_cast<QMetaType::Deleter>(QMetaTypeInterface::Impl<Type>::deleter)), \
+ QT_METATYPE_INTERFACE_INIT_DATASTREAM_IMPL(Type) \
+ /*constructor*/(reinterpret_cast<QMetaType::Constructor>(QMetaTypeInterface::Impl<Type>::constructor)), \
+ /*destructor*/(reinterpret_cast<QMetaType::Destructor>(QMetaTypeInterface::Impl<Type>::destructor)), \
+ /*size*/(sizeof(Type)), \
+ /*flags*/(!QTypeInfo<Type>::isStatic * QMetaType::MovableType) \
+ | (QTypeInfo<Type>::isComplex * QMetaType::NeedsConstruction) \
+ | (QTypeInfo<Type>::isComplex * QMetaType::NeedsDestruction) \
+}
+
QT_END_NAMESPACE
#endif // QMETATYPE_P_H
diff --git a/src/corelib/kernel/qmetatypeswitcher_p.h b/src/corelib/kernel/qmetatypeswitcher_p.h
index cba6504956..d3cf1024c3 100644
--- a/src/corelib/kernel/qmetatypeswitcher_p.h
+++ b/src/corelib/kernel/qmetatypeswitcher_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 9d1e03e9e8..c43ef505fb 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qmimedata.h b/src/corelib/kernel/qmimedata.h
index e8f32ed43c..60498b7ab8 100644
--- a/src/corelib/kernel/qmimedata.h
+++ b/src/corelib/kernel/qmimedata.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index e4ef826ffd..bebdcac662 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -44,6 +44,7 @@
#include "qmetaobject_p.h"
#include "qabstracteventdispatcher.h"
+#include "qabstracteventdispatcher_p.h"
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qvariant.h"
@@ -162,30 +163,28 @@ QObjectPrivate::QObjectPrivate(int version)
q_ptr = 0;
parent = 0; // no parent yet. It is set by setParent()
isWidget = false; // assume not a widget object
- pendTimer = false; // no timers yet
blockSig = false; // not blocking signals
wasDeleted = false; // double-delete catcher
+ isDeletingChildren = false; // set by deleteChildren()
sendChildEvents = true; // if we should send ChildInsert and ChildRemove events to parent
receiveChildEvents = true;
postedEvents = 0;
extraData = 0;
connectedSignals[0] = connectedSignals[1] = 0;
- inThreadChangeEvent = false;
-#ifdef QT_JAMBI_BUILD
- inEventHandler = false;
- deleteWatch = 0;
-#endif
metaObject = 0;
- hasGuards = false;
isWindow = false;
}
QObjectPrivate::~QObjectPrivate()
{
- if (pendTimer) {
+ if (!runningTimers.isEmpty()) {
// unregister pending timers
if (threadData->eventDispatcher)
threadData->eventDispatcher->unregisterTimers(q_ptr);
+
+ // release the timer ids back to the pool
+ for (int i = 0; i < runningTimers.size(); ++i)
+ QAbstractEventDispatcherPrivate::releaseTimerId(runningTimers.at(i));
}
if (postedEvents)
@@ -194,10 +193,6 @@ QObjectPrivate::~QObjectPrivate()
threadData->deref();
delete static_cast<QAbstractDynamicMetaObject*>(metaObject);
-#ifdef QT_JAMBI_BUILD
- if (deleteWatch)
- *deleteWatch = 1;
-#endif
#ifndef QT_NO_USERDATA
if (extraData)
qDeleteAll(extraData->userData);
@@ -205,25 +200,6 @@ QObjectPrivate::~QObjectPrivate()
#endif
}
-
-#ifdef QT_JAMBI_BUILD
-int *QObjectPrivate::setDeleteWatch(QObjectPrivate *d, int *w) {
- int *old = d->deleteWatch;
- d->deleteWatch = w;
- return old;
-}
-
-
-void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch) {
- if (!deleteWatch)
- d->deleteWatch = oldWatch;
-
- if (oldWatch)
- *oldWatch = deleteWatch;
-}
-#endif
-
-
/*!\internal
For a given metaobject, compute the signal offset, and the method offset (including signals)
*/
@@ -408,113 +384,6 @@ void QObjectPrivate::cleanConnectionLists()
}
}
-typedef QMultiHash<QObject *, QObject **> GuardHash;
-Q_GLOBAL_STATIC(GuardHash, guardHash)
-Q_GLOBAL_STATIC(QMutex, guardHashLock)
-
-/*!\internal
- */
-void QMetaObject::addGuard(QObject **ptr)
-{
- if (!*ptr)
- return;
- GuardHash *hash = guardHash();
- if (!hash) {
- *ptr = 0;
- return;
- }
- QMutexLocker locker(guardHashLock());
- QObjectPrivate::get(*ptr)->hasGuards = true;
- hash->insert(*ptr, ptr);
-}
-
-/*!\internal
- */
-void QMetaObject::removeGuard(QObject **ptr)
-{
- if (!*ptr)
- return;
- GuardHash *hash = guardHash();
- /* 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());
- if (!*ptr) //check again, under the lock
- return;
- GuardHash::iterator it = hash->find(*ptr);
- const GuardHash::iterator end = hash->end();
- bool more = false; //if the QObject has more pointer attached to it.
- for (; it.key() == *ptr && it != end; ++it) {
- if (it.value() == ptr) {
- it = hash->erase(it);
- if (!more) more = (it != end && it.key() == *ptr);
- break;
- }
- more = true;
- }
- if (!more)
- QObjectPrivate::get(*ptr)->hasGuards = false;
-}
-
-/*!\internal
- */
-void QMetaObject::changeGuard(QObject **ptr, QObject *o)
-{
- GuardHash *hash = guardHash();
- if (!hash) {
- *ptr = 0;
- return;
- }
- QMutexLocker locker(guardHashLock());
- if (o) {
- hash->insert(o, ptr);
- QObjectPrivate::get(o)->hasGuards = true;
- }
- if (*ptr) {
- bool more = false; //if the QObject has more pointer attached to it.
- GuardHash::iterator it = hash->find(*ptr);
- const GuardHash::iterator end = hash->end();
- for (; it.key() == *ptr && it != end; ++it) {
- if (it.value() == ptr) {
- it = hash->erase(it);
- if (!more) more = (it != end && it.key() == *ptr);
- break;
- }
- more = true;
- }
- if (!more)
- QObjectPrivate::get(*ptr)->hasGuards = false;
- }
- *ptr = o;
-}
-
-/*! \internal
- */
-void QObjectPrivate::clearGuards(QObject *object)
-{
- 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) {
- *it.value() = 0;
- it = hash->erase(it);
- }
- }
-}
-
/*! \internal
*/
QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction,
@@ -546,8 +415,8 @@ QMetaCallEvent::~QMetaCallEvent()
if (types_[i] && args_[i])
QMetaType::destroy(types_[i], args_[i]);
}
- qFree(types_);
- qFree(args_);
+ free(types_);
+ free(args_);
}
#ifndef QT_NO_THREAD
if (semaphore_)
@@ -563,7 +432,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
{
if (slotObj_) {
slotObj_->call(object, args_);
- } else if (callFunction_) {
+ } else if (callFunction_ && method_offset_ <= object->metaObject()->methodOffset()) {
callFunction_(object, QMetaObject::InvokeMetaMethod, method_relative_, args_);
} else {
QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method_offset_ + method_relative_, args_);
@@ -839,12 +708,6 @@ QObject::~QObject()
d->wasDeleted = true;
d->blockSig = 0; // unblock signals so we always emit destroyed()
- if (d->hasGuards && !d->isWidget) {
- // set all QPointers for this object to zero - note that
- // ~QWidget() does this for us, so we don't have to do it twice
- QObjectPrivate::clearGuards(this);
- }
-
QtSharedPointer::ExternalRefCountData *sharedRefcount = d->sharedRefcount.load();
if (sharedRefcount) {
if (sharedRefcount->strongref.load() > 0) {
@@ -950,13 +813,6 @@ QObject::~QObject()
if (d->parent) // remove it from parent object
d->setParent_helper(0);
-
-#ifdef QT_JAMBI_BUILD
- if (d->inEventHandler) {
- qWarning("QObject: Do not delete object, '%s', during its event handler!",
- objectName().isNull() ? "unnamed" : qPrintable(objectName()));
- }
-#endif
}
QObjectPrivate::Connection::~Connection()
@@ -1096,13 +952,20 @@ QString QObject::objectName() const
void QObject::setObjectName(const QString &name)
{
Q_D(QObject);
- bool objectNameChanged = d->declarativeData && d->objectName != name;
+ if (d->objectName != name) {
+ d->objectName = name;
+ if (d->declarativeData)
+ d->declarativeData->objectNameChanged(d->declarativeData, this);
+ emit objectNameChanged(d->objectName);
+ }
+}
- d->objectName = name;
+/*! \fn void QObject::objectNameChanged(const QString &objectName)
- if (objectNameChanged)
- d->declarativeData->objectNameChanged(d->declarativeData, this);
-}
+ This signal is emitted after the object's name has been changed. The new object name is passed as \a objectName.
+
+ \sa QObject::objectName
+*/
/*!
\fn bool QObject::isWidgetType() const
@@ -1144,9 +1007,6 @@ bool QObject::event(QEvent *e)
case QEvent::MetaCall:
{
-#ifdef QT_JAMBI_BUILD
- d_func()->inEventHandler = false;
-#endif
QMetaCallEvent *mce = static_cast<QMetaCallEvent*>(e);
QConnectionSenderSwitcher sw(this, const_cast<QObject*>(mce->sender()), mce->signalId());
@@ -1160,15 +1020,12 @@ bool QObject::event(QEvent *e)
QThreadData *threadData = d->threadData;
QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
if (eventDispatcher) {
- QList<QPair<int, int> > timers = eventDispatcher->registeredTimers(this);
+ QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this);
if (!timers.isEmpty()) {
- // set inThreadChangeEvent to true to tell the dispatcher not to release out timer ids
- // back to the pool (since the timer ids are moving to a new thread).
- d->inThreadChangeEvent = true;
+ // do not to release our timer ids back to the pool (since the timer ids are moving to a new thread).
eventDispatcher->unregisterTimers(this);
- d->inThreadChangeEvent = false;
QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
- Q_ARG(void*, (new QList<QPair<int, int> >(timers))));
+ Q_ARG(void*, (new QList<QAbstractEventDispatcher::TimerInfo>(timers))));
}
}
break;
@@ -1451,15 +1308,6 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
currentSender->ref = 0;
currentSender = 0;
-#ifdef QT_JAMBI_BUILD
- // the current event thread also shouldn't restore the delete watch
- inEventHandler = false;
-
- if (deleteWatch)
- *deleteWatch = 1;
- deleteWatch = 0;
-#endif
-
// set new thread data
targetData->ref();
threadData->deref();
@@ -1474,11 +1322,11 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
void QObjectPrivate::_q_reregisterTimers(void *pointer)
{
Q_Q(QObject);
- QList<QPair<int, int> > *timerList = reinterpret_cast<QList<QPair<int, int> > *>(pointer);
+ QList<QAbstractEventDispatcher::TimerInfo> *timerList = reinterpret_cast<QList<QAbstractEventDispatcher::TimerInfo> *>(pointer);
QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
for (int i = 0; i < timerList->size(); ++i) {
- const QPair<int, int> &pair = timerList->at(i);
- eventDispatcher->registerTimer(pair.first, pair.second, q);
+ const QAbstractEventDispatcher::TimerInfo &ti = timerList->at(i);
+ eventDispatcher->registerTimer(ti.timerId, ti.interval, ti.timerType, q);
}
delete timerList;
}
@@ -1510,10 +1358,12 @@ void QObjectPrivate::_q_reregisterTimers(void *pointer)
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 8
- Note that QTimer's accuracy depends on the underlying operating
- system and hardware. Most platforms support an accuracy of 20
- milliseconds; some provide more. If Qt is unable to deliver the
- requested number of timer events, it will silently discard some.
+ Note that QTimer's accuracy depends on the underlying operating system and
+ hardware. The \a timerType argument allows you to customize the accuracy of
+ the timer. See Qt::TimerType for information on the different timer types.
+ Most platforms support an accuracy of 20 milliseconds; some provide more.
+ If Qt is unable to deliver the requested number of timer events, it will
+ silently discard some.
The QTimer class provides a high-level programming interface with
single-shot timers and timer signals instead of events. There is
@@ -1523,7 +1373,7 @@ void QObjectPrivate::_q_reregisterTimers(void *pointer)
\sa timerEvent(), killTimer(), QTimer::singleShot()
*/
-int QObject::startTimer(int interval)
+int QObject::startTimer(int interval, Qt::TimerType timerType)
{
Q_D(QObject);
@@ -1532,13 +1382,13 @@ int QObject::startTimer(int interval)
return 0;
}
- d->pendTimer = true; // set timer flag
-
if (!d->threadData->eventDispatcher) {
qWarning("QObject::startTimer: QTimer can only be used with threads started with QThread");
return 0;
}
- return d->threadData->eventDispatcher->registerTimer(interval, this);
+ int timerId = d->threadData->eventDispatcher->registerTimer(interval, timerType, this);
+ d->runningTimers.append(timerId);
+ return timerId;
}
/*!
@@ -1553,8 +1403,23 @@ int QObject::startTimer(int interval)
void QObject::killTimer(int id)
{
Q_D(QObject);
- if (d->threadData->eventDispatcher)
- d->threadData->eventDispatcher->unregisterTimer(id);
+ if (id) {
+ int at = d->runningTimers.indexOf(id);
+ if (at == -1) {
+ // timer isn't owned by this object
+ qWarning("QObject::killTimer(): Error: timer id %d is not valid for object %p (%s), timer has not been killed",
+ id,
+ this,
+ qPrintable(objectName()));
+ return;
+ }
+
+ if (d->threadData->eventDispatcher)
+ d->threadData->eventDispatcher->unregisterTimer(id);
+
+ d->runningTimers.remove(at);
+ QAbstractEventDispatcherPrivate::releaseTimerId(id);
+ }
}
@@ -1774,8 +1639,8 @@ void QObject::setParent(QObject *parent)
void QObjectPrivate::deleteChildren()
{
- const bool reallyWasDeleted = wasDeleted;
- wasDeleted = true;
+ Q_ASSERT_X(!isDeletingChildren, "QObjectPrivate::deleteChildren()", "isDeletingChildren already set, did this function recurse?");
+ isDeletingChildren = true;
// delete children objects
// don't use qDeleteAll as the destructor of the child might
// delete siblings
@@ -1786,7 +1651,7 @@ void QObjectPrivate::deleteChildren()
}
children.clear();
currentChildBeingDeleted = 0;
- wasDeleted = reallyWasDeleted;
+ isDeletingChildren = false;
}
void QObjectPrivate::setParent_helper(QObject *o)
@@ -1796,13 +1661,13 @@ void QObjectPrivate::setParent_helper(QObject *o)
return;
if (parent) {
QObjectPrivate *parentD = parent->d_func();
- if (parentD->wasDeleted && wasDeleted
+ if (parentD->isDeletingChildren && wasDeleted
&& parentD->currentChildBeingDeleted == q) {
// don't do anything since QObjectPrivate::deleteChildren() already
// cleared our entry in parentD->children.
} else {
const int index = parentD->children.indexOf(q);
- if (parentD->wasDeleted) {
+ if (parentD->isDeletingChildren) {
parentD->children[index] = 0;
} else {
parentD->children.removeAt(index);
@@ -1829,7 +1694,7 @@ void QObjectPrivate::setParent_helper(QObject *o)
}
}
}
- if (!wasDeleted && declarativeData)
+ if (!isDeletingChildren && declarativeData)
QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
}
@@ -2060,10 +1925,10 @@ static bool check_signal_macro(const QObject *sender, const char *signal,
int sigcode = extract_code(signal);
if (sigcode != QSIGNAL_CODE) {
if (sigcode == QSLOT_CODE)
- qWarning("Object::%s: Attempt to %s non-signal %s::%s",
+ qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
func, op, sender->metaObject()->className(), signal+1);
else
- qWarning("Object::%s: Use the SIGNAL macro to %s %s::%s",
+ qWarning("QObject::%s: Use the SIGNAL macro to %s %s::%s",
func, op, sender->metaObject()->className(), signal);
return false;
}
@@ -2074,7 +1939,7 @@ static bool check_method_code(int code, const QObject *object,
const char *method, const char *func)
{
if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
- qWarning("Object::%s: Use the SLOT or SIGNAL macro to "
+ qWarning("QObject::%s: Use the SLOT or SIGNAL macro to "
"%s %s::%s", func, func, object->metaObject()->className(), method);
return false;
}
@@ -2091,11 +1956,11 @@ static void err_method_notfound(const QObject *object,
}
const char *loc = extract_location(method);
if (strchr(method,')') == 0) // common typing mistake
- qWarning("Object::%s: Parentheses expected, %s %s::%s%s%s",
+ qWarning("QObject::%s: Parentheses expected, %s %s::%s%s%s",
func, type, object->metaObject()->className(), method+1,
loc ? " in ": "", loc ? loc : "");
else
- qWarning("Object::%s: No such %s %s::%s%s%s",
+ qWarning("QObject::%s: No such %s %s::%s%s%s",
func, type, object->metaObject()->className(), method+1,
loc ? " in ": "", loc ? loc : "");
@@ -2109,9 +1974,9 @@ static void err_info_about_objects(const char * func,
QString a = sender ? sender->objectName() : QString();
QString b = receiver ? receiver->objectName() : QString();
if (!a.isEmpty())
- qWarning("Object::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
+ qWarning("QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
if (!b.isEmpty())
- qWarning("Object::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
+ qWarning("QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
}
/*!
@@ -2691,7 +2556,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method)
{
if (sender == 0 || (receiver == 0 && method != 0)) {
- qWarning("Object::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected null parameter");
return false;
}
@@ -2816,12 +2681,12 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method)
{
if (sender == 0 || (receiver == 0 && method.mobj != 0)) {
- qWarning("Object::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected null parameter");
return false;
}
if (signal.mobj) {
if(signal.methodType() != QMetaMethod::Signal) {
- qWarning("Object::%s: Attempt to %s non-signal %s::%s",
+ qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
"disconnect","unbind",
sender->metaObject()->className(), signal.signature());
return false;
@@ -3239,9 +3104,9 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
int nargs = 1; // include return type
while (argumentTypes[nargs-1])
++nargs;
- int *types = (int *) qMalloc(nargs*sizeof(int));
+ int *types = (int *) malloc(nargs*sizeof(int));
Q_CHECK_PTR(types);
- void **args = (void **) qMalloc(nargs*sizeof(void *));
+ void **args = (void **) malloc(nargs*sizeof(void *));
Q_CHECK_PTR(args);
types[0] = 0; // return type
args[0] = 0; // return value
@@ -4004,11 +3869,6 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
void qDeleteInEventHandler(QObject *o)
{
-#ifdef QT_JAMBI_BUILD
- if (!o)
- return;
- QObjectPrivate::get(o)->inEventHandler = false;
-#endif
delete o;
}
@@ -4273,7 +4133,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject)
{
if (sender == 0 || (receiver == 0 && slot != 0)) {
- qWarning("Object::disconnect: Unexpected null parameter");
+ qWarning("QObject::disconnect: Unexpected null parameter");
return false;
}
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 307518d81e..11f524180c 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -96,17 +96,13 @@ public:
QObjectList children;
uint isWidget : 1;
- uint pendTimer : 1;
uint blockSig : 1;
uint wasDeleted : 1;
- uint ownObjectName : 1;
+ uint isDeletingChildren : 1;
uint sendChildEvents : 1;
uint receiveChildEvents : 1;
- uint inEventHandler : 1; //only used if QT_JAMBI_BUILD
- uint inThreadChangeEvent : 1;
- uint hasGuards : 1; //true iff there is one or more QPointer attached to this object
uint isWindow : 1; //for QWindow
- uint unused : 21;
+ uint unused : 25;
int postedEvents;
QMetaObject *metaObject; // assert dynamic
};
@@ -115,7 +111,7 @@ public:
class Q_CORE_EXPORT QObject
{
Q_OBJECT
- Q_PROPERTY(QString objectName READ objectName WRITE setObjectName)
+ Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
Q_DECLARE_PRIVATE(QObject)
public:
@@ -152,7 +148,7 @@ public:
QThread *thread() const;
void moveToThread(QThread *thread);
- int startTimer(int interval);
+ int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
void killTimer(int id);
template<typename T>
@@ -214,7 +210,12 @@ public:
reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
//compilation error if the arguments does not match.
- typedef typename QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::IncompatibleSignalSlotArguments EnsureCompatibleArguments;
+ Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
+ "The slot requires more arguments than the signal provides.");
+ Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
+ "Signal and slot arguments are not compatible.");
+ Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
+ "Return type of the slot is not compatible with the return type of the signal.");
const int *types = 0;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
@@ -236,8 +237,12 @@ public:
typedef QtPrivate::FunctionPointer<Func2> SlotType;
//compilation error if the arguments does not match.
- typedef typename QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::IncompatibleSignalSlotArguments EnsureCompatibleArguments;
- typedef typename QtPrivate::QEnableIf<(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount))>::Type EnsureArgumentsCount;
+ Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
+ "The slot requires more arguments than the signal provides.");
+ Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
+ "Signal and slot arguments are not compatible.");
+ Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
+ "Return type of the slot is not compatible with the return type of the signal.");
return connectImpl(sender, reinterpret_cast<void **>(&signal), sender, 0,
new QStaticSlotObject<Func2,
@@ -278,7 +283,9 @@ public:
reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
//compilation error if the arguments does not match.
- typedef typename QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::IncompatibleSignalSlotArguments EnsureCompatibleArguments;
+ Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
+ "Signal and slot arguments are not compatible.");
+
return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot),
&SignalType::Object::staticMetaObject);
}
@@ -287,8 +294,8 @@ public:
const QObject *receiver, void **zero)
{
// This is the overload for when one wish to disconnect a signal from any slot. (slot=0)
- // Since the function template parametter cannot be deduced from '0', we use a
- // dummy void ** parametter that must be equal to 0
+ // Since the function template parameter cannot be deduced from '0', we use a
+ // dummy void ** parameter that must be equal to 0
Q_ASSERT(!zero);
typedef QtPrivate::FunctionPointer<Func1> SignalType;
return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
@@ -313,6 +320,7 @@ public:
Q_SIGNALS:
void destroyed(QObject * = 0);
+ void objectNameChanged(const QString &objectName);
public:
inline QObject *parent() const { return d_ptr->parent; }
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 660294b956..44aaa9a218 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -441,36 +441,40 @@ namespace QtPrivate {
/*
Logic that check if the arguments of the slot matches the argument of the signal.
To be used like this:
- CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::IncompatibleSignalSlotArguments
- The IncompatibleSignalSlotArguments type do not exist if the argument are incompatible and can
- then produce error message.
+ Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
*/
- template<typename T, bool B> struct CheckCompatibleArgumentsHelper {};
- template<typename T> struct CheckCompatibleArgumentsHelper<T, true> : T {};
template<typename A1, typename A2> struct AreArgumentsCompatible {
static int test(A2);
static char test(...);
- static A2 dummy();
+ static A1 dummy();
enum { value = sizeof(test(dummy())) == sizeof(int) };
};
template<typename A1, typename A2> struct AreArgumentsCompatible<A1, A2&> { enum { value = false }; };
template<typename A> struct AreArgumentsCompatible<A&, A&> { enum { value = true }; };
+ // void as a return value
+ template<typename A> struct AreArgumentsCompatible<void, A> { enum { value = true }; };
+ template<typename A> struct AreArgumentsCompatible<A, void> { enum { value = true }; };
+ template<> struct AreArgumentsCompatible<void, void> { enum { value = true }; };
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
- template <typename List1, typename List2> struct CheckCompatibleArguments{};
- template <> struct CheckCompatibleArguments<void, void> { typedef bool IncompatibleSignalSlotArguments; };
- template <typename List1> struct CheckCompatibleArguments<List1, void> { typedef bool IncompatibleSignalSlotArguments; };
+ template <typename List1, typename List2> struct CheckCompatibleArguments { enum { value = false }; };
+ template <> struct CheckCompatibleArguments<void, void> { enum { value = true }; };
+ template <typename List1> struct CheckCompatibleArguments<List1, void> { enum { value = true }; };
template <typename Arg1, typename Arg2, typename Tail1, typename Tail2> struct CheckCompatibleArguments<List<Arg1, Tail1>, List<Arg2, Tail2> >
- : CheckCompatibleArgumentsHelper<CheckCompatibleArguments<Tail1, Tail2>, AreArgumentsCompatible<
- typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value > {};
+ {
+ enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
+ && CheckCompatibleArguments<Tail1, Tail2>::value };
+ };
#else
- template <typename List1, typename List2> struct CheckCompatibleArguments{};
- template <> struct CheckCompatibleArguments<List<>, List<>> { typedef bool IncompatibleSignalSlotArguments; };
- template <typename List1> struct CheckCompatibleArguments<List1, List<>> { typedef bool IncompatibleSignalSlotArguments; };
+ template <typename List1, typename List2> struct CheckCompatibleArguments { enum { value = false }; };
+ template <> struct CheckCompatibleArguments<List<>, List<>> { enum { value = true }; };
+ template <typename List1> struct CheckCompatibleArguments<List1, List<>> { enum { value = true }; };
template <typename Arg1, typename Arg2, typename... Tail1, typename... Tail2>
struct CheckCompatibleArguments<List<Arg1, Tail1...>, List<Arg2, Tail2...>>
- : CheckCompatibleArgumentsHelper<CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>, AreArgumentsCompatible<
- typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value > {};
+ {
+ enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
+ && CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>::value };
+ };
#endif
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 5519a69c34..dbd2e4fa37 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -179,11 +179,6 @@ public:
static inline void resetCurrentSender(QObject *receiver,
Sender *currentSender,
Sender *previousSender);
-#ifdef QT_JAMBI_BUILD
- static int *setDeleteWatch(QObjectPrivate *d, int *newWatch);
- static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch);
-#endif
- static void clearGuards(QObject *);
static QObjectPrivate *get(QObject *o) {
return o->d_func();
@@ -203,6 +198,7 @@ public:
Sender *currentSender; // object currently activating the object
mutable quint32 connectedSignals[2];
+ QVector<int> runningTimers;
QList<QPointer<QObject> > eventFilters;
union {
QObject *currentChildBeingDeleted;
@@ -212,9 +208,6 @@ public:
// these objects are all used to indicate that a QObject was deleted
// plus QPointer, which keeps a separate list
QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
-#ifdef QT_JAMBI_BUILD
- int *deleteWatch;
-#endif
};
diff --git a/src/corelib/kernel/qobjectcleanuphandler.cpp b/src/corelib/kernel/qobjectcleanuphandler.cpp
index 512aa097ee..8a0cc2840e 100644
--- a/src/corelib/kernel/qobjectcleanuphandler.cpp
+++ b/src/corelib/kernel/qobjectcleanuphandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qobjectcleanuphandler.h b/src/corelib/kernel/qobjectcleanuphandler.h
index 601164f784..5997f0e250 100644
--- a/src/corelib/kernel/qobjectcleanuphandler.h
+++ b/src/corelib/kernel/qobjectcleanuphandler.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index bfb6808ad5..dfcc81be03 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -136,18 +136,11 @@ template <typename T1, typename T2>
inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
#endif // QT_NO_QOBJECT_CHECK
-#ifdef Q_NO_DATA_RELOCATION
-#define Q_OBJECT_GETSTATICMETAOBJECT static const QMetaObject &getStaticMetaObject();
-#else
-#define Q_OBJECT_GETSTATICMETAOBJECT
-#endif
-
/* tmake ignore Q_OBJECT */
#define Q_OBJECT \
public: \
Q_OBJECT_CHECK \
static const QMetaObject staticMetaObject; \
- Q_OBJECT_GETSTATICMETAOBJECT \
virtual const QMetaObject *metaObject() const; \
virtual void *qt_metacast(const char *); \
QT_TR_FUNCTIONS \
@@ -162,8 +155,8 @@ private: \
#define Q_GADGET \
public: \
static const QMetaObject staticMetaObject; \
- Q_OBJECT_GETSTATICMETAOBJECT \
private:
+
#else // Q_MOC_RUN
#define slots slots
#define signals signals
@@ -341,11 +334,6 @@ struct Q_CORE_EXPORT QMetaObject
static void activate(QObject *sender, int signal_index, void **argv);
static void activate(QObject *sender, const QMetaObject *, int local_signal_index, void **argv);
- // internal guarded pointers
- static void addGuard(QObject **ptr);
- static void removeGuard(QObject **ptr);
- static void changeGuard(QObject **ptr, QObject *o);
-
static bool invokeMethod(QObject *obj, const char *member,
Qt::ConnectionType,
QGenericReturnArgument ret,
@@ -474,11 +462,7 @@ typedef const QMetaObject& (*QMetaObjectAccessor)();
struct QMetaObjectExtraData
{
-#ifdef Q_NO_DATA_RELOCATION
- const QMetaObjectAccessor *objects;
-#else
const QMetaObject **objects;
-#endif
typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); //from revision 6
//typedef int (*StaticMetaCall)(QMetaObject::Call, int, void **); //used from revison 2 until revison 5
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index c7fcf4f1e8..575dad9ed8 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -44,7 +44,7 @@
\brief The QPointer class is a template class that provides guarded pointers to QObject.
\ingroup objectmodel
-
+ \obsolete Use QWeakPointer instead.
A guarded pointer, QPointer<T>, behaves like a normal C++
pointer \c{T *}, except that it is automatically set to 0 when the
@@ -57,6 +57,24 @@
destroyed while you still hold a reference to it. You can safely
test the pointer for validity.
+ Note that Qt 5 introduces two slight changes in behavior when using QPointer.
+
+ \list
+
+ \i When using QPointer on a QWidget (or a subclass of QWidget), previously
+ the QPointer would be cleared by the QWidget destructor. Now, the QPointer
+ is cleared by the QObject destructor (since this is when QWeakPointers are
+ cleared). Any QPointers tracking a widget will \b NOT be cleared before the
+ QWidget destructor destroys the children for the widget being tracked.
+
+ \i When constructing a QSharedPointer to take ownership of an object after a
+ QPointer is already tracking the object. Previously, the shared pointer
+ construction would not be affected by the QPointer, but now that QPointer
+ is implemented using QWeakPoiner, constructing the QSharedPointer will
+ cause an \c abort().
+
+ \endlist
+
Qt also provides QSharedPointer, an implementation of a reference-counted
shared pointer object, which can be used to maintain a collection of
references to an individual pointer.
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h
index e9f302e317..4c0aebb41d 100644
--- a/src/corelib/kernel/qpointer.h
+++ b/src/corelib/kernel/qpointer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -42,7 +42,7 @@
#ifndef QPOINTER_H
#define QPOINTER_H
-#include <QtCore/qobject.h>
+#include <QtCore/qsharedpointer.h>
QT_BEGIN_HEADER
@@ -50,34 +50,35 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
+#if QT_DEPRECATED_SINCE(5,0)
+
template <class T>
-class QPointer
+class QT_DEPRECATED QPointer
{
- QObject *o;
+ QWeakPointer<T> wp;
+
public:
- inline QPointer() : o(0) {}
- inline QPointer(T *p) : o(p)
- { QMetaObject::addGuard(&o); }
- inline QPointer(const QPointer<T> &p) : o(p.o)
- { QMetaObject::addGuard(&o); }
- inline ~QPointer()
- { QMetaObject::removeGuard(&o); }
+ inline QPointer() : wp() { }
+ inline QPointer(T *p) : wp(p) { }
+ inline QPointer(const QPointer<T> &p) : wp(p.wp) { }
+ inline ~QPointer() { }
+
inline QPointer<T> &operator=(const QPointer<T> &p)
- { if (this != &p) QMetaObject::changeGuard(&o, p.o); return *this; }
+ { wp = p.wp; return *this; }
inline QPointer<T> &operator=(T* p)
- { if (o != p) QMetaObject::changeGuard(&o, p); return *this; }
+ { wp = p; return *this; }
inline bool isNull() const
- { return !o; }
+ { return wp.isNull(); }
inline T* operator->() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
+ { return wp.data(); }
inline T& operator*() const
- { return *static_cast<T*>(const_cast<QObject*>(o)); }
+ { return *wp.data(); }
inline operator T*() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
+ { return wp.data(); }
inline T* data() const
- { return static_cast<T*>(const_cast<QObject*>(o)); }
+ { return wp.data(); }
};
@@ -161,6 +162,8 @@ inline bool operator!= (int i, const QPointer<T> &p)
{ Q_ASSERT(i == 0); return !i && !p.isNull(); }
#endif
+#endif // QT_DEPRECATED_SINCE(5,0)
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index acb6044bac..c5b1b56747 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index b2ce7e20f4..d536e94fa1 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h
index d5fafeff97..d3d3c023ba 100644
--- a/src/corelib/kernel/qsharedmemory_p.h
+++ b/src/corelib/kernel/qsharedmemory_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp
deleted file mode 100644
index fdd513a475..0000000000
--- a/src/corelib/kernel/qsharedmemory_symbian.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsharedmemory.h"
-#include "qsharedmemory_p.h"
-#include "qsystemsemaphore.h"
-#include "qcore_symbian_p.h"
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_SHAREDMEMORY
-
-#define QSHAREDMEMORY_DEBUG
-
-QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(),
- memory(0), size(0), error(QSharedMemory::NoError),
- systemSemaphore(QString()), lockedByMe(false)
-{
-}
-
-void QSharedMemoryPrivate::setErrorString(const QString &function, TInt errorCode)
-{
- if (errorCode == KErrNone)
- return;
- switch (errorCode) {
- case KErrAlreadyExists:
- error = QSharedMemory::AlreadyExists;
- errorString = QSharedMemory::tr("%1: already exists").arg(function);
- break;
- case KErrNotFound:
- error = QSharedMemory::NotFound;
- errorString = QSharedMemory::tr("%1: doesn't exists").arg(function);
- break;
- case KErrArgument:
- error = QSharedMemory::InvalidSize;
- errorString = QSharedMemory::tr("%1: invalid size").arg(function);
- break;
- case KErrNoMemory:
- error = QSharedMemory::OutOfResources;
- errorString = QSharedMemory::tr("%1: out of resources").arg(function);
- break;
- case KErrPermissionDenied:
- error = QSharedMemory::PermissionDenied;
- errorString = QSharedMemory::tr("%1: permission denied").arg(function);
- break;
- default:
- errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errorCode);
- error = QSharedMemory::UnknownError;
-#if defined QSHAREDMEMORY_DEBUG
- qDebug() << errorString << "key" << key;
-#endif
- }
-}
-
-key_t QSharedMemoryPrivate::handle()
-{
- // Not really cost effective to check here if shared memory is attachable, as it requires
- // exactly the same call as attaching, so always assume handle is valid and return failure
- // from attach.
- return 1;
-}
-
-bool QSharedMemoryPrivate::cleanHandle()
-{
- chunk.Close();
- return true;
-}
-
-bool QSharedMemoryPrivate::create(int size)
-{
- QString function = QLatin1String("QSharedMemory::create");
- if (nativeKey.isEmpty()) {
- error = QSharedMemory::KeyError;
- errorString = QSharedMemory::tr("%1: key error").arg(function);
- return false;
- }
-
- TPtrC ptr(qt_QString2TPtrC(nativeKey));
-
- TInt err = chunk.CreateGlobal(ptr, size, size);
-
- setErrorString(function, err);
-
- if (err != KErrNone)
- return false;
-
- // Zero out the created chunk
- Mem::FillZ(chunk.Base(), chunk.Size());
-
- return true;
-}
-
-bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */)
-{
- // Grab a pointer to the memory block
- if (!chunk.Handle()) {
- QString function = QLatin1String("QSharedMemory::handle");
- if (nativeKey.isEmpty()) {
- error = QSharedMemory::KeyError;
- errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
- return false;
- }
-
- TPtrC ptr(qt_QString2TPtrC(nativeKey));
-
- TInt err = KErrNoMemory;
-
- err = chunk.OpenGlobal(ptr, false);
-
- if (err != KErrNone) {
- setErrorString(function, err);
- return false;
- }
- }
-
- size = chunk.Size();
- memory = chunk.Base();
-
- return true;
-}
-
-bool QSharedMemoryPrivate::detach()
-{
- chunk.Close();
-
- memory = 0;
- size = 0;
-
- return true;
-}
-
-#endif //QT_NO_SHAREDMEMORY
-
-QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 2bbda4933f..fd435d7b97 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 3cc14fe512..c02ab15c88 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp
index 665b9e22b5..7bdffd4153 100644
--- a/src/corelib/kernel/qsignalmapper.cpp
+++ b/src/corelib/kernel/qsignalmapper.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index 72593679a9..04278b491c 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index 5e99d1d483..60970f1cd2 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -168,7 +168,7 @@ QT_BEGIN_NAMESPACE
\sa setEnabled(), isEnabled()
*/
-QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent)
+QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
: QObject(parent)
{
if (socket < 0)
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 07dc129825..186979db4c 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -58,7 +58,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject
public:
enum Type { Read, Write, Exception };
- QSocketNotifier(int socket, Type, QObject *parent = 0);
+ QSocketNotifier(qintptr socket, Type, QObject *parent = 0);
~QSocketNotifier();
inline int socket() const { return sockfd; }
@@ -78,7 +78,7 @@ protected:
private:
Q_DISABLE_COPY(QSocketNotifier)
- int sockfd;
+ qintptr sockfd;
Type sntype;
bool snenabled;
};
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 71c2807341..708eba89a6 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -46,6 +46,10 @@
# if defined(Q_CC_MSVC)
# include <crtdbg.h>
# endif
+#else
+# if (_WIN32_WCE >= 0x700)
+# include <errno.h>
+# endif
#endif
#ifdef Q_OS_WIN
#include <windows.h>
@@ -76,6 +80,27 @@ namespace {
}
#endif
+#ifdef Q_OS_WIN
+static QString windowsErrorString(int errorCode)
+{
+ QString ret;
+ wchar_t *string = 0;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPWSTR)&string,
+ 0,
+ NULL);
+ ret = QString::fromWCharArray(string);
+ LocalFree((HLOCAL)string);
+
+ if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
+ ret = QString::fromLatin1("The specified module could not be found.");
+ return ret;
+}
+#endif
+
static QString standardLibraryErrorString(int errorCode)
{
const char *s = 0;
@@ -96,11 +121,15 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
- #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
- QByteArray buf(1024, '\0');
- ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
+ #ifdef Q_OS_WINCE
+ ret = windowsErrorString(errorCode);
#else
- ret = QString::fromLocal8Bit(strerror(errorCode));
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ QByteArray buf(1024, '\0');
+ ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
+ #else
+ ret = QString::fromLocal8Bit(strerror(errorCode));
+ #endif
#endif
break; }
}
@@ -112,27 +141,6 @@ static QString standardLibraryErrorString(int errorCode)
return ret.trimmed();
}
-#ifdef Q_OS_WIN
-static QString windowsErrorString(int errorCode)
-{
- QString ret;
- wchar_t *string = 0;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&string,
- 0,
- NULL);
- ret = QString::fromWCharArray(string);
- LocalFree((HLOCAL)string);
-
- if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
- ret = QString::fromLatin1("The specified module could not be found.");
- return ret;
-}
-#endif
-
#ifdef Q_OS_SYMBIAN
static QString symbianErrorString(int errorCode)
{
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index 0bcada7350..2a90760197 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp
index 98ee6f4231..690a4e8b92 100644
--- a/src/corelib/kernel/qsystemsemaphore.cpp
+++ b/src/corelib/kernel/qsystemsemaphore.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsystemsemaphore.h b/src/corelib/kernel/qsystemsemaphore.h
index 1623215ec5..0cb69d5e7c 100644
--- a/src/corelib/kernel/qsystemsemaphore.h
+++ b/src/corelib/kernel/qsystemsemaphore.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index d4e86e8866..31fd596fd5 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsystemsemaphore_symbian.cpp b/src/corelib/kernel/qsystemsemaphore_symbian.cpp
deleted file mode 100644
index 96c19afcfc..0000000000
--- a/src/corelib/kernel/qsystemsemaphore_symbian.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, 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.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsystemsemaphore.h"
-#include "qsystemsemaphore_p.h"
-#include "qcoreapplication.h"
-#include <qdebug.h>
-
-#include "qcore_symbian_p.h"
-#include <e32cmn.h>
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_SYSTEMSEMAPHORE
-
-QSystemSemaphorePrivate::QSystemSemaphorePrivate() :
- error(QSystemSemaphore::NoError)
-{
-}
-
-void QSystemSemaphorePrivate::setErrorString(const QString &function, int err)
-{
- if (err == KErrNone){
- return;
- }
- switch(err){
- case KErrAlreadyExists:
- errorString = QCoreApplication::tr("%1: already exists", "QSystemSemaphore").arg(function);
- error = QSystemSemaphore::AlreadyExists;
- break;
- case KErrNotFound:
- errorString = QCoreApplication::tr("%1: does not exist", "QSystemSemaphore").arg(function);
- error = QSystemSemaphore::NotFound;
- break;
- case KErrNoMemory:
- case KErrInUse:
- errorString = QCoreApplication::tr("%1: out of resources", "QSystemSemaphore").arg(function);
- error = QSystemSemaphore::OutOfResources;
- break;
- case KErrPermissionDenied:
- errorString = QCoreApplication::tr("%1: permission denied", "QSystemSemaphore").arg(function);
- error = QSystemSemaphore::PermissionDenied;
- break;
-default:
- errorString = QCoreApplication::tr("%1: unknown error %2", "QSystemSemaphore").arg(function).arg(err);
- error = QSystemSemaphore::UnknownError;
- }
-
-#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << errorString << "key" << key;
-#endif
-}
-
-int QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
-{
- if (semaphore.Handle()) {
- return semaphore.Handle();
- }
-
- // don't allow making handles on empty keys
- if (key.isEmpty())
- return 0;
-
- TPtrC name(qt_QString2TPtrC(fileName));
- int err = KErrAlreadyExists;
- int tryCount = 10;
- // Sort out race conditions by retrying several times until existing handle is acquired.
- // Sometimes opening can fail inexplicably with KErrPermissionDenied many times in a row.
- while (err != KErrNoMemory && err != KErrNone && tryCount-- >= 0) {
- err = semaphore.CreateGlobal(name, initialValue, EOwnerProcess);
- if (err != KErrNoMemory && err != KErrNone)
- err = semaphore.OpenGlobal(name,EOwnerProcess);
- }
- if (err){
- setErrorString(QLatin1String("QSystemSemaphore::handle"),err);
- return 0;
- }
- return semaphore.Handle();
-}
-
-void QSystemSemaphorePrivate::cleanHandle()
-{
- semaphore.Close();
-}
-
-bool QSystemSemaphorePrivate::modifySemaphore(int count)
-{
- if (0 == handle())
- return false;
-
- if (count > 0) {
- semaphore.Signal(count);
- } else {
- semaphore.Wait();
- }
- return true;
-}
-
-#endif //QT_NO_SYSTEMSEMAPHORE
-
-QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index 5e533e7f0e..cc86e335e5 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 30cab7ebfe..aad78459d7 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp
index 927aa672a1..2f9ccdae46 100644
--- a/src/corelib/kernel/qtcore_eval.cpp
+++ b/src/corelib/kernel/qtcore_eval.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
static const char boilerplate_unsuported[] =
"\nQt %1 Evaluation License\n"
- "Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).\n"
"All rights reserved.\n\n"
"This trial version may only be used for evaluation purposes\n"
"and will shut down after 120 minutes.\n"
@@ -65,7 +65,7 @@ static const char boilerplate_unsuported[] =
static const char boilerplate_supported[] =
"\nQt %1 Evaluation License\n"
- "Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).\n"
"All rights reserved.\n\n"
"This trial version may only be used for evaluation purposes\n"
"Registered to:\n"
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 9be661e42f..da1cfe91b2 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -134,7 +134,6 @@ QT_BEGIN_NAMESPACE
{Analog Clock Example}, {Wiggly Example}
*/
-
static const int INV_TIMER = -1; // invalid timer id
/*!
@@ -142,7 +141,7 @@ static const int INV_TIMER = -1; // invalid timer id
*/
QTimer::QTimer(QObject *parent)
- : QObject(parent), id(INV_TIMER), inter(0), del(0), single(0), nulltimer(0)
+ : QObject(parent), id(INV_TIMER), inter(0), del(0), single(0), nulltimer(0), type(Qt::CoarseTimer)
{
}
@@ -203,7 +202,7 @@ void QTimer::start()
if (id != INV_TIMER) // stop running timer
stop();
nulltimer = (!inter && single);
- id = QObject::startTimer(inter);
+ id = QObject::startTimer(inter, Qt::TimerType(type));
}
/*!
@@ -257,18 +256,18 @@ class QSingleShotTimer : public QObject
int timerId;
public:
~QSingleShotTimer();
- QSingleShotTimer(int msec, QObject *r, const char * m);
+ QSingleShotTimer(int msec, Qt::TimerType timerType, QObject *r, const char * m);
Q_SIGNALS:
void timeout();
protected:
void timerEvent(QTimerEvent *);
};
-QSingleShotTimer::QSingleShotTimer(int msec, QObject *receiver, const char *member)
+QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, QObject *receiver, const char *member)
: QObject(QAbstractEventDispatcher::instance())
{
connect(this, SIGNAL(timeout()), receiver, member);
- timerId = startTimer(msec);
+ timerId = startTimer(msec, timerType);
}
QSingleShotTimer::~QSingleShotTimer()
@@ -318,6 +317,28 @@ QT_END_INCLUDE_NAMESPACE
void QTimer::singleShot(int msec, QObject *receiver, const char *member)
{
+ // coarse timers are worst in their first firing
+ // so we prefer a high precision timer for something that happens only once
+ // unless the timeout is too big, in which case we go for coarse anyway
+ singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, receiver, member);
+}
+
+/*! \overload
+ \reentrant
+ This static function calls a slot after a given time interval.
+
+ It is very convenient to use this function because you do not need
+ to bother with a \link QObject::timerEvent() timerEvent\endlink or
+ create a local QTimer object.
+
+ The \a receiver is the receiving object and the \a member is the slot. The
+ time interval is \a msec milliseconds. The \a timerType affects the
+ accuracy of the timer.
+
+ \sa start()
+*/
+void QTimer::singleShot(int msec, Qt::TimerType timerType, QObject *receiver, const char *member)
+{
if (receiver && member) {
if (msec == 0) {
// special code shortpath for 0-timers
@@ -330,7 +351,7 @@ void QTimer::singleShot(int msec, QObject *receiver, const char *member)
QMetaObject::invokeMethod(receiver, methodName.constData(), Qt::QueuedConnection);
return;
}
- (void) new QSingleShotTimer(msec, receiver, member);
+ (void) new QSingleShotTimer(msec, timerType, receiver, member);
}
}
@@ -361,8 +382,17 @@ void QTimer::setInterval(int msec)
inter = msec;
if (id != INV_TIMER) { // create new timer
QObject::killTimer(id); // restart timer
- id = QObject::startTimer(msec);
+ id = QObject::startTimer(msec, Qt::TimerType(type));
}
}
+/*!
+ \property QTimer::timerType
+ \brief controls the accuracy of the timer
+
+ The default value for this property is \c Qt::CoarseTimer.
+
+ \sa Qt::TimerType
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 707bc83d3c..6fb32f9bde 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -58,6 +58,7 @@ class Q_CORE_EXPORT QTimer : public QObject
Q_OBJECT
Q_PROPERTY(bool singleShot READ isSingleShot WRITE setSingleShot)
Q_PROPERTY(int interval READ interval WRITE setInterval)
+ Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType)
Q_PROPERTY(bool active READ isActive)
public:
explicit QTimer(QObject *parent = 0);
@@ -69,10 +70,14 @@ public:
void setInterval(int msec);
int interval() const { return inter; }
+ void setTimerType(Qt::TimerType atype) { this->type = atype; }
+ Qt::TimerType timerType() const { return Qt::TimerType(type); }
+
inline void setSingleShot(bool singleShot);
inline bool isSingleShot() const { return single; }
static void singleShot(int msec, QObject *receiver, const char *member);
+ static void singleShot(int msec, Qt::TimerType timerType, QObject *receiver, const char *member);
public Q_SLOTS:
void start(int msec);
@@ -95,6 +100,8 @@ private:
int id, inter, del;
uint single : 1;
uint nulltimer : 1;
+ uint type : 2;
+ // reserved : 28
};
inline void QTimer::setSingleShot(bool asingleShot) { single = asingleShot; }
diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp
new file mode 100644
index 0000000000..b89d4ccb30
--- /dev/null
+++ b/src/corelib/kernel/qtimerinfo_unix.cpp
@@ -0,0 +1,625 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qelapsedtimer.h>
+#include <qcoreapplication.h>
+
+#include "private/qcore_unix_p.h"
+#include "private/qtimerinfo_unix_p.h"
+#include "private/qobject_p.h"
+#include "private/qabstracteventdispatcher_p.h"
+
+#ifdef QTIMERINFO_DEBUG
+# include <QDebug>
+# include <QThread>
+#endif
+
+#include <sys/times.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false;
+
+/*
+ * Internal functions for manipulating timer data structures. The
+ * timerBitVec array is used for keeping track of timer identifiers.
+ */
+
+QTimerInfoList::QTimerInfoList()
+{
+#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_NACL)
+ if (!QElapsedTimer::isMonotonic()) {
+ // not using monotonic timers, initialize the timeChanged() machinery
+ previousTime = qt_gettime();
+
+ tms unused;
+ previousTicks = times(&unused);
+
+ ticksPerSecond = sysconf(_SC_CLK_TCK);
+ msPerTick = 1000/ticksPerSecond;
+ } else {
+ // detected monotonic timers
+ previousTime.tv_sec = previousTime.tv_usec = 0;
+ previousTicks = 0;
+ ticksPerSecond = 0;
+ msPerTick = 0;
+ }
+#endif
+
+ firstTimerInfo = 0;
+}
+
+timeval QTimerInfoList::updateCurrentTime()
+{
+ return (currentTime = qt_gettime());
+}
+
+#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED)
+
+template <>
+timeval qAbs(const timeval &t)
+{
+ timeval tmp = t;
+ if (tmp.tv_sec < 0) {
+ tmp.tv_sec = -tmp.tv_sec - 1;
+ tmp.tv_usec -= 1000000;
+ }
+ if (tmp.tv_sec == 0 && tmp.tv_usec < 0) {
+ tmp.tv_usec = -tmp.tv_usec;
+ }
+ return normalizedTimeval(tmp);
+}
+
+/*
+ Returns true if the real time clock has changed by more than 10%
+ relative to the processor time since the last time this function was
+ called. This presumably means that the system time has been changed.
+
+ If /a delta is nonzero, delta is set to our best guess at how much the system clock was changed.
+*/
+bool QTimerInfoList::timeChanged(timeval *delta)
+{
+#ifdef Q_OS_NACL
+ Q_UNUSED(delta)
+ return false; // Calling "times" crashes.
+#endif
+ struct tms unused;
+ clock_t currentTicks = times(&unused);
+
+ clock_t elapsedTicks = currentTicks - previousTicks;
+ timeval elapsedTime = currentTime - previousTime;
+
+ timeval elapsedTimeTicks;
+ elapsedTimeTicks.tv_sec = elapsedTicks / ticksPerSecond;
+ elapsedTimeTicks.tv_usec = (((elapsedTicks * 1000) / ticksPerSecond) % 1000) * 1000;
+
+ timeval dummy;
+ if (!delta)
+ delta = &dummy;
+ *delta = elapsedTime - elapsedTimeTicks;
+
+ previousTicks = currentTicks;
+ previousTime = currentTime;
+
+ // If tick drift is more than 10% off compared to realtime, we assume that the clock has
+ // been set. Of course, we have to allow for the tick granularity as well.
+ timeval tickGranularity;
+ tickGranularity.tv_sec = 0;
+ tickGranularity.tv_usec = msPerTick * 1000;
+ return elapsedTimeTicks < ((qAbs(*delta) - tickGranularity) * 10);
+}
+
+/*
+ repair broken timer
+*/
+void QTimerInfoList::timerRepair(const timeval &diff)
+{
+ // repair all timers
+ for (int i = 0; i < size(); ++i) {
+ register QTimerInfo *t = at(i);
+ t->timeout = t->timeout + diff;
+ }
+}
+
+void QTimerInfoList::repairTimersIfNeeded()
+{
+ if (QElapsedTimer::isMonotonic())
+ return;
+ timeval delta;
+ if (timeChanged(&delta))
+ timerRepair(delta);
+}
+
+#else // !(_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(QT_BOOTSTRAPPED)
+
+void QTimerInfoList::repairTimersIfNeeded()
+{
+}
+
+#endif
+
+/*
+ insert timer info into list
+*/
+void QTimerInfoList::timerInsert(QTimerInfo *ti)
+{
+ int index = size();
+ while (index--) {
+ register const QTimerInfo * const t = at(index);
+ if (!(ti->timeout < t->timeout))
+ break;
+ }
+ insert(index+1, ti);
+}
+
+inline timeval &operator+=(timeval &t1, int ms)
+{
+ t1.tv_sec += ms / 1000;
+ t1.tv_usec += ms % 1000 * 1000;
+ return normalizedTimeval(t1);
+}
+
+inline timeval operator+(const timeval &t1, int ms)
+{
+ timeval t2 = t1;
+ return t2 += ms;
+}
+
+static timeval roundToMillisecond(timeval val)
+{
+ // always round up
+ // worst case scenario is that the first trigger of a 1-ms timer is 0.999 ms late
+
+ int us = val.tv_usec % 1000;
+ val.tv_usec += 1000 - us;
+ return normalizedTimeval(val);
+}
+
+#ifdef QTIMERINFO_DEBUG
+QDebug operator<<(QDebug s, timeval tv)
+{
+ s.nospace() << tv.tv_sec << "." << qSetFieldWidth(6) << qSetPadChar(QChar(48)) << tv.tv_usec << reset;
+ return s.space();
+}
+QDebug operator<<(QDebug s, Qt::TimerType t)
+{
+ s << (t == Qt::PreciseTimer ? "P" :
+ t == Qt::CoarseTimer ? "C" : "VC");
+ return s;
+}
+#endif
+
+static void calculateCoarseTimerTimeout(QTimerInfo *t, timeval currentTime)
+{
+ // The coarse timer works like this:
+ // - interval under 40 ms: round to even
+ // - between 40 and 99 ms: round to multiple of 4
+ // - otherwise: try to wake up at a multiple of 25 ms, with a maximum error of 5%
+ //
+ // We try to wake up at the following second-fraction, in order of preference:
+ // 0 ms
+ // 500 ms
+ // 250 ms or 750 ms
+ // 200, 400, 600, 800 ms
+ // other multiples of 100
+ // other multiples of 50
+ // other multiples of 25
+ //
+ // The objective is to make most timers wake up at the same time, thereby reducing CPU wakeups.
+
+ register uint interval = uint(t->interval);
+ register uint msec = uint(t->timeout.tv_usec) / 1000;
+ Q_ASSERT(interval >= 20);
+
+ // Calculate how much we can round and still keep within 5% error
+ uint absMaxRounding = interval / 20;
+
+ if (interval < 100 && interval != 25 && interval != 50 && interval != 75) {
+ // special mode for timers of less than 100 ms
+ if (interval < 50) {
+ // round to even
+ // round towards multiples of 50 ms
+ register bool roundUp = (msec % 50) >= 25;
+ msec >>= 1;
+ msec |= uint(roundUp);
+ msec <<= 1;
+ } else {
+ // round to multiple of 4
+ // round towards multiples of 100 ms
+ register bool roundUp = (msec % 100) >= 50;
+ msec >>= 2;
+ msec |= uint(roundUp);
+ msec <<= 2;
+ }
+ } else {
+ uint min = qMax<int>(0, msec - absMaxRounding);
+ uint max = qMin(1000u, msec + absMaxRounding);
+
+ // find the boundary that we want, according to the rules above
+ // extra rules:
+ // 1) whatever the interval, we'll take any round-to-the-second timeout
+ if (min == 0) {
+ msec = 0;
+ goto recalculate;
+ } else if (max == 1000) {
+ msec = 1000;
+ goto recalculate;
+ }
+
+ uint wantedBoundaryMultiple;
+
+ // 2) if the interval is a multiple of 500 ms and > 5000 ms, we'll always round
+ // towards a round-to-the-second
+ // 3) if the interval is a multiple of 500 ms, we'll round towards the nearest
+ // multiple of 500 ms
+ if ((interval % 500) == 0) {
+ if (interval >= 5000) {
+ msec = msec >= 500 ? max : min;
+ goto recalculate;
+ } else {
+ wantedBoundaryMultiple = 500;
+ }
+ } else if ((interval % 50) == 0) {
+ // 4) same for multiples of 250, 200, 100, 50
+ uint mult50 = interval / 50;
+ if ((mult50 % 4) == 0) {
+ // multiple of 200
+ wantedBoundaryMultiple = 200;
+ } else if ((mult50 % 2) == 0) {
+ // multiple of 100
+ wantedBoundaryMultiple = 100;
+ } else if ((mult50 % 5) == 0) {
+ // multiple of 250
+ wantedBoundaryMultiple = 250;
+ } else {
+ // multiple of 50
+ wantedBoundaryMultiple = 50;
+ }
+ } else {
+ wantedBoundaryMultiple = 25;
+ }
+
+ uint base = msec / wantedBoundaryMultiple * wantedBoundaryMultiple;
+ uint middlepoint = base + wantedBoundaryMultiple / 2;
+ if (msec < middlepoint)
+ msec = qMax(base, min);
+ else
+ msec = qMin(base + wantedBoundaryMultiple, max);
+ }
+
+recalculate:
+ if (msec == 1000u) {
+ ++t->timeout.tv_sec;
+ t->timeout.tv_usec = 0;
+ } else {
+ t->timeout.tv_usec = msec * 1000;
+ }
+
+ if (t->timeout < currentTime)
+ t->timeout += interval;
+}
+
+static void calculateNextTimeout(QTimerInfo *t, timeval currentTime)
+{
+ switch (t->timerType) {
+ case Qt::PreciseTimer:
+ case Qt::CoarseTimer:
+ t->timeout += t->interval;
+ if (t->timeout < currentTime) {
+ t->timeout = currentTime;
+ t->timeout += t->interval;
+ }
+#ifdef QTIMERINFO_DEBUG
+ t->expected += t->interval;
+ if (t->expected < currentTime) {
+ t->expected = currentTime;
+ t->expected += t->interval;
+ }
+#endif
+ if (t->timerType == Qt::CoarseTimer)
+ calculateCoarseTimerTimeout(t, currentTime);
+ return;
+
+ case Qt::VeryCoarseTimer:
+ // we don't need to take care of the microsecond component of t->interval
+ t->timeout.tv_sec += t->interval;
+ if (t->timeout.tv_sec <= currentTime.tv_sec)
+ t->timeout.tv_sec = currentTime.tv_sec + t->interval;
+#ifdef QTIMERINFO_DEBUG
+ t->expected.tv_sec += t->interval;
+ if (t->expected.tv_sec <= currentTime.tv_sec)
+ t->expected.tv_sec = currentTime.tv_sec + t->interval;
+#endif
+ return;
+ }
+
+#ifdef QTIMERINFO_DEBUG
+ if (t->timerType != Qt::PreciseTimer)
+ qDebug() << "timer" << t->timerType << hex << t->id << dec << "interval" << t->interval
+ << "originally expected at" << t->expected << "will fire at" << t->timeout
+ << "or" << (t->timeout - t->expected) << "s late";
+#endif
+}
+
+/*
+ Returns the time to wait for the next timer, or null if no timers
+ are waiting.
+*/
+bool QTimerInfoList::timerWait(timeval &tm)
+{
+ timeval currentTime = updateCurrentTime();
+ repairTimersIfNeeded();
+
+ // Find first waiting timer not already active
+ QTimerInfo *t = 0;
+ for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
+ if (!(*it)->activateRef) {
+ t = *it;
+ break;
+ }
+ }
+
+ if (!t)
+ return false;
+
+ if (currentTime < t->timeout) {
+ // time to wait
+ tm = roundToMillisecond(t->timeout - currentTime);
+ } else {
+ // no time to wait
+ tm.tv_sec = 0;
+ tm.tv_usec = 0;
+ }
+
+ return true;
+}
+
+void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
+{
+ QTimerInfo *t = new QTimerInfo;
+ t->id = timerId;
+ t->interval = interval;
+ t->timerType = timerType;
+ t->obj = object;
+ t->activateRef = 0;
+
+ timeval expected = updateCurrentTime() + interval;
+
+ switch (timerType) {
+ case Qt::PreciseTimer:
+ // high precision timer is based on millisecond precision
+ // so no adjustment is necessary
+ t->timeout = expected;
+ break;
+
+ case Qt::CoarseTimer:
+ // this timer has up to 5% coarseness
+ // so our boundaries are 20 ms and 20 s
+ // below 20 ms, 5% inaccuracy is below 1 ms, so we convert to high precision
+ // above 20 s, 5% inaccuracy is above 1 s, so we convert to VeryCoarseTimer
+ if (interval >= 20000) {
+ t->timerType = Qt::VeryCoarseTimer;
+ // fall through
+ } else {
+ t->timeout = expected;
+ if (interval <= 20) {
+ t->timerType = Qt::PreciseTimer;
+ // no adjustment is necessary
+ } else if (interval <= 20000) {
+ calculateCoarseTimerTimeout(t, currentTime);
+ }
+ break;
+ }
+ // fall through
+ case Qt::VeryCoarseTimer:
+ // the very coarse timer is based on full second precision,
+ // so we keep the interval in seconds (round to closest second)
+ t->interval /= 500;
+ t->interval += 1;
+ t->interval >>= 1;
+ t->timeout.tv_sec = currentTime.tv_sec + t->interval;
+ t->timeout.tv_usec = 0;
+
+ // if we're past the half-second mark, increase the timeout again
+ if (currentTime.tv_usec > 500*1000)
+ ++t->timeout.tv_sec;
+ }
+
+ timerInsert(t);
+
+#ifdef QTIMERINFO_DEBUG
+ t->expected = expected;
+ t->cumulativeError = 0;
+ t->count = 0;
+ if (t->timerType != Qt::PreciseTimer)
+ qDebug() << "timer" << t->timerType << hex <<t->id << dec << "interval" << t->interval << "expected at"
+ << t->expected << "will fire first at" << t->timeout;
+#endif
+}
+
+bool QTimerInfoList::unregisterTimer(int timerId)
+{
+ // set timer inactive
+ for (int i = 0; i < count(); ++i) {
+ register QTimerInfo *t = at(i);
+ if (t->id == timerId) {
+ // found it
+ removeAt(i);
+ if (t == firstTimerInfo)
+ firstTimerInfo = 0;
+ if (t->activateRef)
+ *(t->activateRef) = 0;
+ delete t;
+ return true;
+ }
+ }
+ // id not found
+ return false;
+}
+
+bool QTimerInfoList::unregisterTimers(QObject *object)
+{
+ if (isEmpty())
+ return false;
+ for (int i = 0; i < count(); ++i) {
+ register QTimerInfo *t = at(i);
+ if (t->obj == object) {
+ // object found
+ removeAt(i);
+ if (t == firstTimerInfo)
+ firstTimerInfo = 0;
+ if (t->activateRef)
+ *(t->activateRef) = 0;
+ delete t;
+ // move back one so that we don't skip the new current item
+ --i;
+ }
+ }
+ return true;
+}
+
+QList<QAbstractEventDispatcher::TimerInfo> QTimerInfoList::registeredTimers(QObject *object) const
+{
+ QList<QAbstractEventDispatcher::TimerInfo> list;
+ for (int i = 0; i < count(); ++i) {
+ register const QTimerInfo * const t = at(i);
+ if (t->obj == object) {
+ list << QAbstractEventDispatcher::TimerInfo(t->id,
+ (t->timerType == Qt::VeryCoarseTimer
+ ? t->interval * 1000
+ : t->interval),
+ t->timerType);
+ }
+ }
+ return list;
+}
+
+/*
+ Activate pending timers, returning how many where activated.
+*/
+int QTimerInfoList::activateTimers()
+{
+ if (qt_disable_lowpriority_timers || isEmpty())
+ return 0; // nothing to do
+
+ int n_act = 0, maxCount = 0;
+ firstTimerInfo = 0;
+
+ timeval currentTime = updateCurrentTime();
+ // qDebug() << "Thread" << QThread::currentThreadId() << "woken up at" << currentTime;
+ repairTimersIfNeeded();
+
+
+ // Find out how many timer have expired
+ for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
+ if (currentTime < (*it)->timeout)
+ break;
+ maxCount++;
+ }
+
+ //fire the timers.
+ while (maxCount--) {
+ if (isEmpty())
+ break;
+
+ QTimerInfo *currentTimerInfo = first();
+ if (currentTime < currentTimerInfo->timeout)
+ break; // no timer has expired
+
+ if (!firstTimerInfo) {
+ firstTimerInfo = currentTimerInfo;
+ } else if (firstTimerInfo == currentTimerInfo) {
+ // avoid sending the same timer multiple times
+ break;
+ } else if (currentTimerInfo->interval < firstTimerInfo->interval
+ || currentTimerInfo->interval == firstTimerInfo->interval) {
+ firstTimerInfo = currentTimerInfo;
+ }
+
+ // remove from list
+ removeFirst();
+
+#ifdef QTIMERINFO_DEBUG
+ float diff;
+ if (currentTime < currentTimerInfo->expected) {
+ // early
+ timeval early = currentTimerInfo->expected - currentTime;
+ diff = -(early.tv_sec + early.tv_usec / 1000000.0);
+ } else {
+ timeval late = currentTime - currentTimerInfo->expected;
+ diff = late.tv_sec + late.tv_usec / 1000000.0;
+ }
+ currentTimerInfo->cumulativeError += diff;
+ ++currentTimerInfo->count;
+ if (currentTimerInfo->timerType != Qt::PreciseTimer)
+ qDebug() << "timer" << currentTimerInfo->timerType << hex << currentTimerInfo->id << dec << "interval"
+ << currentTimerInfo->interval << "firing at" << currentTime
+ << "(orig" << currentTimerInfo->expected << "scheduled at" << currentTimerInfo->timeout
+ << ") off by" << diff << "activation" << currentTimerInfo->count
+ << "avg error" << (currentTimerInfo->cumulativeError / currentTimerInfo->count);
+#endif
+
+ // determine next timeout time
+ calculateNextTimeout(currentTimerInfo, currentTime);
+
+ // reinsert timer
+ timerInsert(currentTimerInfo);
+ if (currentTimerInfo->interval > 0)
+ n_act++;
+
+ if (!currentTimerInfo->activateRef) {
+ // send event, but don't allow it to recurse
+ currentTimerInfo->activateRef = &currentTimerInfo;
+
+ QTimerEvent e(currentTimerInfo->id);
+ QCoreApplication::sendEvent(currentTimerInfo->obj, &e);
+
+ if (currentTimerInfo)
+ currentTimerInfo->activateRef = 0;
+ }
+ }
+
+ firstTimerInfo = 0;
+ // qDebug() << "Thread" << QThread::currentThreadId() << "activated" << n_act << "timers";
+ return n_act;
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h
new file mode 100644
index 0000000000..8a057dda60
--- /dev/null
+++ b/src/corelib/kernel/qtimerinfo_unix_p.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTIMERINFO_UNIX_P_H
+#define QTIMERINFO_UNIX_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.
+//
+
+// #define QTIMERINFO_DEBUG
+
+#include "qabstracteventdispatcher.h"
+
+#include <sys/time.h> // struct timeval
+
+QT_BEGIN_NAMESPACE
+
+// internal timer info
+struct QTimerInfo {
+ int id; // - timer identifier
+ int interval; // - timer interval in milliseconds
+ Qt::TimerType timerType; // - timer type
+ timeval timeout; // - when to actually fire
+ QObject *obj; // - object to receive event
+ QTimerInfo **activateRef; // - ref from activateTimers
+
+#ifdef QTIMERINFO_DEBUG
+ timeval expected; // when timer is expected to fire
+ float cumulativeError;
+ uint count;
+#endif
+};
+
+class Q_CORE_EXPORT QTimerInfoList : public QList<QTimerInfo*>
+{
+#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED)
+ timeval previousTime;
+ clock_t previousTicks;
+ int ticksPerSecond;
+ int msPerTick;
+
+ bool timeChanged(timeval *delta);
+ void timerRepair(const timeval &);
+#endif
+
+ // state variables used by activateTimers()
+ QTimerInfo *firstTimerInfo;
+
+public:
+ QTimerInfoList();
+
+ timeval currentTime;
+ timeval updateCurrentTime();
+
+ // must call updateCurrentTime() first!
+ void repairTimersIfNeeded();
+
+ bool timerWait(timeval &);
+ void timerInsert(QTimerInfo *);
+
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
+ bool unregisterTimer(int timerId);
+ bool unregisterTimers(QObject *object);
+ QList<QAbstractEventDispatcher::TimerInfo> registeredTimers(QObject *object) const;
+
+ int activateTimers();
+};
+
+QT_END_NAMESPACE
+
+#endif // QTIMERINFO_UNIX_P_H
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 2796902590..aadf3a76e9 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index 43cd63d1da..b1f378a8b5 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qtranslator_p.h b/src/corelib/kernel/qtranslator_p.h
index 426be0b19b..23164ecac6 100644
--- a/src/corelib/kernel/qtranslator_p.h
+++ b/src/corelib/kernel/qtranslator_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 29717398a8..72229c0e63 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -52,6 +52,10 @@
#include "qstringlist.h"
#include "qurl.h"
#include "qlocale.h"
+#include "quuid.h"
+#ifndef QT_BOOTSTRAPPED
+#include "qabstractitemmodel.h"
+#endif
#include "private/qvariant_p.h"
#include "qmetatype_p.h"
@@ -74,6 +78,25 @@ QT_BEGIN_NAMESPACE
#endif
namespace {
+class HandlersManager
+{
+ static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount];
+public:
+ const QVariant::Handler *operator[] (const int typeId) const
+ {
+ return Handlers[QModulesPrivate::moduleForType(typeId)];
+ }
+
+ void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler)
+ {
+ Handlers[name] = handler;
+ }
+
+ inline void unregisterHandler(const QModulesPrivate::Names name);
+};
+} // namespace
+
+namespace {
template<typename T>
struct TypeDefiniton {
static const bool IsAvailable = true;
@@ -82,6 +105,7 @@ struct TypeDefiniton {
// Ignore these types, as incomplete
#ifdef QT_BOOTSTRAPPED
template<> struct TypeDefiniton<QEasingCurve> { static const bool IsAvailable = false; };
+template<> struct TypeDefiniton<QModelIndex> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_GEOM_VARIANT
template<> struct TypeDefiniton<QRect> { static const bool IsAvailable = false; };
@@ -100,7 +124,9 @@ struct CoreTypesFilter {
static const bool IsAccepted = QTypeModuleInfo<T>::IsCore && TypeDefiniton<T>::IsAvailable;
};
};
-} // namspace
+} // annonymous used to hide TypeDefiniton
+
+namespace { // annonymous used to hide QVariant handlers
static void construct(QVariant::Private *x, const void *copy)
{
@@ -324,6 +350,9 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
case QVariant::Url:
*str = v_cast<QUrl>(d)->toString();
break;
+ case QVariant::Uuid:
+ *str = v_cast<QUuid>(d)->toString();
+ break;
default:
return false;
}
@@ -688,6 +717,15 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
return *ok;
}
#endif
+ case QVariant::Uuid:
+ switch (d->type) {
+ case QVariant::String:
+ *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
+ break;
+ default:
+ return false;
+ }
+ break;
default:
return false;
}
@@ -697,101 +735,9 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result,
#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
static void streamDebug(QDebug dbg, const QVariant &v)
{
- switch (v.userType()) {
- case QVariant::Int:
- dbg.nospace() << v.toInt();
- break;
- case QVariant::UInt:
- dbg.nospace() << v.toUInt();
- break;
- case QVariant::LongLong:
- dbg.nospace() << v.toLongLong();
- break;
- case QVariant::ULongLong:
- dbg.nospace() << v.toULongLong();
- break;
- case QMetaType::Float:
- dbg.nospace() << v.toFloat();
- break;
- case QMetaType::QObjectStar:
- dbg.nospace() << qvariant_cast<QObject *>(v);
- break;
- case QVariant::Double:
- dbg.nospace() << v.toDouble();
- break;
- case QVariant::Bool:
- dbg.nospace() << v.toBool();
- break;
- case QVariant::String:
- dbg.nospace() << v.toString();
- break;
- case QVariant::Char:
- dbg.nospace() << v.toChar();
- break;
- case QVariant::StringList:
- dbg.nospace() << v.toStringList();
- break;
- case QVariant::Map:
- dbg.nospace() << v.toMap();
- break;
- case QVariant::Hash:
- dbg.nospace() << v.toHash();
- break;
- case QVariant::List:
- dbg.nospace() << v.toList();
- break;
- case QVariant::Date:
- dbg.nospace() << v.toDate();
- break;
- case QVariant::Time:
- dbg.nospace() << v.toTime();
- break;
- case QVariant::DateTime:
- dbg.nospace() << v.toDateTime();
- break;
-#ifndef QT_BOOTSTRAPPED
- case QVariant::EasingCurve:
- dbg.nospace() << v.toEasingCurve();
- break;
-#endif
- case QVariant::ByteArray:
- dbg.nospace() << v.toByteArray();
- break;
- case QVariant::Url:
- dbg.nospace() << v.toUrl();
- break;
-#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Point:
- dbg.nospace() << v.toPoint();
- break;
- case QVariant::PointF:
- dbg.nospace() << v.toPointF();
- break;
- case QVariant::Rect:
- dbg.nospace() << v.toRect();
- break;
- case QVariant::Size:
- dbg.nospace() << v.toSize();
- break;
- case QVariant::SizeF:
- dbg.nospace() << v.toSizeF();
- break;
- case QVariant::Line:
- dbg.nospace() << v.toLine();
- break;
- case QVariant::LineF:
- dbg.nospace() << v.toLineF();
- break;
- case QVariant::RectF:
- dbg.nospace() << v.toRectF();
- break;
-#endif
- case QVariant::BitArray:
- //dbg.nospace() << v.toBitArray();
- break;
- default:
- break;
- }
+ QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
+ QVariantDebugStream<CoreTypesFilter> stream(dbg, d);
+ QMetaTypeSwitcher::switcher<void>(stream, d->type, 0);
}
#endif
@@ -813,13 +759,142 @@ const QVariant::Handler qt_kernel_variant_handler = {
#endif
};
+static void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false, "QVariant", "Trying to construct an unknown type"); }
+static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); }
+static bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; }
+static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; }
+static bool dummyConvert(const QVariant::Private *, QVariant::Type , void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); }
+#endif
+const QVariant::Handler qt_dummy_variant_handler = {
+ dummyConstruct,
+ dummyClear,
+ dummyIsNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ dummyCompare,
+ dummyConvert,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ dummyStreamDebug
+#else
+ 0
+#endif
+};
+
+static void customConstruct(QVariant::Private *d, const void *copy)
+{
+ const uint size = QMetaType::sizeOf(d->type);
+ if (!size) {
+ d->type = QVariant::Invalid;
+ return;
+ }
+
+ // this logic should match with QVariantIntegrator::CanUseInternalSpace
+ if (size <= sizeof(QVariant::Private::Data)
+ && (QMetaType::typeFlags(d->type) & QMetaType::MovableType)) {
+ QMetaType::construct(d->type, &d->data.ptr, copy);
+ d->is_shared = false;
+ } else {
+ void *ptr = QMetaType::create(d->type, copy);
+ d->is_shared = true;
+ d->data.shared = new QVariant::PrivateShared(ptr);
+ }
+}
+
+static void customClear(QVariant::Private *d)
+{
+ if (!d->is_shared) {
+ QMetaType::destruct(d->type, &d->data.ptr);
+ } else {
+ QMetaType::destroy(d->type, d->data.shared->ptr);
+ delete d->data.shared;
+ }
+}
+
+static bool customIsNull(const QVariant::Private *d)
+{
+ return d->is_null;
+}
+
+static bool customCompare(const QVariant::Private *a, const QVariant::Private *b)
+{
+ const char *const typeName = QMetaType::typeName(a->type);
+ if (Q_UNLIKELY(!typeName) && Q_LIKELY(!QMetaType::isRegistered(a->type)))
+ qFatal("QVariant::compare: type %d unknown to QVariant.", a->type);
+
+ const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr);
+ const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr);
+
+ uint typeNameLen = qstrlen(typeName);
+ if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*')
+ return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);
+
+ if (a->is_null && b->is_null)
+ return true;
+
+ return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type));
+}
+
+static bool customConvert(const QVariant::Private *, QVariant::Type, void *, bool *ok)
+{
+ if (ok)
+ *ok = false;
+ return false;
+}
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+static void customStreamDebug(QDebug, const QVariant &) {}
+#endif
+
+const QVariant::Handler qt_custom_variant_handler = {
+ customConstruct,
+ customClear,
+ customIsNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ customCompare,
+ customConvert,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ customStreamDebug
+#else
+ 0
+#endif
+};
+
+} // annonymous used to hide QVariant handlers
+
+static HandlersManager handlerManager;
+Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0");
+const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount]
+ = { &qt_kernel_variant_handler, &qt_dummy_variant_handler,
+ &qt_dummy_variant_handler, &qt_custom_variant_handler };
+
Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler()
{
return &qt_kernel_variant_handler;
}
+inline void HandlersManager::unregisterHandler(const QModulesPrivate::Names name)
+{
+ Handlers[name] = &qt_dummy_variant_handler;
+}
-const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
+Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names */name, const QVariant::Handler *handler)
+{
+ handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler);
+}
+
+Q_CORE_EXPORT void QVariantPrivate::unregisterHandler(const int /* Modules::Names */ name)
+{
+ handlerManager.unregisterHandler(static_cast<QModulesPrivate::Names>(name));
+}
/*!
\class QVariant
@@ -923,6 +998,8 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
\value DateTime a QDateTime
\value Double a double
\value EasingCurve a QEasingCurve
+ \value Uuid a QUuid
+ \value ModelIndex a QModelIndex
\value Font a QFont
\value Hash a QVariantHash
\value Icon a QIcon
@@ -1018,7 +1095,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
void QVariant::create(int type, const void *copy)
{
d.type = type;
- handler->construct(&d, copy);
+ handlerManager[type]->construct(&d, copy);
}
/*!
@@ -1035,7 +1112,7 @@ void QVariant::create(int type, const void *copy)
QVariant::~QVariant()
{
if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
- handler->clear(&d);
+ handlerManager[d.type]->clear(&d);
}
/*!
@@ -1051,7 +1128,7 @@ QVariant::QVariant(const QVariant &p)
if (d.is_shared) {
d.data.shared->ref.ref();
} else if (p.d.type > Char) {
- handler->construct(&d, p.constData());
+ handlerManager[d.type]->construct(&d, p.constData());
d.is_null = p.d.is_null;
}
}
@@ -1435,7 +1512,7 @@ QVariant& QVariant::operator=(const QVariant &variant)
d = variant.d;
} else if (variant.d.type > Char) {
d.type = variant.d.type;
- handler->construct(&d, variant.constData());
+ handlerManager[d.type]->construct(&d, variant.constData());
d.is_null = variant.d.is_null;
} else {
d = variant.d;
@@ -1465,9 +1542,9 @@ void QVariant::detach()
Private dd;
dd.type = d.type;
- handler->construct(&dd, constData());
+ handlerManager[d.type]->construct(&dd, constData());
if (!d.data.shared->ref.deref())
- handler->clear(&d);
+ handlerManager[d.type]->clear(&d);
d.data.shared = dd.data.shared;
}
@@ -1496,7 +1573,7 @@ const char *QVariant::typeName() const
void QVariant::clear()
{
if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
- handler->clear(&d);
+ handlerManager[d.type]->clear(&d);
d.type = Invalid;
d.is_null = true;
d.is_shared = false;
@@ -1732,14 +1809,14 @@ QDataStream& operator<<(QDataStream &s, const QVariant::Type p)
*/
template <typename T>
-inline T qVariantToHelper(const QVariant::Private &d, QVariant::Type t,
- const QVariant::Handler *handler, T * = 0)
+inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager)
{
- if (d.type == t)
+ const QVariant::Type targetType = static_cast<const QVariant::Type>(qMetaTypeId<T>());
+ if (d.type == targetType)
return *v_cast<T>(&d);
T ret;
- handler->convert(&d, t, &ret, 0);
+ handlerManager[d.type]->convert(&d, targetType, &ret, 0);
return ret;
}
@@ -1754,7 +1831,7 @@ inline T qVariantToHelper(const QVariant::Private &d, QVariant::Type t,
*/
QStringList QVariant::toStringList() const
{
- return qVariantToHelper<QStringList>(d, StringList, handler);
+ return qVariantToHelper<QStringList>(d, handlerManager);
}
/*!
@@ -1767,7 +1844,7 @@ QStringList QVariant::toStringList() const
*/
QString QVariant::toString() const
{
- return qVariantToHelper<QString>(d, String, handler);
+ return qVariantToHelper<QString>(d, handlerManager);
}
/*!
@@ -1778,7 +1855,7 @@ QString QVariant::toString() const
*/
QVariantMap QVariant::toMap() const
{
- return qVariantToHelper<QVariantMap>(d, Map, handler);
+ return qVariantToHelper<QVariantMap>(d, handlerManager);
}
/*!
@@ -1789,7 +1866,7 @@ QVariantMap QVariant::toMap() const
*/
QVariantHash QVariant::toHash() const
{
- return qVariantToHelper<QVariantHash>(d, Hash, handler);
+ return qVariantToHelper<QVariantHash>(d, handlerManager);
}
/*!
@@ -1805,7 +1882,7 @@ QVariantHash QVariant::toHash() const
*/
QDate QVariant::toDate() const
{
- return qVariantToHelper<QDate>(d, Date, handler);
+ return qVariantToHelper<QDate>(d, handlerManager);
}
/*!
@@ -1821,7 +1898,7 @@ QDate QVariant::toDate() const
*/
QTime QVariant::toTime() const
{
- return qVariantToHelper<QTime>(d, Time, handler);
+ return qVariantToHelper<QTime>(d, handlerManager);
}
/*!
@@ -1838,7 +1915,7 @@ QTime QVariant::toTime() const
*/
QDateTime QVariant::toDateTime() const
{
- return qVariantToHelper<QDateTime>(d, DateTime, handler);
+ return qVariantToHelper<QDateTime>(d, handlerManager);
}
/*!
@@ -1853,7 +1930,7 @@ QDateTime QVariant::toDateTime() const
#ifndef QT_BOOTSTRAPPED
QEasingCurve QVariant::toEasingCurve() const
{
- return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler);
+ return qVariantToHelper<QEasingCurve>(d, handlerManager);
}
#endif
@@ -1868,7 +1945,7 @@ QEasingCurve QVariant::toEasingCurve() const
*/
QByteArray QVariant::toByteArray() const
{
- return qVariantToHelper<QByteArray>(d, ByteArray, handler);
+ return qVariantToHelper<QByteArray>(d, handlerManager);
}
#ifndef QT_NO_GEOM_VARIANT
@@ -1882,7 +1959,7 @@ QByteArray QVariant::toByteArray() const
*/
QPoint QVariant::toPoint() const
{
- return qVariantToHelper<QPoint>(d, Point, handler);
+ return qVariantToHelper<QPoint>(d, handlerManager);
}
/*!
@@ -1895,7 +1972,7 @@ QPoint QVariant::toPoint() const
*/
QRect QVariant::toRect() const
{
- return qVariantToHelper<QRect>(d, Rect, handler);
+ return qVariantToHelper<QRect>(d, handlerManager);
}
/*!
@@ -1908,7 +1985,7 @@ QRect QVariant::toRect() const
*/
QSize QVariant::toSize() const
{
- return qVariantToHelper<QSize>(d, Size, handler);
+ return qVariantToHelper<QSize>(d, handlerManager);
}
/*!
@@ -1921,7 +1998,7 @@ QSize QVariant::toSize() const
*/
QSizeF QVariant::toSizeF() const
{
- return qVariantToHelper<QSizeF>(d, SizeF, handler);
+ return qVariantToHelper<QSizeF>(d, handlerManager);
}
/*!
@@ -1934,7 +2011,7 @@ QSizeF QVariant::toSizeF() const
*/
QRectF QVariant::toRectF() const
{
- return qVariantToHelper<QRectF>(d, RectF, handler);
+ return qVariantToHelper<QRectF>(d, handlerManager);
}
/*!
@@ -1947,7 +2024,7 @@ QRectF QVariant::toRectF() const
*/
QLineF QVariant::toLineF() const
{
- return qVariantToHelper<QLineF>(d, LineF, handler);
+ return qVariantToHelper<QLineF>(d, handlerManager);
}
/*!
@@ -1960,7 +2037,7 @@ QLineF QVariant::toLineF() const
*/
QLine QVariant::toLine() const
{
- return qVariantToHelper<QLine>(d, Line, handler);
+ return qVariantToHelper<QLine>(d, handlerManager);
}
/*!
@@ -1973,7 +2050,7 @@ QLine QVariant::toLine() const
*/
QPointF QVariant::toPointF() const
{
- return qVariantToHelper<QPointF>(d, PointF, handler);
+ return qVariantToHelper<QPointF>(d, handlerManager);
}
#endif // QT_NO_GEOM_VARIANT
@@ -1988,7 +2065,7 @@ QPointF QVariant::toPointF() const
*/
QUrl QVariant::toUrl() const
{
- return qVariantToHelper<QUrl>(d, Url, handler);
+ return qVariantToHelper<QUrl>(d, handlerManager);
}
/*!
@@ -2001,7 +2078,7 @@ QUrl QVariant::toUrl() const
*/
QLocale QVariant::toLocale() const
{
- return qVariantToHelper<QLocale>(d, Locale, handler);
+ return qVariantToHelper<QLocale>(d, handlerManager);
}
/*!
@@ -2016,7 +2093,7 @@ QLocale QVariant::toLocale() const
#ifndef QT_NO_REGEXP
QRegExp QVariant::toRegExp() const
{
- return qVariantToHelper<QRegExp>(d, RegExp, handler);
+ return qVariantToHelper<QRegExp>(d, handlerManager);
}
#endif
@@ -2030,7 +2107,7 @@ QRegExp QVariant::toRegExp() const
*/
QChar QVariant::toChar() const
{
- return qVariantToHelper<QChar>(d, Char, handler);
+ return qVariantToHelper<QChar>(d, handlerManager);
}
/*!
@@ -2041,12 +2118,12 @@ QChar QVariant::toChar() const
*/
QBitArray QVariant::toBitArray() const
{
- return qVariantToHelper<QBitArray>(d, BitArray, handler);
+ return qVariantToHelper<QBitArray>(d, handlerManager);
}
template <typename T>
inline T qNumVariantToHelper(const QVariant::Private &d,
- const QVariant::Handler *handler, bool *ok, const T& val)
+ const HandlersManager &handlerManager, bool *ok, const T& val)
{
uint t = qMetaTypeId<T>();
if (ok)
@@ -2054,8 +2131,8 @@ inline T qNumVariantToHelper(const QVariant::Private &d,
if (d.type == t)
return val;
- T ret;
- if (!handler->convert(&d, QVariant::Type(t), &ret, ok) && ok)
+ T ret = 0;
+ if (!handlerManager[d.type]->convert(&d, QVariant::Type(t), &ret, ok) && ok)
*ok = false;
return ret;
}
@@ -2077,7 +2154,7 @@ inline T qNumVariantToHelper(const QVariant::Private &d,
*/
int QVariant::toInt(bool *ok) const
{
- return qNumVariantToHelper<int>(d, handler, ok, d.data.i);
+ return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
}
/*!
@@ -2097,7 +2174,7 @@ int QVariant::toInt(bool *ok) const
*/
uint QVariant::toUInt(bool *ok) const
{
- return qNumVariantToHelper<uint>(d, handler, ok, d.data.u);
+ return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);
}
/*!
@@ -2112,7 +2189,7 @@ uint QVariant::toUInt(bool *ok) const
*/
qlonglong QVariant::toLongLong(bool *ok) const
{
- return qNumVariantToHelper<qlonglong>(d, handler, ok, d.data.ll);
+ return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);
}
/*!
@@ -2128,7 +2205,7 @@ qlonglong QVariant::toLongLong(bool *ok) const
*/
qulonglong QVariant::toULongLong(bool *ok) const
{
- return qNumVariantToHelper<qulonglong>(d, handler, ok, d.data.ull);
+ return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);
}
/*!
@@ -2148,7 +2225,7 @@ bool QVariant::toBool() const
return d.data.b;
bool res = false;
- handler->convert(&d, Bool, &res, 0);
+ handlerManager[d.type]->convert(&d, Bool, &res, 0);
return res;
}
@@ -2165,7 +2242,7 @@ bool QVariant::toBool() const
*/
double QVariant::toDouble(bool *ok) const
{
- return qNumVariantToHelper<double>(d, handler, ok, d.data.d);
+ return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);
}
/*!
@@ -2182,7 +2259,7 @@ double QVariant::toDouble(bool *ok) const
*/
float QVariant::toFloat(bool *ok) const
{
- return qNumVariantToHelper<float>(d, handler, ok, d.data.f);
+ return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);
}
/*!
@@ -2199,7 +2276,7 @@ float QVariant::toFloat(bool *ok) const
*/
qreal QVariant::toReal(bool *ok) const
{
- return qNumVariantToHelper<qreal>(d, handler, ok, d.data.real);
+ return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);
}
/*!
@@ -2210,7 +2287,7 @@ qreal QVariant::toReal(bool *ok) const
*/
QVariantList QVariant::toList() const
{
- return qVariantToHelper<QVariantList>(d, List, handler);
+ return qVariantToHelper<QVariantList>(d, handlerManager);
}
@@ -2253,7 +2330,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
| 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double
| 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime
| 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char
- | 1 << QVariant::Url,
+ | 1 << QVariant::Url | 1 << QVariant::Uuid,
/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String,
@@ -2292,7 +2369,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QHash*/ 0,
-/*QEasingCurve*/ 0
+/*QEasingCurve*/ 0,
+
+/*QUuid*/ 1 << QVariant::String
};
/*!
@@ -2418,13 +2497,25 @@ bool QVariant::convert(Type t)
return false;
bool isOk = true;
- if (!handler->convert(&oldValue.d, t, data(), &isOk))
+ if (!handlerManager[d.type]->convert(&oldValue.d, t, data(), &isOk))
isOk = false;
d.is_null = !isOk;
return isOk;
}
/*!
+ \fn convert(const int type, void *ptr) const
+ \internal
+ Created for qvariant_cast() usage
+*/
+bool QVariant::convert(const int type, void *ptr) const
+{
+ Q_ASSERT(type < int(QMetaType::User));
+ return handlerManager[type]->convert(&d, QVariant::Type(type), ptr, 0);
+}
+
+
+/*!
\fn bool operator==(const QVariant &v1, const QVariant &v2)
\relates QVariant
@@ -2490,7 +2581,7 @@ bool QVariant::cmp(const QVariant &v) const
if (!v2.canConvert(Type(d.type)) || !v2.convert(Type(d.type)))
return false;
}
- return handler->compare(&d, &v2.d);
+ return handlerManager[d.type]->compare(&d, &v2.d);
}
/*! \internal
@@ -2520,15 +2611,15 @@ void* QVariant::data()
*/
bool QVariant::isNull() const
{
- return handler->isNull(&d);
+ return handlerManager[d.type]->isNull(&d);
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QVariant &v)
{
#ifndef Q_BROKEN_DEBUG_STREAM
- dbg.nospace() << "QVariant(" << v.typeName() << ", ";
- QVariant::handler->debugStream(dbg, v);
+ dbg.nospace() << "QVariant(" << QMetaType::typeName(v.userType()) << ", ";
+ handlerManager[v.d.type]->debugStream(dbg, v);
dbg.nospace() << ')';
return dbg.space();
#else
@@ -2541,7 +2632,7 @@ QDebug operator<<(QDebug dbg, const QVariant &v)
QDebug operator<<(QDebug dbg, const QVariant::Type p)
{
#ifndef Q_BROKEN_DEBUG_STREAM
- dbg.nospace() << "QVariant::" << QVariant::typeToName(p);
+ dbg.nospace() << "QVariant::" << QMetaType::typeName(p);
return dbg.space();
#else
qWarning("This compiler doesn't support streaming QVariant::Type to QDebug");
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 02458a07e0..35c584fa51 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -123,6 +123,8 @@ class Q_CORE_EXPORT QVariant
RegExp = QMetaType::QRegExp,
Hash = QMetaType::QVariantHash,
EasingCurve = QMetaType::QEasingCurve,
+ Uuid = QMetaType::QUuid,
+ ModelIndex = QMetaType::QModelIndex,
LastCoreType = QMetaType::LastCoreType,
Font = QMetaType::QFont,
@@ -370,35 +372,35 @@ class Q_CORE_EXPORT QVariant
{ return !cmp(v); }
protected:
- friend inline bool qvariant_cast_helper(const QVariant &, QVariant::Type, void *);
- friend void qRegisterGuiVariant();
- friend void qUnregisterGuiVariant();
friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &);
#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant &);
#endif
Private d;
-
- static const Handler *handler;
-
+#ifndef Q_NO_TEMPLATE_FRIENDS
+ template<typename T>
+ friend inline T qvariant_cast(const QVariant &);
+private:
+#else
+public:
+#endif
void create(int type, const void *copy);
bool cmp(const QVariant &other) const;
+ bool convert(const int t, void *ptr) const;
private:
// force compile error, prevent QVariant(bool) to be called
- inline QVariant(void *) { Q_ASSERT(false); }
+ inline QVariant(void *) Q_DECL_EQ_DELETE;
#ifdef QT_NO_CAST_FROM_ASCII
// force compile error when implicit conversion is not wanted
- inline QVariant(const char *) { Q_ASSERT(false); }
+ inline QVariant(const char *) Q_DECL_EQ_DELETE;
#endif
public:
typedef Private DataPtr;
inline DataPtr &data_ptr() { return d; }
+ inline const DataPtr &data_ptr() const { return d; }
};
-inline bool qvariant_cast_helper(const QVariant &v, QVariant::Type tp, void *ptr)
-{ return QVariant::handler->convert(&v.d, tp, ptr, 0); }
-
template <typename T>
inline QVariant qVariantFromValue(const T &t)
{
@@ -488,7 +490,7 @@ template<typename T> inline T qvariant_cast(const QVariant &v)
return *reinterpret_cast<const T *>(v.constData());
if (vid < int(QMetaType::User)) {
T t;
- if (qvariant_cast_helper(v, QVariant::Type(vid), &t))
+ if (v.convert(vid, &t))
return t;
}
return T();
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 3c2176856d..015ca5b464 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -58,20 +58,34 @@
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
+#include <QtCore/private/qmetatype_p.h>
+#include <QtCore/qdebug.h>
#include "qmetatypeswitcher_p.h"
QT_BEGIN_NAMESPACE
+namespace {
+template<typename T>
+struct QVariantIntegrator
+{
+ static const bool CanUseInternalSpace = sizeof(T) <= sizeof(QVariant::Private::Data)
+ && (!QTypeInfo<T>::isStatic);
+};
+Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace);
+Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace);
+Q_STATIC_ASSERT(QVariantIntegrator<qulonglong>::CanUseInternalSpace);
+} // namespace
+
#ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack
template <typename T>
inline T *v_cast(const QVariant::Private *nd, T * = 0)
{
QVariant::Private *d = const_cast<QVariant::Private *>(nd);
- return ((sizeof(T) > sizeof(QVariant::Private::Data))
+ return !QVariantIntegrator<T>::CanUseInternalSpace
? static_cast<T *>(d->data.shared->ptr)
- : static_cast<T *>(static_cast<void *>(&d->data.c)));
+ : static_cast<T *>(static_cast<void *>(&d->data.c));
}
#else // every other compiler in this world
@@ -79,17 +93,17 @@ inline T *v_cast(const QVariant::Private *nd, T * = 0)
template <typename T>
inline const T *v_cast(const QVariant::Private *d, T * = 0)
{
- return ((sizeof(T) > sizeof(QVariant::Private::Data))
+ return !QVariantIntegrator<T>::CanUseInternalSpace
? static_cast<const T *>(d->data.shared->ptr)
- : static_cast<const T *>(static_cast<const void *>(&d->data.c)));
+ : static_cast<const T *>(static_cast<const void *>(&d->data.c));
}
template <typename T>
inline T *v_cast(QVariant::Private *d, T * = 0)
{
- return ((sizeof(T) > sizeof(QVariant::Private::Data))
+ return !QVariantIntegrator<T>::CanUseInternalSpace
? static_cast<T *>(d->data.shared->ptr)
- : static_cast<T *>(static_cast<void *>(&d->data.c)));
+ : static_cast<T *>(static_cast<void *>(&d->data.c));
}
#endif
@@ -110,7 +124,7 @@ private:
template <class T>
inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
{
- if (sizeof(T) > sizeof(QVariant::Private::Data)) {
+ if (!QVariantIntegrator<T>::CanUseInternalSpace) {
x->data.shared = copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T *>(copy))
: new QVariantPrivateSharedEx<T>;
x->is_shared = true;
@@ -125,7 +139,7 @@ inline void v_construct(QVariant::Private *x, const void *copy, T * = 0)
template <class T>
inline void v_construct(QVariant::Private *x, const T &t)
{
- if (sizeof(T) > sizeof(QVariant::Private::Data)) {
+ if (!QVariantIntegrator<T>::CanUseInternalSpace) {
x->data.shared = new QVariantPrivateSharedEx<T>(t);
x->is_shared = true;
} else {
@@ -138,7 +152,7 @@ template <class T>
inline void v_clear(QVariant::Private *d, T* = 0)
{
- if (sizeof(T) > sizeof(QVariant::Private::Data)) {
+ if (!QVariantIntegrator<T>::CanUseInternalSpace) {
//now we need to cast
//because QVariant::PrivateShared doesn't have a virtual destructor
delete static_cast<QVariantPrivateSharedEx<T>*>(d->data.shared);
@@ -159,24 +173,7 @@ class QVariantComparator {
};
template<typename T>
struct FilteredComparator<T, /* IsAcceptedType = */ false> {
- static bool compare(const QVariant::Private *m_a, const QVariant::Private *m_b)
- {
- const char *const typeName = QMetaType::typeName(m_a->type);
- if (Q_UNLIKELY(!typeName) && Q_LIKELY(!QMetaType::isRegistered(m_a->type)))
- qFatal("QVariant::compare: type %d unknown to QVariant.", m_a->type);
-
- const void *a_ptr = m_a->is_shared ? m_a->data.shared->ptr : &(m_a->data.ptr);
- const void *b_ptr = m_b->is_shared ? m_b->data.shared->ptr : &(m_b->data.ptr);
-
- uint typeNameLen = qstrlen(typeName);
- if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*')
- return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);
-
- if (m_a->is_null && m_b->is_null)
- return true;
-
- return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(m_a->type));
- }
+ static bool compare(const QVariant::Private *, const QVariant::Private *) { return false; }
};
public:
QVariantComparator(const QVariant::Private *a, const QVariant::Private *b)
@@ -293,11 +290,11 @@ protected:
template<class Filter>
class QVariantConstructor
{
- template<typename T, bool IsSmall = (sizeof(T) <= sizeof(QVariant::Private::Data))>
+ template<typename T, bool CanUseInternalSpace = QVariantIntegrator<T>::CanUseInternalSpace>
struct CallConstructor {};
template<typename T>
- struct CallConstructor<T, /* IsSmall = */ true>
+ struct CallConstructor<T, /* CanUseInternalSpace = */ true>
{
CallConstructor(const QVariantConstructor &tc)
{
@@ -310,11 +307,11 @@ class QVariantConstructor
};
template<typename T>
- struct CallConstructor<T, /* IsSmall = */ false>
+ struct CallConstructor<T, /* CanUseInternalSpace = */ false>
{
CallConstructor(const QVariantConstructor &tc)
{
- Q_STATIC_ASSERT(QTypeInfo<T>::isComplex);
+ Q_STATIC_ASSERT(QTypeInfo<T>::isComplex || sizeof(T) > sizeof(QVariant::Private::Data));
tc.m_x->data.shared = tc.m_copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T*>(tc.m_copy))
: new QVariantPrivateSharedEx<T>;
tc.m_x->is_shared = true;
@@ -359,24 +356,8 @@ public:
m_x->is_shared = false;
return;
}
- // it is not a static known type, lets ask QMetaType if it can be constructed for us.
- const uint size = QMetaType::sizeOf(m_x->type);
-
- if (size && size <= sizeof(QVariant::Private::Data)) {
- void *ptr = QMetaType::construct(m_x->type, &m_x->data.ptr, m_copy);
- if (!ptr) {
- m_x->type = QVariant::Invalid;
- }
- m_x->is_shared = false;
- } else {
- void *ptr = QMetaType::create(m_x->type, m_copy);
- if (!ptr) {
- m_x->type = QVariant::Invalid;
- } else {
- m_x->is_shared = true;
- m_x->data.shared = new QVariant::PrivateShared(ptr);
- }
- }
+ qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type);
+ m_x->type = QVariant::Invalid;
}
void delegate(const void*)
@@ -425,13 +406,9 @@ public:
void delegate(const QMetaTypeSwitcher::UnknownType*)
{
- // This is not a static type, so lets delegate everyting to QMetaType
- if (!m_d->is_shared) {
- QMetaType::destruct(m_d->type, &m_d->data.ptr);
- } else {
- QMetaType::destroy(m_d->type, m_d->data.shared->ptr);
- delete m_d->data.shared;
- }
+ if (m_d->type == QVariant::UserType)
+ return;
+ qWarning("Trying to destruct an instance of an invalid type, type id: %i", m_d->type);
}
// Ignore nonconstructible type
void delegate(const void*) {}
@@ -439,6 +416,59 @@ private:
QVariant::Private *m_d;
};
+namespace QVariantPrivate {
+Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QVariant::Handler *handler);
+Q_CORE_EXPORT void unregisterHandler(const int /* Modules::Names */ name);
+}
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+template<class Filter>
+class QVariantDebugStream
+{
+ template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted>
+ struct Filtered {
+ Filtered(QDebug dbg, QVariant::Private *d)
+ {
+ dbg.nospace() << *v_cast<T>(d);
+ }
+ };
+ template<typename T>
+ struct Filtered<T, /* IsAcceptedType = */ false> {
+ Filtered(QDebug dbg, QVariant::Private *d)
+ {
+ dbg.nospace() << "QVariant::Type(" << d->type << ")";
+ }
+ };
+
+public:
+ QVariantDebugStream(QDebug dbg, QVariant::Private *d)
+ : m_debugStream(dbg)
+ , m_d(d)
+ {}
+
+ template<typename T>
+ void delegate(const T*)
+ {
+ Filtered<T> streamIt(m_debugStream, m_d);
+ }
+
+ void delegate(const QMetaTypeSwitcher::UnknownType*)
+ {
+ if (m_d->type == QVariant::UserType)
+ m_debugStream.nospace() << "QVariant::UserType";
+ else
+ qWarning("Trying to stream an instance of an invalid type, type id: %i", m_d->type);
+ }
+ void delegate(const void*)
+ {
+ m_debugStream.nospace() << "QVariant::Invalid";
+ }
+private:
+ QDebug m_debugStream;
+ QVariant::Private *m_d;
+};
+#endif
+
QT_END_NAMESPACE
#endif // QVARIANT_P_H
diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp
index 1ef77cdf62..e06e1d5b0a 100644
--- a/src/corelib/kernel/qwineventnotifier.cpp
+++ b/src/corelib/kernel/qwineventnotifier.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h
index d265c8c181..386a640434 100644
--- a/src/corelib/kernel/qwineventnotifier.h
+++ b/src/corelib/kernel/qwineventnotifier.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index e3c6b30820..cfe9a9d1b5 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 510ffed567..2f10807720 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qfactoryinterface.h b/src/corelib/plugin/qfactoryinterface.h
index 647d97f173..b7e4f3de16 100644
--- a/src/corelib/plugin/qfactoryinterface.h
+++ b/src/corelib/plugin/qfactoryinterface.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 749a7deddd..9ae97c6313 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h
index 75d40f8c3f..be40e66efd 100644
--- a/src/corelib/plugin/qfactoryloader_p.h
+++ b/src/corelib/plugin/qfactoryloader_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 6a40b5b818..f20abb660d 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -96,7 +96,7 @@ Q_GLOBAL_STATIC(QMutex, qt_library_mutex)
Unix), unless the file name has an absolute path. If the file
cannot be found, QLibrary tries the name with different
platform-specific file suffixes, like ".so" on Unix, ".dylib" on
- the Mac, or ".dll" on Windows and Symbian. This makes it possible
+ the Mac, or ".dll" on Windows. This makes it possible
to specify shared libraries that are only identified by their
basename (i.e. without their suffix), so the same code will work
on different operating systems.
@@ -118,11 +118,6 @@ Q_GLOBAL_STATIC(QMutex, qt_library_mutex)
linking", which is done by the link step in the build process when
linking an executable against a library.
- Note: In Symbian resolving symbols using their names is supported
- only if the library is built as STDDLL. Otherwise ordinals must
- be used. Also, in Symbian the path of the library is ignored and
- system default library location is always used.
-
The following code snippet loads a library, resolves the symbol
"mysymbol", and calls the function if everything succeeded. If
something goes wrong, e.g. the library file does not exist or the
@@ -287,7 +282,7 @@ static bool qt_parse_pattern(const char *s, uint *version, bool *debug)
}
#endif // QT_NO_PLUGIN_CHECK
-#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_PLUGIN_CHECK)
static long qt_find_pattern(const char *s, ulong s_len,
const char *pattern, ulong p_len)
@@ -398,7 +393,7 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QL
return ret;
}
-#endif // Q_OS_UNIX && !Q_OS_MAC && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK)
+#endif // Q_OS_UNIX && !Q_OS_MAC && !defined(QT_NO_PLUGIN_CHECK)
static void installCoverageTool(QLibraryPrivate *libPrivate)
{
@@ -435,25 +430,6 @@ static void installCoverageTool(QLibraryPrivate *libPrivate)
#endif
}
-static void releaseCoverageTool(QLibraryPrivate *libPrivate)
-{
-#ifdef __COVERAGESCANNER__
- /*
- __COVERAGESCANNER__ is defined when Qt has been instrumented for code
- coverage by TestCocoon.
- Here is the code to save the execution data.
- See comments about initialization in QLibraryPrivate::load().
- */
- if (libPrivate->pHnd) {
- __coveragescanner_save();
- __coveragescanner_clear();
- __coveragescanner_unregister_library(libPrivate->fileName.toLocal8Bit());
- }
-#else
- Q_UNUSED(libPrivate);
-#endif
-}
-
typedef QMap<QString, QLibraryPrivate*> LibraryMap;
struct LibraryData {
@@ -550,8 +526,6 @@ bool QLibraryPrivate::unload()
void QLibraryPrivate::release()
{
- releaseCoverageTool(this);
-
QMutexLocker locker(qt_library_mutex());
if (!libraryRefCount.deref())
delete this;
@@ -567,14 +541,6 @@ bool QLibraryPrivate::loadPlugin()
return false;
if (load()) {
instance = (QtPluginInstanceFunction)resolve("qt_plugin_instance");
-#if defined(Q_OS_SYMBIAN)
- if (!instance) {
- // If resolving with function name failed (i.e. not STDDLL),
- // try resolving using known ordinal, which for
- // qt_plugin_instance function is always "2".
- instance = (QtPluginInstanceFunction)resolve("2");
- }
-#endif
return instance;
}
if (qt_debug_component())
@@ -594,7 +560,6 @@ bool QLibraryPrivate::loadPlugin()
\row \i AIX \i \c .a
\row \i HP-UX \i \c .sl, \c .so (HP-UXi)
\row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
- \row \i Symbian \i \c .dll
\endtable
Trailing versioning numbers on Unix are ignored.
@@ -603,10 +568,6 @@ bool QLibrary::isLibrary(const QString &fileName)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive);
-#elif defined(Q_OS_SYMBIAN)
- // Plugin stubs are also considered libraries in Symbian.
- return (fileName.endsWith(QLatin1String(".dll")) ||
- fileName.endsWith(QLatin1String(".qtplugin")));
#else
QString completeSuffix = QFileInfo(fileName).completeSuffix();
if (completeSuffix.isEmpty())
@@ -728,7 +689,7 @@ bool QLibraryPrivate::isPlugin()
}
#endif
-#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
if (!pHnd) {
// use unix shortcut to avoid loading the library
success = qt_unix_query(fileName, &qt_version, &debug, this);
@@ -749,11 +710,7 @@ bool QLibraryPrivate::isPlugin()
hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags);
SetErrorMode(oldmode);
#else
-# if defined(Q_OS_SYMBIAN)
- //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
- if (fileinfo.exists())
-# endif
- temporary_load = load_sys();
+ temporary_load = load_sys();
#endif
}
#ifdef Q_OS_WIN
@@ -766,16 +723,7 @@ bool QLibraryPrivate::isPlugin()
: (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
#else
QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL;
-# if defined(Q_OS_SYMBIAN)
- if (temporary_load) {
- qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
- // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal
- if (!qtPluginQueryVerificationDataFunction)
- qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1");
- }
-# else
qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data");
-# endif
#endif
bool exceptionThrown = false;
bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction,
@@ -927,8 +875,6 @@ QLibrary::QLibrary(QObject *parent)
QLibrary will automatically look for the file with the appropriate
suffix in accordance with the platform, e.g. ".so" on Unix,
".dylib" on Mac OS X, and ".dll" on Windows. (See \l{fileName}.)
-
- Note: In Symbian the path portion of the \a fileName is ignored.
*/
QLibrary::QLibrary(const QString& fileName, QObject *parent)
:QObject(parent), d(0), did_load(false)
@@ -940,14 +886,12 @@ QLibrary::QLibrary(const QString& fileName, QObject *parent)
/*!
Constructs a library object with the given \a parent that will
load the library specified by \a fileName and major version number \a verNum.
- Currently, the version number is ignored on Windows and Symbian.
+ Currently, the version number is ignored on Windows.
We recommend omitting the file's suffix in \a fileName, since
QLibrary will automatically look for the file with the appropriate
suffix in accordance with the platform, e.g. ".so" on Unix,
".dylib" on Mac OS X, and ".dll" on Windows. (See \l{fileName}.)
-
- Note: In Symbian the path portion of the \a fileName is ignored.
*/
QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent)
:QObject(parent), d(0), did_load(false)
@@ -958,14 +902,12 @@ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent)
/*!
Constructs a library object with the given \a parent that will
load the library specified by \a fileName and full version number \a version.
- Currently, the version number is ignored on Windows and Symbian.
+ Currently, the version number is ignored on Windows.
We recommend omitting the file's suffix in \a fileName, since
QLibrary will automatically look for the file with the appropriate
suffix in accordance with the platform, e.g. ".so" on Unix,
".dylib" on Mac OS X, and ".dll" on Windows. (See \l{fileName}.)
-
- Note: In Symbian the path portion of the \a fileName is ignored.
*/
QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent)
:QObject(parent), d(0), did_load(false)
@@ -1007,8 +949,6 @@ QLibrary::~QLibrary()
platforms, fileName() will return "libGL.so". If the file name was
originally passed as "/usr/lib/libGL", fileName() will return
"/usr/lib/libGL.so".
-
- Note: In Symbian the path portion of the \a fileName is ignored.
*/
void QLibrary::setFileName(const QString &fileName)
@@ -1036,9 +976,7 @@ QString QLibrary::fileName() const
Sets the fileName property and major version number to \a fileName
and \a versionNumber respectively.
- The \a versionNumber is ignored on Windows and Symbian.
-
- Note: In Symbian the path portion of the \a fileName is ignored.
+ The \a versionNumber is ignored on Windows.
\sa setFileName()
*/
@@ -1060,9 +998,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum)
Sets the fileName property and full version number to \a fileName
and \a version respectively.
- The \a version parameter is ignored on Windows and Symbian.
-
- Note: In Symbian the path portion of the \a fileName is ignored.
+ The \a version parameter is ignored on Windows.
\sa setFileName()
*/
@@ -1098,9 +1034,6 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver
with \c MY_EXPORT defined as
\snippet doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp 4
-
- Note: In Symbian resolving with symbol names works only if the loaded
- library was built as STDDLL. Otherwise, the ordinals must be used.
*/
QFunctionPointer QLibrary::resolve(const char *symbol)
{
@@ -1120,9 +1053,6 @@ QFunctionPointer QLibrary::resolve(const char *symbol)
The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.
- Note: In Symbian resolving with symbol names works only if the loaded
- library was built as STDDLL. Otherwise, the ordinals must be used.
-
\sa resolve()
*/
QFunctionPointer QLibrary::resolve(const QString &fileName, const char *symbol)
@@ -1143,9 +1073,6 @@ QFunctionPointer QLibrary::resolve(const QString &fileName, const char *symbol)
The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.
- Note: In Symbian resolving with symbol names works only if the loaded
- library was built as STDDLL. Otherwise, the ordinals must be used.
-
\sa resolve()
*/
QFunctionPointer QLibrary::resolve(const QString &fileName, int verNum, const char *symbol)
@@ -1167,9 +1094,6 @@ QFunctionPointer QLibrary::resolve(const QString &fileName, int verNum, const ch
The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.
- Note: In Symbian resolving with symbol names works only if the loaded
- library was built as STDDLL. Otherwise, the ordinals must be used.
-
\sa resolve()
*/
QFunctionPointer QLibrary::resolve(const QString &fileName, const QString &version, const char *symbol)
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index e3f557dd7d..729277e838 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index 15825c699f..45c8843d20 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index d3b08e1acf..ce6d645ca4 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index 4eeb2fc441..fd46a7107e 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index 52661671b5..c9388c1337 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index 1c24de3254..2149fa7179 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 591e36e20a..1557df2eef 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -48,11 +48,6 @@
#include "qdebug.h"
#include "qdir.h"
-#if defined(Q_OS_SYMBIAN)
-# include <f32file.h>
-# include "private/qcore_symbian_p.h"
-#endif
-
#ifndef QT_NO_LIBRARY
QT_BEGIN_NAMESPACE
@@ -106,16 +101,6 @@ QT_BEGIN_NAMESPACE
link to plugins statically. You can use QLibrary if you need to
load dynamic libraries in a statically linked application.
- \note In Symbian the plugin stub files must be used whenever a
- path to plugin is needed. For the purposes of loading plugins,
- the stubs can be considered to have the same name as the actual
- plugin binary. In practice they have ".qtplugin" extension
- instead of ".dll", but this difference is handled transparently
- by QPluginLoader and QLibrary to avoid need for Symbian specific
- plugin handling in most Qt applications. Plugin stubs are needed
- because Symbian Platform Security denies all access to the directory
- where the actual plugin binaries are located.
-
\sa QLibrary, {Plug & Paint Example}
*/
@@ -136,8 +121,6 @@ QPluginLoader::QPluginLoader(QObject *parent)
Unix, - \c .dylib on Mac OS X, and \c .dll on Windows. The suffix
can be verified with QLibrary::isLibrary().
- Note: In Symbian the \a fileName must point to plugin stub file.
-
\sa setFileName()
*/
QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent)
@@ -263,8 +246,6 @@ bool QPluginLoader::isLoaded() const
By default, this property contains an empty string.
- Note: In Symbian the \a fileName must point to plugin stub file.
-
\sa load()
*/
void QPluginLoader::setFileName(const QString &fileName)
@@ -278,48 +259,7 @@ void QPluginLoader::setFileName(const QString &fileName)
did_load = false;
}
-#if defined(Q_OS_SYMBIAN)
- // In Symbian we actually look for plugin stub, so modify the filename
- // to make canonicalFilePath find the file, if .dll is specified.
- QFileInfo fi(fileName);
-
- if (fi.suffix() == QLatin1String("dll")) {
- QString stubName = fileName;
- stubName.chop(3);
- stubName += QLatin1String("qtplugin");
- fi = QFileInfo(stubName);
- }
-
- 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());
- RFs rfs = qt_s60GetRFs();
- foreach(const QFileInfo& drive, driveList) {
- QString testFilePath(drive.absolutePath() + stubPath);
- testFilePath = QDir::cleanPath(testFilePath);
- // Use native Symbian code to check for file existence, because checking
- // for file from under non-existent protected dir like E:/private/<uid> using
- // QFile::exists causes platform security violations on most apps.
- QString nativePath = QDir::toNativeSeparators(testFilePath);
- TPtrC ptr(qt_QString2TPtrC(nativePath));
- TUint attributes;
- TInt err = rfs.Att(ptr, attributes);
- if (err == KErrNone) {
- fn = testFilePath;
- break;
- }
- }
- }
- }
-
-#else
QString fn = QFileInfo(fileName).canonicalFilePath();
-#endif
d = QLibraryPrivate::findOrCreate(fn);
d->loadHints = lh;
diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h
index b8f40379c8..0854d3dcdf 100644
--- a/src/corelib/plugin/qpluginloader.h
+++ b/src/corelib/plugin/qpluginloader.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index bb9c82a35a..f949cc0f86 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index 3298f05b8f..4015fb6958 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 6fca1b6709..e73508fce6 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,6 +43,7 @@
#include "qdatastream.h"
#include "qendian.h"
+#include "qdebug.h"
QT_BEGIN_NAMESPACE
@@ -132,6 +133,29 @@ bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&
}
#endif
+static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCryptographicHash::Algorithm algorithm, int version)
+{
+ QByteArray hashResult;
+
+ // create a scope so later resize won't reallocate
+ {
+ QCryptographicHash hash(algorithm);
+ hash.addData(ns.toRfc4122());
+ hash.addData(baseData);
+ hashResult = hash.result();
+ }
+ hashResult.resize(16); // Sha1 will be too long
+
+ QUuid result = QUuid::fromRfc4122(hashResult);
+
+ result.data3 &= 0x0FFF;
+ result.data3 |= (version << 12);
+ result.data4[0] &= 0x3F;
+ result.data4[0] |= 0x80;
+
+ return result;
+}
+
/*!
\class QUuid
\brief The QUuid class stores a Universally Unique Identifier (UUID).
@@ -230,7 +254,7 @@ bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&
\o 0
\o 1
\o 1
- \o Name
+ \o Md5(Name)
\row
\o 0
@@ -239,6 +263,13 @@ bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&
\o 0
\o Random
+ \row
+ \o 0
+ \o 1
+ \o 0
+ \o 1
+ \o Sha1
+
\endtable
The field layouts for the DCE versions listed in the table above
@@ -384,9 +415,40 @@ QUuid::QUuid(const QByteArray &text)
return;
}
}
+
#endif
/*!
+ \since 5.0
+ \fn QUuid::createUuidV3()
+
+ This functions returns a new UUID with variant QUuid::DCE and version QUuid::MD5.
+ \a ns is the namespace and \a name is the name as described by RFC 4122.
+
+ \sa variant(), version(), createUuidV5()
+*/
+
+/*!
+ \since 5.0
+ \fn QUuid::createUuidV5()
+
+ This functions returns a new UUID with variant QUuid::DCE and version QUuid::SHA1.
+ \a ns is the namespace and \a name is the name as described by RFC 4122.
+
+ \sa variant(), version(), createUuidV3()
+*/
+
+QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData)
+{
+ return createFromName(ns, baseData, QCryptographicHash::Md5, 3);
+}
+
+QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData)
+{
+ return createFromName(ns, baseData, QCryptographicHash::Sha1, 5);
+}
+
+/*!
Creates a QUuid object from the binary representation of the UUID, as
specified by RFC 4122 section 4.1.2. See toRfc4122() for a further
explanation of the order of bytes required.
@@ -440,15 +502,6 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes)
*/
#ifndef QT_NO_QUUID_STRING
/*!
- \fn QUuid::operator QString() const
- \obsolete
-
- Returns the string representation of the uuid.
-
- \sa toString()
-*/
-
-/*!
Returns the string representation of this QUuid. The string is
formatted as five hex fields separated by '-' and enclosed in
curly braces, i.e., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where
@@ -739,7 +792,7 @@ QUuid::Version QUuid::version() const
if (isNull()
|| (variant() != DCE)
|| ver < Time
- || ver > Random)
+ || ver > Sha1)
return VerUnknown;
return ver;
}
@@ -927,6 +980,14 @@ QUuid QUuid::createUuid()
guid; otherwise returns false.
*/
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QUuid &id)
+{
+ dbg.nospace() << "QUuid(" << id.toString() << ')';
+ return dbg.space();
+}
+#endif
+
/**
Returns a hash of the QUuid
*/
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index b941079df0..9efb2ba37c 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,6 +43,7 @@
#define QUUID_H
#include <QtCore/qstring.h>
+#include <QtCore/qcryptographichash.h>
QT_BEGIN_HEADER
@@ -64,8 +65,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
-struct Q_CORE_EXPORT QUuid
+class Q_CORE_EXPORT QUuid
{
+public:
enum Variant {
VarUnknown =-1,
NCS = 0, // 0 - -
@@ -78,8 +80,10 @@ struct Q_CORE_EXPORT QUuid
VerUnknown =-1,
Time = 1, // 0 0 0 1
EmbeddedPOSIX = 2, // 0 0 1 0
- Name = 3, // 0 0 1 1
- Random = 4 // 0 1 0 0
+ Md5 = 3, // 0 0 1 1
+ Name = Md5,
+ Random = 4, // 0 1 0 0
+ Sha1 = 5 // 0 1 0 1
};
QUuid()
@@ -108,9 +112,6 @@ struct Q_CORE_EXPORT QUuid
QUuid(const QString &);
QUuid(const char *);
QString toString() const;
-#if QT_DEPRECATED_SINCE(5,0)
- QT_DEPRECATED operator QString() const { return toString(); }
-#endif
QUuid(const QByteArray &);
QByteArray toByteArray() const;
#endif
@@ -175,6 +176,21 @@ struct Q_CORE_EXPORT QUuid
}
#endif
static QUuid createUuid();
+ static QUuid createUuidV3(const QUuid &ns, const QByteArray &baseData);
+ static QUuid createUuidV5(const QUuid &ns, const QByteArray &baseData);
+#ifndef QT_NO_QUUID_STRING
+ static inline QUuid createUuidV3(const QUuid &ns, const QString &baseData)
+ {
+ return QUuid::createUuidV3(ns, baseData.toUtf8());
+ }
+
+ static inline QUuid createUuidV5(const QUuid &ns, const QString &baseData)
+ {
+ return QUuid::createUuidV5(ns, baseData.toUtf8());
+ }
+
+#endif
+
QUuid::Variant variant() const;
QUuid::Version version() const;
@@ -184,11 +200,17 @@ struct Q_CORE_EXPORT QUuid
uchar data4[8];
};
+Q_DECLARE_TYPEINFO(QUuid, Q_MOVABLE_TYPE);
+
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUuid &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &);
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &);
+#endif
+
Q_CORE_EXPORT uint qHash(const QUuid &uuid);
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index 79b72ea538..c2d24e3c00 100644
--- a/src/corelib/statemachine/qabstractstate.cpp
+++ b/src/corelib/statemachine/qabstractstate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qabstractstate.h b/src/corelib/statemachine/qabstractstate.h
index 21169e4fee..33dbde23aa 100644
--- a/src/corelib/statemachine/qabstractstate.h
+++ b/src/corelib/statemachine/qabstractstate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h
index 98b1d0a9b4..cf86e0cbe9 100644
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index ff2b4b5978..a8fdea2cfc 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qabstracttransition.h b/src/corelib/statemachine/qabstracttransition.h
index dbe7f3aa38..fd1eedb72e 100644
--- a/src/corelib/statemachine/qabstracttransition.h
+++ b/src/corelib/statemachine/qabstracttransition.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h
index 57f962d77d..4de0f4b8d6 100644
--- a/src/corelib/statemachine/qabstracttransition_p.h
+++ b/src/corelib/statemachine/qabstracttransition_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp
index 63f89669b9..f55cdbc927 100644
--- a/src/corelib/statemachine/qeventtransition.cpp
+++ b/src/corelib/statemachine/qeventtransition.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qeventtransition.h b/src/corelib/statemachine/qeventtransition.h
index 434b72e76c..173d24ef4a 100644
--- a/src/corelib/statemachine/qeventtransition.h
+++ b/src/corelib/statemachine/qeventtransition.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qeventtransition_p.h b/src/corelib/statemachine/qeventtransition_p.h
index ed096df81d..6c3dc9dda4 100644
--- a/src/corelib/statemachine/qeventtransition_p.h
+++ b/src/corelib/statemachine/qeventtransition_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp
index c583c32183..c2bb2ee218 100644
--- a/src/corelib/statemachine/qfinalstate.cpp
+++ b/src/corelib/statemachine/qfinalstate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qfinalstate.h b/src/corelib/statemachine/qfinalstate.h
index 9a18888c84..652abd6600 100644
--- a/src/corelib/statemachine/qfinalstate.h
+++ b/src/corelib/statemachine/qfinalstate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index 5f3a5dcf4c..b45cd30935 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qhistorystate.h b/src/corelib/statemachine/qhistorystate.h
index 1ba28e97f1..e9ec058d53 100644
--- a/src/corelib/statemachine/qhistorystate.h
+++ b/src/corelib/statemachine/qhistorystate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qhistorystate_p.h b/src/corelib/statemachine/qhistorystate_p.h
index b915c2820c..35662d88f8 100644
--- a/src/corelib/statemachine/qhistorystate_p.h
+++ b/src/corelib/statemachine/qhistorystate_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h
index c38177b766..e681add086 100644
--- a/src/corelib/statemachine/qsignaleventgenerator_p.h
+++ b/src/corelib/statemachine/qsignaleventgenerator_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp
index 92862cbab6..51a8a82b2d 100644
--- a/src/corelib/statemachine/qsignaltransition.cpp
+++ b/src/corelib/statemachine/qsignaltransition.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index 155e0f3d9d..fd91dd4c6d 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qsignaltransition_p.h b/src/corelib/statemachine/qsignaltransition_p.h
index 8bf928804b..aadb4efcc7 100644
--- a/src/corelib/statemachine/qsignaltransition_p.h
+++ b/src/corelib/statemachine/qsignaltransition_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 7dc9889dc0..4f37bb0642 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index 4d3acc1341..337659295e 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 74b425361b..daa2f467c1 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 927389a33b..a24c71c105 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 1238f480f4..b2a251038d 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 3227f81e58..88b16a22bf 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index 3cdb3c6d7b..c2c9484cf6 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index eff2182e28..07350ecfcd 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -44,7 +44,7 @@
#ifndef QATOMIC_H
#define QATOMIC_H
-#include <QtCore/qbasicatomic.h>
+#include <QtCore/qoldbasicatomic.h>
QT_BEGIN_HEADER
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index df36120d88..6c8ed3b897 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 086a289569..1d7e591b7d 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp
index 18ddd23819..9bb9c9061e 100644
--- a/src/corelib/thread/qmutex_linux.cpp
+++ b/src/corelib/thread/qmutex_linux.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex_mac.cpp b/src/corelib/thread/qmutex_mac.cpp
index 2fdb2ec489..1a561aa5d5 100644
--- a/src/corelib/thread/qmutex_mac.cpp
+++ b/src/corelib/thread/qmutex_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index e385181e0f..0cbc99adc6 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp
index b693088015..a426d958f2 100644
--- a/src/corelib/thread/qmutex_unix.cpp
+++ b/src/corelib/thread/qmutex_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index 781a632a61..b513b6e1ad 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index ef4e9560fb..6be5e092d7 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 20449c24d4..90b89f9a17 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qoldbasicatomic.h
index d3e988d8c5..2f952c9e0a 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qoldbasicatomic.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index e65a601369..14a29c7edf 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index f552e6f6d6..54926111d5 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -107,19 +107,12 @@ QT_BEGIN_NAMESPACE
*/
/*!
- Constructs a QReadWriteLock object in NonRecursive mode.
-
- \sa lockForRead(), lockForWrite()
-*/
-QReadWriteLock::QReadWriteLock()
- :d(new QReadWriteLockPrivate(NonRecursive))
-{ }
-
-/*!
\since 4.4
Constructs a QReadWriteLock object in the given \a recursionMode.
+ The default recursion mode is NonRecursive.
+
\sa lockForRead(), lockForWrite(), RecursionMode
*/
QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
@@ -513,7 +506,7 @@ void QReadWriteLock::unlock()
\ingroup thread
- The purpose of QWriteLocker (and QReadLocker is to simplify
+ The purpose of QWriteLocker (and QReadLocker) is to simplify
QReadWriteLock locking and unlocking. Locking and unlocking
statements or in exception handling code is error-prone and
difficult to debug. QWriteLocker can be used in such situations
diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h
index 7bb6329522..cdbd7894a1 100644
--- a/src/corelib/thread/qreadwritelock.h
+++ b/src/corelib/thread/qreadwritelock.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,8 +60,7 @@ class Q_CORE_EXPORT QReadWriteLock
public:
enum RecursionMode { NonRecursive, Recursive };
- QReadWriteLock(); // ### Qt 5: merge with below
- QReadWriteLock(RecursionMode recursionMode);
+ explicit QReadWriteLock(RecursionMode recursionMode = NonRecursive);
~QReadWriteLock();
void lockForRead();
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h
index fda7bf44e6..125245bb4a 100644
--- a/src/corelib/thread/qreadwritelock_p.h
+++ b/src/corelib/thread/qreadwritelock_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index acfd478a14..12539a794d 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h
index 50d32c5f65..4790a84bb6 100644
--- a/src/corelib/thread/qsemaphore.h
+++ b/src/corelib/thread/qsemaphore.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 1df768c1ed..9d48c4dbe5 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index baad793969..597e29546a 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index bbaf664a2d..094c9b0daf 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -81,6 +81,8 @@ public:
: receiver(r), event(e), priority(p)
{ }
};
+Q_DECLARE_TYPEINFO(QPostEvent, Q_MOVABLE_TYPE);
+
inline bool operator<(int priority, const QPostEvent &pe)
{
return pe.priority < priority;
@@ -92,7 +94,7 @@ inline bool operator<(const QPostEvent &pe, int priority)
// This class holds the list of posted events.
// The list has to be kept sorted by priority
-class QPostEventList : public QList<QPostEvent>
+class QPostEventList : public QVector<QPostEvent>
{
public:
// recursion == recursion count for sendPostedEvents()
@@ -106,12 +108,14 @@ public:
QMutex mutex;
inline QPostEventList()
- : QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0)
+ : QVector<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0)
{ }
void addEvent(const QPostEvent &ev) {
int priority = ev.priority;
- if (isEmpty() || last().priority >= priority) {
+ if (isEmpty() ||
+ last().priority >= priority ||
+ begin() + insertionOffset >= end()) {
// optimization: we can simply append if the last event in
// the queue has higher or equal priority
append(ev);
@@ -125,8 +129,8 @@ public:
}
private:
//hides because they do not keep that list sorted. addEvent must be used
- using QList<QPostEvent>::append;
- using QList<QPostEvent>::insert;
+ using QVector<QPostEvent>::append;
+ using QVector<QPostEvent>::insert;
};
#ifndef QT_NO_THREAD
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 6deae261c6..672b7cb976 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 0c834cfff2..3184b18471 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 0913292852..6dba8d670e 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h
index 172dff0b3d..790f9a51ef 100644
--- a/src/corelib/thread/qthreadstorage.h
+++ b/src/corelib/thread/qthreadstorage.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h
index 0a96689f0b..7d4eb684ee 100644
--- a/src/corelib/thread/qwaitcondition.h
+++ b/src/corelib/thread/qwaitcondition.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index 00d4b0ff00..f079e5a6ba 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index dd85bf4023..91aea010d9 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index bf1ec5e5ba..0106dbf13a 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri
index d63bb914e1..974e086684 100644
--- a/src/corelib/thread/thread.pri
+++ b/src/corelib/thread/thread.pri
@@ -7,7 +7,8 @@ HEADERS += thread/qmutex.h \
thread/qthread.h \
thread/qthreadstorage.h \
thread/qwaitcondition.h \
- thread/qatomic.h
+ thread/qatomic.h \
+ thread/qoldbasicatomic.h
# private headers
HEADERS += thread/qmutex_p.h \
@@ -40,3 +41,4 @@ unix: {
else:linux-* { SOURCES += thread/qmutex_linux.cpp }
else { SOURCES += thread/qmutex_unix.cpp }
}
+
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index 90a9caa905..a1c656934d 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index b11f4092a8..3ba86b6838 100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 5538180b37..96811cc179 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -725,6 +725,24 @@ QDataStream &operator>>(QDataStream &in, QBitArray &ba)
}
#endif // QT_NO_DATASTREAM
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QBitArray &array)
+{
+ dbg.nospace() << "QBitArray(";
+ for (int i = 0; i < array.size();) {
+ if (array.testBit(i))
+ dbg.nospace() << '1';
+ else
+ dbg.nospace() << '0';
+ i += 1;
+ if (!(i % 4) && (i < array.size()))
+ dbg.nospace() << ' ';
+ }
+ dbg.nospace() << ')';
+ return dbg.space();
+}
+#endif
+
/*!
\fn DataPtr &QBitArray::data_ptr()
\internal
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 3b66b9f4df..83c81eca90 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -170,6 +170,10 @@ Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QBitArray &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &);
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QBitArray &);
+#endif
+
Q_DECLARE_TYPEINFO(QBitArray, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED(QBitArray)
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index e56e4fc8ff..47bf5da619 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -546,7 +546,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
qWarning("qUncompress: Input data is corrupted");
return QByteArray();
}
- QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc + 1));
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + alloc + 1));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
@@ -567,7 +567,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
qWarning("qUncompress: Input data is corrupted");
return QByteArray();
}
- QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len + 1));
+ QByteArray::Data *p = static_cast<QByteArray::Data *>(::realloc(d.data(), sizeof(QByteArray::Data) + len + 1));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
qWarning("qUncompress: could not allocate enough memory to uncompress data");
@@ -883,7 +883,7 @@ QByteArray &QByteArray::operator=(const QByteArray & other)
{
other.d->ref.ref();
if (!d->ref.deref())
- qFree(d);
+ free(d);
d = other.d;
return *this;
}
@@ -912,7 +912,7 @@ QByteArray &QByteArray::operator=(const char *str)
}
x->ref.ref();
if (!d->ref.deref())
- qFree(d);
+ free(d);
d = x;
return *this;
}
@@ -1302,7 +1302,7 @@ QByteArray::QByteArray(const char *str)
d = const_cast<Data *>(&shared_empty.ba);
} else {
int len = qstrlen(str);
- d = static_cast<Data *>(qMalloc(sizeof(Data) + len + 1));
+ d = static_cast<Data *>(malloc(sizeof(Data) + len + 1));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = len;
@@ -1331,7 +1331,7 @@ QByteArray::QByteArray(const char *data, int size)
} else if (size <= 0) {
d = const_cast<Data *>(&shared_empty.ba);
} else {
- d = static_cast<Data *>(qMalloc(sizeof(Data) + size + 1));
+ d = static_cast<Data *>(malloc(sizeof(Data) + size + 1));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1355,7 +1355,7 @@ QByteArray::QByteArray(int size, char ch)
if (size <= 0) {
d = const_cast<Data *>(&shared_null.ba);
} else {
- d = static_cast<Data *>(qMalloc(sizeof(Data) + size + 1));
+ d = static_cast<Data *>(malloc(sizeof(Data) + size + 1));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1375,7 +1375,7 @@ QByteArray::QByteArray(int size, char ch)
QByteArray::QByteArray(int size, Qt::Initialization)
{
- d = static_cast<Data *>(qMalloc(sizeof(Data) + size + 1));
+ d = static_cast<Data *>(malloc(sizeof(Data) + size + 1));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1411,7 +1411,7 @@ void QByteArray::resize(int size)
if (size == 0 && !d->capacityReserved) {
Data *x = const_cast<Data *>(&shared_empty.ba);
if (!d->ref.deref())
- qFree(d);
+ free(d);
d = x;
} else if (d == &shared_null.ba || d == &shared_empty.ba) {
//
@@ -1422,7 +1422,7 @@ void QByteArray::resize(int size)
// which is used in place of the Qt 3 idiom:
// QByteArray a(sz);
//
- Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + size + 1));
+ Data *x = static_cast<Data *>(malloc(sizeof(Data) + size + 1));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = size;
@@ -1464,7 +1464,7 @@ QByteArray &QByteArray::fill(char ch, int size)
void QByteArray::realloc(int alloc)
{
if (d->ref != 1 || d->offset) {
- Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc + 1));
+ Data *x = static_cast<Data *>(malloc(sizeof(Data) + alloc + 1));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = qMin(alloc, d->size);
@@ -1474,10 +1474,10 @@ void QByteArray::realloc(int alloc)
::memcpy(x->data(), d->data(), x->size);
x->data()[x->size] = '\0';
if (!d->ref.deref())
- qFree(d);
+ free(d);
d = x;
} else {
- Data *x = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc + 1));
+ Data *x = static_cast<Data *>(::realloc(d, sizeof(Data) + alloc + 1));
Q_CHECK_PTR(x);
x->alloc = alloc;
x->offset = 0;
@@ -2730,7 +2730,7 @@ QByteArray QByteArray::toUpper() const
void QByteArray::clear()
{
if (!d->ref.deref())
- qFree(d);
+ free(d);
d = const_cast<Data *>(&shared_null.ba);
d->ref.ref();
}
@@ -3885,7 +3885,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size)
} else if (!size) {
x = const_cast<Data *>(&shared_empty.ba);
} else {
- x = static_cast<Data *>(qMalloc(sizeof(Data) + 1));
+ x = static_cast<Data *>(malloc(sizeof(Data) + 1));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = size;
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index dcaa6153f9..2409ff1232 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qbytearraymatcher.cpp b/src/corelib/tools/qbytearraymatcher.cpp
index 43924a764e..fbe54fb9b3 100644
--- a/src/corelib/tools/qbytearraymatcher.cpp
+++ b/src/corelib/tools/qbytearraymatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index 0eb50bb77d..9acfa0d581 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h
index 22ec47fb9d..2708df3d52 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/tools/qbytedata_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 2928140863..fc5b8a0a9f 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -61,7 +61,6 @@ class QCache
};
Node *f, *l;
QHash<Key, Node> hash;
- void *unused; // ### Qt5: remove
int mx, total;
inline void unlink(Node &n) {
@@ -123,7 +122,7 @@ private:
template <class Key, class T>
inline QCache<Key, T>::QCache(int amaxCost)
- : f(0), l(0), unused(0), mx(amaxCost), total(0) {}
+ : f(0), l(0), mx(amaxCost), total(0) {}
template <class Key, class T>
inline void QCache<Key,T>::clear()
diff --git a/src/corelib/tools/qcache.qdoc b/src/corelib/tools/qcache.qdoc
index 397c5fbb0c..9c8aef15df 100644
--- a/src/corelib/tools/qcache.qdoc
+++ b/src/corelib/tools/qcache.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ec4b0cce58..5109bf22a4 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 1bc6962ca1..0e02d109f6 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qcontainerfwd.h b/src/corelib/tools/qcontainerfwd.h
index ed6ab4332c..51ba07d856 100644
--- a/src/corelib/tools/qcontainerfwd.h
+++ b/src/corelib/tools/qcontainerfwd.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp
index eef1f74b8c..29601149e4 100644
--- a/src/corelib/tools/qcontiguouscache.cpp
+++ b/src/corelib/tools/qcontiguouscache.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index e192edf0ab..3c43b3abe7 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 89b3bab7c6..350c785e8b 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -50,6 +50,7 @@
#include "../../3rdparty/md4/md4.h"
#include "../../3rdparty/md4/md4.cpp"
#include "../../3rdparty/sha1/sha1.cpp"
+#include <qiodevice.h>
QT_BEGIN_NAMESPACE
@@ -155,6 +156,28 @@ void QCryptographicHash::addData(const QByteArray &data)
}
/*!
+ Reads the data from the open QIODevice \a device until it ends
+ and hashes it. Returns true if reading was successful.
+ */
+bool QCryptographicHash::addData(QIODevice* device)
+{
+ if (!device->isReadable())
+ return false;
+
+ if (!device->isOpen())
+ return false;
+
+ char buffer[1024];
+ int length;
+
+ while ((length = device->read(buffer,sizeof(buffer))) > 0)
+ addData(buffer,length);
+
+ return device->atEnd();
+}
+
+
+/*!
Returns the final hash value.
\sa QByteArray::toHex()
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index b40e8cc25b..64d54838fa 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QCryptographicHashPrivate;
+class QIODevice;
class Q_CORE_EXPORT QCryptographicHash
{
@@ -68,6 +69,7 @@ public:
void addData(const char *data, int length);
void addData(const QByteArray &data);
+ bool addData(QIODevice* device);
QByteArray result() const;
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 3c8848ba0f..d20b07589e 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -566,18 +566,6 @@ QString QDate::shortMonthName(int month, QDate::MonthNameType type)
}
/*!
- Returns the short version of the name of the \a month. The
- returned name is in normal type which can be used for date formatting.
-
- \sa toString(), longMonthName(), shortDayName(), longDayName()
- */
-
-QString QDate::shortMonthName(int month)
-{
- return shortMonthName(month, QDate::DateFormat);
-}
-
-/*!
\since 4.5
Returns the long name of the \a month for the representation specified
@@ -623,21 +611,6 @@ QString QDate::longMonthName(int month, MonthNameType type)
}
/*!
- Returns the long version of the name of the \a month. The
- returned name is in normal type which can be used for date formatting.
-
- \sa toString(), shortMonthName(), shortDayName(), longDayName()
- */
-
-QString QDate::longMonthName(int month)
-{
- if (month < 1 || month > 12) {
- month = 1;
- }
- return QLocale::system().monthName(month, QLocale::LongFormat);
-}
-
-/*!
\since 4.5
Returns the short name of the \a weekday for the representation specified
@@ -678,21 +651,6 @@ QString QDate::shortDayName(int weekday, MonthNameType type)
}
/*!
- Returns the short version of the name of the \a weekday. The
- returned name is in normal type which can be used for date formatting.
-
- \sa toString(), longDayName(), shortMonthName(), longMonthName()
- */
-
-QString QDate::shortDayName(int weekday)
-{
- if (weekday < 1 || weekday > 7) {
- weekday = 1;
- }
- return QLocale::system().dayName(weekday, QLocale::ShortFormat);
-}
-
-/*!
\since 4.5
Returns the long name of the \a weekday for the representation specified
@@ -731,21 +689,6 @@ QString QDate::longDayName(int weekday, MonthNameType type)
}
return QLocale::system().dayName(weekday, QLocale::LongFormat);
}
-
-/*!
- Returns the long version of the name of the \a weekday. The
- returned name is in normal type which can be used for date formatting.
-
- \sa toString(), shortDayName(), shortMonthName(), longMonthName()
- */
-
-QString QDate::longDayName(int weekday)
-{
- if (weekday < 1 || weekday > 7) {
- weekday = 1;
- }
- return QLocale::system().dayName(weekday, QLocale::LongFormat);
-}
#endif //QT_NO_TEXTDATE
#ifndef QT_NO_DATESTRING
@@ -1346,30 +1289,6 @@ bool QDate::isLeapYear(int y)
}
}
-/*!
- \internal
-
- This function has a confusing name and shouldn't be part of the
- API anyway, since we have toJulian() and fromJulian().
- ### Qt 5: remove it
-*/
-uint QDate::gregorianToJulian(int y, int m, int d)
-{
- return julianDayFromDate(y, m, d);
-}
-
-/*!
- \internal
-
- This function has a confusing name and shouldn't be part of the
- API anyway, since we have toJulian() and fromJulian().
- ### Qt 5: remove it
-*/
-void QDate::julianToGregorian(uint jd, int &y, int &m, int &d)
-{
- getDateFromJulianDay(jd, &y, &m, &d);
-}
-
/*! \fn static QDate QDate::fromJulianDay(int jd)
Converts the Julian day \a jd to a QDate.
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 62bdcab7cc..ba52f7455c 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -76,15 +76,10 @@ public:
int weekNumber(int *yearNum = 0) const;
#ifndef QT_NO_TEXTDATE
- // ### Qt 5: merge these functions.
- static QString shortMonthName(int month);
- static QString shortMonthName(int month, MonthNameType type);
- static QString shortDayName(int weekday);
- static QString shortDayName(int weekday, MonthNameType type);
- static QString longMonthName(int month);
- static QString longMonthName(int month, MonthNameType type);
- static QString longDayName(int weekday);
- static QString longDayName(int weekday, MonthNameType type);
+ static QString shortMonthName(int month, MonthNameType type = DateFormat);
+ static QString shortDayName(int weekday, MonthNameType type = DateFormat);
+ static QString longMonthName(int month, MonthNameType type = DateFormat);
+ static QString longDayName(int weekday, MonthNameType type = DateFormat);
#endif // QT_NO_TEXTDATE
#ifndef QT_NO_DATESTRING
QString toString(Qt::DateFormat f = Qt::TextDate) const;
@@ -115,10 +110,6 @@ public:
static bool isValid(int y, int m, int d);
static bool isLeapYear(int year);
- // ### Qt 5: remove these two functions
- static uint gregorianToJulian(int y, int m, int d);
- static void julianToGregorian(uint jd, int &y, int &m, int &d);
-
static inline QDate fromJulianDay(int jd) { QDate d; d.jd = jd; return d; }
inline int toJulianDay() const { return jd; }
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index c20f2123f9..38aa748c6c 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index 4337c4a594..a3614f9b6c 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index 326e7f6e61..ef18ae20bc 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/tools/qelapsedtimer.cpp
index 039c76960e..087252a926 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/tools/qelapsedtimer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/tools/qelapsedtimer.h
index 6e5be84c00..73ec8d637e 100644
--- a/src/corelib/tools/qelapsedtimer.h
+++ b/src/corelib/tools/qelapsedtimer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/tools/qelapsedtimer_generic.cpp
index 165efa96f2..3c7bb197d7 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/tools/qelapsedtimer_generic.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/tools/qelapsedtimer_mac.cpp
index 4b1275fe5c..f8f124f6a9 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/tools/qelapsedtimer_mac.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer_symbian.cpp b/src/corelib/tools/qelapsedtimer_symbian.cpp
index dd5909f76f..4ae3f3d1ab 100644
--- a/src/corelib/tools/qelapsedtimer_symbian.cpp
+++ b/src/corelib/tools/qelapsedtimer_symbian.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp
index 8a046063f9..7f3d4f635c 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/tools/qelapsedtimer_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp
index cd076a60d7..183171e306 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/tools/qelapsedtimer_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qfreelist.cpp b/src/corelib/tools/qfreelist.cpp
index bbbdb25e49..57530cf3c8 100644
--- a/src/corelib/tools/qfreelist.cpp
+++ b/src/corelib/tools/qfreelist.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index 5af0bb1807..2105e5af56 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp
index 324cd481ed..4eb6565557 100644
--- a/src/corelib/tools/qharfbuzz.cpp
+++ b/src/corelib/tools/qharfbuzz.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/tools/qharfbuzz_p.h
index f67b094c2d..a8da47b71c 100644
--- a/src/corelib/tools/qharfbuzz_p.h
+++ b/src/corelib/tools/qharfbuzz_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 373b59872c..82ac8a0591 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -171,7 +171,7 @@ const QHashData QHashData::shared_null = {
void *QHashData::allocateNode(int nodeAlign)
{
- void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : qMalloc(nodeSize);
+ void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : malloc(nodeSize);
Q_CHECK_PTR(ptr);
return ptr;
}
@@ -181,7 +181,7 @@ void QHashData::freeNode(void *node)
if (strictAlignment)
qFreeAligned(node);
else
- qFree(node);
+ free(node);
}
QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index ec9bd42c83..0fdb1ad794 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h
index c789e23ddc..0747940bf2 100644
--- a/src/corelib/tools/qiterator.h
+++ b/src/corelib/tools/qiterator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qiterator.qdoc b/src/corelib/tools/qiterator.qdoc
index 6594a2f874..0e33aecbe4 100644
--- a/src/corelib/tools/qiterator.qdoc
+++ b/src/corelib/tools/qiterator.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index 0f67652fb5..161123cfff 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h
index af2eda0850..956cbf9ce8 100644
--- a/src/corelib/tools/qline.h
+++ b/src/corelib/tools/qline.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index e5919363a0..acfbcd07eb 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 55d229d351..966b74ddfa 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 2a3695bb35..2afe1ab969 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -42,7 +42,9 @@
#include <new>
#include "qlist.h"
#include "qtools_p.h"
+
#include <string.h>
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -82,7 +84,7 @@ QListData::Data *QListData::detach_grow(int *idx, int num)
int l = x->end - x->begin;
int nl = l + num;
int alloc = grow(nl);
- Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + alloc * sizeof(void *)));
+ Data* t = static_cast<Data *>(::malloc(DataHeaderSize + alloc * sizeof(void *)));
Q_CHECK_PTR(t);
t->ref.initializeOwned();
@@ -124,7 +126,7 @@ QListData::Data *QListData::detach_grow(int *idx, int num)
QListData::Data *QListData::detach(int alloc)
{
Data *x = d;
- Data* t = static_cast<Data *>(qMalloc(DataHeaderSize + alloc * sizeof(void *)));
+ Data* t = static_cast<Data *>(::malloc(DataHeaderSize + alloc * sizeof(void *)));
Q_CHECK_PTR(t);
t->ref.initializeOwned();
@@ -145,7 +147,7 @@ QListData::Data *QListData::detach(int alloc)
void QListData::realloc(int alloc)
{
Q_ASSERT(d->ref == 1);
- Data *x = static_cast<Data *>(qRealloc(d, DataHeaderSize + alloc * sizeof(void *)));
+ Data *x = static_cast<Data *>(::realloc(d, DataHeaderSize + alloc * sizeof(void *)));
Q_CHECK_PTR(x);
d = x;
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 5c8a58a196..d192d31234 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index d2bb752c6d..1dc384985b 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -56,6 +56,7 @@ QT_END_NAMESPACE
#include "qplatformdefs.h"
#include "qdatastream.h"
+#include "qdebug.h"
#include "qstring.h"
#include "qlocale.h"
#include "qlocale_p.h"
@@ -775,6 +776,16 @@ QLocale &QLocale::operator=(const QLocale &other)
return *this;
}
+bool QLocale::operator==(const QLocale &other) const
+{
+ return d() == other.d() && numberOptions() == other.numberOptions();
+}
+
+bool QLocale::operator!=(const QLocale &other) const
+{
+ return d() != other.d() || numberOptions() != other.numberOptions();
+}
+
/*!
\since 4.2
@@ -3315,4 +3326,13 @@ QString QLocale::nativeCountryName() const
return getLocaleData(endonyms_data + d()->m_country_endonym_idx, d()->m_country_endonym_size);
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QLocale &l)
+{
+ dbg.nospace() << "QLocale(" << qPrintable(QLocale::languageToString(l.language()))
+ << ", " << qPrintable(QLocale::scriptToString(l.script()))
+ << ", " << qPrintable(QLocale::countryToString(l.country())) << ')';
+ return dbg.space();
+}
+#endif
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 55dd55b984..9bc4ea70b8 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -739,8 +739,8 @@ public:
QStringList uiLanguages() const;
- inline bool operator==(const QLocale &other) const;
- inline bool operator!=(const QLocale &other) const;
+ bool operator==(const QLocale &other) const;
+ bool operator!=(const QLocale &other) const;
static QString languageToString(Language language);
static QString countryToString(Country country);
@@ -789,10 +789,6 @@ inline QString QLocale::toString(uint i) const
{ return toString(qulonglong(i)); }
inline QString QLocale::toString(float i, char f, int prec) const
{ return toString(double(i), f, prec); }
-inline bool QLocale::operator==(const QLocale &other) const
- { return d() == other.d() && numberOptions() == other.numberOptions(); }
-inline bool QLocale::operator!=(const QLocale &other) const
- { return d() != other.d() || numberOptions() != other.numberOptions(); }
inline QString QLocale::toCurrencyString(short i, const QString &symbol) const
{ return toCurrencyString(qlonglong(i), symbol); }
@@ -810,6 +806,10 @@ Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QLocale &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QLocale &);
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QLocale &);
+#endif
+
QT_END_NAMESPACE
#ifndef QT_NO_SYSTEMLOCALE
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index fd139c3bec..0337c708a9 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -89,7 +89,7 @@
pair; it does not use the system locale database.
\note For the current keyboard input locale take a look at
- QApplication::keyboardInputLocale().
+ QInputPanel::locale().
QLocale's data is based on Common Locale Data Repository v1.8.1.
@@ -114,7 +114,7 @@
California, Berkeley and its contributors.
\sa QString::arg(), QString::toInt(), QString::toDouble(),
- QApplication::keyboardInputLocale()
+ QInputPanel::locale()
*/
/*!
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index 95b23a29a6..a29e40079a 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_icu.cpp b/src/corelib/tools/qlocale_icu.cpp
index a04b0bfc5f..0e220ff000 100644
--- a/src/corelib/tools/qlocale_icu.cpp
+++ b/src/corelib/tools/qlocale_icu.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 82b6b00e5e..ffcbbbca4b 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index b607038aaf..0b229e5e3f 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index a4f6cc8458..abe437fc89 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index 750379c014..8a57a418e4 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -50,6 +50,10 @@
#include <stdlib.h>
#include <time.h>
+#ifdef Q_OS_WINCE
+# include "qfunctions_wince.h" // for _control87
+#endif
+
#if defined(Q_OS_LINUX) && !defined(__UCLIBC__)
# include <fenv.h>
#endif
diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/tools/qlocale_tools_p.h
index 996b612208..85e6d3b0d0 100644
--- a/src/corelib/tools/qlocale_tools_p.h
+++ b/src/corelib/tools/qlocale_tools_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index 27e1782b93..5839a80e00 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index 8b4b1b55bf..c09802879c 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 76cb203e10..b1e8ecb0ad 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -85,7 +85,7 @@ void QMapData::continueFreeData(int offset)
if (strictAlignment)
qFreeAligned(reinterpret_cast<char *>(prev) - offset);
else
- qFree(reinterpret_cast<char *>(prev) - offset);
+ free(reinterpret_cast<char *>(prev) - offset);
}
delete this;
}
@@ -127,7 +127,7 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset, int alignment)
void *concreteNode = strictAlignment ?
qMallocAligned(offset + sizeof(Node) + level * sizeof(Node *), alignment) :
- qMalloc(offset + sizeof(Node) + level * sizeof(Node *));
+ malloc(offset + sizeof(Node) + level * sizeof(Node *));
Q_CHECK_PTR(concreteNode);
Node *abstractNode = reinterpret_cast<Node *>(reinterpret_cast<char *>(concreteNode) + offset);
@@ -157,7 +157,7 @@ void QMapData::node_delete(Node *update[], int offset, Node *node)
if (strictAlignment)
qFreeAligned(reinterpret_cast<char *>(node) - offset);
else
- qFree(reinterpret_cast<char *>(node) - offset);
+ free(reinterpret_cast<char *>(node) - offset);
}
#ifdef QT_QMAP_DEBUG
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 362b723b0a..f975b7eb16 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp
index 9c7dd038e7..e14e2aa227 100644
--- a/src/corelib/tools/qmargins.cpp
+++ b/src/corelib/tools/qmargins.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h
index 635ac56137..4e69907440 100644
--- a/src/corelib/tools/qmargins.h
+++ b/src/corelib/tools/qmargins.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h
index 95868840ea..0acd617e26 100644
--- a/src/corelib/tools/qpair.h
+++ b/src/corelib/tools/qpair.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qpair.qdoc b/src/corelib/tools/qpair.qdoc
index a9d73419ff..26e7c78996 100644
--- a/src/corelib/tools/qpair.qdoc
+++ b/src/corelib/tools/qpair.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qpodlist_p.h b/src/corelib/tools/qpodlist_p.h
index d06c9479e7..9c03f0e64a 100644
--- a/src/corelib/tools/qpodlist_p.h
+++ b/src/corelib/tools/qpodlist_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index bd32fe77b1..9139f4033c 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index b394ece1a6..a6381578d8 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qqueue.cpp b/src/corelib/tools/qqueue.cpp
index 2f5aae4026..5753c7d695 100644
--- a/src/corelib/tools/qqueue.cpp
+++ b/src/corelib/tools/qqueue.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h
index c10e6c0b2b..9aa7a7bdb0 100644
--- a/src/corelib/tools/qqueue.h
+++ b/src/corelib/tools/qqueue.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 41ec816c46..2d63eb85e6 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 58221f4739..34000750ee 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -136,29 +136,23 @@ public:
bool contains(int x, int y) const; // inline methods, _don't_ merge these
bool contains(int x, int y, bool proper) const;
bool contains(const QRect &r, bool proper = false) const;
- QRect unite(const QRect &r) const; // ### Qt 5: make QT4_SUPPORT
QRect united(const QRect &other) const;
- QRect intersect(const QRect &r) const; // ### Qt 5: make QT4_SUPPORT
QRect intersected(const QRect &other) const;
bool intersects(const QRect &r) const;
+#if QT_DEPRECATED_SINCE(5, 0)
+ QT_DEPRECATED QRect unite(const QRect &r) const { return united(r); }
+ QT_DEPRECATED QRect intersect(const QRect &r) const { return intersected(r); }
+#endif
+
friend Q_CORE_EXPORT_INLINE bool operator==(const QRect &, const QRect &);
friend Q_CORE_EXPORT_INLINE bool operator!=(const QRect &, const QRect &);
private:
- // ### Qt 5; remove the ifdef and just have the same order on all platforms.
-#if defined(Q_OS_MAC)
- int y1;
- int x1;
- int y2;
- int x2;
-#else
int x1;
int y1;
int x2;
int y2;
-#endif
-
};
Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE);
@@ -440,24 +434,14 @@ inline QRect& QRect::operator&=(const QRect &r)
return *this;
}
-inline QRect QRect::intersect(const QRect &r) const
-{
- return *this & r;
-}
-
inline QRect QRect::intersected(const QRect &other) const
{
- return intersect(other);
-}
-
-inline QRect QRect::unite(const QRect &r) const
-{
- return *this | r;
+ return *this & other;
}
inline QRect QRect::united(const QRect &r) const
{
- return unite(r);
+ return *this | r;
}
inline bool operator==(const QRect &r1, const QRect &r2)
@@ -557,12 +541,15 @@ public:
bool contains(const QPointF &p) const;
bool contains(qreal x, qreal y) const;
bool contains(const QRectF &r) const;
- QRectF unite(const QRectF &r) const; // ### Qt 5: make QT4_SUPPORT
QRectF united(const QRectF &other) const;
- QRectF intersect(const QRectF &r) const; // ### Qt 5: make QT4_SUPPORT
QRectF intersected(const QRectF &other) const;
bool intersects(const QRectF &r) const;
+#if QT_DEPRECATED_SINCE(5, 0)
+ QT_DEPRECATED QRectF unite(const QRectF &r) const { return united(r); }
+ QT_DEPRECATED QRectF intersect(const QRectF &r) const { return intersected(r); }
+#endif
+
friend Q_CORE_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &);
friend Q_CORE_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &);
@@ -777,24 +764,14 @@ inline QRectF& QRectF::operator&=(const QRectF &r)
return *this;
}
-inline QRectF QRectF::intersect(const QRectF &r) const
-{
- return *this & r;
-}
-
inline QRectF QRectF::intersected(const QRectF &r) const
{
- return intersect(r);
-}
-
-inline QRectF QRectF::unite(const QRectF &r) const
-{
- return *this | r;
+ return *this & r;
}
inline QRectF QRectF::united(const QRectF &r) const
{
- return unite(r);
+ return *this | r;
}
inline bool operator==(const QRectF &r1, const QRectF &r2)
diff --git a/src/corelib/tools/qrefcount.cpp b/src/corelib/tools/qrefcount.cpp
index c40214b2ab..5341d27a91 100644
--- a/src/corelib/tools/qrefcount.cpp
+++ b/src/corelib/tools/qrefcount.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h
index bf864f2f58..698351456f 100644
--- a/src/corelib/tools/qrefcount.h
+++ b/src/corelib/tools/qrefcount.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 688b38d132..d300ed967d 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -45,6 +45,7 @@
#include "qbitarray.h"
#include "qcache.h"
#include "qdatastream.h"
+#include "qdebug.h"
#include "qlist.h"
#include "qmap.h"
#include "qmutex.h"
@@ -4571,4 +4572,13 @@ QDataStream &operator>>(QDataStream &in, QRegExp &regExp)
}
#endif // QT_NO_DATASTREAM
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QRegExp &r)
+{
+ dbg.nospace() << "QRegExp(patternSyntax=" << r.patternSyntax()
+ << ", pattern='"<< r.pattern() << "')";
+ return dbg.space();
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 4ce2f6e0be..364745e24a 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -127,6 +127,10 @@ Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QRegExp &regExp);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegExp &regExp);
#endif
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QRegExp &);
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 4a19e12647..6bbce03a44 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 9277a3ebbf..a95468617b 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index a24f62e7ba..41e6dff90c 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
index 8dcc503ad2..eb7cc80e54 100644
--- a/src/corelib/tools/qscopedpointer_p.h
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qscopedvaluerollback.cpp b/src/corelib/tools/qscopedvaluerollback.cpp
index 1ad47f45dd..e5b68ded1f 100644
--- a/src/corelib/tools/qscopedvaluerollback.cpp
+++ b/src/corelib/tools/qscopedvaluerollback.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h
index ee62147540..3b821956eb 100644
--- a/src/corelib/tools/qscopedvaluerollback.h
+++ b/src/corelib/tools/qscopedvaluerollback.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 5f48042114..7ad16a7943 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -176,9 +176,8 @@ public:
typedef iterator Iterator;
typedef const_iterator ConstIterator;
inline int count() const { return q_hash.count(); }
- inline const_iterator insert(const T &value) // ### Qt 5: should return an 'iterator'
- { return static_cast<typename Hash::const_iterator>(q_hash.insert(value,
- QHashDummyValue())); }
+ inline iterator insert(const T &value)
+ { return static_cast<typename Hash::iterator>(q_hash.insert(value, QHashDummyValue())); }
iterator find(const T &value) { return q_hash.find(value); }
const_iterator find(const T &value) const { return q_hash.find(value); }
inline const_iterator constFind(const T &value) const { return find(value); }
@@ -216,17 +215,6 @@ public:
{ QSet<T> result = *this; result += other; return result; }
inline QSet<T> operator-(const QSet<T> &other) const
{ QSet<T> result = *this; result -= other; return result; }
-#if QT_VERSION < 0x050000
- // ### Qt 5: remove
- inline QSet<T> operator|(const QSet<T> &other)
- { QSet<T> result = *this; result |= other; return result; }
- inline QSet<T> operator&(const QSet<T> &other)
- { QSet<T> result = *this; result &= other; return result; }
- inline QSet<T> operator+(const QSet<T> &other)
- { QSet<T> result = *this; result += other; return result; }
- inline QSet<T> operator-(const QSet<T> &other)
- { QSet<T> result = *this; result -= other; return result; }
-#endif
QList<T> toList() const;
inline QList<T> values() const { return toList(); }
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index f562c68b72..28b53e690d 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp
index ee2b0c4f3c..2995d4a123 100644
--- a/src/corelib/tools/qshareddata.cpp
+++ b/src/corelib/tools/qshareddata.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 6de6a19289..add8025d5a 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 34060926c7..0069eb6831 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 6b2b41f1de..f4a0c02ebf 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index f03889106f..3cad13856c 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 3dfe38a4d1..9001c4a399 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 296c275b61..2fc6d88fb6 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index d8bd14de8d..41abb0be17 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index adc857be96..c9712b3976 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstack.cpp b/src/corelib/tools/qstack.cpp
index 0fbb8d8516..de851d2f0d 100644
--- a/src/corelib/tools/qstack.cpp
+++ b/src/corelib/tools/qstack.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h
index 224935455d..35518cfe5e 100644
--- a/src/corelib/tools/qstack.h
+++ b/src/corelib/tools/qstack.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index d57adbe731..dbe1e913c3 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -1030,7 +1030,7 @@ QString::QString(const QChar *unicode, int size)
} else if (size <= 0) {
d = const_cast<Data *>(&shared_empty.str);
} else {
- d = (Data*) qMalloc(sizeof(Data)+(size+1)*sizeof(QChar));
+ d = (Data*) ::malloc(sizeof(Data)+(size+1)*sizeof(QChar));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1062,7 +1062,7 @@ QString::QString(const QChar *unicode)
if (!size) {
d = const_cast<Data *>(&shared_empty.str);
} else {
- d = (Data*) qMalloc(sizeof(Data)+(size+1)*sizeof(QChar));
+ d = (Data*) ::malloc(sizeof(Data)+(size+1)*sizeof(QChar));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1087,7 +1087,7 @@ QString::QString(int size, QChar ch)
if (size <= 0) {
d = const_cast<Data *>(&shared_empty.str);
} else {
- d = (Data*) qMalloc(sizeof(Data)+(size+1)*sizeof(QChar));
+ d = (Data*) ::malloc(sizeof(Data)+(size+1)*sizeof(QChar));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1111,7 +1111,7 @@ QString::QString(int size, QChar ch)
*/
QString::QString(int size, Qt::Initialization)
{
- d = (Data*) qMalloc(sizeof(Data)+(size+1)*sizeof(QChar));
+ d = (Data*) ::malloc(sizeof(Data)+(size+1)*sizeof(QChar));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -1133,7 +1133,7 @@ QString::QString(int size, Qt::Initialization)
*/
QString::QString(QChar ch)
{
- d = (Data *) qMalloc(sizeof(Data) + 2*sizeof(QChar));
+ d = (Data *) ::malloc(sizeof(Data) + 2*sizeof(QChar));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = 1;
@@ -1199,7 +1199,7 @@ QString::QString(QChar ch)
// ### Qt 5: rename freeData() to avoid confusion. See task 197625.
void QString::free(Data *d)
{
- qFree(d);
+ ::free(d);
}
/*!
@@ -1312,7 +1312,7 @@ void QString::resize(int size)
void QString::realloc(int alloc)
{
if (d->ref != 1 || d->offset) {
- Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + (alloc+1) * sizeof(QChar)));
+ Data *x = static_cast<Data *>(::malloc(sizeof(Data) + (alloc+1) * sizeof(QChar)));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = qMin(alloc, d->size);
@@ -1325,7 +1325,7 @@ void QString::realloc(int alloc)
QString::free(d);
d = x;
} else {
- Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + (alloc+1) * sizeof(QChar)));
+ Data *p = static_cast<Data *>(::realloc(d, sizeof(Data) + (alloc+1) * sizeof(QChar)));
Q_CHECK_PTR(p);
d = p;
d->alloc = alloc;
@@ -1483,11 +1483,11 @@ QString& QString::insert(int i, const QChar *unicode, int size)
const ushort *s = (const ushort *)unicode;
if (s >= d->data() && s < d->data() + d->alloc) {
// Part of me - take a copy
- ushort *tmp = static_cast<ushort *>(qMalloc(size * sizeof(QChar)));
+ ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar)));
Q_CHECK_PTR(tmp);
memcpy(tmp, s, size * sizeof(QChar));
insert(i, reinterpret_cast<const QChar *>(tmp), size);
- qFree(tmp);
+ ::free(tmp);
return *this;
}
@@ -1843,7 +1843,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
// (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)));
+ afterBuffer = static_cast<QChar *>(::malloc(alen*sizeof(QChar)));
Q_CHECK_PTR(afterBuffer);
::memcpy(afterBuffer, after, alen*sizeof(QChar));
}
@@ -1898,11 +1898,11 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar
}
} QT_CATCH(const std::bad_alloc &) {
if (afterBuffer != after)
- qFree(afterBuffer);
+ ::free(afterBuffer);
QT_RETHROW;
}
if (afterBuffer != after)
- qFree(afterBuffer);
+ ::free(afterBuffer);
}
/*!
@@ -3756,7 +3756,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
} else {
if (size < 0)
size = qstrlen(str);
- d = static_cast<Data *>(qMalloc(sizeof(Data) + (size+1) * sizeof(QChar)));
+ d = static_cast<Data *>(::malloc(sizeof(Data) + (size+1) * sizeof(QChar)));
Q_CHECK_PTR(d);
d->ref.initializeOwned();
d->size = size;
@@ -3818,33 +3818,29 @@ QString::Data *QString::fromAscii_helper(const char *str, int size)
return fromLatin1_helper(str, size);
}
-/*!
+/*! \fn QString QString::fromLatin1(const char *str, int size)
Returns a QString initialized with the first \a size characters
of the Latin-1 string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
\sa toLatin1(), fromAscii(), fromUtf8(), fromLocal8Bit()
*/
-QString QString::fromLatin1(const char *str, int size)
-{
- return QString(fromLatin1_helper(str, size), 0);
-}
-/*!
+/*! \fn QString QString::fromLocal8Bit(const char *str, int size)
Returns a QString initialized with the first \a size characters
of the 8-bit string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
QTextCodec::codecForLocale() is used to perform the conversion.
\sa toLocal8Bit(), fromAscii(), fromLatin1(), fromUtf8()
*/
-QString QString::fromLocal8Bit(const char *str, int size)
+QString QString::fromLocal8Bit_helper(const char *str, int size)
{
if (!str)
return QString();
@@ -3860,11 +3856,11 @@ QString QString::fromLocal8Bit(const char *str, int size)
return fromLatin1(str, size);
}
-/*!
+/*! \fn QString QString::fromAscii(const char *, int size);
Returns a QString initialized with the first \a size characters
from the string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
Note that, despite the name, this function actually uses the codec
@@ -3875,16 +3871,12 @@ QString QString::fromLocal8Bit(const char *str, int size)
\sa toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit()
*/
-QString QString::fromAscii(const char *str, int size)
-{
- return QString(fromAscii_helper(str, size), 0);
-}
-/*!
+/*! \fn QString QString::fromUtf8(const char *str, int size)
Returns a QString initialized with the first \a size bytes
of the UTF-8 string \a str.
- If \a size is -1 (default), it is taken to be qstrlen(\a
+ If \a size is -1 (default), it is taken to be strlen(\a
str).
UTF-8 is a Unicode codec and can represent all characters in a Unicode
@@ -3901,13 +3893,12 @@ QString QString::fromAscii(const char *str, int size)
\sa toUtf8(), fromAscii(), fromLatin1(), fromLocal8Bit()
*/
-QString QString::fromUtf8(const char *str, int size)
+QString QString::fromUtf8_helper(const char *str, int size)
{
if (!str)
return QString();
- if (size < 0)
- size = qstrlen(str);
+ Q_ASSERT(size != -1);
return QUtf8::convertToUnicode(str, size, 0);
}
@@ -7072,7 +7063,7 @@ QString QString::fromRawData(const QChar *unicode, int size)
} else if (!size) {
x = const_cast<Data *>(&shared_empty.str);
} else {
- x = static_cast<Data *>(qMalloc(sizeof(Data) + sizeof(ushort)));
+ x = static_cast<Data *>(::malloc(sizeof(Data) + sizeof(ushort)));
Q_CHECK_PTR(x);
x->ref.initializeOwned();
x->size = size;
@@ -8817,13 +8808,37 @@ QString QString::toHtmlEscaped() const
Creating a QString from it is free in this case, and the generated string data is stored in
the read-only segment of the compiled object file.
+ For compilers not supporting the creation of compile time strings, QStringLiteral will fall back to
+ QLatin1String.
+
+ The result of the QStringLiteral expression can be cast into a QString.
+
+ If you have code looking like:
+ \code
+ if (node.hasAttribute("http-contents-length")) //...
+ \endcode
+ One temporary QString will be created to be passed as the hasAttribute function parameter.
+ This can be quite expensive, as it involves a memory allocation and the copy and the conversion
+ of the data into QString's internal encoding.
+
+ This can be avoided by doing
+ \code
+ if (node.hasAttribute(QStringLiteral("http-contents-length"))) //...
+ \endcode
+ Then the QString's internal data will be generated at compile time and no conversion or allocation
+ will occur at runtime
+
Using QStringLiteral instead of a double quoted ascii literal can significantly speed up creation
of QString's from data known at compile time.
- If the compiler is c++0x enabled the string \a str can actually contain unicode data.
+ If the compiler is C++11 enabled the string \a str can actually contain unicode data.
- For compilers not supporting the creation of compile time strings, QStringLiteral will fall back to
- QLatin1String.
+ \note There are still a few cases in which QLatin1String is more efficient than QStringLiteral:
+ If it is passed to a function that has an overload that takes the QLatin1String directly, without
+ conversion to QString. For instance, this is the case of QString::operator==
+ \code
+ if (attribute.name() == QLatin1String("http-contents-length")) //...
+ \endcode
*/
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 898c80ce35..f7898bbadb 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -49,12 +49,6 @@
#ifndef QT_NO_STL
# include <string>
-
-# ifndef QT_NO_STL_WCHAR
-// workaround for some headers not typedef'ing std::wstring
-typedef std::basic_string<wchar_t> QStdWString;
-# endif // QT_NO_STL_WCHAR
-
#endif // QT_NO_STL
#include <stdarg.h>
@@ -407,10 +401,23 @@ public:
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
- static QString fromAscii(const char *, int size = -1);
- static QString fromLatin1(const char *, int size = -1);
- static QString fromUtf8(const char *, int size = -1);
- static QString fromLocal8Bit(const char *, int size = -1);
+ // note - this are all inline so we can benefit from strlen() compile time optimizations
+ static inline QString fromAscii(const char *str, int size = -1)
+ {
+ return QString(fromAscii_helper(str, (str && size == -1) ? int(strlen(str)) : size), 0);
+ }
+ static inline QString fromLatin1(const char *str, int size = -1)
+ {
+ return QString(fromLatin1_helper(str, (str && size == -1) ? int(strlen(str)) : size), 0);
+ }
+ static inline QString fromUtf8(const char *str, int size = -1)
+ {
+ return fromUtf8_helper(str, (str && size == -1) ? int(strlen(str)) : size);
+ }
+ static inline QString fromLocal8Bit(const char *str, int size = -1)
+ {
+ return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size);
+ }
static QString fromUtf16(const ushort *, int size = -1);
static QString fromUcs4(const uint *, int size = -1);
static QString fromRawData(const QChar *, int size);
@@ -492,13 +499,14 @@ public:
// ASCII compatibility
#ifndef QT_NO_CAST_FROM_ASCII
- inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch) : d(fromAscii_helper(ch))
+ inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch)
+ : d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1))
{}
inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const QByteArray &a)
: d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size())))
{}
inline QT_ASCII_CAST_WARN QString &operator=(const char *ch)
- { return (*this = fromAscii(ch)); }
+ { return (*this = fromAscii(ch, ch ? int(strlen(ch)) : -1)); }
inline QT_ASCII_CAST_WARN QString &operator=(const QByteArray &a)
{ return (*this = fromAscii(a.constData(), qstrnlen(a.constData(), a.size()))); }
inline QT_ASCII_CAST_WARN QString &operator=(char c)
@@ -506,15 +514,15 @@ public:
// these are needed, so it compiles with STL support enabled
inline QT_ASCII_CAST_WARN QString &prepend(const char *s)
- { return prepend(QString::fromAscii(s)); }
+ { return prepend(QString::fromAscii(s, s ? int(strlen(s)) : -1)); }
inline QT_ASCII_CAST_WARN QString &prepend(const QByteArray &s)
{ return prepend(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
inline QT_ASCII_CAST_WARN QString &append(const char *s)
- { return append(QString::fromAscii(s)); }
+ { return append(QString::fromAscii(s, s ? int(strlen(s)) : -1)); }
inline QT_ASCII_CAST_WARN QString &append(const QByteArray &s)
{ return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
inline QT_ASCII_CAST_WARN QString &operator+=(const char *s)
- { return append(QString::fromAscii(s)); }
+ { return append(QString::fromAscii(s, s ? int(strlen(s)) : -1)); }
inline QT_ASCII_CAST_WARN QString &operator+=(const QByteArray &s)
{ return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
inline QT_ASCII_CAST_WARN QString &operator+=(char c)
@@ -562,15 +570,8 @@ public:
#ifndef QT_NO_STL
static inline QString fromStdString(const std::string &s);
inline std::string toStdString() const;
-# ifdef qdoc
static inline QString fromStdWString(const std::wstring &s);
inline std::wstring toStdWString() const;
-# else
-# ifndef QT_NO_STL_WCHAR
- static inline QString fromStdWString(const QStdWString &s);
- inline QStdWString toStdWString() const;
-# endif // QT_NO_STL_WCHAR
-# endif // qdoc
#endif
// compatibility
@@ -625,6 +626,8 @@ private:
const QChar *data2, int length2);
static Data *fromLatin1_helper(const char *str, int size = -1);
static Data *fromAscii_helper(const char *str, int size = -1);
+ static QString fromUtf8_helper(const char *str, int size);
+ static QString fromLocal8Bit_helper(const char *, int size);
static int toUcs4_helper(const ushort *uc, int length, uint *out);
void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen);
friend class QCharRef;
@@ -662,17 +665,17 @@ public:
{ return s >= *this; }
inline QT_ASCII_CAST_WARN bool operator==(const char *s) const
- { return QString::fromAscii(s) == *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) == *this; }
inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const
- { return QString::fromAscii(s) != *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) != *this; }
inline QT_ASCII_CAST_WARN bool operator<(const char *s) const
- { return QString::fromAscii(s) > *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) > *this; }
inline QT_ASCII_CAST_WARN bool operator>(const char *s) const
- { return QString::fromAscii(s) < *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) < *this; }
inline QT_ASCII_CAST_WARN bool operator<=(const char *s) const
- { return QString::fromAscii(s) >= *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) >= *this; }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s) const
- { return QString::fromAscii(s) <= *this; }
+ { return QString::fromAscii(s, s ? int(strlen(s)) : -1) <= *this; }
private:
int m_size;
const char *m_data;
@@ -925,7 +928,7 @@ inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); }
inline bool qStringComparisonHelper(const QString &s1, const char *s2)
{
# ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
+ if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1));
# endif
return (s1 == QLatin1String(s2));
}
@@ -934,39 +937,39 @@ inline bool QString::operator==(const char *s) const
inline bool QString::operator!=(const char *s) const
{ return !qStringComparisonHelper(*this, s); }
inline bool QString::operator<(const char *s) const
-{ return *this < QString::fromAscii(s); }
+{ return *this < QString::fromAscii(s, s ? int(strlen(s)) : -1); }
inline bool QString::operator>(const char *s) const
-{ return *this > QString::fromAscii(s); }
+{ return *this > QString::fromAscii(s, s ? int(strlen(s)) : -1); }
inline bool QString::operator<=(const char *s) const
-{ return *this <= QString::fromAscii(s); }
+{ return *this <= QString::fromAscii(s, s ? int(strlen(s)) : -1); }
inline bool QString::operator>=(const char *s) const
-{ return *this >= QString::fromAscii(s); }
+{ return *this >= QString::fromAscii(s, s ? int(strlen(s)) : -1); }
inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2)
{ return qStringComparisonHelper(s2, s1); }
inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2)
{ return !qStringComparisonHelper(s2, s1); }
inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2)
-{ return (QString::fromAscii(s1) < s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) < s2); }
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2)
-{ return (QString::fromAscii(s1) > s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) > s2); }
inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2)
-{ return (QString::fromAscii(s1) <= s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) <= s2); }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2)
-{ return (QString::fromAscii(s1) >= s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) >= s2); }
inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QLatin1String &s2)
-{ return QString::fromAscii(s1) == s2; }
+{ return QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) == s2; }
inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QLatin1String &s2)
-{ return QString::fromAscii(s1) != s2; }
+{ return QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) != s2; }
inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QLatin1String &s2)
-{ return (QString::fromAscii(s1) < s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) < s2); }
inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QLatin1String &s2)
-{ return (QString::fromAscii(s1) > s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) > s2); }
inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QLatin1String &s2)
-{ return (QString::fromAscii(s1) <= s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) <= s2); }
inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QLatin1String &s2)
-{ return (QString::fromAscii(s1) >= s2); }
+{ return (QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1) >= s2); }
inline bool operator==(const QLatin1String &s1, const QLatin1String &s2)
{ return (qstrcmp(s1.latin1(), s2.latin1()) == 0); }
@@ -1029,9 +1032,9 @@ inline const QString operator+(QChar s1, const QString &s2)
{ QString t(s1); t += s2; return t; }
# ifndef QT_NO_CAST_FROM_ASCII
inline QT_ASCII_CAST_WARN const QString operator+(const QString &s1, const char *s2)
-{ QString t(s1); t += QString::fromAscii(s2); return t; }
+{ QString t(s1); t += QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1); return t; }
inline QT_ASCII_CAST_WARN const QString operator+(const char *s1, const QString &s2)
-{ QString t = QString::fromAscii(s1); t += s2; return t; }
+{ QString t = QString::fromAscii(s1, s1 ? int(strlen(s1)) : -1); t += s2; return t; }
inline QT_ASCII_CAST_WARN const QString operator+(char c, const QString &s)
{ QString t = s; t.prepend(QChar::fromAscii(c)); return t; }
inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, char c)
@@ -1050,10 +1053,9 @@ inline std::string QString::toStdString() const
inline QString QString::fromStdString(const std::string &s)
{ return fromAscii(s.data(), int(s.size())); }
-# ifndef QT_NO_STL_WCHAR
-inline QStdWString QString::toStdWString() const
+inline std::wstring QString::toStdWString() const
{
- QStdWString str;
+ std::wstring str;
str.resize(length());
#if defined(_MSC_VER) && _MSC_VER >= 1400
@@ -1065,9 +1067,8 @@ inline QStdWString QString::toStdWString() const
str.resize(toWCharArray(&(*str.begin())));
return str;
}
-inline QString QString::fromStdWString(const QStdWString &s)
+inline QString QString::fromStdWString(const std::wstring &s)
{ return fromWCharArray(s.data(), int(s.size())); }
-# endif
#endif
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
@@ -1212,7 +1213,7 @@ inline bool operator>=(const QStringRef &s1, const QStringRef &s2)
inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2)
{
# ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
+ if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2, s2 ? int(strlen(s2)) : -1));
# endif
return (s1 == QLatin1String(s2));
}
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 2b40a68e0b..018a312fa6 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index de6b655e95..016e37fb38 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index bab7d42215..1fca78b03b 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index bded94399d..6c32f11096 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp
index 0117d78544..36016a9401 100644
--- a/src/corelib/tools/qstringmatcher.cpp
+++ b/src/corelib/tools/qstringmatcher.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h
index ed4e503644..9f5e10b942 100644
--- a/src/corelib/tools/qstringmatcher.h
+++ b/src/corelib/tools/qstringmatcher.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qtextboundaryfinder.cpp b/src/corelib/tools/qtextboundaryfinder.cpp
index aabb6949ad..4554ebb34f 100644
--- a/src/corelib/tools/qtextboundaryfinder.cpp
+++ b/src/corelib/tools/qtextboundaryfinder.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qtextboundaryfinder.h b/src/corelib/tools/qtextboundaryfinder.h
index 4d5369c3af..3f4f309d31 100644
--- a/src/corelib/tools/qtextboundaryfinder.h
+++ b/src/corelib/tools/qtextboundaryfinder.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index 0ca406308a..2ff25a9a46 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qtimeline.h b/src/corelib/tools/qtimeline.h
index d65822ff40..06a5d76a4b 100644
--- a/src/corelib/tools/qtimeline.h
+++ b/src/corelib/tools/qtimeline.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 9a7f5dd852..6a1b78b12b 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qunicodetables.cpp b/src/corelib/tools/qunicodetables.cpp
index 88fd2afb72..7fc09e7d60 100644
--- a/src/corelib/tools/qunicodetables.cpp
+++ b/src/corelib/tools/qunicodetables.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index 0c9bd02c04..0a357c0da6 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 6da6cf524d..d37389a8dc 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -95,6 +95,11 @@ public:
}
inline int size() const { return s; }
inline int count() const { return s; }
+ inline int length() const { return s; }
+ inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); }
+ T& last() { Q_ASSERT(!isEmpty()); return *(end() - 1); }
+ const T& last() const { Q_ASSERT(!isEmpty()); return *(end() - 1); }
inline bool isEmpty() const { return (s == 0); }
inline void resize(int size);
inline void clear() { resize(0); }
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index b1d7a1a5b1..c4198aafa7 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -118,6 +118,43 @@
\sa isEmpty(), resize()
*/
+/*! \fn int QVarLengthArray::length() const
+
+ Same as size().
+
+ \sa isEmpty(), resize()
+*/
+
+/*! \fn T& QVarLengthArray::first()
+
+ Returns a reference to the first item in the array. The array must
+ not be empty. If the array can be empty, check isEmpty() before
+ calling this function.
+
+ \sa last(), isEmpty()
+*/
+
+/*! \fn const T& QVarLengthArray::first() const
+
+ \overload
+*/
+
+/*! \fn T& QVarLengthArray::last()
+
+ Returns a reference to the last item in the array. The array must
+ not be empty. If the array can be empty, check isEmpty() before
+ calling this function.
+
+ \sa first(), isEmpty()
+*/
+
+/*! \fn const T& QVarLengthArray::last() const
+
+ \overload
+*/
+
+
+
/*! \fn bool QVarLengthArray::isEmpty() const
Returns true if the array has size 0; otherwise returns false.
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index d4c7fd79f7..59ca11179b 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -41,7 +41,9 @@
#include "qvector.h"
#include "qtools_p.h"
+
#include <string.h>
+#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -56,7 +58,7 @@ const QVectorData QVectorData::shared_null = { Q_REFCOUNT_INITIALIZE_STATIC, 0,
QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init)
{
- QVectorData* p = (QVectorData *)qMalloc(sizeofTypedData + (size - 1) * sizeofT);
+ QVectorData* p = (QVectorData *)::malloc(sizeofTypedData + (size - 1) * sizeofT);
Q_CHECK_PTR(p);
::memcpy(p, init, sizeofTypedData + (qMin(size, init->alloc) - 1) * sizeofT);
return p;
@@ -64,14 +66,14 @@ QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVe
QVectorData *QVectorData::allocate(int size, int alignment)
{
- return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size));
+ return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : ::malloc(size));
}
QVectorData *QVectorData::reallocate(QVectorData *x, int newsize, int oldsize, int alignment)
{
if (alignment > alignmentThreshold())
return static_cast<QVectorData *>(qReallocAligned(x, newsize, oldsize, alignment));
- return static_cast<QVectorData *>(qRealloc(x, newsize));
+ return static_cast<QVectorData *>(realloc(x, newsize));
}
void QVectorData::free(QVectorData *x, int alignment)
@@ -79,7 +81,7 @@ void QVectorData::free(QVectorData *x, int alignment)
if (alignment > alignmentThreshold())
qFreeAligned(x);
else
- qFree(x);
+ ::free(x);
}
int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index f9db421fdb..51364df91d 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -603,7 +603,7 @@ void QVector<T>::append(const T &t)
}
template <typename T>
-Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t)
+typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t)
{
int offset = int(before - p->array);
if (n != 0) {
@@ -637,7 +637,7 @@ Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before, size_type n,
}
template <typename T>
-Q_TYPENAME QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
+typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
{
int f = int(abegin - p->array);
int l = int(aend - p->array);
diff --git a/src/corelib/tools/qvsnprintf.cpp b/src/corelib/tools/qvsnprintf.cpp
index 0b85cf0c0a..85f8270ffd 100644
--- a/src/corelib/tools/qvsnprintf.cpp
+++ b/src/corelib/tools/qvsnprintf.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/xml/make-parser.sh b/src/corelib/xml/make-parser.sh
index 11ac2196a6..a02538ba79 100755
--- a/src/corelib/xml/make-parser.sh
+++ b/src/corelib/xml/make-parser.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#############################################################################
##
-## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
## All rights reserved.
## Contact: Nokia Corporation (qt-info@nokia.com)
##
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index bf37902950..04336c3a31 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -885,9 +885,9 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value)
inline void QXmlStreamReaderPrivate::reallocateStack()
{
stack_size <<= 1;
- sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
+ sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
Q_CHECK_PTR(sym_stack);
- state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
+ state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
Q_CHECK_PTR(sym_stack);
}
@@ -897,8 +897,8 @@ QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate()
#ifndef QT_NO_TEXTCODEC
delete decoder;
#endif
- qFree(sym_stack);
- qFree(state_stack);
+ free(sym_stack);
+ free(state_stack);
delete entityParser;
}
diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g
index 26e7323a5f..88bfcd47cc 100644
--- a/src/corelib/xml/qxmlstream.g
+++ b/src/corelib/xml/qxmlstream.g
@@ -1,6 +1,6 @@
----------------------------------------------------------------------------
--
--- Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+-- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-- All rights reserved.
-- Contact: Nokia Corporation (qt-info@nokia.com)
--
diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h
index 3e19bef273..04f9322712 100644
--- a/src/corelib/xml/qxmlstream.h
+++ b/src/corelib/xml/qxmlstream.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index db5fb65246..e67ff3d76b 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/xml/qxmlutils.cpp b/src/corelib/xml/qxmlutils.cpp
index 9cae7632e5..afc4fff8d6 100644
--- a/src/corelib/xml/qxmlutils.cpp
+++ b/src/corelib/xml/qxmlutils.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/corelib/xml/qxmlutils_p.h b/src/corelib/xml/qxmlutils_p.h
index 5fa913e63a..8b8d2358c9 100644
--- a/src/corelib/xml/qxmlutils_p.h
+++ b/src/corelib/xml/qxmlutils_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**